babylon.module.d.ts 6.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. /**
  1057. * Prepass texture index for color
  1058. */
  1059. static readonly PREPASS_COLOR_INDEX: number;
  1060. /**
  1061. * Prepass texture index for irradiance
  1062. */
  1063. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1064. /**
  1065. * Prepass texture index for depth + normal
  1066. */
  1067. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1068. /**
  1069. * Prepass texture index for albedo
  1070. */
  1071. static readonly PREPASS_ALBEDO_INDEX: number;
  1072. }
  1073. }
  1074. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1075. import { Nullable } from "babylonjs/types";
  1076. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1077. /**
  1078. * This represents the required contract to create a new type of texture loader.
  1079. */
  1080. export interface IInternalTextureLoader {
  1081. /**
  1082. * Defines wether the loader supports cascade loading the different faces.
  1083. */
  1084. supportCascades: boolean;
  1085. /**
  1086. * This returns if the loader support the current file information.
  1087. * @param extension defines the file extension of the file being loaded
  1088. * @param mimeType defines the optional mime type of the file being loaded
  1089. * @returns true if the loader can load the specified file
  1090. */
  1091. canLoad(extension: string, mimeType?: string): boolean;
  1092. /**
  1093. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1094. * @param data contains the texture data
  1095. * @param texture defines the BabylonJS internal texture
  1096. * @param createPolynomials will be true if polynomials have been requested
  1097. * @param onLoad defines the callback to trigger once the texture is ready
  1098. * @param onError defines the callback to trigger in case of error
  1099. */
  1100. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1101. /**
  1102. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1103. * @param data contains the texture data
  1104. * @param texture defines the BabylonJS internal texture
  1105. * @param callback defines the method to call once ready to upload
  1106. */
  1107. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1108. }
  1109. }
  1110. declare module "babylonjs/Engines/IPipelineContext" {
  1111. /**
  1112. * Class used to store and describe the pipeline context associated with an effect
  1113. */
  1114. export interface IPipelineContext {
  1115. /**
  1116. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1117. */
  1118. isAsync: boolean;
  1119. /**
  1120. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1121. */
  1122. isReady: boolean;
  1123. /** @hidden */
  1124. _getVertexShaderCode(): string | null;
  1125. /** @hidden */
  1126. _getFragmentShaderCode(): string | null;
  1127. /** @hidden */
  1128. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1129. }
  1130. }
  1131. declare module "babylonjs/Meshes/dataBuffer" {
  1132. /**
  1133. * Class used to store gfx data (like WebGLBuffer)
  1134. */
  1135. export class DataBuffer {
  1136. /**
  1137. * Gets or sets the number of objects referencing this buffer
  1138. */
  1139. references: number;
  1140. /** Gets or sets the size of the underlying buffer */
  1141. capacity: number;
  1142. /**
  1143. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1144. */
  1145. is32Bits: boolean;
  1146. /**
  1147. * Gets the underlying buffer
  1148. */
  1149. get underlyingResource(): any;
  1150. }
  1151. }
  1152. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1153. /** @hidden */
  1154. export interface IShaderProcessor {
  1155. attributeProcessor?: (attribute: string) => string;
  1156. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1157. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1158. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1159. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1160. lineProcessor?: (line: string, isFragment: boolean) => string;
  1161. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1162. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1163. }
  1164. }
  1165. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1166. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1167. /** @hidden */
  1168. export interface ProcessingOptions {
  1169. defines: string[];
  1170. indexParameters: any;
  1171. isFragment: boolean;
  1172. shouldUseHighPrecisionShader: boolean;
  1173. supportsUniformBuffers: boolean;
  1174. shadersRepository: string;
  1175. includesShadersStore: {
  1176. [key: string]: string;
  1177. };
  1178. processor?: IShaderProcessor;
  1179. version: string;
  1180. platformName: string;
  1181. lookForClosingBracketForUniformBuffer?: boolean;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1185. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1186. /** @hidden */
  1187. export class ShaderCodeNode {
  1188. line: string;
  1189. children: ShaderCodeNode[];
  1190. additionalDefineKey?: string;
  1191. additionalDefineValue?: string;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. process(preprocessors: {
  1196. [key: string]: string;
  1197. }, options: ProcessingOptions): string;
  1198. }
  1199. }
  1200. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1201. /** @hidden */
  1202. export class ShaderCodeCursor {
  1203. private _lines;
  1204. lineIndex: number;
  1205. get currentLine(): string;
  1206. get canRead(): boolean;
  1207. set lines(value: string[]);
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1213. /** @hidden */
  1214. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1215. process(preprocessors: {
  1216. [key: string]: string;
  1217. }, options: ProcessingOptions): string;
  1218. }
  1219. }
  1220. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1221. /** @hidden */
  1222. export class ShaderDefineExpression {
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. private static _OperatorPriority;
  1227. private static _Stack;
  1228. static postfixToInfix(postfix: string[]): string;
  1229. static infixToPostfix(infix: string): string[];
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1233. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderCodeTestNode extends ShaderCodeNode {
  1237. testExpression: ShaderDefineExpression;
  1238. isValid(preprocessors: {
  1239. [key: string]: string;
  1240. }): boolean;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1244. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1245. /** @hidden */
  1246. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. not: boolean;
  1249. constructor(define: string, not?: boolean);
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1259. leftOperand: ShaderDefineExpression;
  1260. rightOperand: ShaderDefineExpression;
  1261. isTrue(preprocessors: {
  1262. [key: string]: string;
  1263. }): boolean;
  1264. }
  1265. }
  1266. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1267. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1268. /** @hidden */
  1269. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1270. leftOperand: ShaderDefineExpression;
  1271. rightOperand: ShaderDefineExpression;
  1272. isTrue(preprocessors: {
  1273. [key: string]: string;
  1274. }): boolean;
  1275. }
  1276. }
  1277. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1278. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1279. /** @hidden */
  1280. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1281. define: string;
  1282. operand: string;
  1283. testValue: string;
  1284. constructor(define: string, operand: string, testValue: string);
  1285. isTrue(preprocessors: {
  1286. [key: string]: string;
  1287. }): boolean;
  1288. }
  1289. }
  1290. declare module "babylonjs/Offline/IOfflineProvider" {
  1291. /**
  1292. * Class used to enable access to offline support
  1293. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1294. */
  1295. export interface IOfflineProvider {
  1296. /**
  1297. * Gets a boolean indicating if scene must be saved in the database
  1298. */
  1299. enableSceneOffline: boolean;
  1300. /**
  1301. * Gets a boolean indicating if textures must be saved in the database
  1302. */
  1303. enableTexturesOffline: boolean;
  1304. /**
  1305. * Open the offline support and make it available
  1306. * @param successCallback defines the callback to call on success
  1307. * @param errorCallback defines the callback to call on error
  1308. */
  1309. open(successCallback: () => void, errorCallback: () => void): void;
  1310. /**
  1311. * Loads an image from the offline support
  1312. * @param url defines the url to load from
  1313. * @param image defines the target DOM image
  1314. */
  1315. loadImage(url: string, image: HTMLImageElement): void;
  1316. /**
  1317. * Loads a file from offline support
  1318. * @param url defines the URL to load from
  1319. * @param sceneLoaded defines a callback to call on success
  1320. * @param progressCallBack defines a callback to call when progress changed
  1321. * @param errorCallback defines a callback to call on error
  1322. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1323. */
  1324. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1325. }
  1326. }
  1327. declare module "babylonjs/Misc/filesInputStore" {
  1328. /**
  1329. * Class used to help managing file picking and drag'n'drop
  1330. * File Storage
  1331. */
  1332. export class FilesInputStore {
  1333. /**
  1334. * List of files ready to be loaded
  1335. */
  1336. static FilesToLoad: {
  1337. [key: string]: File;
  1338. };
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/retryStrategy" {
  1342. import { WebRequest } from "babylonjs/Misc/webRequest";
  1343. /**
  1344. * Class used to define a retry strategy when error happens while loading assets
  1345. */
  1346. export class RetryStrategy {
  1347. /**
  1348. * Function used to defines an exponential back off strategy
  1349. * @param maxRetries defines the maximum number of retries (3 by default)
  1350. * @param baseInterval defines the interval between retries
  1351. * @returns the strategy function to use
  1352. */
  1353. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1354. }
  1355. }
  1356. declare module "babylonjs/Misc/baseError" {
  1357. /**
  1358. * @ignore
  1359. * Application error to support additional information when loading a file
  1360. */
  1361. export abstract class BaseError extends Error {
  1362. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1363. }
  1364. }
  1365. declare module "babylonjs/Misc/fileTools" {
  1366. import { WebRequest } from "babylonjs/Misc/webRequest";
  1367. import { Nullable } from "babylonjs/types";
  1368. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1369. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1370. import { BaseError } from "babylonjs/Misc/baseError";
  1371. /** @ignore */
  1372. export class LoadFileError extends BaseError {
  1373. request?: WebRequest;
  1374. file?: File;
  1375. /**
  1376. * Creates a new LoadFileError
  1377. * @param message defines the message of the error
  1378. * @param request defines the optional web request
  1379. * @param file defines the optional file
  1380. */
  1381. constructor(message: string, object?: WebRequest | File);
  1382. }
  1383. /** @ignore */
  1384. export class RequestFileError extends BaseError {
  1385. request: WebRequest;
  1386. /**
  1387. * Creates a new LoadFileError
  1388. * @param message defines the message of the error
  1389. * @param request defines the optional web request
  1390. */
  1391. constructor(message: string, request: WebRequest);
  1392. }
  1393. /** @ignore */
  1394. export class ReadFileError extends BaseError {
  1395. file: File;
  1396. /**
  1397. * Creates a new ReadFileError
  1398. * @param message defines the message of the error
  1399. * @param file defines the optional file
  1400. */
  1401. constructor(message: string, file: File);
  1402. }
  1403. /**
  1404. * @hidden
  1405. */
  1406. export class FileTools {
  1407. /**
  1408. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1409. */
  1410. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1411. /**
  1412. * Gets or sets the base URL to use to load assets
  1413. */
  1414. static BaseUrl: string;
  1415. /**
  1416. * Default behaviour for cors in the application.
  1417. * It can be a string if the expected behavior is identical in the entire app.
  1418. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1419. */
  1420. static CorsBehavior: string | ((url: string | string[]) => string);
  1421. /**
  1422. * Gets or sets a function used to pre-process url before using them to load assets
  1423. */
  1424. static PreprocessUrl: (url: string) => string;
  1425. /**
  1426. * Removes unwanted characters from an url
  1427. * @param url defines the url to clean
  1428. * @returns the cleaned url
  1429. */
  1430. private static _CleanUrl;
  1431. /**
  1432. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1433. * @param url define the url we are trying
  1434. * @param element define the dom element where to configure the cors policy
  1435. */
  1436. static SetCorsBehavior(url: string | string[], element: {
  1437. crossOrigin: string | null;
  1438. }): void;
  1439. /**
  1440. * Loads an image as an HTMLImageElement.
  1441. * @param input url string, ArrayBuffer, or Blob to load
  1442. * @param onLoad callback called when the image successfully loads
  1443. * @param onError callback called when the image fails to load
  1444. * @param offlineProvider offline provider for caching
  1445. * @param mimeType optional mime type
  1446. * @returns the HTMLImageElement of the loaded image
  1447. */
  1448. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1449. /**
  1450. * Reads a file from a File object
  1451. * @param file defines the file to load
  1452. * @param onSuccess defines the callback to call when data is loaded
  1453. * @param onProgress defines the callback to call during loading process
  1454. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1455. * @param onError defines the callback to call when an error occurs
  1456. * @returns a file request object
  1457. */
  1458. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1459. /**
  1460. * Loads a file from a url
  1461. * @param url url to load
  1462. * @param onSuccess callback called when the file successfully loads
  1463. * @param onProgress callback called while file is loading (if the server supports this mode)
  1464. * @param offlineProvider defines the offline provider for caching
  1465. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1466. * @param onError callback called when the file fails to load
  1467. * @returns a file request object
  1468. */
  1469. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1470. /**
  1471. * Loads a file
  1472. * @param url url to load
  1473. * @param onSuccess callback called when the file successfully loads
  1474. * @param onProgress callback called while file is loading (if the server supports this mode)
  1475. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1476. * @param onError callback called when the file fails to load
  1477. * @param onOpened callback called when the web request is opened
  1478. * @returns a file request object
  1479. */
  1480. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1481. /**
  1482. * Checks if the loaded document was accessed via `file:`-Protocol.
  1483. * @returns boolean
  1484. */
  1485. static IsFileURL(): boolean;
  1486. }
  1487. }
  1488. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1489. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1490. import { WebRequest } from "babylonjs/Misc/webRequest";
  1491. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1492. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1493. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1494. /** @hidden */
  1495. export class ShaderProcessor {
  1496. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1497. private static _ProcessPrecision;
  1498. private static _ExtractOperation;
  1499. private static _BuildSubExpression;
  1500. private static _BuildExpression;
  1501. private static _MoveCursorWithinIf;
  1502. private static _MoveCursor;
  1503. private static _EvaluatePreProcessors;
  1504. private static _PreparePreProcessors;
  1505. private static _ProcessShaderConversion;
  1506. private static _ProcessIncludes;
  1507. /**
  1508. * Loads a file from a url
  1509. * @param url url to load
  1510. * @param onSuccess callback called when the file successfully loads
  1511. * @param onProgress callback called while file is loading (if the server supports this mode)
  1512. * @param offlineProvider defines the offline provider for caching
  1513. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1514. * @param onError callback called when the file fails to load
  1515. * @returns a file request object
  1516. * @hidden
  1517. */
  1518. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1519. }
  1520. }
  1521. declare module "babylonjs/Maths/math.like" {
  1522. import { float, int, DeepImmutable } from "babylonjs/types";
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IColor4Like {
  1527. r: float;
  1528. g: float;
  1529. b: float;
  1530. a: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IColor3Like {
  1536. r: float;
  1537. g: float;
  1538. b: float;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IVector4Like {
  1544. x: float;
  1545. y: float;
  1546. z: float;
  1547. w: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IVector3Like {
  1553. x: float;
  1554. y: float;
  1555. z: float;
  1556. }
  1557. /**
  1558. * @hidden
  1559. */
  1560. export interface IVector2Like {
  1561. x: float;
  1562. y: float;
  1563. }
  1564. /**
  1565. * @hidden
  1566. */
  1567. export interface IMatrixLike {
  1568. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1569. updateFlag: int;
  1570. }
  1571. /**
  1572. * @hidden
  1573. */
  1574. export interface IViewportLike {
  1575. x: float;
  1576. y: float;
  1577. width: float;
  1578. height: float;
  1579. }
  1580. /**
  1581. * @hidden
  1582. */
  1583. export interface IPlaneLike {
  1584. normal: IVector3Like;
  1585. d: float;
  1586. normalize(): void;
  1587. }
  1588. }
  1589. declare module "babylonjs/Materials/iEffectFallbacks" {
  1590. import { Effect } from "babylonjs/Materials/effect";
  1591. /**
  1592. * Interface used to define common properties for effect fallbacks
  1593. */
  1594. export interface IEffectFallbacks {
  1595. /**
  1596. * Removes the defines that should be removed when falling back.
  1597. * @param currentDefines defines the current define statements for the shader.
  1598. * @param effect defines the current effect we try to compile
  1599. * @returns The resulting defines with defines of the current rank removed.
  1600. */
  1601. reduce(currentDefines: string, effect: Effect): string;
  1602. /**
  1603. * Removes the fallback from the bound mesh.
  1604. */
  1605. unBindMesh(): void;
  1606. /**
  1607. * Checks to see if more fallbacks are still availible.
  1608. */
  1609. hasMoreFallbacks: boolean;
  1610. }
  1611. }
  1612. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1613. /**
  1614. * Class used to evalaute queries containing `and` and `or` operators
  1615. */
  1616. export class AndOrNotEvaluator {
  1617. /**
  1618. * Evaluate a query
  1619. * @param query defines the query to evaluate
  1620. * @param evaluateCallback defines the callback used to filter result
  1621. * @returns true if the query matches
  1622. */
  1623. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1624. private static _HandleParenthesisContent;
  1625. private static _SimplifyNegation;
  1626. }
  1627. }
  1628. declare module "babylonjs/Misc/tags" {
  1629. /**
  1630. * Class used to store custom tags
  1631. */
  1632. export class Tags {
  1633. /**
  1634. * Adds support for tags on the given object
  1635. * @param obj defines the object to use
  1636. */
  1637. static EnableFor(obj: any): void;
  1638. /**
  1639. * Removes tags support
  1640. * @param obj defines the object to use
  1641. */
  1642. static DisableFor(obj: any): void;
  1643. /**
  1644. * Gets a boolean indicating if the given object has tags
  1645. * @param obj defines the object to use
  1646. * @returns a boolean
  1647. */
  1648. static HasTags(obj: any): boolean;
  1649. /**
  1650. * Gets the tags available on a given object
  1651. * @param obj defines the object to use
  1652. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1653. * @returns the tags
  1654. */
  1655. static GetTags(obj: any, asString?: boolean): any;
  1656. /**
  1657. * Adds tags to an object
  1658. * @param obj defines the object to use
  1659. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1660. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1661. */
  1662. static AddTagsTo(obj: any, tagsString: string): void;
  1663. /**
  1664. * @hidden
  1665. */
  1666. static _AddTagTo(obj: any, tag: string): void;
  1667. /**
  1668. * Removes specific tags from a specific object
  1669. * @param obj defines the object to use
  1670. * @param tagsString defines the tags to remove
  1671. */
  1672. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1673. /**
  1674. * @hidden
  1675. */
  1676. static _RemoveTagFrom(obj: any, tag: string): void;
  1677. /**
  1678. * Defines if tags hosted on an object match a given query
  1679. * @param obj defines the object to use
  1680. * @param tagsQuery defines the tag query
  1681. * @returns a boolean
  1682. */
  1683. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1684. }
  1685. }
  1686. declare module "babylonjs/Maths/math.scalar" {
  1687. /**
  1688. * Scalar computation library
  1689. */
  1690. export class Scalar {
  1691. /**
  1692. * Two pi constants convenient for computation.
  1693. */
  1694. static TwoPi: number;
  1695. /**
  1696. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1697. * @param a number
  1698. * @param b number
  1699. * @param epsilon (default = 1.401298E-45)
  1700. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1701. */
  1702. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1703. /**
  1704. * Returns a string : the upper case translation of the number i to hexadecimal.
  1705. * @param i number
  1706. * @returns the upper case translation of the number i to hexadecimal.
  1707. */
  1708. static ToHex(i: number): string;
  1709. /**
  1710. * Returns -1 if value is negative and +1 is value is positive.
  1711. * @param value the value
  1712. * @returns the value itself if it's equal to zero.
  1713. */
  1714. static Sign(value: number): number;
  1715. /**
  1716. * Returns the value itself if it's between min and max.
  1717. * Returns min if the value is lower than min.
  1718. * Returns max if the value is greater than max.
  1719. * @param value the value to clmap
  1720. * @param min the min value to clamp to (default: 0)
  1721. * @param max the max value to clamp to (default: 1)
  1722. * @returns the clamped value
  1723. */
  1724. static Clamp(value: number, min?: number, max?: number): number;
  1725. /**
  1726. * the log2 of value.
  1727. * @param value the value to compute log2 of
  1728. * @returns the log2 of value.
  1729. */
  1730. static Log2(value: number): number;
  1731. /**
  1732. * Loops the value, so that it is never larger than length and never smaller than 0.
  1733. *
  1734. * This is similar to the modulo operator but it works with floating point numbers.
  1735. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1736. * With t = 5 and length = 2.5, the result would be 0.0.
  1737. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1738. * @param value the value
  1739. * @param length the length
  1740. * @returns the looped value
  1741. */
  1742. static Repeat(value: number, length: number): number;
  1743. /**
  1744. * Normalize the value between 0.0 and 1.0 using min and max values
  1745. * @param value value to normalize
  1746. * @param min max to normalize between
  1747. * @param max min to normalize between
  1748. * @returns the normalized value
  1749. */
  1750. static Normalize(value: number, min: number, max: number): number;
  1751. /**
  1752. * Denormalize the value from 0.0 and 1.0 using min and max values
  1753. * @param normalized value to denormalize
  1754. * @param min max to denormalize between
  1755. * @param max min to denormalize between
  1756. * @returns the denormalized value
  1757. */
  1758. static Denormalize(normalized: number, min: number, max: number): number;
  1759. /**
  1760. * Calculates the shortest difference between two given angles given in degrees.
  1761. * @param current current angle in degrees
  1762. * @param target target angle in degrees
  1763. * @returns the delta
  1764. */
  1765. static DeltaAngle(current: number, target: number): number;
  1766. /**
  1767. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1768. * @param tx value
  1769. * @param length length
  1770. * @returns The returned value will move back and forth between 0 and length
  1771. */
  1772. static PingPong(tx: number, length: number): number;
  1773. /**
  1774. * Interpolates between min and max with smoothing at the limits.
  1775. *
  1776. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1777. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1778. * @param from from
  1779. * @param to to
  1780. * @param tx value
  1781. * @returns the smooth stepped value
  1782. */
  1783. static SmoothStep(from: number, to: number, tx: number): number;
  1784. /**
  1785. * Moves a value current towards target.
  1786. *
  1787. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1788. * Negative values of maxDelta pushes the value away from target.
  1789. * @param current current value
  1790. * @param target target value
  1791. * @param maxDelta max distance to move
  1792. * @returns resulting value
  1793. */
  1794. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1795. /**
  1796. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1797. *
  1798. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1799. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1800. * @param current current value
  1801. * @param target target value
  1802. * @param maxDelta max distance to move
  1803. * @returns resulting angle
  1804. */
  1805. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1806. /**
  1807. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1808. * @param start start value
  1809. * @param end target value
  1810. * @param amount amount to lerp between
  1811. * @returns the lerped value
  1812. */
  1813. static Lerp(start: number, end: number, amount: number): number;
  1814. /**
  1815. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1817. * @param start start value
  1818. * @param end target value
  1819. * @param amount amount to lerp between
  1820. * @returns the lerped value
  1821. */
  1822. static LerpAngle(start: number, end: number, amount: number): number;
  1823. /**
  1824. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1825. * @param a start value
  1826. * @param b target value
  1827. * @param value value between a and b
  1828. * @returns the inverseLerp value
  1829. */
  1830. static InverseLerp(a: number, b: number, value: number): number;
  1831. /**
  1832. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1833. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1834. * @param value1 spline value
  1835. * @param tangent1 spline value
  1836. * @param value2 spline value
  1837. * @param tangent2 spline value
  1838. * @param amount input value
  1839. * @returns hermite result
  1840. */
  1841. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1842. /**
  1843. * Returns a random float number between and min and max values
  1844. * @param min min value of random
  1845. * @param max max value of random
  1846. * @returns random value
  1847. */
  1848. static RandomRange(min: number, max: number): number;
  1849. /**
  1850. * This function returns percentage of a number in a given range.
  1851. *
  1852. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1853. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1854. * @param number to convert to percentage
  1855. * @param min min range
  1856. * @param max max range
  1857. * @returns the percentage
  1858. */
  1859. static RangeToPercent(number: number, min: number, max: number): number;
  1860. /**
  1861. * This function returns number that corresponds to the percentage in a given range.
  1862. *
  1863. * PercentToRange(0.34,0,100) will return 34.
  1864. * @param percent to convert to number
  1865. * @param min min range
  1866. * @param max max range
  1867. * @returns the number
  1868. */
  1869. static PercentToRange(percent: number, min: number, max: number): number;
  1870. /**
  1871. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1872. * @param angle The angle to normalize in radian.
  1873. * @return The converted angle.
  1874. */
  1875. static NormalizeRadians(angle: number): number;
  1876. }
  1877. }
  1878. declare module "babylonjs/Maths/math.constants" {
  1879. /**
  1880. * Constant used to convert a value to gamma space
  1881. * @ignorenaming
  1882. */
  1883. export const ToGammaSpace: number;
  1884. /**
  1885. * Constant used to convert a value to linear space
  1886. * @ignorenaming
  1887. */
  1888. export const ToLinearSpace = 2.2;
  1889. /**
  1890. * Constant used to define the minimal number value in Babylon.js
  1891. * @ignorenaming
  1892. */
  1893. let Epsilon: number;
  1894. export { Epsilon };
  1895. }
  1896. declare module "babylonjs/Maths/math.viewport" {
  1897. /**
  1898. * Class used to represent a viewport on screen
  1899. */
  1900. export class Viewport {
  1901. /** viewport left coordinate */
  1902. x: number;
  1903. /** viewport top coordinate */
  1904. y: number;
  1905. /**viewport width */
  1906. width: number;
  1907. /** viewport height */
  1908. height: number;
  1909. /**
  1910. * Creates a Viewport object located at (x, y) and sized (width, height)
  1911. * @param x defines viewport left coordinate
  1912. * @param y defines viewport top coordinate
  1913. * @param width defines the viewport width
  1914. * @param height defines the viewport height
  1915. */
  1916. constructor(
  1917. /** viewport left coordinate */
  1918. x: number,
  1919. /** viewport top coordinate */
  1920. y: number,
  1921. /**viewport width */
  1922. width: number,
  1923. /** viewport height */
  1924. height: number);
  1925. /**
  1926. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1927. * @param renderWidth defines the rendering width
  1928. * @param renderHeight defines the rendering height
  1929. * @returns a new Viewport
  1930. */
  1931. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1932. /**
  1933. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1934. * @param renderWidth defines the rendering width
  1935. * @param renderHeight defines the rendering height
  1936. * @param ref defines the target viewport
  1937. * @returns the current viewport
  1938. */
  1939. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1940. /**
  1941. * Returns a new Viewport copied from the current one
  1942. * @returns a new Viewport
  1943. */
  1944. clone(): Viewport;
  1945. }
  1946. }
  1947. declare module "babylonjs/Misc/arrayTools" {
  1948. /**
  1949. * Class containing a set of static utilities functions for arrays.
  1950. */
  1951. export class ArrayTools {
  1952. /**
  1953. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1954. * @param size the number of element to construct and put in the array
  1955. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1956. * @returns a new array filled with new objects
  1957. */
  1958. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1959. }
  1960. }
  1961. declare module "babylonjs/Maths/math.plane" {
  1962. import { DeepImmutable } from "babylonjs/types";
  1963. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1964. /**
  1965. * Represents a plane by the equation ax + by + cz + d = 0
  1966. */
  1967. export class Plane {
  1968. private static _TmpMatrix;
  1969. /**
  1970. * Normal of the plane (a,b,c)
  1971. */
  1972. normal: Vector3;
  1973. /**
  1974. * d component of the plane
  1975. */
  1976. d: number;
  1977. /**
  1978. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1979. * @param a a component of the plane
  1980. * @param b b component of the plane
  1981. * @param c c component of the plane
  1982. * @param d d component of the plane
  1983. */
  1984. constructor(a: number, b: number, c: number, d: number);
  1985. /**
  1986. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1987. */
  1988. asArray(): number[];
  1989. /**
  1990. * @returns a new plane copied from the current Plane.
  1991. */
  1992. clone(): Plane;
  1993. /**
  1994. * @returns the string "Plane".
  1995. */
  1996. getClassName(): string;
  1997. /**
  1998. * @returns the Plane hash code.
  1999. */
  2000. getHashCode(): number;
  2001. /**
  2002. * Normalize the current Plane in place.
  2003. * @returns the updated Plane.
  2004. */
  2005. normalize(): Plane;
  2006. /**
  2007. * Applies a transformation the plane and returns the result
  2008. * @param transformation the transformation matrix to be applied to the plane
  2009. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2010. */
  2011. transform(transformation: DeepImmutable<Matrix>): Plane;
  2012. /**
  2013. * Compute the dot product between the point and the plane normal
  2014. * @param point point to calculate the dot product with
  2015. * @returns the dot product (float) of the point coordinates and the plane normal.
  2016. */
  2017. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2018. /**
  2019. * Updates the current Plane from the plane defined by the three given points.
  2020. * @param point1 one of the points used to contruct the plane
  2021. * @param point2 one of the points used to contruct the plane
  2022. * @param point3 one of the points used to contruct the plane
  2023. * @returns the updated Plane.
  2024. */
  2025. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2026. /**
  2027. * Checks if the plane is facing a given direction
  2028. * @param direction the direction to check if the plane is facing
  2029. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2030. * @returns True is the vector "direction" is the same side than the plane normal.
  2031. */
  2032. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2033. /**
  2034. * Calculates the distance to a point
  2035. * @param point point to calculate distance to
  2036. * @returns the signed distance (float) from the given point to the Plane.
  2037. */
  2038. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2039. /**
  2040. * Creates a plane from an array
  2041. * @param array the array to create a plane from
  2042. * @returns a new Plane from the given array.
  2043. */
  2044. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2045. /**
  2046. * Creates a plane from three points
  2047. * @param point1 point used to create the plane
  2048. * @param point2 point used to create the plane
  2049. * @param point3 point used to create the plane
  2050. * @returns a new Plane defined by the three given points.
  2051. */
  2052. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2053. /**
  2054. * Creates a plane from an origin point and a normal
  2055. * @param origin origin of the plane to be constructed
  2056. * @param normal normal of the plane to be constructed
  2057. * @returns a new Plane the normal vector to this plane at the given origin point.
  2058. * Note : the vector "normal" is updated because normalized.
  2059. */
  2060. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2061. /**
  2062. * Calculates the distance from a plane and a point
  2063. * @param origin origin of the plane to be constructed
  2064. * @param normal normal of the plane to be constructed
  2065. * @param point point to calculate distance to
  2066. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2067. */
  2068. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2069. }
  2070. }
  2071. declare module "babylonjs/Engines/performanceConfigurator" {
  2072. /** @hidden */
  2073. export class PerformanceConfigurator {
  2074. /** @hidden */
  2075. static MatrixUse64Bits: boolean;
  2076. /** @hidden */
  2077. static MatrixTrackPrecisionChange: boolean;
  2078. /** @hidden */
  2079. static MatrixCurrentType: any;
  2080. /** @hidden */
  2081. static MatrixTrackedMatrices: Array<any> | null;
  2082. /** @hidden */
  2083. static SetMatrixPrecision(use64bits: boolean): void;
  2084. }
  2085. }
  2086. declare module "babylonjs/Maths/math.vector" {
  2087. import { Viewport } from "babylonjs/Maths/math.viewport";
  2088. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2089. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2090. import { Plane } from "babylonjs/Maths/math.plane";
  2091. /**
  2092. * Class representing a vector containing 2 coordinates
  2093. */
  2094. export class Vector2 {
  2095. /** defines the first coordinate */
  2096. x: number;
  2097. /** defines the second coordinate */
  2098. y: number;
  2099. /**
  2100. * Creates a new Vector2 from the given x and y coordinates
  2101. * @param x defines the first coordinate
  2102. * @param y defines the second coordinate
  2103. */
  2104. constructor(
  2105. /** defines the first coordinate */
  2106. x?: number,
  2107. /** defines the second coordinate */
  2108. y?: number);
  2109. /**
  2110. * Gets a string with the Vector2 coordinates
  2111. * @returns a string with the Vector2 coordinates
  2112. */
  2113. toString(): string;
  2114. /**
  2115. * Gets class name
  2116. * @returns the string "Vector2"
  2117. */
  2118. getClassName(): string;
  2119. /**
  2120. * Gets current vector hash code
  2121. * @returns the Vector2 hash code as a number
  2122. */
  2123. getHashCode(): number;
  2124. /**
  2125. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2126. * @param array defines the source array
  2127. * @param index defines the offset in source array
  2128. * @returns the current Vector2
  2129. */
  2130. toArray(array: FloatArray, index?: number): Vector2;
  2131. /**
  2132. * Update the current vector from an array
  2133. * @param array defines the destination array
  2134. * @param index defines the offset in the destination array
  2135. * @returns the current Vector3
  2136. */
  2137. fromArray(array: FloatArray, index?: number): Vector2;
  2138. /**
  2139. * Copy the current vector to an array
  2140. * @returns a new array with 2 elements: the Vector2 coordinates.
  2141. */
  2142. asArray(): number[];
  2143. /**
  2144. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2145. * @param source defines the source Vector2
  2146. * @returns the current updated Vector2
  2147. */
  2148. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2149. /**
  2150. * Sets the Vector2 coordinates with the given floats
  2151. * @param x defines the first coordinate
  2152. * @param y defines the second coordinate
  2153. * @returns the current updated Vector2
  2154. */
  2155. copyFromFloats(x: number, y: number): Vector2;
  2156. /**
  2157. * Sets the Vector2 coordinates with the given floats
  2158. * @param x defines the first coordinate
  2159. * @param y defines the second coordinate
  2160. * @returns the current updated Vector2
  2161. */
  2162. set(x: number, y: number): Vector2;
  2163. /**
  2164. * Add another vector with the current one
  2165. * @param otherVector defines the other vector
  2166. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2167. */
  2168. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2171. * @param otherVector defines the other vector
  2172. * @param result defines the target vector
  2173. * @returns the unmodified current Vector2
  2174. */
  2175. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2176. /**
  2177. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2178. * @param otherVector defines the other vector
  2179. * @returns the current updated Vector2
  2180. */
  2181. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2182. /**
  2183. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2184. * @param otherVector defines the other vector
  2185. * @returns a new Vector2
  2186. */
  2187. addVector3(otherVector: Vector3): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2190. * @param otherVector defines the other vector
  2191. * @returns a new Vector2
  2192. */
  2193. subtract(otherVector: Vector2): Vector2;
  2194. /**
  2195. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2196. * @param otherVector defines the other vector
  2197. * @param result defines the target vector
  2198. * @returns the unmodified current Vector2
  2199. */
  2200. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2201. /**
  2202. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2203. * @param otherVector defines the other vector
  2204. * @returns the current updated Vector2
  2205. */
  2206. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Multiplies in place the current Vector2 coordinates by the given ones
  2209. * @param otherVector defines the other vector
  2210. * @returns the current updated Vector2
  2211. */
  2212. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2213. /**
  2214. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2215. * @param otherVector defines the other vector
  2216. * @returns a new Vector2
  2217. */
  2218. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2221. * @param otherVector defines the other vector
  2222. * @param result defines the target vector
  2223. * @returns the unmodified current Vector2
  2224. */
  2225. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2226. /**
  2227. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2228. * @param x defines the first coordinate
  2229. * @param y defines the second coordinate
  2230. * @returns a new Vector2
  2231. */
  2232. multiplyByFloats(x: number, y: number): Vector2;
  2233. /**
  2234. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2235. * @param otherVector defines the other vector
  2236. * @returns a new Vector2
  2237. */
  2238. divide(otherVector: Vector2): Vector2;
  2239. /**
  2240. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2241. * @param otherVector defines the other vector
  2242. * @param result defines the target vector
  2243. * @returns the unmodified current Vector2
  2244. */
  2245. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2246. /**
  2247. * Divides the current Vector2 coordinates by the given ones
  2248. * @param otherVector defines the other vector
  2249. * @returns the current updated Vector2
  2250. */
  2251. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vector2 with current Vector2 negated coordinates
  2254. * @returns a new Vector2
  2255. */
  2256. negate(): Vector2;
  2257. /**
  2258. * Negate this vector in place
  2259. * @returns this
  2260. */
  2261. negateInPlace(): Vector2;
  2262. /**
  2263. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2264. * @param result defines the Vector3 object where to store the result
  2265. * @returns the current Vector2
  2266. */
  2267. negateToRef(result: Vector2): Vector2;
  2268. /**
  2269. * Multiply the Vector2 coordinates by scale
  2270. * @param scale defines the scaling factor
  2271. * @returns the current updated Vector2
  2272. */
  2273. scaleInPlace(scale: number): Vector2;
  2274. /**
  2275. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2276. * @param scale defines the scaling factor
  2277. * @returns a new Vector2
  2278. */
  2279. scale(scale: number): Vector2;
  2280. /**
  2281. * Scale the current Vector2 values by a factor to a given Vector2
  2282. * @param scale defines the scale factor
  2283. * @param result defines the Vector2 object where to store the result
  2284. * @returns the unmodified current Vector2
  2285. */
  2286. scaleToRef(scale: number, result: Vector2): Vector2;
  2287. /**
  2288. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2289. * @param scale defines the scale factor
  2290. * @param result defines the Vector2 object where to store the result
  2291. * @returns the unmodified current Vector2
  2292. */
  2293. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2294. /**
  2295. * Gets a boolean if two vectors are equals
  2296. * @param otherVector defines the other vector
  2297. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2298. */
  2299. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2300. /**
  2301. * Gets a boolean if two vectors are equals (using an epsilon value)
  2302. * @param otherVector defines the other vector
  2303. * @param epsilon defines the minimal distance to consider equality
  2304. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2305. */
  2306. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2307. /**
  2308. * Gets a new Vector2 from current Vector2 floored values
  2309. * @returns a new Vector2
  2310. */
  2311. floor(): Vector2;
  2312. /**
  2313. * Gets a new Vector2 from current Vector2 floored values
  2314. * @returns a new Vector2
  2315. */
  2316. fract(): Vector2;
  2317. /**
  2318. * Gets the length of the vector
  2319. * @returns the vector length (float)
  2320. */
  2321. length(): number;
  2322. /**
  2323. * Gets the vector squared length
  2324. * @returns the vector squared length (float)
  2325. */
  2326. lengthSquared(): number;
  2327. /**
  2328. * Normalize the vector
  2329. * @returns the current updated Vector2
  2330. */
  2331. normalize(): Vector2;
  2332. /**
  2333. * Gets a new Vector2 copied from the Vector2
  2334. * @returns a new Vector2
  2335. */
  2336. clone(): Vector2;
  2337. /**
  2338. * Gets a new Vector2(0, 0)
  2339. * @returns a new Vector2
  2340. */
  2341. static Zero(): Vector2;
  2342. /**
  2343. * Gets a new Vector2(1, 1)
  2344. * @returns a new Vector2
  2345. */
  2346. static One(): Vector2;
  2347. /**
  2348. * Gets a new Vector2 set from the given index element of the given array
  2349. * @param array defines the data source
  2350. * @param offset defines the offset in the data source
  2351. * @returns a new Vector2
  2352. */
  2353. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2354. /**
  2355. * Sets "result" from the given index element of the given array
  2356. * @param array defines the data source
  2357. * @param offset defines the offset in the data source
  2358. * @param result defines the target vector
  2359. */
  2360. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2361. /**
  2362. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2363. * @param value1 defines 1st point of control
  2364. * @param value2 defines 2nd point of control
  2365. * @param value3 defines 3rd point of control
  2366. * @param value4 defines 4th point of control
  2367. * @param amount defines the interpolation factor
  2368. * @returns a new Vector2
  2369. */
  2370. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2371. /**
  2372. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2373. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2374. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2375. * @param value defines the value to clamp
  2376. * @param min defines the lower limit
  2377. * @param max defines the upper limit
  2378. * @returns a new Vector2
  2379. */
  2380. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2381. /**
  2382. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2383. * @param value1 defines the 1st control point
  2384. * @param tangent1 defines the outgoing tangent
  2385. * @param value2 defines the 2nd control point
  2386. * @param tangent2 defines the incoming tangent
  2387. * @param amount defines the interpolation factor
  2388. * @returns a new Vector2
  2389. */
  2390. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2391. /**
  2392. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2393. * @param start defines the start vector
  2394. * @param end defines the end vector
  2395. * @param amount defines the interpolation factor
  2396. * @returns a new Vector2
  2397. */
  2398. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2399. /**
  2400. * Gets the dot product of the vector "left" and the vector "right"
  2401. * @param left defines first vector
  2402. * @param right defines second vector
  2403. * @returns the dot product (float)
  2404. */
  2405. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2406. /**
  2407. * Returns a new Vector2 equal to the normalized given vector
  2408. * @param vector defines the vector to normalize
  2409. * @returns a new Vector2
  2410. */
  2411. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2414. * @param left defines 1st vector
  2415. * @param right defines 2nd vector
  2416. * @returns a new Vector2
  2417. */
  2418. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2419. /**
  2420. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2421. * @param left defines 1st vector
  2422. * @param right defines 2nd vector
  2423. * @returns a new Vector2
  2424. */
  2425. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2426. /**
  2427. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2428. * @param vector defines the vector to transform
  2429. * @param transformation defines the matrix to apply
  2430. * @returns a new Vector2
  2431. */
  2432. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2433. /**
  2434. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2435. * @param vector defines the vector to transform
  2436. * @param transformation defines the matrix to apply
  2437. * @param result defines the target vector
  2438. */
  2439. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2440. /**
  2441. * Determines if a given vector is included in a triangle
  2442. * @param p defines the vector to test
  2443. * @param p0 defines 1st triangle point
  2444. * @param p1 defines 2nd triangle point
  2445. * @param p2 defines 3rd triangle point
  2446. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2447. */
  2448. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2449. /**
  2450. * Gets the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines first vector
  2452. * @param value2 defines second vector
  2453. * @returns the distance between vectors
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines first vector
  2459. * @param value2 defines second vector
  2460. * @returns the squared distance between vectors
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2463. /**
  2464. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2465. * @param value1 defines first vector
  2466. * @param value2 defines second vector
  2467. * @returns a new Vector2
  2468. */
  2469. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2470. /**
  2471. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2472. * @param p defines the middle point
  2473. * @param segA defines one point of the segment
  2474. * @param segB defines the other point of the segment
  2475. * @returns the shortest distance
  2476. */
  2477. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2478. }
  2479. /**
  2480. * Class used to store (x,y,z) vector representation
  2481. * A Vector3 is the main object used in 3D geometry
  2482. * It can represent etiher the coordinates of a point the space, either a direction
  2483. * Reminder: js uses a left handed forward facing system
  2484. */
  2485. export class Vector3 {
  2486. private static _UpReadOnly;
  2487. private static _ZeroReadOnly;
  2488. /** @hidden */
  2489. _x: number;
  2490. /** @hidden */
  2491. _y: number;
  2492. /** @hidden */
  2493. _z: number;
  2494. /** @hidden */
  2495. _isDirty: boolean;
  2496. /** Gets or sets the x coordinate */
  2497. get x(): number;
  2498. set x(value: number);
  2499. /** Gets or sets the y coordinate */
  2500. get y(): number;
  2501. set y(value: number);
  2502. /** Gets or sets the z coordinate */
  2503. get z(): number;
  2504. set z(value: number);
  2505. /**
  2506. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2507. * @param x defines the first coordinates (on X axis)
  2508. * @param y defines the second coordinates (on Y axis)
  2509. * @param z defines the third coordinates (on Z axis)
  2510. */
  2511. constructor(x?: number, y?: number, z?: number);
  2512. /**
  2513. * Creates a string representation of the Vector3
  2514. * @returns a string with the Vector3 coordinates.
  2515. */
  2516. toString(): string;
  2517. /**
  2518. * Gets the class name
  2519. * @returns the string "Vector3"
  2520. */
  2521. getClassName(): string;
  2522. /**
  2523. * Creates the Vector3 hash code
  2524. * @returns a number which tends to be unique between Vector3 instances
  2525. */
  2526. getHashCode(): number;
  2527. /**
  2528. * Creates an array containing three elements : the coordinates of the Vector3
  2529. * @returns a new array of numbers
  2530. */
  2531. asArray(): number[];
  2532. /**
  2533. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2534. * @param array defines the destination array
  2535. * @param index defines the offset in the destination array
  2536. * @returns the current Vector3
  2537. */
  2538. toArray(array: FloatArray, index?: number): Vector3;
  2539. /**
  2540. * Update the current vector from an array
  2541. * @param array defines the destination array
  2542. * @param index defines the offset in the destination array
  2543. * @returns the current Vector3
  2544. */
  2545. fromArray(array: FloatArray, index?: number): Vector3;
  2546. /**
  2547. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2548. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2549. */
  2550. toQuaternion(): Quaternion;
  2551. /**
  2552. * Adds the given vector to the current Vector3
  2553. * @param otherVector defines the second operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2557. /**
  2558. * Adds the given coordinates to the current Vector3
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2567. * @param otherVector defines the second operand
  2568. * @returns the resulting Vector3
  2569. */
  2570. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2571. /**
  2572. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2573. * @param otherVector defines the second operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2578. /**
  2579. * Subtract the given vector from the current Vector3
  2580. * @param otherVector defines the second operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2584. /**
  2585. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2586. * @param otherVector defines the second operand
  2587. * @returns the resulting Vector3
  2588. */
  2589. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2592. * @param otherVector defines the second operand
  2593. * @param result defines the Vector3 object where to store the result
  2594. * @returns the current Vector3
  2595. */
  2596. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2597. /**
  2598. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2599. * @param x defines the x coordinate of the operand
  2600. * @param y defines the y coordinate of the operand
  2601. * @param z defines the z coordinate of the operand
  2602. * @returns the resulting Vector3
  2603. */
  2604. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2605. /**
  2606. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2607. * @param x defines the x coordinate of the operand
  2608. * @param y defines the y coordinate of the operand
  2609. * @param z defines the z coordinate of the operand
  2610. * @param result defines the Vector3 object where to store the result
  2611. * @returns the current Vector3
  2612. */
  2613. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2614. /**
  2615. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2616. * @returns a new Vector3
  2617. */
  2618. negate(): Vector3;
  2619. /**
  2620. * Negate this vector in place
  2621. * @returns this
  2622. */
  2623. negateInPlace(): Vector3;
  2624. /**
  2625. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2626. * @param result defines the Vector3 object where to store the result
  2627. * @returns the current Vector3
  2628. */
  2629. negateToRef(result: Vector3): Vector3;
  2630. /**
  2631. * Multiplies the Vector3 coordinates by the float "scale"
  2632. * @param scale defines the multiplier factor
  2633. * @returns the current updated Vector3
  2634. */
  2635. scaleInPlace(scale: number): Vector3;
  2636. /**
  2637. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2638. * @param scale defines the multiplier factor
  2639. * @returns a new Vector3
  2640. */
  2641. scale(scale: number): Vector3;
  2642. /**
  2643. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2644. * @param scale defines the multiplier factor
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. scaleToRef(scale: number, result: Vector3): Vector3;
  2649. /**
  2650. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2651. * @param scale defines the scale factor
  2652. * @param result defines the Vector3 object where to store the result
  2653. * @returns the unmodified current Vector3
  2654. */
  2655. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2656. /**
  2657. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2658. * @param origin defines the origin of the projection ray
  2659. * @param plane defines the plane to project to
  2660. * @returns the projected vector3
  2661. */
  2662. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2663. /**
  2664. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2665. * @param origin defines the origin of the projection ray
  2666. * @param plane defines the plane to project to
  2667. * @param result defines the Vector3 where to store the result
  2668. */
  2669. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2670. /**
  2671. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2672. * @param otherVector defines the second operand
  2673. * @returns true if both vectors are equals
  2674. */
  2675. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2676. /**
  2677. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2678. * @param otherVector defines the second operand
  2679. * @param epsilon defines the minimal distance to define values as equals
  2680. * @returns true if both vectors are distant less than epsilon
  2681. */
  2682. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2683. /**
  2684. * Returns true if the current Vector3 coordinates equals the given floats
  2685. * @param x defines the x coordinate of the operand
  2686. * @param y defines the y coordinate of the operand
  2687. * @param z defines the z coordinate of the operand
  2688. * @returns true if both vectors are equals
  2689. */
  2690. equalsToFloats(x: number, y: number, z: number): boolean;
  2691. /**
  2692. * Multiplies the current Vector3 coordinates by the given ones
  2693. * @param otherVector defines the second operand
  2694. * @returns the current updated Vector3
  2695. */
  2696. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2697. /**
  2698. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2699. * @param otherVector defines the second operand
  2700. * @returns the new Vector3
  2701. */
  2702. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2703. /**
  2704. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2705. * @param otherVector defines the second operand
  2706. * @param result defines the Vector3 object where to store the result
  2707. * @returns the current Vector3
  2708. */
  2709. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2710. /**
  2711. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2712. * @param x defines the x coordinate of the operand
  2713. * @param y defines the y coordinate of the operand
  2714. * @param z defines the z coordinate of the operand
  2715. * @returns the new Vector3
  2716. */
  2717. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2720. * @param otherVector defines the second operand
  2721. * @returns the new Vector3
  2722. */
  2723. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2724. /**
  2725. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2726. * @param otherVector defines the second operand
  2727. * @param result defines the Vector3 object where to store the result
  2728. * @returns the current Vector3
  2729. */
  2730. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2731. /**
  2732. * Divides the current Vector3 coordinates by the given ones.
  2733. * @param otherVector defines the second operand
  2734. * @returns the current updated Vector3
  2735. */
  2736. divideInPlace(otherVector: Vector3): Vector3;
  2737. /**
  2738. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2739. * @param other defines the second operand
  2740. * @returns the current updated Vector3
  2741. */
  2742. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2743. /**
  2744. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2745. * @param other defines the second operand
  2746. * @returns the current updated Vector3
  2747. */
  2748. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2749. /**
  2750. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2751. * @param x defines the x coordinate of the operand
  2752. * @param y defines the y coordinate of the operand
  2753. * @param z defines the z coordinate of the operand
  2754. * @returns the current updated Vector3
  2755. */
  2756. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2757. /**
  2758. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2759. * @param x defines the x coordinate of the operand
  2760. * @param y defines the y coordinate of the operand
  2761. * @param z defines the z coordinate of the operand
  2762. * @returns the current updated Vector3
  2763. */
  2764. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2765. /**
  2766. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2767. * Check if is non uniform within a certain amount of decimal places to account for this
  2768. * @param epsilon the amount the values can differ
  2769. * @returns if the the vector is non uniform to a certain number of decimal places
  2770. */
  2771. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2772. /**
  2773. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2774. */
  2775. get isNonUniform(): boolean;
  2776. /**
  2777. * Gets a new Vector3 from current Vector3 floored values
  2778. * @returns a new Vector3
  2779. */
  2780. floor(): Vector3;
  2781. /**
  2782. * Gets a new Vector3 from current Vector3 floored values
  2783. * @returns a new Vector3
  2784. */
  2785. fract(): Vector3;
  2786. /**
  2787. * Gets the length of the Vector3
  2788. * @returns the length of the Vector3
  2789. */
  2790. length(): number;
  2791. /**
  2792. * Gets the squared length of the Vector3
  2793. * @returns squared length of the Vector3
  2794. */
  2795. lengthSquared(): number;
  2796. /**
  2797. * Normalize the current Vector3.
  2798. * Please note that this is an in place operation.
  2799. * @returns the current updated Vector3
  2800. */
  2801. normalize(): Vector3;
  2802. /**
  2803. * Reorders the x y z properties of the vector in place
  2804. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2805. * @returns the current updated vector
  2806. */
  2807. reorderInPlace(order: string): this;
  2808. /**
  2809. * Rotates the vector around 0,0,0 by a quaternion
  2810. * @param quaternion the rotation quaternion
  2811. * @param result vector to store the result
  2812. * @returns the resulting vector
  2813. */
  2814. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2815. /**
  2816. * Rotates a vector around a given point
  2817. * @param quaternion the rotation quaternion
  2818. * @param point the point to rotate around
  2819. * @param result vector to store the result
  2820. * @returns the resulting vector
  2821. */
  2822. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2823. /**
  2824. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2825. * The cross product is then orthogonal to both current and "other"
  2826. * @param other defines the right operand
  2827. * @returns the cross product
  2828. */
  2829. cross(other: Vector3): Vector3;
  2830. /**
  2831. * Normalize the current Vector3 with the given input length.
  2832. * Please note that this is an in place operation.
  2833. * @param len the length of the vector
  2834. * @returns the current updated Vector3
  2835. */
  2836. normalizeFromLength(len: number): Vector3;
  2837. /**
  2838. * Normalize the current Vector3 to a new vector
  2839. * @returns the new Vector3
  2840. */
  2841. normalizeToNew(): Vector3;
  2842. /**
  2843. * Normalize the current Vector3 to the reference
  2844. * @param reference define the Vector3 to update
  2845. * @returns the updated Vector3
  2846. */
  2847. normalizeToRef(reference: Vector3): Vector3;
  2848. /**
  2849. * Creates a new Vector3 copied from the current Vector3
  2850. * @returns the new Vector3
  2851. */
  2852. clone(): Vector3;
  2853. /**
  2854. * Copies the given vector coordinates to the current Vector3 ones
  2855. * @param source defines the source Vector3
  2856. * @returns the current updated Vector3
  2857. */
  2858. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2859. /**
  2860. * Copies the given floats to the current Vector3 coordinates
  2861. * @param x defines the x coordinate of the operand
  2862. * @param y defines the y coordinate of the operand
  2863. * @param z defines the z coordinate of the operand
  2864. * @returns the current updated Vector3
  2865. */
  2866. copyFromFloats(x: number, y: number, z: number): Vector3;
  2867. /**
  2868. * Copies the given floats to the current Vector3 coordinates
  2869. * @param x defines the x coordinate of the operand
  2870. * @param y defines the y coordinate of the operand
  2871. * @param z defines the z coordinate of the operand
  2872. * @returns the current updated Vector3
  2873. */
  2874. set(x: number, y: number, z: number): Vector3;
  2875. /**
  2876. * Copies the given float to the current Vector3 coordinates
  2877. * @param v defines the x, y and z coordinates of the operand
  2878. * @returns the current updated Vector3
  2879. */
  2880. setAll(v: number): Vector3;
  2881. /**
  2882. * Get the clip factor between two vectors
  2883. * @param vector0 defines the first operand
  2884. * @param vector1 defines the second operand
  2885. * @param axis defines the axis to use
  2886. * @param size defines the size along the axis
  2887. * @returns the clip factor
  2888. */
  2889. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2890. /**
  2891. * Get angle between two vectors
  2892. * @param vector0 angle between vector0 and vector1
  2893. * @param vector1 angle between vector0 and vector1
  2894. * @param normal direction of the normal
  2895. * @return the angle between vector0 and vector1
  2896. */
  2897. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2898. /**
  2899. * Returns a new Vector3 set from the index "offset" of the given array
  2900. * @param array defines the source array
  2901. * @param offset defines the offset in the source array
  2902. * @returns the new Vector3
  2903. */
  2904. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2907. * @param array defines the source array
  2908. * @param offset defines the offset in the source array
  2909. * @returns the new Vector3
  2910. * @deprecated Please use FromArray instead.
  2911. */
  2912. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2913. /**
  2914. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2915. * @param array defines the source array
  2916. * @param offset defines the offset in the source array
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2920. /**
  2921. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2922. * @param array defines the source array
  2923. * @param offset defines the offset in the source array
  2924. * @param result defines the Vector3 where to store the result
  2925. * @deprecated Please use FromArrayToRef instead.
  2926. */
  2927. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2928. /**
  2929. * Sets the given vector "result" with the given floats.
  2930. * @param x defines the x coordinate of the source
  2931. * @param y defines the y coordinate of the source
  2932. * @param z defines the z coordinate of the source
  2933. * @param result defines the Vector3 where to store the result
  2934. */
  2935. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2936. /**
  2937. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2938. * @returns a new empty Vector3
  2939. */
  2940. static Zero(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2943. * @returns a new unit Vector3
  2944. */
  2945. static One(): Vector3;
  2946. /**
  2947. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2948. * @returns a new up Vector3
  2949. */
  2950. static Up(): Vector3;
  2951. /**
  2952. * Gets a up Vector3 that must not be updated
  2953. */
  2954. static get UpReadOnly(): DeepImmutable<Vector3>;
  2955. /**
  2956. * Gets a zero Vector3 that must not be updated
  2957. */
  2958. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2961. * @returns a new down Vector3
  2962. */
  2963. static Down(): Vector3;
  2964. /**
  2965. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2966. * @param rightHandedSystem is the scene right-handed (negative z)
  2967. * @returns a new forward Vector3
  2968. */
  2969. static Forward(rightHandedSystem?: boolean): Vector3;
  2970. /**
  2971. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2972. * @param rightHandedSystem is the scene right-handed (negative-z)
  2973. * @returns a new forward Vector3
  2974. */
  2975. static Backward(rightHandedSystem?: boolean): Vector3;
  2976. /**
  2977. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2978. * @returns a new right Vector3
  2979. */
  2980. static Right(): Vector3;
  2981. /**
  2982. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2983. * @returns a new left Vector3
  2984. */
  2985. static Left(): Vector3;
  2986. /**
  2987. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2988. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2989. * @param vector defines the Vector3 to transform
  2990. * @param transformation defines the transformation matrix
  2991. * @returns the transformed Vector3
  2992. */
  2993. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2994. /**
  2995. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2996. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2997. * @param vector defines the Vector3 to transform
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3004. * This method computes tranformed coordinates only, not transformed direction vectors
  3005. * @param x define the x coordinate of the source vector
  3006. * @param y define the y coordinate of the source vector
  3007. * @param z define the z coordinate of the source vector
  3008. * @param transformation defines the transformation matrix
  3009. * @param result defines the Vector3 where to store the result
  3010. */
  3011. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3012. /**
  3013. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3014. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3015. * @param vector defines the Vector3 to transform
  3016. * @param transformation defines the transformation matrix
  3017. * @returns the new Vector3
  3018. */
  3019. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3020. /**
  3021. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3022. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3023. * @param vector defines the Vector3 to transform
  3024. * @param transformation defines the transformation matrix
  3025. * @param result defines the Vector3 where to store the result
  3026. */
  3027. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3028. /**
  3029. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3030. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3031. * @param x define the x coordinate of the source vector
  3032. * @param y define the y coordinate of the source vector
  3033. * @param z define the z coordinate of the source vector
  3034. * @param transformation defines the transformation matrix
  3035. * @param result defines the Vector3 where to store the result
  3036. */
  3037. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3038. /**
  3039. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3040. * @param value1 defines the first control point
  3041. * @param value2 defines the second control point
  3042. * @param value3 defines the third control point
  3043. * @param value4 defines the fourth control point
  3044. * @param amount defines the amount on the spline to use
  3045. * @returns the new Vector3
  3046. */
  3047. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3048. /**
  3049. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3050. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3051. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3052. * @param value defines the current value
  3053. * @param min defines the lower range value
  3054. * @param max defines the upper range value
  3055. * @returns the new Vector3
  3056. */
  3057. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3058. /**
  3059. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3060. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3061. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3062. * @param value defines the current value
  3063. * @param min defines the lower range value
  3064. * @param max defines the upper range value
  3065. * @param result defines the Vector3 where to store the result
  3066. */
  3067. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3068. /**
  3069. * Checks if a given vector is inside a specific range
  3070. * @param v defines the vector to test
  3071. * @param min defines the minimum range
  3072. * @param max defines the maximum range
  3073. */
  3074. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3075. /**
  3076. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3077. * @param value1 defines the first control point
  3078. * @param tangent1 defines the first tangent vector
  3079. * @param value2 defines the second control point
  3080. * @param tangent2 defines the second tangent vector
  3081. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3082. * @returns the new Vector3
  3083. */
  3084. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3085. /**
  3086. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3087. * @param start defines the start value
  3088. * @param end defines the end value
  3089. * @param amount max defines amount between both (between 0 and 1)
  3090. * @returns the new Vector3
  3091. */
  3092. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3093. /**
  3094. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3095. * @param start defines the start value
  3096. * @param end defines the end value
  3097. * @param amount max defines amount between both (between 0 and 1)
  3098. * @param result defines the Vector3 where to store the result
  3099. */
  3100. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3101. /**
  3102. * Returns the dot product (float) between the vectors "left" and "right"
  3103. * @param left defines the left operand
  3104. * @param right defines the right operand
  3105. * @returns the dot product
  3106. */
  3107. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3108. /**
  3109. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3110. * The cross product is then orthogonal to both "left" and "right"
  3111. * @param left defines the left operand
  3112. * @param right defines the right operand
  3113. * @returns the cross product
  3114. */
  3115. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3116. /**
  3117. * Sets the given vector "result" with the cross product of "left" and "right"
  3118. * The cross product is then orthogonal to both "left" and "right"
  3119. * @param left defines the left operand
  3120. * @param right defines the right operand
  3121. * @param result defines the Vector3 where to store the result
  3122. */
  3123. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3124. /**
  3125. * Returns a new Vector3 as the normalization of the given vector
  3126. * @param vector defines the Vector3 to normalize
  3127. * @returns the new Vector3
  3128. */
  3129. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3130. /**
  3131. * Sets the given vector "result" with the normalization of the given first vector
  3132. * @param vector defines the Vector3 to normalize
  3133. * @param result defines the Vector3 where to store the result
  3134. */
  3135. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3136. /**
  3137. * Project a Vector3 onto screen space
  3138. * @param vector defines the Vector3 to project
  3139. * @param world defines the world matrix to use
  3140. * @param transform defines the transform (view x projection) matrix to use
  3141. * @param viewport defines the screen viewport to use
  3142. * @returns the new Vector3
  3143. */
  3144. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3145. /** @hidden */
  3146. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3147. /**
  3148. * Unproject from screen space to object space
  3149. * @param source defines the screen space Vector3 to use
  3150. * @param viewportWidth defines the current width of the viewport
  3151. * @param viewportHeight defines the current height of the viewport
  3152. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3153. * @param transform defines the transform (view x projection) matrix to use
  3154. * @returns the new Vector3
  3155. */
  3156. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3157. /**
  3158. * Unproject from screen space to object space
  3159. * @param source defines the screen space Vector3 to use
  3160. * @param viewportWidth defines the current width of the viewport
  3161. * @param viewportHeight defines the current height of the viewport
  3162. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3163. * @param view defines the view matrix to use
  3164. * @param projection defines the projection matrix to use
  3165. * @returns the new Vector3
  3166. */
  3167. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3168. /**
  3169. * Unproject from screen space to object space
  3170. * @param source defines the screen space Vector3 to use
  3171. * @param viewportWidth defines the current width of the viewport
  3172. * @param viewportHeight defines the current height of the viewport
  3173. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3174. * @param view defines the view matrix to use
  3175. * @param projection defines the projection matrix to use
  3176. * @param result defines the Vector3 where to store the result
  3177. */
  3178. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3179. /**
  3180. * Unproject from screen space to object space
  3181. * @param sourceX defines the screen space x coordinate to use
  3182. * @param sourceY defines the screen space y coordinate to use
  3183. * @param sourceZ defines the screen space z coordinate to use
  3184. * @param viewportWidth defines the current width of the viewport
  3185. * @param viewportHeight defines the current height of the viewport
  3186. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3187. * @param view defines the view matrix to use
  3188. * @param projection defines the projection matrix to use
  3189. * @param result defines the Vector3 where to store the result
  3190. */
  3191. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3192. /**
  3193. * Gets the minimal coordinate values between two Vector3
  3194. * @param left defines the first operand
  3195. * @param right defines the second operand
  3196. * @returns the new Vector3
  3197. */
  3198. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3199. /**
  3200. * Gets the maximal coordinate values between two Vector3
  3201. * @param left defines the first operand
  3202. * @param right defines the second operand
  3203. * @returns the new Vector3
  3204. */
  3205. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3206. /**
  3207. * Returns the distance between the vectors "value1" and "value2"
  3208. * @param value1 defines the first operand
  3209. * @param value2 defines the second operand
  3210. * @returns the distance
  3211. */
  3212. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3213. /**
  3214. * Returns the squared distance between the vectors "value1" and "value2"
  3215. * @param value1 defines the first operand
  3216. * @param value2 defines the second operand
  3217. * @returns the squared distance
  3218. */
  3219. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3220. /**
  3221. * Returns a new Vector3 located at the center between "value1" and "value2"
  3222. * @param value1 defines the first operand
  3223. * @param value2 defines the second operand
  3224. * @returns the new Vector3
  3225. */
  3226. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3227. /**
  3228. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3229. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3230. * to something in order to rotate it from its local system to the given target system
  3231. * Note: axis1, axis2 and axis3 are normalized during this operation
  3232. * @param axis1 defines the first axis
  3233. * @param axis2 defines the second axis
  3234. * @param axis3 defines the third axis
  3235. * @returns a new Vector3
  3236. */
  3237. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3238. /**
  3239. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3240. * @param axis1 defines the first axis
  3241. * @param axis2 defines the second axis
  3242. * @param axis3 defines the third axis
  3243. * @param ref defines the Vector3 where to store the result
  3244. */
  3245. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3246. }
  3247. /**
  3248. * Vector4 class created for EulerAngle class conversion to Quaternion
  3249. */
  3250. export class Vector4 {
  3251. /** x value of the vector */
  3252. x: number;
  3253. /** y value of the vector */
  3254. y: number;
  3255. /** z value of the vector */
  3256. z: number;
  3257. /** w value of the vector */
  3258. w: number;
  3259. /**
  3260. * Creates a Vector4 object from the given floats.
  3261. * @param x x value of the vector
  3262. * @param y y value of the vector
  3263. * @param z z value of the vector
  3264. * @param w w value of the vector
  3265. */
  3266. constructor(
  3267. /** x value of the vector */
  3268. x: number,
  3269. /** y value of the vector */
  3270. y: number,
  3271. /** z value of the vector */
  3272. z: number,
  3273. /** w value of the vector */
  3274. w: number);
  3275. /**
  3276. * Returns the string with the Vector4 coordinates.
  3277. * @returns a string containing all the vector values
  3278. */
  3279. toString(): string;
  3280. /**
  3281. * Returns the string "Vector4".
  3282. * @returns "Vector4"
  3283. */
  3284. getClassName(): string;
  3285. /**
  3286. * Returns the Vector4 hash code.
  3287. * @returns a unique hash code
  3288. */
  3289. getHashCode(): number;
  3290. /**
  3291. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3292. * @returns the resulting array
  3293. */
  3294. asArray(): number[];
  3295. /**
  3296. * Populates the given array from the given index with the Vector4 coordinates.
  3297. * @param array array to populate
  3298. * @param index index of the array to start at (default: 0)
  3299. * @returns the Vector4.
  3300. */
  3301. toArray(array: FloatArray, index?: number): Vector4;
  3302. /**
  3303. * Update the current vector from an array
  3304. * @param array defines the destination array
  3305. * @param index defines the offset in the destination array
  3306. * @returns the current Vector3
  3307. */
  3308. fromArray(array: FloatArray, index?: number): Vector4;
  3309. /**
  3310. * Adds the given vector to the current Vector4.
  3311. * @param otherVector the vector to add
  3312. * @returns the updated Vector4.
  3313. */
  3314. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3315. /**
  3316. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3317. * @param otherVector the vector to add
  3318. * @returns the resulting vector
  3319. */
  3320. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3321. /**
  3322. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3323. * @param otherVector the vector to add
  3324. * @param result the vector to store the result
  3325. * @returns the current Vector4.
  3326. */
  3327. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3328. /**
  3329. * Subtract in place the given vector from the current Vector4.
  3330. * @param otherVector the vector to subtract
  3331. * @returns the updated Vector4.
  3332. */
  3333. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3336. * @param otherVector the vector to add
  3337. * @returns the new vector with the result
  3338. */
  3339. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3342. * @param otherVector the vector to subtract
  3343. * @param result the vector to store the result
  3344. * @returns the current Vector4.
  3345. */
  3346. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3347. /**
  3348. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3349. */
  3350. /**
  3351. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3352. * @param x value to subtract
  3353. * @param y value to subtract
  3354. * @param z value to subtract
  3355. * @param w value to subtract
  3356. * @returns new vector containing the result
  3357. */
  3358. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3359. /**
  3360. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3361. * @param x value to subtract
  3362. * @param y value to subtract
  3363. * @param z value to subtract
  3364. * @param w value to subtract
  3365. * @param result the vector to store the result in
  3366. * @returns the current Vector4.
  3367. */
  3368. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3369. /**
  3370. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3371. * @returns a new vector with the negated values
  3372. */
  3373. negate(): Vector4;
  3374. /**
  3375. * Negate this vector in place
  3376. * @returns this
  3377. */
  3378. negateInPlace(): Vector4;
  3379. /**
  3380. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3381. * @param result defines the Vector3 object where to store the result
  3382. * @returns the current Vector4
  3383. */
  3384. negateToRef(result: Vector4): Vector4;
  3385. /**
  3386. * Multiplies the current Vector4 coordinates by scale (float).
  3387. * @param scale the number to scale with
  3388. * @returns the updated Vector4.
  3389. */
  3390. scaleInPlace(scale: number): Vector4;
  3391. /**
  3392. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3393. * @param scale the number to scale with
  3394. * @returns a new vector with the result
  3395. */
  3396. scale(scale: number): Vector4;
  3397. /**
  3398. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3399. * @param scale the number to scale with
  3400. * @param result a vector to store the result in
  3401. * @returns the current Vector4.
  3402. */
  3403. scaleToRef(scale: number, result: Vector4): Vector4;
  3404. /**
  3405. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3406. * @param scale defines the scale factor
  3407. * @param result defines the Vector4 object where to store the result
  3408. * @returns the unmodified current Vector4
  3409. */
  3410. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3411. /**
  3412. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3413. * @param otherVector the vector to compare against
  3414. * @returns true if they are equal
  3415. */
  3416. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3417. /**
  3418. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3419. * @param otherVector vector to compare against
  3420. * @param epsilon (Default: very small number)
  3421. * @returns true if they are equal
  3422. */
  3423. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3424. /**
  3425. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3426. * @param x x value to compare against
  3427. * @param y y value to compare against
  3428. * @param z z value to compare against
  3429. * @param w w value to compare against
  3430. * @returns true if equal
  3431. */
  3432. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3433. /**
  3434. * Multiplies in place the current Vector4 by the given one.
  3435. * @param otherVector vector to multiple with
  3436. * @returns the updated Vector4.
  3437. */
  3438. multiplyInPlace(otherVector: Vector4): Vector4;
  3439. /**
  3440. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3441. * @param otherVector vector to multiple with
  3442. * @returns resulting new vector
  3443. */
  3444. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3445. /**
  3446. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3447. * @param otherVector vector to multiple with
  3448. * @param result vector to store the result
  3449. * @returns the current Vector4.
  3450. */
  3451. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3452. /**
  3453. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3454. * @param x x value multiply with
  3455. * @param y y value multiply with
  3456. * @param z z value multiply with
  3457. * @param w w value multiply with
  3458. * @returns resulting new vector
  3459. */
  3460. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3461. /**
  3462. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3463. * @param otherVector vector to devide with
  3464. * @returns resulting new vector
  3465. */
  3466. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3467. /**
  3468. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3469. * @param otherVector vector to devide with
  3470. * @param result vector to store the result
  3471. * @returns the current Vector4.
  3472. */
  3473. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3474. /**
  3475. * Divides the current Vector3 coordinates by the given ones.
  3476. * @param otherVector vector to devide with
  3477. * @returns the updated Vector3.
  3478. */
  3479. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3480. /**
  3481. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3482. * @param other defines the second operand
  3483. * @returns the current updated Vector4
  3484. */
  3485. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3488. * @param other defines the second operand
  3489. * @returns the current updated Vector4
  3490. */
  3491. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3492. /**
  3493. * Gets a new Vector4 from current Vector4 floored values
  3494. * @returns a new Vector4
  3495. */
  3496. floor(): Vector4;
  3497. /**
  3498. * Gets a new Vector4 from current Vector3 floored values
  3499. * @returns a new Vector4
  3500. */
  3501. fract(): Vector4;
  3502. /**
  3503. * Returns the Vector4 length (float).
  3504. * @returns the length
  3505. */
  3506. length(): number;
  3507. /**
  3508. * Returns the Vector4 squared length (float).
  3509. * @returns the length squared
  3510. */
  3511. lengthSquared(): number;
  3512. /**
  3513. * Normalizes in place the Vector4.
  3514. * @returns the updated Vector4.
  3515. */
  3516. normalize(): Vector4;
  3517. /**
  3518. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3519. * @returns this converted to a new vector3
  3520. */
  3521. toVector3(): Vector3;
  3522. /**
  3523. * Returns a new Vector4 copied from the current one.
  3524. * @returns the new cloned vector
  3525. */
  3526. clone(): Vector4;
  3527. /**
  3528. * Updates the current Vector4 with the given one coordinates.
  3529. * @param source the source vector to copy from
  3530. * @returns the updated Vector4.
  3531. */
  3532. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3533. /**
  3534. * Updates the current Vector4 coordinates with the given floats.
  3535. * @param x float to copy from
  3536. * @param y float to copy from
  3537. * @param z float to copy from
  3538. * @param w float to copy from
  3539. * @returns the updated Vector4.
  3540. */
  3541. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3542. /**
  3543. * Updates the current Vector4 coordinates with the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @returns the updated Vector4.
  3549. */
  3550. set(x: number, y: number, z: number, w: number): Vector4;
  3551. /**
  3552. * Copies the given float to the current Vector3 coordinates
  3553. * @param v defines the x, y, z and w coordinates of the operand
  3554. * @returns the current updated Vector3
  3555. */
  3556. setAll(v: number): Vector4;
  3557. /**
  3558. * Returns a new Vector4 set from the starting index of the given array.
  3559. * @param array the array to pull values from
  3560. * @param offset the offset into the array to start at
  3561. * @returns the new vector
  3562. */
  3563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3564. /**
  3565. * Updates the given vector "result" from the starting index of the given array.
  3566. * @param array the array to pull values from
  3567. * @param offset the offset into the array to start at
  3568. * @param result the vector to store the result in
  3569. */
  3570. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3571. /**
  3572. * Updates the given vector "result" from the starting index of the given Float32Array.
  3573. * @param array the array to pull values from
  3574. * @param offset the offset into the array to start at
  3575. * @param result the vector to store the result in
  3576. */
  3577. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3578. /**
  3579. * Updates the given vector "result" coordinates from the given floats.
  3580. * @param x float to set from
  3581. * @param y float to set from
  3582. * @param z float to set from
  3583. * @param w float to set from
  3584. * @param result the vector to the floats in
  3585. */
  3586. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3587. /**
  3588. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3589. * @returns the new vector
  3590. */
  3591. static Zero(): Vector4;
  3592. /**
  3593. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3594. * @returns the new vector
  3595. */
  3596. static One(): Vector4;
  3597. /**
  3598. * Returns a new normalized Vector4 from the given one.
  3599. * @param vector the vector to normalize
  3600. * @returns the vector
  3601. */
  3602. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3603. /**
  3604. * Updates the given vector "result" from the normalization of the given one.
  3605. * @param vector the vector to normalize
  3606. * @param result the vector to store the result in
  3607. */
  3608. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3609. /**
  3610. * Returns a vector with the minimum values from the left and right vectors
  3611. * @param left left vector to minimize
  3612. * @param right right vector to minimize
  3613. * @returns a new vector with the minimum of the left and right vector values
  3614. */
  3615. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3616. /**
  3617. * Returns a vector with the maximum values from the left and right vectors
  3618. * @param left left vector to maximize
  3619. * @param right right vector to maximize
  3620. * @returns a new vector with the maximum of the left and right vector values
  3621. */
  3622. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3623. /**
  3624. * Returns the distance (float) between the vectors "value1" and "value2".
  3625. * @param value1 value to calulate the distance between
  3626. * @param value2 value to calulate the distance between
  3627. * @return the distance between the two vectors
  3628. */
  3629. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3630. /**
  3631. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3632. * @param value1 value to calulate the distance between
  3633. * @param value2 value to calulate the distance between
  3634. * @return the distance between the two vectors squared
  3635. */
  3636. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3637. /**
  3638. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3639. * @param value1 value to calulate the center between
  3640. * @param value2 value to calulate the center between
  3641. * @return the center between the two vectors
  3642. */
  3643. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3644. /**
  3645. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3646. * This methods computes transformed normalized direction vectors only.
  3647. * @param vector the vector to transform
  3648. * @param transformation the transformation matrix to apply
  3649. * @returns the new vector
  3650. */
  3651. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3652. /**
  3653. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3654. * This methods computes transformed normalized direction vectors only.
  3655. * @param vector the vector to transform
  3656. * @param transformation the transformation matrix to apply
  3657. * @param result the vector to store the result in
  3658. */
  3659. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3660. /**
  3661. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3662. * This methods computes transformed normalized direction vectors only.
  3663. * @param x value to transform
  3664. * @param y value to transform
  3665. * @param z value to transform
  3666. * @param w value to transform
  3667. * @param transformation the transformation matrix to apply
  3668. * @param result the vector to store the results in
  3669. */
  3670. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3671. /**
  3672. * Creates a new Vector4 from a Vector3
  3673. * @param source defines the source data
  3674. * @param w defines the 4th component (default is 0)
  3675. * @returns a new Vector4
  3676. */
  3677. static FromVector3(source: Vector3, w?: number): Vector4;
  3678. }
  3679. /**
  3680. * Class used to store quaternion data
  3681. * @see https://en.wikipedia.org/wiki/Quaternion
  3682. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3683. */
  3684. export class Quaternion {
  3685. /** @hidden */
  3686. _x: number;
  3687. /** @hidden */
  3688. _y: number;
  3689. /** @hidden */
  3690. _z: number;
  3691. /** @hidden */
  3692. _w: number;
  3693. /** @hidden */
  3694. _isDirty: boolean;
  3695. /** Gets or sets the x coordinate */
  3696. get x(): number;
  3697. set x(value: number);
  3698. /** Gets or sets the y coordinate */
  3699. get y(): number;
  3700. set y(value: number);
  3701. /** Gets or sets the z coordinate */
  3702. get z(): number;
  3703. set z(value: number);
  3704. /** Gets or sets the w coordinate */
  3705. get w(): number;
  3706. set w(value: number);
  3707. /**
  3708. * Creates a new Quaternion from the given floats
  3709. * @param x defines the first component (0 by default)
  3710. * @param y defines the second component (0 by default)
  3711. * @param z defines the third component (0 by default)
  3712. * @param w defines the fourth component (1.0 by default)
  3713. */
  3714. constructor(x?: number, y?: number, z?: number, w?: number);
  3715. /**
  3716. * Gets a string representation for the current quaternion
  3717. * @returns a string with the Quaternion coordinates
  3718. */
  3719. toString(): string;
  3720. /**
  3721. * Gets the class name of the quaternion
  3722. * @returns the string "Quaternion"
  3723. */
  3724. getClassName(): string;
  3725. /**
  3726. * Gets a hash code for this quaternion
  3727. * @returns the quaternion hash code
  3728. */
  3729. getHashCode(): number;
  3730. /**
  3731. * Copy the quaternion to an array
  3732. * @returns a new array populated with 4 elements from the quaternion coordinates
  3733. */
  3734. asArray(): number[];
  3735. /**
  3736. * Check if two quaternions are equals
  3737. * @param otherQuaternion defines the second operand
  3738. * @return true if the current quaternion and the given one coordinates are strictly equals
  3739. */
  3740. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3741. /**
  3742. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3743. * @param otherQuaternion defines the other quaternion
  3744. * @param epsilon defines the minimal distance to consider equality
  3745. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3746. */
  3747. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3748. /**
  3749. * Clone the current quaternion
  3750. * @returns a new quaternion copied from the current one
  3751. */
  3752. clone(): Quaternion;
  3753. /**
  3754. * Copy a quaternion to the current one
  3755. * @param other defines the other quaternion
  3756. * @returns the updated current quaternion
  3757. */
  3758. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3759. /**
  3760. * Updates the current quaternion with the given float coordinates
  3761. * @param x defines the x coordinate
  3762. * @param y defines the y coordinate
  3763. * @param z defines the z coordinate
  3764. * @param w defines the w coordinate
  3765. * @returns the updated current quaternion
  3766. */
  3767. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3768. /**
  3769. * Updates the current quaternion from the given float coordinates
  3770. * @param x defines the x coordinate
  3771. * @param y defines the y coordinate
  3772. * @param z defines the z coordinate
  3773. * @param w defines the w coordinate
  3774. * @returns the updated current quaternion
  3775. */
  3776. set(x: number, y: number, z: number, w: number): Quaternion;
  3777. /**
  3778. * Adds two quaternions
  3779. * @param other defines the second operand
  3780. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3781. */
  3782. add(other: DeepImmutable<Quaternion>): Quaternion;
  3783. /**
  3784. * Add a quaternion to the current one
  3785. * @param other defines the quaternion to add
  3786. * @returns the current quaternion
  3787. */
  3788. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3789. /**
  3790. * Subtract two quaternions
  3791. * @param other defines the second operand
  3792. * @returns a new quaternion as the subtraction result of the given one from the current one
  3793. */
  3794. subtract(other: Quaternion): Quaternion;
  3795. /**
  3796. * Multiplies the current quaternion by a scale factor
  3797. * @param value defines the scale factor
  3798. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3799. */
  3800. scale(value: number): Quaternion;
  3801. /**
  3802. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3803. * @param scale defines the scale factor
  3804. * @param result defines the Quaternion object where to store the result
  3805. * @returns the unmodified current quaternion
  3806. */
  3807. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3808. /**
  3809. * Multiplies in place the current quaternion by a scale factor
  3810. * @param value defines the scale factor
  3811. * @returns the current modified quaternion
  3812. */
  3813. scaleInPlace(value: number): Quaternion;
  3814. /**
  3815. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3816. * @param scale defines the scale factor
  3817. * @param result defines the Quaternion object where to store the result
  3818. * @returns the unmodified current quaternion
  3819. */
  3820. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3821. /**
  3822. * Multiplies two quaternions
  3823. * @param q1 defines the second operand
  3824. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3825. */
  3826. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3827. /**
  3828. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3829. * @param q1 defines the second operand
  3830. * @param result defines the target quaternion
  3831. * @returns the current quaternion
  3832. */
  3833. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3834. /**
  3835. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3836. * @param q1 defines the second operand
  3837. * @returns the currentupdated quaternion
  3838. */
  3839. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3840. /**
  3841. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3842. * @param ref defines the target quaternion
  3843. * @returns the current quaternion
  3844. */
  3845. conjugateToRef(ref: Quaternion): Quaternion;
  3846. /**
  3847. * Conjugates in place (1-q) the current quaternion
  3848. * @returns the current updated quaternion
  3849. */
  3850. conjugateInPlace(): Quaternion;
  3851. /**
  3852. * Conjugates in place (1-q) the current quaternion
  3853. * @returns a new quaternion
  3854. */
  3855. conjugate(): Quaternion;
  3856. /**
  3857. * Gets length of current quaternion
  3858. * @returns the quaternion length (float)
  3859. */
  3860. length(): number;
  3861. /**
  3862. * Normalize in place the current quaternion
  3863. * @returns the current updated quaternion
  3864. */
  3865. normalize(): Quaternion;
  3866. /**
  3867. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3868. * @param order is a reserved parameter and is ignore for now
  3869. * @returns a new Vector3 containing the Euler angles
  3870. */
  3871. toEulerAngles(order?: string): Vector3;
  3872. /**
  3873. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3874. * @param result defines the vector which will be filled with the Euler angles
  3875. * @param order is a reserved parameter and is ignore for now
  3876. * @returns the current unchanged quaternion
  3877. */
  3878. toEulerAnglesToRef(result: Vector3): Quaternion;
  3879. /**
  3880. * Updates the given rotation matrix with the current quaternion values
  3881. * @param result defines the target matrix
  3882. * @returns the current unchanged quaternion
  3883. */
  3884. toRotationMatrix(result: Matrix): Quaternion;
  3885. /**
  3886. * Updates the current quaternion from the given rotation matrix values
  3887. * @param matrix defines the source matrix
  3888. * @returns the current updated quaternion
  3889. */
  3890. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3891. /**
  3892. * Creates a new quaternion from a rotation matrix
  3893. * @param matrix defines the source matrix
  3894. * @returns a new quaternion created from the given rotation matrix values
  3895. */
  3896. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3897. /**
  3898. * Updates the given quaternion with the given rotation matrix values
  3899. * @param matrix defines the source matrix
  3900. * @param result defines the target quaternion
  3901. */
  3902. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3903. /**
  3904. * Returns the dot product (float) between the quaternions "left" and "right"
  3905. * @param left defines the left operand
  3906. * @param right defines the right operand
  3907. * @returns the dot product
  3908. */
  3909. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3910. /**
  3911. * Checks if the two quaternions are close to each other
  3912. * @param quat0 defines the first quaternion to check
  3913. * @param quat1 defines the second quaternion to check
  3914. * @returns true if the two quaternions are close to each other
  3915. */
  3916. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3917. /**
  3918. * Creates an empty quaternion
  3919. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3920. */
  3921. static Zero(): Quaternion;
  3922. /**
  3923. * Inverse a given quaternion
  3924. * @param q defines the source quaternion
  3925. * @returns a new quaternion as the inverted current quaternion
  3926. */
  3927. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3928. /**
  3929. * Inverse a given quaternion
  3930. * @param q defines the source quaternion
  3931. * @param result the quaternion the result will be stored in
  3932. * @returns the result quaternion
  3933. */
  3934. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3935. /**
  3936. * Creates an identity quaternion
  3937. * @returns the identity quaternion
  3938. */
  3939. static Identity(): Quaternion;
  3940. /**
  3941. * Gets a boolean indicating if the given quaternion is identity
  3942. * @param quaternion defines the quaternion to check
  3943. * @returns true if the quaternion is identity
  3944. */
  3945. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3946. /**
  3947. * Creates a quaternion from a rotation around an axis
  3948. * @param axis defines the axis to use
  3949. * @param angle defines the angle to use
  3950. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3951. */
  3952. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3953. /**
  3954. * Creates a rotation around an axis and stores it into the given quaternion
  3955. * @param axis defines the axis to use
  3956. * @param angle defines the angle to use
  3957. * @param result defines the target quaternion
  3958. * @returns the target quaternion
  3959. */
  3960. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3961. /**
  3962. * Creates a new quaternion from data stored into an array
  3963. * @param array defines the data source
  3964. * @param offset defines the offset in the source array where the data starts
  3965. * @returns a new quaternion
  3966. */
  3967. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3968. /**
  3969. * Updates the given quaternion "result" from the starting index of the given array.
  3970. * @param array the array to pull values from
  3971. * @param offset the offset into the array to start at
  3972. * @param result the quaternion to store the result in
  3973. */
  3974. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3975. /**
  3976. * Create a quaternion from Euler rotation angles
  3977. * @param x Pitch
  3978. * @param y Yaw
  3979. * @param z Roll
  3980. * @returns the new Quaternion
  3981. */
  3982. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3983. /**
  3984. * Updates a quaternion from Euler rotation angles
  3985. * @param x Pitch
  3986. * @param y Yaw
  3987. * @param z Roll
  3988. * @param result the quaternion to store the result
  3989. * @returns the updated quaternion
  3990. */
  3991. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3992. /**
  3993. * Create a quaternion from Euler rotation vector
  3994. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3995. * @returns the new Quaternion
  3996. */
  3997. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3998. /**
  3999. * Updates a quaternion from Euler rotation vector
  4000. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4001. * @param result the quaternion to store the result
  4002. * @returns the updated quaternion
  4003. */
  4004. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4005. /**
  4006. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4007. * @param yaw defines the rotation around Y axis
  4008. * @param pitch defines the rotation around X axis
  4009. * @param roll defines the rotation around Z axis
  4010. * @returns the new quaternion
  4011. */
  4012. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4013. /**
  4014. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4015. * @param yaw defines the rotation around Y axis
  4016. * @param pitch defines the rotation around X axis
  4017. * @param roll defines the rotation around Z axis
  4018. * @param result defines the target quaternion
  4019. */
  4020. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4021. /**
  4022. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4023. * @param alpha defines the rotation around first axis
  4024. * @param beta defines the rotation around second axis
  4025. * @param gamma defines the rotation around third axis
  4026. * @returns the new quaternion
  4027. */
  4028. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4029. /**
  4030. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4031. * @param alpha defines the rotation around first axis
  4032. * @param beta defines the rotation around second axis
  4033. * @param gamma defines the rotation around third axis
  4034. * @param result defines the target quaternion
  4035. */
  4036. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4037. /**
  4038. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4039. * @param axis1 defines the first axis
  4040. * @param axis2 defines the second axis
  4041. * @param axis3 defines the third axis
  4042. * @returns the new quaternion
  4043. */
  4044. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4045. /**
  4046. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4047. * @param axis1 defines the first axis
  4048. * @param axis2 defines the second axis
  4049. * @param axis3 defines the third axis
  4050. * @param ref defines the target quaternion
  4051. */
  4052. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4053. /**
  4054. * Interpolates between two quaternions
  4055. * @param left defines first quaternion
  4056. * @param right defines second quaternion
  4057. * @param amount defines the gradient to use
  4058. * @returns the new interpolated quaternion
  4059. */
  4060. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4061. /**
  4062. * Interpolates between two quaternions and stores it into a target quaternion
  4063. * @param left defines first quaternion
  4064. * @param right defines second quaternion
  4065. * @param amount defines the gradient to use
  4066. * @param result defines the target quaternion
  4067. */
  4068. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4069. /**
  4070. * Interpolate between two quaternions using Hermite interpolation
  4071. * @param value1 defines first quaternion
  4072. * @param tangent1 defines the incoming tangent
  4073. * @param value2 defines second quaternion
  4074. * @param tangent2 defines the outgoing tangent
  4075. * @param amount defines the target quaternion
  4076. * @returns the new interpolated quaternion
  4077. */
  4078. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4079. }
  4080. /**
  4081. * Class used to store matrix data (4x4)
  4082. */
  4083. export class Matrix {
  4084. /**
  4085. * Gets the precision of matrix computations
  4086. */
  4087. static get Use64Bits(): boolean;
  4088. private static _updateFlagSeed;
  4089. private static _identityReadOnly;
  4090. private _isIdentity;
  4091. private _isIdentityDirty;
  4092. private _isIdentity3x2;
  4093. private _isIdentity3x2Dirty;
  4094. /**
  4095. * Gets the update flag of the matrix which is an unique number for the matrix.
  4096. * It will be incremented every time the matrix data change.
  4097. * You can use it to speed the comparison between two versions of the same matrix.
  4098. */
  4099. updateFlag: number;
  4100. private readonly _m;
  4101. /**
  4102. * Gets the internal data of the matrix
  4103. */
  4104. get m(): DeepImmutable<Float32Array | Array<number>>;
  4105. /** @hidden */
  4106. _markAsUpdated(): void;
  4107. /** @hidden */
  4108. private _updateIdentityStatus;
  4109. /**
  4110. * Creates an empty matrix (filled with zeros)
  4111. */
  4112. constructor();
  4113. /**
  4114. * Check if the current matrix is identity
  4115. * @returns true is the matrix is the identity matrix
  4116. */
  4117. isIdentity(): boolean;
  4118. /**
  4119. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4120. * @returns true is the matrix is the identity matrix
  4121. */
  4122. isIdentityAs3x2(): boolean;
  4123. /**
  4124. * Gets the determinant of the matrix
  4125. * @returns the matrix determinant
  4126. */
  4127. determinant(): number;
  4128. /**
  4129. * Returns the matrix as a Float32Array or Array<number>
  4130. * @returns the matrix underlying array
  4131. */
  4132. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4133. /**
  4134. * Returns the matrix as a Float32Array or Array<number>
  4135. * @returns the matrix underlying array.
  4136. */
  4137. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4138. /**
  4139. * Inverts the current matrix in place
  4140. * @returns the current inverted matrix
  4141. */
  4142. invert(): Matrix;
  4143. /**
  4144. * Sets all the matrix elements to zero
  4145. * @returns the current matrix
  4146. */
  4147. reset(): Matrix;
  4148. /**
  4149. * Adds the current matrix with a second one
  4150. * @param other defines the matrix to add
  4151. * @returns a new matrix as the addition of the current matrix and the given one
  4152. */
  4153. add(other: DeepImmutable<Matrix>): Matrix;
  4154. /**
  4155. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4156. * @param other defines the matrix to add
  4157. * @param result defines the target matrix
  4158. * @returns the current matrix
  4159. */
  4160. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4161. /**
  4162. * Adds in place the given matrix to the current matrix
  4163. * @param other defines the second operand
  4164. * @returns the current updated matrix
  4165. */
  4166. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4167. /**
  4168. * Sets the given matrix to the current inverted Matrix
  4169. * @param other defines the target matrix
  4170. * @returns the unmodified current matrix
  4171. */
  4172. invertToRef(other: Matrix): Matrix;
  4173. /**
  4174. * add a value at the specified position in the current Matrix
  4175. * @param index the index of the value within the matrix. between 0 and 15.
  4176. * @param value the value to be added
  4177. * @returns the current updated matrix
  4178. */
  4179. addAtIndex(index: number, value: number): Matrix;
  4180. /**
  4181. * mutiply the specified position in the current Matrix by a value
  4182. * @param index the index of the value within the matrix. between 0 and 15.
  4183. * @param value the value to be added
  4184. * @returns the current updated matrix
  4185. */
  4186. multiplyAtIndex(index: number, value: number): Matrix;
  4187. /**
  4188. * Inserts the translation vector (using 3 floats) in the current matrix
  4189. * @param x defines the 1st component of the translation
  4190. * @param y defines the 2nd component of the translation
  4191. * @param z defines the 3rd component of the translation
  4192. * @returns the current updated matrix
  4193. */
  4194. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4195. /**
  4196. * Adds the translation vector (using 3 floats) in the current matrix
  4197. * @param x defines the 1st component of the translation
  4198. * @param y defines the 2nd component of the translation
  4199. * @param z defines the 3rd component of the translation
  4200. * @returns the current updated matrix
  4201. */
  4202. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4203. /**
  4204. * Inserts the translation vector in the current matrix
  4205. * @param vector3 defines the translation to insert
  4206. * @returns the current updated matrix
  4207. */
  4208. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Gets the translation value of the current matrix
  4211. * @returns a new Vector3 as the extracted translation from the matrix
  4212. */
  4213. getTranslation(): Vector3;
  4214. /**
  4215. * Fill a Vector3 with the extracted translation from the matrix
  4216. * @param result defines the Vector3 where to store the translation
  4217. * @returns the current matrix
  4218. */
  4219. getTranslationToRef(result: Vector3): Matrix;
  4220. /**
  4221. * Remove rotation and scaling part from the matrix
  4222. * @returns the updated matrix
  4223. */
  4224. removeRotationAndScaling(): Matrix;
  4225. /**
  4226. * Multiply two matrices
  4227. * @param other defines the second operand
  4228. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4229. */
  4230. multiply(other: DeepImmutable<Matrix>): Matrix;
  4231. /**
  4232. * Copy the current matrix from the given one
  4233. * @param other defines the source matrix
  4234. * @returns the current updated matrix
  4235. */
  4236. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4237. /**
  4238. * Populates the given array from the starting index with the current matrix values
  4239. * @param array defines the target array
  4240. * @param offset defines the offset in the target array where to start storing values
  4241. * @returns the current matrix
  4242. */
  4243. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4244. /**
  4245. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4246. * @param other defines the second operand
  4247. * @param result defines the matrix where to store the multiplication
  4248. * @returns the current matrix
  4249. */
  4250. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4251. /**
  4252. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4253. * @param other defines the second operand
  4254. * @param result defines the array where to store the multiplication
  4255. * @param offset defines the offset in the target array where to start storing values
  4256. * @returns the current matrix
  4257. */
  4258. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4259. /**
  4260. * Check equality between this matrix and a second one
  4261. * @param value defines the second matrix to compare
  4262. * @returns true is the current matrix and the given one values are strictly equal
  4263. */
  4264. equals(value: DeepImmutable<Matrix>): boolean;
  4265. /**
  4266. * Clone the current matrix
  4267. * @returns a new matrix from the current matrix
  4268. */
  4269. clone(): Matrix;
  4270. /**
  4271. * Returns the name of the current matrix class
  4272. * @returns the string "Matrix"
  4273. */
  4274. getClassName(): string;
  4275. /**
  4276. * Gets the hash code of the current matrix
  4277. * @returns the hash code
  4278. */
  4279. getHashCode(): number;
  4280. /**
  4281. * Decomposes the current Matrix into a translation, rotation and scaling components
  4282. * @param scale defines the scale vector3 given as a reference to update
  4283. * @param rotation defines the rotation quaternion given as a reference to update
  4284. * @param translation defines the translation vector3 given as a reference to update
  4285. * @returns true if operation was successful
  4286. */
  4287. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4288. /**
  4289. * Gets specific row of the matrix
  4290. * @param index defines the number of the row to get
  4291. * @returns the index-th row of the current matrix as a new Vector4
  4292. */
  4293. getRow(index: number): Nullable<Vector4>;
  4294. /**
  4295. * Sets the index-th row of the current matrix to the vector4 values
  4296. * @param index defines the number of the row to set
  4297. * @param row defines the target vector4
  4298. * @returns the updated current matrix
  4299. */
  4300. setRow(index: number, row: Vector4): Matrix;
  4301. /**
  4302. * Compute the transpose of the matrix
  4303. * @returns the new transposed matrix
  4304. */
  4305. transpose(): Matrix;
  4306. /**
  4307. * Compute the transpose of the matrix and store it in a given matrix
  4308. * @param result defines the target matrix
  4309. * @returns the current matrix
  4310. */
  4311. transposeToRef(result: Matrix): Matrix;
  4312. /**
  4313. * Sets the index-th row of the current matrix with the given 4 x float values
  4314. * @param index defines the row index
  4315. * @param x defines the x component to set
  4316. * @param y defines the y component to set
  4317. * @param z defines the z component to set
  4318. * @param w defines the w component to set
  4319. * @returns the updated current matrix
  4320. */
  4321. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4322. /**
  4323. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4324. * @param scale defines the scale factor
  4325. * @returns a new matrix
  4326. */
  4327. scale(scale: number): Matrix;
  4328. /**
  4329. * Scale the current matrix values by a factor to a given result matrix
  4330. * @param scale defines the scale factor
  4331. * @param result defines the matrix to store the result
  4332. * @returns the current matrix
  4333. */
  4334. scaleToRef(scale: number, result: Matrix): Matrix;
  4335. /**
  4336. * Scale the current matrix values by a factor and add the result to a given matrix
  4337. * @param scale defines the scale factor
  4338. * @param result defines the Matrix to store the result
  4339. * @returns the current matrix
  4340. */
  4341. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4342. /**
  4343. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4344. * @param ref matrix to store the result
  4345. */
  4346. toNormalMatrix(ref: Matrix): void;
  4347. /**
  4348. * Gets only rotation part of the current matrix
  4349. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4350. */
  4351. getRotationMatrix(): Matrix;
  4352. /**
  4353. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4354. * @param result defines the target matrix to store data to
  4355. * @returns the current matrix
  4356. */
  4357. getRotationMatrixToRef(result: Matrix): Matrix;
  4358. /**
  4359. * Toggles model matrix from being right handed to left handed in place and vice versa
  4360. */
  4361. toggleModelMatrixHandInPlace(): void;
  4362. /**
  4363. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4364. */
  4365. toggleProjectionMatrixHandInPlace(): void;
  4366. /**
  4367. * Creates a matrix from an array
  4368. * @param array defines the source array
  4369. * @param offset defines an offset in the source array
  4370. * @returns a new Matrix set from the starting index of the given array
  4371. */
  4372. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4373. /**
  4374. * Copy the content of an array into a given matrix
  4375. * @param array defines the source array
  4376. * @param offset defines an offset in the source array
  4377. * @param result defines the target matrix
  4378. */
  4379. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4380. /**
  4381. * Stores an array into a matrix after having multiplied each component by a given factor
  4382. * @param array defines the source array
  4383. * @param offset defines the offset in the source array
  4384. * @param scale defines the scaling factor
  4385. * @param result defines the target matrix
  4386. */
  4387. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4388. /**
  4389. * Gets an identity matrix that must not be updated
  4390. */
  4391. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4392. /**
  4393. * Stores a list of values (16) inside a given matrix
  4394. * @param initialM11 defines 1st value of 1st row
  4395. * @param initialM12 defines 2nd value of 1st row
  4396. * @param initialM13 defines 3rd value of 1st row
  4397. * @param initialM14 defines 4th value of 1st row
  4398. * @param initialM21 defines 1st value of 2nd row
  4399. * @param initialM22 defines 2nd value of 2nd row
  4400. * @param initialM23 defines 3rd value of 2nd row
  4401. * @param initialM24 defines 4th value of 2nd row
  4402. * @param initialM31 defines 1st value of 3rd row
  4403. * @param initialM32 defines 2nd value of 3rd row
  4404. * @param initialM33 defines 3rd value of 3rd row
  4405. * @param initialM34 defines 4th value of 3rd row
  4406. * @param initialM41 defines 1st value of 4th row
  4407. * @param initialM42 defines 2nd value of 4th row
  4408. * @param initialM43 defines 3rd value of 4th row
  4409. * @param initialM44 defines 4th value of 4th row
  4410. * @param result defines the target matrix
  4411. */
  4412. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4413. /**
  4414. * Creates new matrix from a list of values (16)
  4415. * @param initialM11 defines 1st value of 1st row
  4416. * @param initialM12 defines 2nd value of 1st row
  4417. * @param initialM13 defines 3rd value of 1st row
  4418. * @param initialM14 defines 4th value of 1st row
  4419. * @param initialM21 defines 1st value of 2nd row
  4420. * @param initialM22 defines 2nd value of 2nd row
  4421. * @param initialM23 defines 3rd value of 2nd row
  4422. * @param initialM24 defines 4th value of 2nd row
  4423. * @param initialM31 defines 1st value of 3rd row
  4424. * @param initialM32 defines 2nd value of 3rd row
  4425. * @param initialM33 defines 3rd value of 3rd row
  4426. * @param initialM34 defines 4th value of 3rd row
  4427. * @param initialM41 defines 1st value of 4th row
  4428. * @param initialM42 defines 2nd value of 4th row
  4429. * @param initialM43 defines 3rd value of 4th row
  4430. * @param initialM44 defines 4th value of 4th row
  4431. * @returns the new matrix
  4432. */
  4433. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4434. /**
  4435. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4436. * @param scale defines the scale vector3
  4437. * @param rotation defines the rotation quaternion
  4438. * @param translation defines the translation vector3
  4439. * @returns a new matrix
  4440. */
  4441. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4442. /**
  4443. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4444. * @param scale defines the scale vector3
  4445. * @param rotation defines the rotation quaternion
  4446. * @param translation defines the translation vector3
  4447. * @param result defines the target matrix
  4448. */
  4449. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4450. /**
  4451. * Creates a new identity matrix
  4452. * @returns a new identity matrix
  4453. */
  4454. static Identity(): Matrix;
  4455. /**
  4456. * Creates a new identity matrix and stores the result in a given matrix
  4457. * @param result defines the target matrix
  4458. */
  4459. static IdentityToRef(result: Matrix): void;
  4460. /**
  4461. * Creates a new zero matrix
  4462. * @returns a new zero matrix
  4463. */
  4464. static Zero(): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the X axis
  4467. * @param angle defines the angle (in radians) to use
  4468. * @return the new matrix
  4469. */
  4470. static RotationX(angle: number): Matrix;
  4471. /**
  4472. * Creates a new matrix as the invert of a given matrix
  4473. * @param source defines the source matrix
  4474. * @returns the new matrix
  4475. */
  4476. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4477. /**
  4478. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4479. * @param angle defines the angle (in radians) to use
  4480. * @param result defines the target matrix
  4481. */
  4482. static RotationXToRef(angle: number, result: Matrix): void;
  4483. /**
  4484. * Creates a new rotation matrix for "angle" radians around the Y axis
  4485. * @param angle defines the angle (in radians) to use
  4486. * @return the new matrix
  4487. */
  4488. static RotationY(angle: number): Matrix;
  4489. /**
  4490. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4491. * @param angle defines the angle (in radians) to use
  4492. * @param result defines the target matrix
  4493. */
  4494. static RotationYToRef(angle: number, result: Matrix): void;
  4495. /**
  4496. * Creates a new rotation matrix for "angle" radians around the Z axis
  4497. * @param angle defines the angle (in radians) to use
  4498. * @return the new matrix
  4499. */
  4500. static RotationZ(angle: number): Matrix;
  4501. /**
  4502. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4503. * @param angle defines the angle (in radians) to use
  4504. * @param result defines the target matrix
  4505. */
  4506. static RotationZToRef(angle: number, result: Matrix): void;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the given axis
  4509. * @param axis defines the axis to use
  4510. * @param angle defines the angle (in radians) to use
  4511. * @return the new matrix
  4512. */
  4513. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4514. /**
  4515. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4516. * @param axis defines the axis to use
  4517. * @param angle defines the angle (in radians) to use
  4518. * @param result defines the target matrix
  4519. */
  4520. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4521. /**
  4522. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4523. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4524. * @param from defines the vector to align
  4525. * @param to defines the vector to align to
  4526. * @param result defines the target matrix
  4527. */
  4528. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4529. /**
  4530. * Creates a rotation matrix
  4531. * @param yaw defines the yaw angle in radians (Y axis)
  4532. * @param pitch defines the pitch angle in radians (X axis)
  4533. * @param roll defines the roll angle in radians (Z axis)
  4534. * @returns the new rotation matrix
  4535. */
  4536. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4537. /**
  4538. * Creates a rotation matrix and stores it in a given matrix
  4539. * @param yaw defines the yaw angle in radians (Y axis)
  4540. * @param pitch defines the pitch angle in radians (X axis)
  4541. * @param roll defines the roll angle in radians (Z axis)
  4542. * @param result defines the target matrix
  4543. */
  4544. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4545. /**
  4546. * Creates a scaling matrix
  4547. * @param x defines the scale factor on X axis
  4548. * @param y defines the scale factor on Y axis
  4549. * @param z defines the scale factor on Z axis
  4550. * @returns the new matrix
  4551. */
  4552. static Scaling(x: number, y: number, z: number): Matrix;
  4553. /**
  4554. * Creates a scaling matrix and stores it in a given matrix
  4555. * @param x defines the scale factor on X axis
  4556. * @param y defines the scale factor on Y axis
  4557. * @param z defines the scale factor on Z axis
  4558. * @param result defines the target matrix
  4559. */
  4560. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4561. /**
  4562. * Creates a translation matrix
  4563. * @param x defines the translation on X axis
  4564. * @param y defines the translation on Y axis
  4565. * @param z defines the translationon Z axis
  4566. * @returns the new matrix
  4567. */
  4568. static Translation(x: number, y: number, z: number): Matrix;
  4569. /**
  4570. * Creates a translation matrix and stores it in a given matrix
  4571. * @param x defines the translation on X axis
  4572. * @param y defines the translation on Y axis
  4573. * @param z defines the translationon Z axis
  4574. * @param result defines the target matrix
  4575. */
  4576. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4577. /**
  4578. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4579. * @param startValue defines the start value
  4580. * @param endValue defines the end value
  4581. * @param gradient defines the gradient factor
  4582. * @returns the new matrix
  4583. */
  4584. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4585. /**
  4586. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4587. * @param startValue defines the start value
  4588. * @param endValue defines the end value
  4589. * @param gradient defines the gradient factor
  4590. * @param result defines the Matrix object where to store data
  4591. */
  4592. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4593. /**
  4594. * Builds a new matrix whose values are computed by:
  4595. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4596. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4597. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4598. * @param startValue defines the first matrix
  4599. * @param endValue defines the second matrix
  4600. * @param gradient defines the gradient between the two matrices
  4601. * @returns the new matrix
  4602. */
  4603. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4604. /**
  4605. * Update a matrix to values which are computed by:
  4606. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4607. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4608. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4609. * @param startValue defines the first matrix
  4610. * @param endValue defines the second matrix
  4611. * @param gradient defines the gradient between the two matrices
  4612. * @param result defines the target matrix
  4613. */
  4614. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4615. /**
  4616. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4617. * This function works in left handed mode
  4618. * @param eye defines the final position of the entity
  4619. * @param target defines where the entity should look at
  4620. * @param up defines the up vector for the entity
  4621. * @returns the new matrix
  4622. */
  4623. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4624. /**
  4625. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4626. * This function works in left handed mode
  4627. * @param eye defines the final position of the entity
  4628. * @param target defines where the entity should look at
  4629. * @param up defines the up vector for the entity
  4630. * @param result defines the target matrix
  4631. */
  4632. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4633. /**
  4634. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4635. * This function works in right handed mode
  4636. * @param eye defines the final position of the entity
  4637. * @param target defines where the entity should look at
  4638. * @param up defines the up vector for the entity
  4639. * @returns the new matrix
  4640. */
  4641. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4642. /**
  4643. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4644. * This function works in right handed mode
  4645. * @param eye defines the final position of the entity
  4646. * @param target defines where the entity should look at
  4647. * @param up defines the up vector for the entity
  4648. * @param result defines the target matrix
  4649. */
  4650. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4651. /**
  4652. * Create a left-handed orthographic projection matrix
  4653. * @param width defines the viewport width
  4654. * @param height defines the viewport height
  4655. * @param znear defines the near clip plane
  4656. * @param zfar defines the far clip plane
  4657. * @returns a new matrix as a left-handed orthographic projection matrix
  4658. */
  4659. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4660. /**
  4661. * Store a left-handed orthographic projection to a given matrix
  4662. * @param width defines the viewport width
  4663. * @param height defines the viewport height
  4664. * @param znear defines the near clip plane
  4665. * @param zfar defines the far clip plane
  4666. * @param result defines the target matrix
  4667. */
  4668. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4669. /**
  4670. * Create a left-handed orthographic projection matrix
  4671. * @param left defines the viewport left coordinate
  4672. * @param right defines the viewport right coordinate
  4673. * @param bottom defines the viewport bottom coordinate
  4674. * @param top defines the viewport top coordinate
  4675. * @param znear defines the near clip plane
  4676. * @param zfar defines the far clip plane
  4677. * @returns a new matrix as a left-handed orthographic projection matrix
  4678. */
  4679. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4680. /**
  4681. * Stores a left-handed orthographic projection into a given matrix
  4682. * @param left defines the viewport left coordinate
  4683. * @param right defines the viewport right coordinate
  4684. * @param bottom defines the viewport bottom coordinate
  4685. * @param top defines the viewport top coordinate
  4686. * @param znear defines the near clip plane
  4687. * @param zfar defines the far clip plane
  4688. * @param result defines the target matrix
  4689. */
  4690. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4691. /**
  4692. * Creates a right-handed orthographic projection matrix
  4693. * @param left defines the viewport left coordinate
  4694. * @param right defines the viewport right coordinate
  4695. * @param bottom defines the viewport bottom coordinate
  4696. * @param top defines the viewport top coordinate
  4697. * @param znear defines the near clip plane
  4698. * @param zfar defines the far clip plane
  4699. * @returns a new matrix as a right-handed orthographic projection matrix
  4700. */
  4701. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4702. /**
  4703. * Stores a right-handed orthographic projection into a given matrix
  4704. * @param left defines the viewport left coordinate
  4705. * @param right defines the viewport right coordinate
  4706. * @param bottom defines the viewport bottom coordinate
  4707. * @param top defines the viewport top coordinate
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. */
  4712. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4713. /**
  4714. * Creates a left-handed perspective projection matrix
  4715. * @param width defines the viewport width
  4716. * @param height defines the viewport height
  4717. * @param znear defines the near clip plane
  4718. * @param zfar defines the far clip plane
  4719. * @returns a new matrix as a left-handed perspective projection matrix
  4720. */
  4721. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4722. /**
  4723. * Creates a left-handed perspective projection matrix
  4724. * @param fov defines the horizontal field of view
  4725. * @param aspect defines the aspect ratio
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @returns a new matrix as a left-handed perspective projection matrix
  4729. */
  4730. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4731. /**
  4732. * Stores a left-handed perspective projection into a given matrix
  4733. * @param fov defines the horizontal field of view
  4734. * @param aspect defines the aspect ratio
  4735. * @param znear defines the near clip plane
  4736. * @param zfar defines the far clip plane
  4737. * @param result defines the target matrix
  4738. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4739. */
  4740. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4741. /**
  4742. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4743. * @param fov defines the horizontal field of view
  4744. * @param aspect defines the aspect ratio
  4745. * @param znear defines the near clip plane
  4746. * @param zfar not used as infinity is used as far clip
  4747. * @param result defines the target matrix
  4748. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4749. */
  4750. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4751. /**
  4752. * Creates a right-handed perspective projection matrix
  4753. * @param fov defines the horizontal field of view
  4754. * @param aspect defines the aspect ratio
  4755. * @param znear defines the near clip plane
  4756. * @param zfar defines the far clip plane
  4757. * @returns a new matrix as a right-handed perspective projection matrix
  4758. */
  4759. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4760. /**
  4761. * Stores a right-handed perspective projection into a given matrix
  4762. * @param fov defines the horizontal field of view
  4763. * @param aspect defines the aspect ratio
  4764. * @param znear defines the near clip plane
  4765. * @param zfar defines the far clip plane
  4766. * @param result defines the target matrix
  4767. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4768. */
  4769. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4770. /**
  4771. * Stores a right-handed perspective projection into a given matrix
  4772. * @param fov defines the horizontal field of view
  4773. * @param aspect defines the aspect ratio
  4774. * @param znear defines the near clip plane
  4775. * @param zfar not used as infinity is used as far clip
  4776. * @param result defines the target matrix
  4777. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4778. */
  4779. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4780. /**
  4781. * Stores a perspective projection for WebVR info a given matrix
  4782. * @param fov defines the field of view
  4783. * @param znear defines the near clip plane
  4784. * @param zfar defines the far clip plane
  4785. * @param result defines the target matrix
  4786. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4787. */
  4788. static PerspectiveFovWebVRToRef(fov: {
  4789. upDegrees: number;
  4790. downDegrees: number;
  4791. leftDegrees: number;
  4792. rightDegrees: number;
  4793. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4794. /**
  4795. * Computes a complete transformation matrix
  4796. * @param viewport defines the viewport to use
  4797. * @param world defines the world matrix
  4798. * @param view defines the view matrix
  4799. * @param projection defines the projection matrix
  4800. * @param zmin defines the near clip plane
  4801. * @param zmax defines the far clip plane
  4802. * @returns the transformation matrix
  4803. */
  4804. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4805. /**
  4806. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4807. * @param matrix defines the matrix to use
  4808. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4809. */
  4810. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4811. /**
  4812. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4813. * @param matrix defines the matrix to use
  4814. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4815. */
  4816. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4817. /**
  4818. * Compute the transpose of a given matrix
  4819. * @param matrix defines the matrix to transpose
  4820. * @returns the new matrix
  4821. */
  4822. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4823. /**
  4824. * Compute the transpose of a matrix and store it in a target matrix
  4825. * @param matrix defines the matrix to transpose
  4826. * @param result defines the target matrix
  4827. */
  4828. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4829. /**
  4830. * Computes a reflection matrix from a plane
  4831. * @param plane defines the reflection plane
  4832. * @returns a new matrix
  4833. */
  4834. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4835. /**
  4836. * Computes a reflection matrix from a plane
  4837. * @param plane defines the reflection plane
  4838. * @param result defines the target matrix
  4839. */
  4840. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4841. /**
  4842. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4843. * @param xaxis defines the value of the 1st axis
  4844. * @param yaxis defines the value of the 2nd axis
  4845. * @param zaxis defines the value of the 3rd axis
  4846. * @param result defines the target matrix
  4847. */
  4848. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4849. /**
  4850. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4851. * @param quat defines the quaternion to use
  4852. * @param result defines the target matrix
  4853. */
  4854. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4855. }
  4856. /**
  4857. * @hidden
  4858. */
  4859. export class TmpVectors {
  4860. static Vector2: Vector2[];
  4861. static Vector3: Vector3[];
  4862. static Vector4: Vector4[];
  4863. static Quaternion: Quaternion[];
  4864. static Matrix: Matrix[];
  4865. }
  4866. }
  4867. declare module "babylonjs/Maths/math.path" {
  4868. import { DeepImmutable, Nullable } from "babylonjs/types";
  4869. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4870. /**
  4871. * Defines potential orientation for back face culling
  4872. */
  4873. export enum Orientation {
  4874. /**
  4875. * Clockwise
  4876. */
  4877. CW = 0,
  4878. /** Counter clockwise */
  4879. CCW = 1
  4880. }
  4881. /** Class used to represent a Bezier curve */
  4882. export class BezierCurve {
  4883. /**
  4884. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4885. * @param t defines the time
  4886. * @param x1 defines the left coordinate on X axis
  4887. * @param y1 defines the left coordinate on Y axis
  4888. * @param x2 defines the right coordinate on X axis
  4889. * @param y2 defines the right coordinate on Y axis
  4890. * @returns the interpolated value
  4891. */
  4892. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4893. }
  4894. /**
  4895. * Defines angle representation
  4896. */
  4897. export class Angle {
  4898. private _radians;
  4899. /**
  4900. * Creates an Angle object of "radians" radians (float).
  4901. * @param radians the angle in radians
  4902. */
  4903. constructor(radians: number);
  4904. /**
  4905. * Get value in degrees
  4906. * @returns the Angle value in degrees (float)
  4907. */
  4908. degrees(): number;
  4909. /**
  4910. * Get value in radians
  4911. * @returns the Angle value in radians (float)
  4912. */
  4913. radians(): number;
  4914. /**
  4915. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4916. * @param a defines first point as the origin
  4917. * @param b defines point
  4918. * @returns a new Angle
  4919. */
  4920. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4921. /**
  4922. * Gets a new Angle object from the given float in radians
  4923. * @param radians defines the angle value in radians
  4924. * @returns a new Angle
  4925. */
  4926. static FromRadians(radians: number): Angle;
  4927. /**
  4928. * Gets a new Angle object from the given float in degrees
  4929. * @param degrees defines the angle value in degrees
  4930. * @returns a new Angle
  4931. */
  4932. static FromDegrees(degrees: number): Angle;
  4933. }
  4934. /**
  4935. * This represents an arc in a 2d space.
  4936. */
  4937. export class Arc2 {
  4938. /** Defines the start point of the arc */
  4939. startPoint: Vector2;
  4940. /** Defines the mid point of the arc */
  4941. midPoint: Vector2;
  4942. /** Defines the end point of the arc */
  4943. endPoint: Vector2;
  4944. /**
  4945. * Defines the center point of the arc.
  4946. */
  4947. centerPoint: Vector2;
  4948. /**
  4949. * Defines the radius of the arc.
  4950. */
  4951. radius: number;
  4952. /**
  4953. * Defines the angle of the arc (from mid point to end point).
  4954. */
  4955. angle: Angle;
  4956. /**
  4957. * Defines the start angle of the arc (from start point to middle point).
  4958. */
  4959. startAngle: Angle;
  4960. /**
  4961. * Defines the orientation of the arc (clock wise/counter clock wise).
  4962. */
  4963. orientation: Orientation;
  4964. /**
  4965. * Creates an Arc object from the three given points : start, middle and end.
  4966. * @param startPoint Defines the start point of the arc
  4967. * @param midPoint Defines the midlle point of the arc
  4968. * @param endPoint Defines the end point of the arc
  4969. */
  4970. constructor(
  4971. /** Defines the start point of the arc */
  4972. startPoint: Vector2,
  4973. /** Defines the mid point of the arc */
  4974. midPoint: Vector2,
  4975. /** Defines the end point of the arc */
  4976. endPoint: Vector2);
  4977. }
  4978. /**
  4979. * Represents a 2D path made up of multiple 2D points
  4980. */
  4981. export class Path2 {
  4982. private _points;
  4983. private _length;
  4984. /**
  4985. * If the path start and end point are the same
  4986. */
  4987. closed: boolean;
  4988. /**
  4989. * Creates a Path2 object from the starting 2D coordinates x and y.
  4990. * @param x the starting points x value
  4991. * @param y the starting points y value
  4992. */
  4993. constructor(x: number, y: number);
  4994. /**
  4995. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4996. * @param x the added points x value
  4997. * @param y the added points y value
  4998. * @returns the updated Path2.
  4999. */
  5000. addLineTo(x: number, y: number): Path2;
  5001. /**
  5002. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5003. * @param midX middle point x value
  5004. * @param midY middle point y value
  5005. * @param endX end point x value
  5006. * @param endY end point y value
  5007. * @param numberOfSegments (default: 36)
  5008. * @returns the updated Path2.
  5009. */
  5010. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5011. /**
  5012. * Closes the Path2.
  5013. * @returns the Path2.
  5014. */
  5015. close(): Path2;
  5016. /**
  5017. * Gets the sum of the distance between each sequential point in the path
  5018. * @returns the Path2 total length (float).
  5019. */
  5020. length(): number;
  5021. /**
  5022. * Gets the points which construct the path
  5023. * @returns the Path2 internal array of points.
  5024. */
  5025. getPoints(): Vector2[];
  5026. /**
  5027. * Retreives the point at the distance aways from the starting point
  5028. * @param normalizedLengthPosition the length along the path to retreive the point from
  5029. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5030. */
  5031. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5032. /**
  5033. * Creates a new path starting from an x and y position
  5034. * @param x starting x value
  5035. * @param y starting y value
  5036. * @returns a new Path2 starting at the coordinates (x, y).
  5037. */
  5038. static StartingAt(x: number, y: number): Path2;
  5039. }
  5040. /**
  5041. * Represents a 3D path made up of multiple 3D points
  5042. */
  5043. export class Path3D {
  5044. /**
  5045. * an array of Vector3, the curve axis of the Path3D
  5046. */
  5047. path: Vector3[];
  5048. private _curve;
  5049. private _distances;
  5050. private _tangents;
  5051. private _normals;
  5052. private _binormals;
  5053. private _raw;
  5054. private _alignTangentsWithPath;
  5055. private readonly _pointAtData;
  5056. /**
  5057. * new Path3D(path, normal, raw)
  5058. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5059. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5060. * @param path an array of Vector3, the curve axis of the Path3D
  5061. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5062. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5063. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5064. */
  5065. constructor(
  5066. /**
  5067. * an array of Vector3, the curve axis of the Path3D
  5068. */
  5069. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5070. /**
  5071. * Returns the Path3D array of successive Vector3 designing its curve.
  5072. * @returns the Path3D array of successive Vector3 designing its curve.
  5073. */
  5074. getCurve(): Vector3[];
  5075. /**
  5076. * Returns the Path3D array of successive Vector3 designing its curve.
  5077. * @returns the Path3D array of successive Vector3 designing its curve.
  5078. */
  5079. getPoints(): Vector3[];
  5080. /**
  5081. * @returns the computed length (float) of the path.
  5082. */
  5083. length(): number;
  5084. /**
  5085. * Returns an array populated with tangent vectors on each Path3D curve point.
  5086. * @returns an array populated with tangent vectors on each Path3D curve point.
  5087. */
  5088. getTangents(): Vector3[];
  5089. /**
  5090. * Returns an array populated with normal vectors on each Path3D curve point.
  5091. * @returns an array populated with normal vectors on each Path3D curve point.
  5092. */
  5093. getNormals(): Vector3[];
  5094. /**
  5095. * Returns an array populated with binormal vectors on each Path3D curve point.
  5096. * @returns an array populated with binormal vectors on each Path3D curve point.
  5097. */
  5098. getBinormals(): Vector3[];
  5099. /**
  5100. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5101. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5102. */
  5103. getDistances(): number[];
  5104. /**
  5105. * Returns an interpolated point along this path
  5106. * @param position the position of the point along this path, from 0.0 to 1.0
  5107. * @returns a new Vector3 as the point
  5108. */
  5109. getPointAt(position: number): Vector3;
  5110. /**
  5111. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5112. * @param position the position of the point along this path, from 0.0 to 1.0
  5113. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5114. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5115. */
  5116. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5117. /**
  5118. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5119. * @param position the position of the point along this path, from 0.0 to 1.0
  5120. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5121. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5122. */
  5123. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5124. /**
  5125. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5126. * @param position the position of the point along this path, from 0.0 to 1.0
  5127. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5128. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5129. */
  5130. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5131. /**
  5132. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5133. * @param position the position of the point along this path, from 0.0 to 1.0
  5134. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5135. */
  5136. getDistanceAt(position: number): number;
  5137. /**
  5138. * Returns the array index of the previous point of an interpolated point along this path
  5139. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5140. * @returns the array index
  5141. */
  5142. getPreviousPointIndexAt(position: number): number;
  5143. /**
  5144. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5145. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5146. * @returns the sub position
  5147. */
  5148. getSubPositionAt(position: number): number;
  5149. /**
  5150. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5151. * @param target the vector of which to get the closest position to
  5152. * @returns the position of the closest virtual point on this path to the target vector
  5153. */
  5154. getClosestPositionTo(target: Vector3): number;
  5155. /**
  5156. * Returns a sub path (slice) of this path
  5157. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5158. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5159. * @returns a sub path (slice) of this path
  5160. */
  5161. slice(start?: number, end?: number): Path3D;
  5162. /**
  5163. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5164. * @param path path which all values are copied into the curves points
  5165. * @param firstNormal which should be projected onto the curve
  5166. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5167. * @returns the same object updated.
  5168. */
  5169. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5170. private _compute;
  5171. private _getFirstNonNullVector;
  5172. private _getLastNonNullVector;
  5173. private _normalVector;
  5174. /**
  5175. * Updates the point at data for an interpolated point along this curve
  5176. * @param position the position of the point along this curve, from 0.0 to 1.0
  5177. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5178. * @returns the (updated) point at data
  5179. */
  5180. private _updatePointAtData;
  5181. /**
  5182. * Updates the point at data from the specified parameters
  5183. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5184. * @param point the interpolated point
  5185. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5186. */
  5187. private _setPointAtData;
  5188. /**
  5189. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5190. */
  5191. private _updateInterpolationMatrix;
  5192. }
  5193. /**
  5194. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5195. * A Curve3 is designed from a series of successive Vector3.
  5196. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5197. */
  5198. export class Curve3 {
  5199. private _points;
  5200. private _length;
  5201. /**
  5202. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5203. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5204. * @param v1 (Vector3) the control point
  5205. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5206. * @param nbPoints (integer) the wanted number of points in the curve
  5207. * @returns the created Curve3
  5208. */
  5209. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5210. /**
  5211. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5212. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5213. * @param v1 (Vector3) the first control point
  5214. * @param v2 (Vector3) the second control point
  5215. * @param v3 (Vector3) the end point of the Cubic Bezier
  5216. * @param nbPoints (integer) the wanted number of points in the curve
  5217. * @returns the created Curve3
  5218. */
  5219. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5220. /**
  5221. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5222. * @param p1 (Vector3) the origin point of the Hermite Spline
  5223. * @param t1 (Vector3) the tangent vector at the origin point
  5224. * @param p2 (Vector3) the end point of the Hermite Spline
  5225. * @param t2 (Vector3) the tangent vector at the end point
  5226. * @param nbPoints (integer) the wanted number of points in the curve
  5227. * @returns the created Curve3
  5228. */
  5229. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5230. /**
  5231. * Returns a Curve3 object along a CatmullRom Spline curve :
  5232. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5233. * @param nbPoints (integer) the wanted number of points between each curve control points
  5234. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5238. /**
  5239. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5240. * A Curve3 is designed from a series of successive Vector3.
  5241. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5242. * @param points points which make up the curve
  5243. */
  5244. constructor(points: Vector3[]);
  5245. /**
  5246. * @returns the Curve3 stored array of successive Vector3
  5247. */
  5248. getPoints(): Vector3[];
  5249. /**
  5250. * @returns the computed length (float) of the curve.
  5251. */
  5252. length(): number;
  5253. /**
  5254. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5255. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5256. * curveA and curveB keep unchanged.
  5257. * @param curve the curve to continue from this curve
  5258. * @returns the newly constructed curve
  5259. */
  5260. continue(curve: DeepImmutable<Curve3>): Curve3;
  5261. private _computeLength;
  5262. }
  5263. }
  5264. declare module "babylonjs/Animations/easing" {
  5265. /**
  5266. * This represents the main contract an easing function should follow.
  5267. * Easing functions are used throughout the animation system.
  5268. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export interface IEasingFunction {
  5271. /**
  5272. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5273. * of the easing function.
  5274. * The link below provides some of the most common examples of easing functions.
  5275. * @see https://easings.net/
  5276. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5277. * @returns the corresponding value on the curve defined by the easing function
  5278. */
  5279. ease(gradient: number): number;
  5280. }
  5281. /**
  5282. * Base class used for every default easing function.
  5283. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class EasingFunction implements IEasingFunction {
  5286. /**
  5287. * Interpolation follows the mathematical formula associated with the easing function.
  5288. */
  5289. static readonly EASINGMODE_EASEIN: number;
  5290. /**
  5291. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5292. */
  5293. static readonly EASINGMODE_EASEOUT: number;
  5294. /**
  5295. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5296. */
  5297. static readonly EASINGMODE_EASEINOUT: number;
  5298. private _easingMode;
  5299. /**
  5300. * Sets the easing mode of the current function.
  5301. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5302. */
  5303. setEasingMode(easingMode: number): void;
  5304. /**
  5305. * Gets the current easing mode.
  5306. * @returns the easing mode
  5307. */
  5308. getEasingMode(): number;
  5309. /**
  5310. * @hidden
  5311. */
  5312. easeInCore(gradient: number): number;
  5313. /**
  5314. * Given an input gradient between 0 and 1, this returns the corresponding value
  5315. * of the easing function.
  5316. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5317. * @returns the corresponding value on the curve defined by the easing function
  5318. */
  5319. ease(gradient: number): number;
  5320. }
  5321. /**
  5322. * Easing function with a circle shape (see link below).
  5323. * @see https://easings.net/#easeInCirc
  5324. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5325. */
  5326. export class CircleEase extends EasingFunction implements IEasingFunction {
  5327. /** @hidden */
  5328. easeInCore(gradient: number): number;
  5329. }
  5330. /**
  5331. * Easing function with a ease back shape (see link below).
  5332. * @see https://easings.net/#easeInBack
  5333. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5334. */
  5335. export class BackEase extends EasingFunction implements IEasingFunction {
  5336. /** Defines the amplitude of the function */
  5337. amplitude: number;
  5338. /**
  5339. * Instantiates a back ease easing
  5340. * @see https://easings.net/#easeInBack
  5341. * @param amplitude Defines the amplitude of the function
  5342. */
  5343. constructor(
  5344. /** Defines the amplitude of the function */
  5345. amplitude?: number);
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a bouncing shape (see link below).
  5351. * @see https://easings.net/#easeInBounce
  5352. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class BounceEase extends EasingFunction implements IEasingFunction {
  5355. /** Defines the number of bounces */
  5356. bounces: number;
  5357. /** Defines the amplitude of the bounce */
  5358. bounciness: number;
  5359. /**
  5360. * Instantiates a bounce easing
  5361. * @see https://easings.net/#easeInBounce
  5362. * @param bounces Defines the number of bounces
  5363. * @param bounciness Defines the amplitude of the bounce
  5364. */
  5365. constructor(
  5366. /** Defines the number of bounces */
  5367. bounces?: number,
  5368. /** Defines the amplitude of the bounce */
  5369. bounciness?: number);
  5370. /** @hidden */
  5371. easeInCore(gradient: number): number;
  5372. }
  5373. /**
  5374. * Easing function with a power of 3 shape (see link below).
  5375. * @see https://easings.net/#easeInCubic
  5376. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5377. */
  5378. export class CubicEase extends EasingFunction implements IEasingFunction {
  5379. /** @hidden */
  5380. easeInCore(gradient: number): number;
  5381. }
  5382. /**
  5383. * Easing function with an elastic shape (see link below).
  5384. * @see https://easings.net/#easeInElastic
  5385. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5386. */
  5387. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5388. /** Defines the number of oscillations*/
  5389. oscillations: number;
  5390. /** Defines the amplitude of the oscillations*/
  5391. springiness: number;
  5392. /**
  5393. * Instantiates an elastic easing function
  5394. * @see https://easings.net/#easeInElastic
  5395. * @param oscillations Defines the number of oscillations
  5396. * @param springiness Defines the amplitude of the oscillations
  5397. */
  5398. constructor(
  5399. /** Defines the number of oscillations*/
  5400. oscillations?: number,
  5401. /** Defines the amplitude of the oscillations*/
  5402. springiness?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with an exponential shape (see link below).
  5408. * @see https://easings.net/#easeInExpo
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5412. /** Defines the exponent of the function */
  5413. exponent: number;
  5414. /**
  5415. * Instantiates an exponential easing function
  5416. * @see https://easings.net/#easeInExpo
  5417. * @param exponent Defines the exponent of the function
  5418. */
  5419. constructor(
  5420. /** Defines the exponent of the function */
  5421. exponent?: number);
  5422. /** @hidden */
  5423. easeInCore(gradient: number): number;
  5424. }
  5425. /**
  5426. * Easing function with a power shape (see link below).
  5427. * @see https://easings.net/#easeInQuad
  5428. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5429. */
  5430. export class PowerEase extends EasingFunction implements IEasingFunction {
  5431. /** Defines the power of the function */
  5432. power: number;
  5433. /**
  5434. * Instantiates an power base easing function
  5435. * @see https://easings.net/#easeInQuad
  5436. * @param power Defines the power of the function
  5437. */
  5438. constructor(
  5439. /** Defines the power of the function */
  5440. power?: number);
  5441. /** @hidden */
  5442. easeInCore(gradient: number): number;
  5443. }
  5444. /**
  5445. * Easing function with a power of 2 shape (see link below).
  5446. * @see https://easings.net/#easeInQuad
  5447. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5448. */
  5449. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5450. /** @hidden */
  5451. easeInCore(gradient: number): number;
  5452. }
  5453. /**
  5454. * Easing function with a power of 4 shape (see link below).
  5455. * @see https://easings.net/#easeInQuart
  5456. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5457. */
  5458. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5459. /** @hidden */
  5460. easeInCore(gradient: number): number;
  5461. }
  5462. /**
  5463. * Easing function with a power of 5 shape (see link below).
  5464. * @see https://easings.net/#easeInQuint
  5465. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5466. */
  5467. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5468. /** @hidden */
  5469. easeInCore(gradient: number): number;
  5470. }
  5471. /**
  5472. * Easing function with a sin shape (see link below).
  5473. * @see https://easings.net/#easeInSine
  5474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5475. */
  5476. export class SineEase extends EasingFunction implements IEasingFunction {
  5477. /** @hidden */
  5478. easeInCore(gradient: number): number;
  5479. }
  5480. /**
  5481. * Easing function with a bezier shape (see link below).
  5482. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5483. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5484. */
  5485. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5486. /** Defines the x component of the start tangent in the bezier curve */
  5487. x1: number;
  5488. /** Defines the y component of the start tangent in the bezier curve */
  5489. y1: number;
  5490. /** Defines the x component of the end tangent in the bezier curve */
  5491. x2: number;
  5492. /** Defines the y component of the end tangent in the bezier curve */
  5493. y2: number;
  5494. /**
  5495. * Instantiates a bezier function
  5496. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5497. * @param x1 Defines the x component of the start tangent in the bezier curve
  5498. * @param y1 Defines the y component of the start tangent in the bezier curve
  5499. * @param x2 Defines the x component of the end tangent in the bezier curve
  5500. * @param y2 Defines the y component of the end tangent in the bezier curve
  5501. */
  5502. constructor(
  5503. /** Defines the x component of the start tangent in the bezier curve */
  5504. x1?: number,
  5505. /** Defines the y component of the start tangent in the bezier curve */
  5506. y1?: number,
  5507. /** Defines the x component of the end tangent in the bezier curve */
  5508. x2?: number,
  5509. /** Defines the y component of the end tangent in the bezier curve */
  5510. y2?: number);
  5511. /** @hidden */
  5512. easeInCore(gradient: number): number;
  5513. }
  5514. }
  5515. declare module "babylonjs/Maths/math.color" {
  5516. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5517. /**
  5518. * Class used to hold a RBG color
  5519. */
  5520. export class Color3 {
  5521. /**
  5522. * Defines the red component (between 0 and 1, default is 0)
  5523. */
  5524. r: number;
  5525. /**
  5526. * Defines the green component (between 0 and 1, default is 0)
  5527. */
  5528. g: number;
  5529. /**
  5530. * Defines the blue component (between 0 and 1, default is 0)
  5531. */
  5532. b: number;
  5533. /**
  5534. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5535. * @param r defines the red component (between 0 and 1, default is 0)
  5536. * @param g defines the green component (between 0 and 1, default is 0)
  5537. * @param b defines the blue component (between 0 and 1, default is 0)
  5538. */
  5539. constructor(
  5540. /**
  5541. * Defines the red component (between 0 and 1, default is 0)
  5542. */
  5543. r?: number,
  5544. /**
  5545. * Defines the green component (between 0 and 1, default is 0)
  5546. */
  5547. g?: number,
  5548. /**
  5549. * Defines the blue component (between 0 and 1, default is 0)
  5550. */
  5551. b?: number);
  5552. /**
  5553. * Creates a string with the Color3 current values
  5554. * @returns the string representation of the Color3 object
  5555. */
  5556. toString(): string;
  5557. /**
  5558. * Returns the string "Color3"
  5559. * @returns "Color3"
  5560. */
  5561. getClassName(): string;
  5562. /**
  5563. * Compute the Color3 hash code
  5564. * @returns an unique number that can be used to hash Color3 objects
  5565. */
  5566. getHashCode(): number;
  5567. /**
  5568. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5569. * @param array defines the array where to store the r,g,b components
  5570. * @param index defines an optional index in the target array to define where to start storing values
  5571. * @returns the current Color3 object
  5572. */
  5573. toArray(array: FloatArray, index?: number): Color3;
  5574. /**
  5575. * Update the current color with values stored in an array from the starting index of the given array
  5576. * @param array defines the source array
  5577. * @param offset defines an offset in the source array
  5578. * @returns the current Color3 object
  5579. */
  5580. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5581. /**
  5582. * Returns a new Color4 object from the current Color3 and the given alpha
  5583. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5584. * @returns a new Color4 object
  5585. */
  5586. toColor4(alpha?: number): Color4;
  5587. /**
  5588. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5589. * @returns the new array
  5590. */
  5591. asArray(): number[];
  5592. /**
  5593. * Returns the luminance value
  5594. * @returns a float value
  5595. */
  5596. toLuminance(): number;
  5597. /**
  5598. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5599. * @param otherColor defines the second operand
  5600. * @returns the new Color3 object
  5601. */
  5602. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5603. /**
  5604. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5605. * @param otherColor defines the second operand
  5606. * @param result defines the Color3 object where to store the result
  5607. * @returns the current Color3
  5608. */
  5609. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5610. /**
  5611. * Determines equality between Color3 objects
  5612. * @param otherColor defines the second operand
  5613. * @returns true if the rgb values are equal to the given ones
  5614. */
  5615. equals(otherColor: DeepImmutable<Color3>): boolean;
  5616. /**
  5617. * Determines equality between the current Color3 object and a set of r,b,g values
  5618. * @param r defines the red component to check
  5619. * @param g defines the green component to check
  5620. * @param b defines the blue component to check
  5621. * @returns true if the rgb values are equal to the given ones
  5622. */
  5623. equalsFloats(r: number, g: number, b: number): boolean;
  5624. /**
  5625. * Multiplies in place each rgb value by scale
  5626. * @param scale defines the scaling factor
  5627. * @returns the updated Color3
  5628. */
  5629. scale(scale: number): Color3;
  5630. /**
  5631. * Multiplies the rgb values by scale and stores the result into "result"
  5632. * @param scale defines the scaling factor
  5633. * @param result defines the Color3 object where to store the result
  5634. * @returns the unmodified current Color3
  5635. */
  5636. scaleToRef(scale: number, result: Color3): Color3;
  5637. /**
  5638. * Scale the current Color3 values by a factor and add the result to a given Color3
  5639. * @param scale defines the scale factor
  5640. * @param result defines color to store the result into
  5641. * @returns the unmodified current Color3
  5642. */
  5643. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5644. /**
  5645. * Clamps the rgb values by the min and max values and stores the result into "result"
  5646. * @param min defines minimum clamping value (default is 0)
  5647. * @param max defines maximum clamping value (default is 1)
  5648. * @param result defines color to store the result into
  5649. * @returns the original Color3
  5650. */
  5651. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5652. /**
  5653. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5654. * @param otherColor defines the second operand
  5655. * @returns the new Color3
  5656. */
  5657. add(otherColor: DeepImmutable<Color3>): Color3;
  5658. /**
  5659. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5660. * @param otherColor defines the second operand
  5661. * @param result defines Color3 object to store the result into
  5662. * @returns the unmodified current Color3
  5663. */
  5664. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5665. /**
  5666. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5667. * @param otherColor defines the second operand
  5668. * @returns the new Color3
  5669. */
  5670. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5671. /**
  5672. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5673. * @param otherColor defines the second operand
  5674. * @param result defines Color3 object to store the result into
  5675. * @returns the unmodified current Color3
  5676. */
  5677. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5678. /**
  5679. * Copy the current object
  5680. * @returns a new Color3 copied the current one
  5681. */
  5682. clone(): Color3;
  5683. /**
  5684. * Copies the rgb values from the source in the current Color3
  5685. * @param source defines the source Color3 object
  5686. * @returns the updated Color3 object
  5687. */
  5688. copyFrom(source: DeepImmutable<Color3>): Color3;
  5689. /**
  5690. * Updates the Color3 rgb values from the given floats
  5691. * @param r defines the red component to read from
  5692. * @param g defines the green component to read from
  5693. * @param b defines the blue component to read from
  5694. * @returns the current Color3 object
  5695. */
  5696. copyFromFloats(r: number, g: number, b: number): Color3;
  5697. /**
  5698. * Updates the Color3 rgb values from the given floats
  5699. * @param r defines the red component to read from
  5700. * @param g defines the green component to read from
  5701. * @param b defines the blue component to read from
  5702. * @returns the current Color3 object
  5703. */
  5704. set(r: number, g: number, b: number): Color3;
  5705. /**
  5706. * Compute the Color3 hexadecimal code as a string
  5707. * @returns a string containing the hexadecimal representation of the Color3 object
  5708. */
  5709. toHexString(): string;
  5710. /**
  5711. * Computes a new Color3 converted from the current one to linear space
  5712. * @returns a new Color3 object
  5713. */
  5714. toLinearSpace(): Color3;
  5715. /**
  5716. * Converts current color in rgb space to HSV values
  5717. * @returns a new color3 representing the HSV values
  5718. */
  5719. toHSV(): Color3;
  5720. /**
  5721. * Converts current color in rgb space to HSV values
  5722. * @param result defines the Color3 where to store the HSV values
  5723. */
  5724. toHSVToRef(result: Color3): void;
  5725. /**
  5726. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5727. * @param convertedColor defines the Color3 object where to store the linear space version
  5728. * @returns the unmodified Color3
  5729. */
  5730. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5731. /**
  5732. * Computes a new Color3 converted from the current one to gamma space
  5733. * @returns a new Color3 object
  5734. */
  5735. toGammaSpace(): Color3;
  5736. /**
  5737. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5738. * @param convertedColor defines the Color3 object where to store the gamma space version
  5739. * @returns the unmodified Color3
  5740. */
  5741. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5742. private static _BlackReadOnly;
  5743. /**
  5744. * Convert Hue, saturation and value to a Color3 (RGB)
  5745. * @param hue defines the hue
  5746. * @param saturation defines the saturation
  5747. * @param value defines the value
  5748. * @param result defines the Color3 where to store the RGB values
  5749. */
  5750. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5751. /**
  5752. * Creates a new Color3 from the string containing valid hexadecimal values
  5753. * @param hex defines a string containing valid hexadecimal values
  5754. * @returns a new Color3 object
  5755. */
  5756. static FromHexString(hex: string): Color3;
  5757. /**
  5758. * Creates a new Color3 from the starting index of the given array
  5759. * @param array defines the source array
  5760. * @param offset defines an offset in the source array
  5761. * @returns a new Color3 object
  5762. */
  5763. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5764. /**
  5765. * Creates a new Color3 from the starting index element of the given array
  5766. * @param array defines the source array to read from
  5767. * @param offset defines the offset in the source array
  5768. * @param result defines the target Color3 object
  5769. */
  5770. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5771. /**
  5772. * Creates a new Color3 from integer values (< 256)
  5773. * @param r defines the red component to read from (value between 0 and 255)
  5774. * @param g defines the green component to read from (value between 0 and 255)
  5775. * @param b defines the blue component to read from (value between 0 and 255)
  5776. * @returns a new Color3 object
  5777. */
  5778. static FromInts(r: number, g: number, b: number): Color3;
  5779. /**
  5780. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5781. * @param start defines the start Color3 value
  5782. * @param end defines the end Color3 value
  5783. * @param amount defines the gradient value between start and end
  5784. * @returns a new Color3 object
  5785. */
  5786. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5787. /**
  5788. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5789. * @param left defines the start value
  5790. * @param right defines the end value
  5791. * @param amount defines the gradient factor
  5792. * @param result defines the Color3 object where to store the result
  5793. */
  5794. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5795. /**
  5796. * Returns a Color3 value containing a red color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Red(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a green color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Green(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a blue color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Blue(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a black color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Black(): Color3;
  5815. /**
  5816. * Gets a Color3 value containing a black color that must not be updated
  5817. */
  5818. static get BlackReadOnly(): DeepImmutable<Color3>;
  5819. /**
  5820. * Returns a Color3 value containing a white color
  5821. * @returns a new Color3 object
  5822. */
  5823. static White(): Color3;
  5824. /**
  5825. * Returns a Color3 value containing a purple color
  5826. * @returns a new Color3 object
  5827. */
  5828. static Purple(): Color3;
  5829. /**
  5830. * Returns a Color3 value containing a magenta color
  5831. * @returns a new Color3 object
  5832. */
  5833. static Magenta(): Color3;
  5834. /**
  5835. * Returns a Color3 value containing a yellow color
  5836. * @returns a new Color3 object
  5837. */
  5838. static Yellow(): Color3;
  5839. /**
  5840. * Returns a Color3 value containing a gray color
  5841. * @returns a new Color3 object
  5842. */
  5843. static Gray(): Color3;
  5844. /**
  5845. * Returns a Color3 value containing a teal color
  5846. * @returns a new Color3 object
  5847. */
  5848. static Teal(): Color3;
  5849. /**
  5850. * Returns a Color3 value containing a random color
  5851. * @returns a new Color3 object
  5852. */
  5853. static Random(): Color3;
  5854. }
  5855. /**
  5856. * Class used to hold a RBGA color
  5857. */
  5858. export class Color4 {
  5859. /**
  5860. * Defines the red component (between 0 and 1, default is 0)
  5861. */
  5862. r: number;
  5863. /**
  5864. * Defines the green component (between 0 and 1, default is 0)
  5865. */
  5866. g: number;
  5867. /**
  5868. * Defines the blue component (between 0 and 1, default is 0)
  5869. */
  5870. b: number;
  5871. /**
  5872. * Defines the alpha component (between 0 and 1, default is 1)
  5873. */
  5874. a: number;
  5875. /**
  5876. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5877. * @param r defines the red component (between 0 and 1, default is 0)
  5878. * @param g defines the green component (between 0 and 1, default is 0)
  5879. * @param b defines the blue component (between 0 and 1, default is 0)
  5880. * @param a defines the alpha component (between 0 and 1, default is 1)
  5881. */
  5882. constructor(
  5883. /**
  5884. * Defines the red component (between 0 and 1, default is 0)
  5885. */
  5886. r?: number,
  5887. /**
  5888. * Defines the green component (between 0 and 1, default is 0)
  5889. */
  5890. g?: number,
  5891. /**
  5892. * Defines the blue component (between 0 and 1, default is 0)
  5893. */
  5894. b?: number,
  5895. /**
  5896. * Defines the alpha component (between 0 and 1, default is 1)
  5897. */
  5898. a?: number);
  5899. /**
  5900. * Adds in place the given Color4 values to the current Color4 object
  5901. * @param right defines the second operand
  5902. * @returns the current updated Color4 object
  5903. */
  5904. addInPlace(right: DeepImmutable<Color4>): Color4;
  5905. /**
  5906. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5907. * @returns the new array
  5908. */
  5909. asArray(): number[];
  5910. /**
  5911. * Stores from the starting index in the given array the Color4 successive values
  5912. * @param array defines the array where to store the r,g,b components
  5913. * @param index defines an optional index in the target array to define where to start storing values
  5914. * @returns the current Color4 object
  5915. */
  5916. toArray(array: number[], index?: number): Color4;
  5917. /**
  5918. * Update the current color with values stored in an array from the starting index of the given array
  5919. * @param array defines the source array
  5920. * @param offset defines an offset in the source array
  5921. * @returns the current Color4 object
  5922. */
  5923. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5924. /**
  5925. * Determines equality between Color4 objects
  5926. * @param otherColor defines the second operand
  5927. * @returns true if the rgba values are equal to the given ones
  5928. */
  5929. equals(otherColor: DeepImmutable<Color4>): boolean;
  5930. /**
  5931. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5932. * @param right defines the second operand
  5933. * @returns a new Color4 object
  5934. */
  5935. add(right: DeepImmutable<Color4>): Color4;
  5936. /**
  5937. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5938. * @param right defines the second operand
  5939. * @returns a new Color4 object
  5940. */
  5941. subtract(right: DeepImmutable<Color4>): Color4;
  5942. /**
  5943. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5944. * @param right defines the second operand
  5945. * @param result defines the Color4 object where to store the result
  5946. * @returns the current Color4 object
  5947. */
  5948. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5949. /**
  5950. * Creates a new Color4 with the current Color4 values multiplied by scale
  5951. * @param scale defines the scaling factor to apply
  5952. * @returns a new Color4 object
  5953. */
  5954. scale(scale: number): Color4;
  5955. /**
  5956. * Multiplies the current Color4 values by scale and stores the result in "result"
  5957. * @param scale defines the scaling factor to apply
  5958. * @param result defines the Color4 object where to store the result
  5959. * @returns the current unmodified Color4
  5960. */
  5961. scaleToRef(scale: number, result: Color4): Color4;
  5962. /**
  5963. * Scale the current Color4 values by a factor and add the result to a given Color4
  5964. * @param scale defines the scale factor
  5965. * @param result defines the Color4 object where to store the result
  5966. * @returns the unmodified current Color4
  5967. */
  5968. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5969. /**
  5970. * Clamps the rgb values by the min and max values and stores the result into "result"
  5971. * @param min defines minimum clamping value (default is 0)
  5972. * @param max defines maximum clamping value (default is 1)
  5973. * @param result defines color to store the result into.
  5974. * @returns the cuurent Color4
  5975. */
  5976. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5977. /**
  5978. * Multipy an Color4 value by another and return a new Color4 object
  5979. * @param color defines the Color4 value to multiply by
  5980. * @returns a new Color4 object
  5981. */
  5982. multiply(color: Color4): Color4;
  5983. /**
  5984. * Multipy a Color4 value by another and push the result in a reference value
  5985. * @param color defines the Color4 value to multiply by
  5986. * @param result defines the Color4 to fill the result in
  5987. * @returns the result Color4
  5988. */
  5989. multiplyToRef(color: Color4, result: Color4): Color4;
  5990. /**
  5991. * Creates a string with the Color4 current values
  5992. * @returns the string representation of the Color4 object
  5993. */
  5994. toString(): string;
  5995. /**
  5996. * Returns the string "Color4"
  5997. * @returns "Color4"
  5998. */
  5999. getClassName(): string;
  6000. /**
  6001. * Compute the Color4 hash code
  6002. * @returns an unique number that can be used to hash Color4 objects
  6003. */
  6004. getHashCode(): number;
  6005. /**
  6006. * Creates a new Color4 copied from the current one
  6007. * @returns a new Color4 object
  6008. */
  6009. clone(): Color4;
  6010. /**
  6011. * Copies the given Color4 values into the current one
  6012. * @param source defines the source Color4 object
  6013. * @returns the current updated Color4 object
  6014. */
  6015. copyFrom(source: Color4): Color4;
  6016. /**
  6017. * Copies the given float values into the current one
  6018. * @param r defines the red component to read from
  6019. * @param g defines the green component to read from
  6020. * @param b defines the blue component to read from
  6021. * @param a defines the alpha component to read from
  6022. * @returns the current updated Color4 object
  6023. */
  6024. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6025. /**
  6026. * Copies the given float values into the current one
  6027. * @param r defines the red component to read from
  6028. * @param g defines the green component to read from
  6029. * @param b defines the blue component to read from
  6030. * @param a defines the alpha component to read from
  6031. * @returns the current updated Color4 object
  6032. */
  6033. set(r: number, g: number, b: number, a: number): Color4;
  6034. /**
  6035. * Compute the Color4 hexadecimal code as a string
  6036. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6037. * @returns a string containing the hexadecimal representation of the Color4 object
  6038. */
  6039. toHexString(returnAsColor3?: boolean): string;
  6040. /**
  6041. * Computes a new Color4 converted from the current one to linear space
  6042. * @returns a new Color4 object
  6043. */
  6044. toLinearSpace(): Color4;
  6045. /**
  6046. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6047. * @param convertedColor defines the Color4 object where to store the linear space version
  6048. * @returns the unmodified Color4
  6049. */
  6050. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6051. /**
  6052. * Computes a new Color4 converted from the current one to gamma space
  6053. * @returns a new Color4 object
  6054. */
  6055. toGammaSpace(): Color4;
  6056. /**
  6057. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6058. * @param convertedColor defines the Color4 object where to store the gamma space version
  6059. * @returns the unmodified Color4
  6060. */
  6061. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6062. /**
  6063. * Creates a new Color4 from the string containing valid hexadecimal values
  6064. * @param hex defines a string containing valid hexadecimal values
  6065. * @returns a new Color4 object
  6066. */
  6067. static FromHexString(hex: string): Color4;
  6068. /**
  6069. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6070. * @param left defines the start value
  6071. * @param right defines the end value
  6072. * @param amount defines the gradient factor
  6073. * @returns a new Color4 object
  6074. */
  6075. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6076. /**
  6077. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6078. * @param left defines the start value
  6079. * @param right defines the end value
  6080. * @param amount defines the gradient factor
  6081. * @param result defines the Color4 object where to store data
  6082. */
  6083. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6084. /**
  6085. * Creates a new Color4 from a Color3 and an alpha value
  6086. * @param color3 defines the source Color3 to read from
  6087. * @param alpha defines the alpha component (1.0 by default)
  6088. * @returns a new Color4 object
  6089. */
  6090. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6091. /**
  6092. * Creates a new Color4 from the starting index element of the given array
  6093. * @param array defines the source array to read from
  6094. * @param offset defines the offset in the source array
  6095. * @returns a new Color4 object
  6096. */
  6097. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6098. /**
  6099. * Creates a new Color4 from the starting index element of the given array
  6100. * @param array defines the source array to read from
  6101. * @param offset defines the offset in the source array
  6102. * @param result defines the target Color4 object
  6103. */
  6104. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6105. /**
  6106. * Creates a new Color3 from integer values (< 256)
  6107. * @param r defines the red component to read from (value between 0 and 255)
  6108. * @param g defines the green component to read from (value between 0 and 255)
  6109. * @param b defines the blue component to read from (value between 0 and 255)
  6110. * @param a defines the alpha component to read from (value between 0 and 255)
  6111. * @returns a new Color3 object
  6112. */
  6113. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6114. /**
  6115. * Check the content of a given array and convert it to an array containing RGBA data
  6116. * If the original array was already containing count * 4 values then it is returned directly
  6117. * @param colors defines the array to check
  6118. * @param count defines the number of RGBA data to expect
  6119. * @returns an array containing count * 4 values (RGBA)
  6120. */
  6121. static CheckColors4(colors: number[], count: number): number[];
  6122. }
  6123. /**
  6124. * @hidden
  6125. */
  6126. export class TmpColors {
  6127. static Color3: Color3[];
  6128. static Color4: Color4[];
  6129. }
  6130. }
  6131. declare module "babylonjs/Animations/animationKey" {
  6132. /**
  6133. * Defines an interface which represents an animation key frame
  6134. */
  6135. export interface IAnimationKey {
  6136. /**
  6137. * Frame of the key frame
  6138. */
  6139. frame: number;
  6140. /**
  6141. * Value at the specifies key frame
  6142. */
  6143. value: any;
  6144. /**
  6145. * The input tangent for the cubic hermite spline
  6146. */
  6147. inTangent?: any;
  6148. /**
  6149. * The output tangent for the cubic hermite spline
  6150. */
  6151. outTangent?: any;
  6152. /**
  6153. * The animation interpolation type
  6154. */
  6155. interpolation?: AnimationKeyInterpolation;
  6156. }
  6157. /**
  6158. * Enum for the animation key frame interpolation type
  6159. */
  6160. export enum AnimationKeyInterpolation {
  6161. /**
  6162. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6163. */
  6164. STEP = 1
  6165. }
  6166. }
  6167. declare module "babylonjs/Animations/animationRange" {
  6168. /**
  6169. * Represents the range of an animation
  6170. */
  6171. export class AnimationRange {
  6172. /**The name of the animation range**/
  6173. name: string;
  6174. /**The starting frame of the animation */
  6175. from: number;
  6176. /**The ending frame of the animation*/
  6177. to: number;
  6178. /**
  6179. * Initializes the range of an animation
  6180. * @param name The name of the animation range
  6181. * @param from The starting frame of the animation
  6182. * @param to The ending frame of the animation
  6183. */
  6184. constructor(
  6185. /**The name of the animation range**/
  6186. name: string,
  6187. /**The starting frame of the animation */
  6188. from: number,
  6189. /**The ending frame of the animation*/
  6190. to: number);
  6191. /**
  6192. * Makes a copy of the animation range
  6193. * @returns A copy of the animation range
  6194. */
  6195. clone(): AnimationRange;
  6196. }
  6197. }
  6198. declare module "babylonjs/Animations/animationEvent" {
  6199. /**
  6200. * Composed of a frame, and an action function
  6201. */
  6202. export class AnimationEvent {
  6203. /** The frame for which the event is triggered **/
  6204. frame: number;
  6205. /** The event to perform when triggered **/
  6206. action: (currentFrame: number) => void;
  6207. /** Specifies if the event should be triggered only once**/
  6208. onlyOnce?: boolean | undefined;
  6209. /**
  6210. * Specifies if the animation event is done
  6211. */
  6212. isDone: boolean;
  6213. /**
  6214. * Initializes the animation event
  6215. * @param frame The frame for which the event is triggered
  6216. * @param action The event to perform when triggered
  6217. * @param onlyOnce Specifies if the event should be triggered only once
  6218. */
  6219. constructor(
  6220. /** The frame for which the event is triggered **/
  6221. frame: number,
  6222. /** The event to perform when triggered **/
  6223. action: (currentFrame: number) => void,
  6224. /** Specifies if the event should be triggered only once**/
  6225. onlyOnce?: boolean | undefined);
  6226. /** @hidden */
  6227. _clone(): AnimationEvent;
  6228. }
  6229. }
  6230. declare module "babylonjs/Behaviors/behavior" {
  6231. import { Nullable } from "babylonjs/types";
  6232. /**
  6233. * Interface used to define a behavior
  6234. */
  6235. export interface Behavior<T> {
  6236. /** gets or sets behavior's name */
  6237. name: string;
  6238. /**
  6239. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6240. */
  6241. init(): void;
  6242. /**
  6243. * Called when the behavior is attached to a target
  6244. * @param target defines the target where the behavior is attached to
  6245. */
  6246. attach(target: T): void;
  6247. /**
  6248. * Called when the behavior is detached from its target
  6249. */
  6250. detach(): void;
  6251. }
  6252. /**
  6253. * Interface implemented by classes supporting behaviors
  6254. */
  6255. export interface IBehaviorAware<T> {
  6256. /**
  6257. * Attach a behavior
  6258. * @param behavior defines the behavior to attach
  6259. * @returns the current host
  6260. */
  6261. addBehavior(behavior: Behavior<T>): T;
  6262. /**
  6263. * Remove a behavior from the current object
  6264. * @param behavior defines the behavior to detach
  6265. * @returns the current host
  6266. */
  6267. removeBehavior(behavior: Behavior<T>): T;
  6268. /**
  6269. * Gets a behavior using its name to search
  6270. * @param name defines the name to search
  6271. * @returns the behavior or null if not found
  6272. */
  6273. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6274. }
  6275. }
  6276. declare module "babylonjs/Misc/smartArray" {
  6277. /**
  6278. * Defines an array and its length.
  6279. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6280. */
  6281. export interface ISmartArrayLike<T> {
  6282. /**
  6283. * The data of the array.
  6284. */
  6285. data: Array<T>;
  6286. /**
  6287. * The active length of the array.
  6288. */
  6289. length: number;
  6290. }
  6291. /**
  6292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6293. */
  6294. export class SmartArray<T> implements ISmartArrayLike<T> {
  6295. /**
  6296. * The full set of data from the array.
  6297. */
  6298. data: Array<T>;
  6299. /**
  6300. * The active length of the array.
  6301. */
  6302. length: number;
  6303. protected _id: number;
  6304. /**
  6305. * Instantiates a Smart Array.
  6306. * @param capacity defines the default capacity of the array.
  6307. */
  6308. constructor(capacity: number);
  6309. /**
  6310. * Pushes a value at the end of the active data.
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Iterates over the active data and apply the lambda to them.
  6316. * @param func defines the action to apply on each value.
  6317. */
  6318. forEach(func: (content: T) => void): void;
  6319. /**
  6320. * Sorts the full sets of data.
  6321. * @param compareFn defines the comparison function to apply.
  6322. */
  6323. sort(compareFn: (a: T, b: T) => number): void;
  6324. /**
  6325. * Resets the active data to an empty array.
  6326. */
  6327. reset(): void;
  6328. /**
  6329. * Releases all the data from the array as well as the array.
  6330. */
  6331. dispose(): void;
  6332. /**
  6333. * Concats the active data with a given array.
  6334. * @param array defines the data to concatenate with.
  6335. */
  6336. concat(array: any): void;
  6337. /**
  6338. * Returns the position of a value in the active data.
  6339. * @param value defines the value to find the index for
  6340. * @returns the index if found in the active data otherwise -1
  6341. */
  6342. indexOf(value: T): number;
  6343. /**
  6344. * Returns whether an element is part of the active data.
  6345. * @param value defines the value to look for
  6346. * @returns true if found in the active data otherwise false
  6347. */
  6348. contains(value: T): boolean;
  6349. private static _GlobalId;
  6350. }
  6351. /**
  6352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6353. * The data in this array can only be present once
  6354. */
  6355. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6356. private _duplicateId;
  6357. /**
  6358. * Pushes a value at the end of the active data.
  6359. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6360. * @param value defines the object to push in the array.
  6361. */
  6362. push(value: T): void;
  6363. /**
  6364. * Pushes a value at the end of the active data.
  6365. * If the data is already present, it won t be added again
  6366. * @param value defines the object to push in the array.
  6367. * @returns true if added false if it was already present
  6368. */
  6369. pushNoDuplicate(value: T): boolean;
  6370. /**
  6371. * Resets the active data to an empty array.
  6372. */
  6373. reset(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * This ensures no dupplicate will be present in the result.
  6377. * @param array defines the data to concatenate with.
  6378. */
  6379. concatWithNoDuplicate(array: any): void;
  6380. }
  6381. }
  6382. declare module "babylonjs/Cameras/cameraInputsManager" {
  6383. import { Nullable } from "babylonjs/types";
  6384. import { Camera } from "babylonjs/Cameras/camera";
  6385. /**
  6386. * @ignore
  6387. * This is a list of all the different input types that are available in the application.
  6388. * Fo instance: ArcRotateCameraGamepadInput...
  6389. */
  6390. export var CameraInputTypes: {};
  6391. /**
  6392. * This is the contract to implement in order to create a new input class.
  6393. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6394. */
  6395. export interface ICameraInput<TCamera extends Camera> {
  6396. /**
  6397. * Defines the camera the input is attached to.
  6398. */
  6399. camera: Nullable<TCamera>;
  6400. /**
  6401. * Gets the class name of the current intput.
  6402. * @returns the class name
  6403. */
  6404. getClassName(): string;
  6405. /**
  6406. * Get the friendly name associated with the input class.
  6407. * @returns the input friendly name
  6408. */
  6409. getSimpleName(): string;
  6410. /**
  6411. * Attach the input controls to a specific dom element to get the input from.
  6412. * @param element Defines the element the controls should be listened from
  6413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6414. */
  6415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6416. /**
  6417. * Detach the current controls from the specified dom element.
  6418. * @param element Defines the element to stop listening the inputs from
  6419. */
  6420. detachControl(element: Nullable<HTMLElement>): void;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs?: () => void;
  6426. }
  6427. /**
  6428. * Represents a map of input types to input instance or input index to input instance.
  6429. */
  6430. export interface CameraInputsMap<TCamera extends Camera> {
  6431. /**
  6432. * Accessor to the input by input type.
  6433. */
  6434. [name: string]: ICameraInput<TCamera>;
  6435. /**
  6436. * Accessor to the input by input index.
  6437. */
  6438. [idx: number]: ICameraInput<TCamera>;
  6439. }
  6440. /**
  6441. * This represents the input manager used within a camera.
  6442. * It helps dealing with all the different kind of input attached to a camera.
  6443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6444. */
  6445. export class CameraInputsManager<TCamera extends Camera> {
  6446. /**
  6447. * Defines the list of inputs attahed to the camera.
  6448. */
  6449. attached: CameraInputsMap<TCamera>;
  6450. /**
  6451. * Defines the dom element the camera is collecting inputs from.
  6452. * This is null if the controls have not been attached.
  6453. */
  6454. attachedElement: Nullable<HTMLElement>;
  6455. /**
  6456. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6457. */
  6458. noPreventDefault: boolean;
  6459. /**
  6460. * Defined the camera the input manager belongs to.
  6461. */
  6462. camera: TCamera;
  6463. /**
  6464. * Update the current camera state depending on the inputs that have been used this frame.
  6465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6466. */
  6467. checkInputs: () => void;
  6468. /**
  6469. * Instantiate a new Camera Input Manager.
  6470. * @param camera Defines the camera the input manager blongs to
  6471. */
  6472. constructor(camera: TCamera);
  6473. /**
  6474. * Add an input method to a camera
  6475. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6476. * @param input camera input method
  6477. */
  6478. add(input: ICameraInput<TCamera>): void;
  6479. /**
  6480. * Remove a specific input method from a camera
  6481. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6482. * @param inputToRemove camera input method
  6483. */
  6484. remove(inputToRemove: ICameraInput<TCamera>): void;
  6485. /**
  6486. * Remove a specific input type from a camera
  6487. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6488. * @param inputType the type of the input to remove
  6489. */
  6490. removeByType(inputType: string): void;
  6491. private _addCheckInputs;
  6492. /**
  6493. * Attach the input controls to the currently attached dom element to listen the events from.
  6494. * @param input Defines the input to attach
  6495. */
  6496. attachInput(input: ICameraInput<TCamera>): void;
  6497. /**
  6498. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6499. * @param element Defines the dom element to collect the events from
  6500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6501. */
  6502. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6503. /**
  6504. * Detach the current manager inputs controls from a specific dom element.
  6505. * @param element Defines the dom element to collect the events from
  6506. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6507. */
  6508. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6509. /**
  6510. * Rebuild the dynamic inputCheck function from the current list of
  6511. * defined inputs in the manager.
  6512. */
  6513. rebuildInputCheck(): void;
  6514. /**
  6515. * Remove all attached input methods from a camera
  6516. */
  6517. clear(): void;
  6518. /**
  6519. * Serialize the current input manager attached to a camera.
  6520. * This ensures than once parsed,
  6521. * the input associated to the camera will be identical to the current ones
  6522. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6523. */
  6524. serialize(serializedCamera: any): void;
  6525. /**
  6526. * Parses an input manager serialized JSON to restore the previous list of inputs
  6527. * and states associated to a camera.
  6528. * @param parsedCamera Defines the JSON to parse
  6529. */
  6530. parse(parsedCamera: any): void;
  6531. }
  6532. }
  6533. declare module "babylonjs/Meshes/buffer" {
  6534. import { Nullable, DataArray } from "babylonjs/types";
  6535. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6536. /**
  6537. * Class used to store data that will be store in GPU memory
  6538. */
  6539. export class Buffer {
  6540. private _engine;
  6541. private _buffer;
  6542. /** @hidden */
  6543. _data: Nullable<DataArray>;
  6544. private _updatable;
  6545. private _instanced;
  6546. private _divisor;
  6547. /**
  6548. * Gets the byte stride.
  6549. */
  6550. readonly byteStride: number;
  6551. /**
  6552. * Constructor
  6553. * @param engine the engine
  6554. * @param data the data to use for this buffer
  6555. * @param updatable whether the data is updatable
  6556. * @param stride the stride (optional)
  6557. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6558. * @param instanced whether the buffer is instanced (optional)
  6559. * @param useBytes set to true if the stride in in bytes (optional)
  6560. * @param divisor sets an optional divisor for instances (1 by default)
  6561. */
  6562. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6563. /**
  6564. * Create a new VertexBuffer based on the current buffer
  6565. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6566. * @param offset defines offset in the buffer (0 by default)
  6567. * @param size defines the size in floats of attributes (position is 3 for instance)
  6568. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6569. * @param instanced defines if the vertex buffer contains indexed data
  6570. * @param useBytes defines if the offset and stride are in bytes *
  6571. * @param divisor sets an optional divisor for instances (1 by default)
  6572. * @returns the new vertex buffer
  6573. */
  6574. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6575. /**
  6576. * Gets a boolean indicating if the Buffer is updatable?
  6577. * @returns true if the buffer is updatable
  6578. */
  6579. isUpdatable(): boolean;
  6580. /**
  6581. * Gets current buffer's data
  6582. * @returns a DataArray or null
  6583. */
  6584. getData(): Nullable<DataArray>;
  6585. /**
  6586. * Gets underlying native buffer
  6587. * @returns underlying native buffer
  6588. */
  6589. getBuffer(): Nullable<DataBuffer>;
  6590. /**
  6591. * Gets the stride in float32 units (i.e. byte stride / 4).
  6592. * May not be an integer if the byte stride is not divisible by 4.
  6593. * @returns the stride in float32 units
  6594. * @deprecated Please use byteStride instead.
  6595. */
  6596. getStrideSize(): number;
  6597. /**
  6598. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6599. * @param data defines the data to store
  6600. */
  6601. create(data?: Nullable<DataArray>): void;
  6602. /** @hidden */
  6603. _rebuild(): void;
  6604. /**
  6605. * Update current buffer data
  6606. * @param data defines the data to store
  6607. */
  6608. update(data: DataArray): void;
  6609. /**
  6610. * Updates the data directly.
  6611. * @param data the new data
  6612. * @param offset the new offset
  6613. * @param vertexCount the vertex count (optional)
  6614. * @param useBytes set to true if the offset is in bytes
  6615. */
  6616. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6617. /**
  6618. * Release all resources
  6619. */
  6620. dispose(): void;
  6621. }
  6622. /**
  6623. * Specialized buffer used to store vertex data
  6624. */
  6625. export class VertexBuffer {
  6626. /** @hidden */
  6627. _buffer: Buffer;
  6628. private _kind;
  6629. private _size;
  6630. private _ownsBuffer;
  6631. private _instanced;
  6632. private _instanceDivisor;
  6633. /**
  6634. * The byte type.
  6635. */
  6636. static readonly BYTE: number;
  6637. /**
  6638. * The unsigned byte type.
  6639. */
  6640. static readonly UNSIGNED_BYTE: number;
  6641. /**
  6642. * The short type.
  6643. */
  6644. static readonly SHORT: number;
  6645. /**
  6646. * The unsigned short type.
  6647. */
  6648. static readonly UNSIGNED_SHORT: number;
  6649. /**
  6650. * The integer type.
  6651. */
  6652. static readonly INT: number;
  6653. /**
  6654. * The unsigned integer type.
  6655. */
  6656. static readonly UNSIGNED_INT: number;
  6657. /**
  6658. * The float type.
  6659. */
  6660. static readonly FLOAT: number;
  6661. /**
  6662. * Gets or sets the instance divisor when in instanced mode
  6663. */
  6664. get instanceDivisor(): number;
  6665. set instanceDivisor(value: number);
  6666. /**
  6667. * Gets the byte stride.
  6668. */
  6669. readonly byteStride: number;
  6670. /**
  6671. * Gets the byte offset.
  6672. */
  6673. readonly byteOffset: number;
  6674. /**
  6675. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6676. */
  6677. readonly normalized: boolean;
  6678. /**
  6679. * Gets the data type of each component in the array.
  6680. */
  6681. readonly type: number;
  6682. /**
  6683. * Constructor
  6684. * @param engine the engine
  6685. * @param data the data to use for this vertex buffer
  6686. * @param kind the vertex buffer kind
  6687. * @param updatable whether the data is updatable
  6688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6689. * @param stride the stride (optional)
  6690. * @param instanced whether the buffer is instanced (optional)
  6691. * @param offset the offset of the data (optional)
  6692. * @param size the number of components (optional)
  6693. * @param type the type of the component (optional)
  6694. * @param normalized whether the data contains normalized data (optional)
  6695. * @param useBytes set to true if stride and offset are in bytes (optional)
  6696. * @param divisor defines the instance divisor to use (1 by default)
  6697. */
  6698. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6699. /** @hidden */
  6700. _rebuild(): void;
  6701. /**
  6702. * Returns the kind of the VertexBuffer (string)
  6703. * @returns a string
  6704. */
  6705. getKind(): string;
  6706. /**
  6707. * Gets a boolean indicating if the VertexBuffer is updatable?
  6708. * @returns true if the buffer is updatable
  6709. */
  6710. isUpdatable(): boolean;
  6711. /**
  6712. * Gets current buffer's data
  6713. * @returns a DataArray or null
  6714. */
  6715. getData(): Nullable<DataArray>;
  6716. /**
  6717. * Gets underlying native buffer
  6718. * @returns underlying native buffer
  6719. */
  6720. getBuffer(): Nullable<DataBuffer>;
  6721. /**
  6722. * Gets the stride in float32 units (i.e. byte stride / 4).
  6723. * May not be an integer if the byte stride is not divisible by 4.
  6724. * @returns the stride in float32 units
  6725. * @deprecated Please use byteStride instead.
  6726. */
  6727. getStrideSize(): number;
  6728. /**
  6729. * Returns the offset as a multiple of the type byte length.
  6730. * @returns the offset in bytes
  6731. * @deprecated Please use byteOffset instead.
  6732. */
  6733. getOffset(): number;
  6734. /**
  6735. * Returns the number of components per vertex attribute (integer)
  6736. * @returns the size in float
  6737. */
  6738. getSize(): number;
  6739. /**
  6740. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6741. * @returns true if this buffer is instanced
  6742. */
  6743. getIsInstanced(): boolean;
  6744. /**
  6745. * Returns the instancing divisor, zero for non-instanced (integer).
  6746. * @returns a number
  6747. */
  6748. getInstanceDivisor(): number;
  6749. /**
  6750. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6751. * @param data defines the data to store
  6752. */
  6753. create(data?: DataArray): void;
  6754. /**
  6755. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6756. * This function will create a new buffer if the current one is not updatable
  6757. * @param data defines the data to store
  6758. */
  6759. update(data: DataArray): void;
  6760. /**
  6761. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6762. * Returns the directly updated WebGLBuffer.
  6763. * @param data the new data
  6764. * @param offset the new offset
  6765. * @param useBytes set to true if the offset is in bytes
  6766. */
  6767. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6768. /**
  6769. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6770. */
  6771. dispose(): void;
  6772. /**
  6773. * Enumerates each value of this vertex buffer as numbers.
  6774. * @param count the number of values to enumerate
  6775. * @param callback the callback function called for each value
  6776. */
  6777. forEach(count: number, callback: (value: number, index: number) => void): void;
  6778. /**
  6779. * Positions
  6780. */
  6781. static readonly PositionKind: string;
  6782. /**
  6783. * Normals
  6784. */
  6785. static readonly NormalKind: string;
  6786. /**
  6787. * Tangents
  6788. */
  6789. static readonly TangentKind: string;
  6790. /**
  6791. * Texture coordinates
  6792. */
  6793. static readonly UVKind: string;
  6794. /**
  6795. * Texture coordinates 2
  6796. */
  6797. static readonly UV2Kind: string;
  6798. /**
  6799. * Texture coordinates 3
  6800. */
  6801. static readonly UV3Kind: string;
  6802. /**
  6803. * Texture coordinates 4
  6804. */
  6805. static readonly UV4Kind: string;
  6806. /**
  6807. * Texture coordinates 5
  6808. */
  6809. static readonly UV5Kind: string;
  6810. /**
  6811. * Texture coordinates 6
  6812. */
  6813. static readonly UV6Kind: string;
  6814. /**
  6815. * Colors
  6816. */
  6817. static readonly ColorKind: string;
  6818. /**
  6819. * Matrix indices (for bones)
  6820. */
  6821. static readonly MatricesIndicesKind: string;
  6822. /**
  6823. * Matrix weights (for bones)
  6824. */
  6825. static readonly MatricesWeightsKind: string;
  6826. /**
  6827. * Additional matrix indices (for bones)
  6828. */
  6829. static readonly MatricesIndicesExtraKind: string;
  6830. /**
  6831. * Additional matrix weights (for bones)
  6832. */
  6833. static readonly MatricesWeightsExtraKind: string;
  6834. /**
  6835. * Deduces the stride given a kind.
  6836. * @param kind The kind string to deduce
  6837. * @returns The deduced stride
  6838. */
  6839. static DeduceStride(kind: string): number;
  6840. /**
  6841. * Gets the byte length of the given type.
  6842. * @param type the type
  6843. * @returns the number of bytes
  6844. */
  6845. static GetTypeByteLength(type: number): number;
  6846. /**
  6847. * Enumerates each value of the given parameters as numbers.
  6848. * @param data the data to enumerate
  6849. * @param byteOffset the byte offset of the data
  6850. * @param byteStride the byte stride of the data
  6851. * @param componentCount the number of components per element
  6852. * @param componentType the type of the component
  6853. * @param count the number of values to enumerate
  6854. * @param normalized whether the data is normalized
  6855. * @param callback the callback function called for each value
  6856. */
  6857. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6858. private static _GetFloatValue;
  6859. }
  6860. }
  6861. declare module "babylonjs/Collisions/intersectionInfo" {
  6862. import { Nullable } from "babylonjs/types";
  6863. /**
  6864. * @hidden
  6865. */
  6866. export class IntersectionInfo {
  6867. bu: Nullable<number>;
  6868. bv: Nullable<number>;
  6869. distance: number;
  6870. faceId: number;
  6871. subMeshId: number;
  6872. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6873. }
  6874. }
  6875. declare module "babylonjs/Culling/boundingSphere" {
  6876. import { DeepImmutable } from "babylonjs/types";
  6877. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6878. import { Plane } from "babylonjs/Maths/math.plane";
  6879. /**
  6880. * Class used to store bounding sphere information
  6881. */
  6882. export class BoundingSphere {
  6883. /**
  6884. * Gets the center of the bounding sphere in local space
  6885. */
  6886. readonly center: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in local space
  6889. */
  6890. radius: number;
  6891. /**
  6892. * Gets the center of the bounding sphere in world space
  6893. */
  6894. readonly centerWorld: Vector3;
  6895. /**
  6896. * Radius of the bounding sphere in world space
  6897. */
  6898. radiusWorld: number;
  6899. /**
  6900. * Gets the minimum vector in local space
  6901. */
  6902. readonly minimum: Vector3;
  6903. /**
  6904. * Gets the maximum vector in local space
  6905. */
  6906. readonly maximum: Vector3;
  6907. private _worldMatrix;
  6908. private static readonly TmpVector3;
  6909. /**
  6910. * Creates a new bounding sphere
  6911. * @param min defines the minimum vector (in local space)
  6912. * @param max defines the maximum vector (in local space)
  6913. * @param worldMatrix defines the new world matrix
  6914. */
  6915. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6916. /**
  6917. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6918. * @param min defines the new minimum vector (in local space)
  6919. * @param max defines the new maximum vector (in local space)
  6920. * @param worldMatrix defines the new world matrix
  6921. */
  6922. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6923. /**
  6924. * Scale the current bounding sphere by applying a scale factor
  6925. * @param factor defines the scale factor to apply
  6926. * @returns the current bounding box
  6927. */
  6928. scale(factor: number): BoundingSphere;
  6929. /**
  6930. * Gets the world matrix of the bounding box
  6931. * @returns a matrix
  6932. */
  6933. getWorldMatrix(): DeepImmutable<Matrix>;
  6934. /** @hidden */
  6935. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6936. /**
  6937. * Tests if the bounding sphere is intersecting the frustum planes
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @returns true if there is an intersection
  6940. */
  6941. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /**
  6943. * Tests if the bounding sphere center is in between the frustum planes.
  6944. * Used for optimistic fast inclusion.
  6945. * @param frustumPlanes defines the frustum planes to test
  6946. * @returns true if the sphere center is in between the frustum planes
  6947. */
  6948. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6949. /**
  6950. * Tests if a point is inside the bounding sphere
  6951. * @param point defines the point to test
  6952. * @returns true if the point is inside the bounding sphere
  6953. */
  6954. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6955. /**
  6956. * Checks if two sphere intersct
  6957. * @param sphere0 sphere 0
  6958. * @param sphere1 sphere 1
  6959. * @returns true if the speres intersect
  6960. */
  6961. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6962. }
  6963. }
  6964. declare module "babylonjs/Culling/boundingBox" {
  6965. import { DeepImmutable } from "babylonjs/types";
  6966. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6967. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6968. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6969. import { Plane } from "babylonjs/Maths/math.plane";
  6970. /**
  6971. * Class used to store bounding box information
  6972. */
  6973. export class BoundingBox implements ICullable {
  6974. /**
  6975. * Gets the 8 vectors representing the bounding box in local space
  6976. */
  6977. readonly vectors: Vector3[];
  6978. /**
  6979. * Gets the center of the bounding box in local space
  6980. */
  6981. readonly center: Vector3;
  6982. /**
  6983. * Gets the center of the bounding box in world space
  6984. */
  6985. readonly centerWorld: Vector3;
  6986. /**
  6987. * Gets the extend size in local space
  6988. */
  6989. readonly extendSize: Vector3;
  6990. /**
  6991. * Gets the extend size in world space
  6992. */
  6993. readonly extendSizeWorld: Vector3;
  6994. /**
  6995. * Gets the OBB (object bounding box) directions
  6996. */
  6997. readonly directions: Vector3[];
  6998. /**
  6999. * Gets the 8 vectors representing the bounding box in world space
  7000. */
  7001. readonly vectorsWorld: Vector3[];
  7002. /**
  7003. * Gets the minimum vector in world space
  7004. */
  7005. readonly minimumWorld: Vector3;
  7006. /**
  7007. * Gets the maximum vector in world space
  7008. */
  7009. readonly maximumWorld: Vector3;
  7010. /**
  7011. * Gets the minimum vector in local space
  7012. */
  7013. readonly minimum: Vector3;
  7014. /**
  7015. * Gets the maximum vector in local space
  7016. */
  7017. readonly maximum: Vector3;
  7018. private _worldMatrix;
  7019. private static readonly TmpVector3;
  7020. /**
  7021. * @hidden
  7022. */
  7023. _tag: number;
  7024. /**
  7025. * Creates a new bounding box
  7026. * @param min defines the minimum vector (in local space)
  7027. * @param max defines the maximum vector (in local space)
  7028. * @param worldMatrix defines the new world matrix
  7029. */
  7030. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7031. /**
  7032. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7033. * @param min defines the new minimum vector (in local space)
  7034. * @param max defines the new maximum vector (in local space)
  7035. * @param worldMatrix defines the new world matrix
  7036. */
  7037. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7038. /**
  7039. * Scale the current bounding box by applying a scale factor
  7040. * @param factor defines the scale factor to apply
  7041. * @returns the current bounding box
  7042. */
  7043. scale(factor: number): BoundingBox;
  7044. /**
  7045. * Gets the world matrix of the bounding box
  7046. * @returns a matrix
  7047. */
  7048. getWorldMatrix(): DeepImmutable<Matrix>;
  7049. /** @hidden */
  7050. _update(world: DeepImmutable<Matrix>): void;
  7051. /**
  7052. * Tests if the bounding box is intersecting the frustum planes
  7053. * @param frustumPlanes defines the frustum planes to test
  7054. * @returns true if there is an intersection
  7055. */
  7056. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7057. /**
  7058. * Tests if the bounding box is entirely inside the frustum planes
  7059. * @param frustumPlanes defines the frustum planes to test
  7060. * @returns true if there is an inclusion
  7061. */
  7062. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7063. /**
  7064. * Tests if a point is inside the bounding box
  7065. * @param point defines the point to test
  7066. * @returns true if the point is inside the bounding box
  7067. */
  7068. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7069. /**
  7070. * Tests if the bounding box intersects with a bounding sphere
  7071. * @param sphere defines the sphere to test
  7072. * @returns true if there is an intersection
  7073. */
  7074. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7075. /**
  7076. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7077. * @param min defines the min vector to use
  7078. * @param max defines the max vector to use
  7079. * @returns true if there is an intersection
  7080. */
  7081. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7082. /**
  7083. * Tests if two bounding boxes are intersections
  7084. * @param box0 defines the first box to test
  7085. * @param box1 defines the second box to test
  7086. * @returns true if there is an intersection
  7087. */
  7088. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7089. /**
  7090. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7091. * @param minPoint defines the minimum vector of the bounding box
  7092. * @param maxPoint defines the maximum vector of the bounding box
  7093. * @param sphereCenter defines the sphere center
  7094. * @param sphereRadius defines the sphere radius
  7095. * @returns true if there is an intersection
  7096. */
  7097. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7098. /**
  7099. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7100. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7101. * @param frustumPlanes defines the frustum planes to test
  7102. * @return true if there is an inclusion
  7103. */
  7104. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7105. /**
  7106. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7107. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7108. * @param frustumPlanes defines the frustum planes to test
  7109. * @return true if there is an intersection
  7110. */
  7111. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7112. }
  7113. }
  7114. declare module "babylonjs/Collisions/collider" {
  7115. import { Nullable, IndicesArray } from "babylonjs/types";
  7116. import { Vector3 } from "babylonjs/Maths/math.vector";
  7117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7118. import { Plane } from "babylonjs/Maths/math.plane";
  7119. /** @hidden */
  7120. export class Collider {
  7121. /** Define if a collision was found */
  7122. collisionFound: boolean;
  7123. /**
  7124. * Define last intersection point in local space
  7125. */
  7126. intersectionPoint: Vector3;
  7127. /**
  7128. * Define last collided mesh
  7129. */
  7130. collidedMesh: Nullable<AbstractMesh>;
  7131. private _collisionPoint;
  7132. private _planeIntersectionPoint;
  7133. private _tempVector;
  7134. private _tempVector2;
  7135. private _tempVector3;
  7136. private _tempVector4;
  7137. private _edge;
  7138. private _baseToVertex;
  7139. private _destinationPoint;
  7140. private _slidePlaneNormal;
  7141. private _displacementVector;
  7142. /** @hidden */
  7143. _radius: Vector3;
  7144. /** @hidden */
  7145. _retry: number;
  7146. private _velocity;
  7147. private _basePoint;
  7148. private _epsilon;
  7149. /** @hidden */
  7150. _velocityWorldLength: number;
  7151. /** @hidden */
  7152. _basePointWorld: Vector3;
  7153. private _velocityWorld;
  7154. private _normalizedVelocity;
  7155. /** @hidden */
  7156. _initialVelocity: Vector3;
  7157. /** @hidden */
  7158. _initialPosition: Vector3;
  7159. private _nearestDistance;
  7160. private _collisionMask;
  7161. get collisionMask(): number;
  7162. set collisionMask(mask: number);
  7163. /**
  7164. * Gets the plane normal used to compute the sliding response (in local space)
  7165. */
  7166. get slidePlaneNormal(): Vector3;
  7167. /** @hidden */
  7168. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7169. /** @hidden */
  7170. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7171. /** @hidden */
  7172. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7173. /** @hidden */
  7174. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7175. /** @hidden */
  7176. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7177. /** @hidden */
  7178. _getResponse(pos: Vector3, vel: Vector3): void;
  7179. }
  7180. }
  7181. declare module "babylonjs/Culling/boundingInfo" {
  7182. import { DeepImmutable } from "babylonjs/types";
  7183. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7184. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { Plane } from "babylonjs/Maths/math.plane";
  7187. import { Collider } from "babylonjs/Collisions/collider";
  7188. /**
  7189. * Interface for cullable objects
  7190. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7191. */
  7192. export interface ICullable {
  7193. /**
  7194. * Checks if the object or part of the object is in the frustum
  7195. * @param frustumPlanes Camera near/planes
  7196. * @returns true if the object is in frustum otherwise false
  7197. */
  7198. isInFrustum(frustumPlanes: Plane[]): boolean;
  7199. /**
  7200. * Checks if a cullable object (mesh...) is in the camera frustum
  7201. * Unlike isInFrustum this cheks the full bounding box
  7202. * @param frustumPlanes Camera near/planes
  7203. * @returns true if the object is in frustum otherwise false
  7204. */
  7205. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7206. }
  7207. /**
  7208. * Info for a bounding data of a mesh
  7209. */
  7210. export class BoundingInfo implements ICullable {
  7211. /**
  7212. * Bounding box for the mesh
  7213. */
  7214. readonly boundingBox: BoundingBox;
  7215. /**
  7216. * Bounding sphere for the mesh
  7217. */
  7218. readonly boundingSphere: BoundingSphere;
  7219. private _isLocked;
  7220. private static readonly TmpVector3;
  7221. /**
  7222. * Constructs bounding info
  7223. * @param minimum min vector of the bounding box/sphere
  7224. * @param maximum max vector of the bounding box/sphere
  7225. * @param worldMatrix defines the new world matrix
  7226. */
  7227. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7228. /**
  7229. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7230. * @param min defines the new minimum vector (in local space)
  7231. * @param max defines the new maximum vector (in local space)
  7232. * @param worldMatrix defines the new world matrix
  7233. */
  7234. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7235. /**
  7236. * min vector of the bounding box/sphere
  7237. */
  7238. get minimum(): Vector3;
  7239. /**
  7240. * max vector of the bounding box/sphere
  7241. */
  7242. get maximum(): Vector3;
  7243. /**
  7244. * If the info is locked and won't be updated to avoid perf overhead
  7245. */
  7246. get isLocked(): boolean;
  7247. set isLocked(value: boolean);
  7248. /**
  7249. * Updates the bounding sphere and box
  7250. * @param world world matrix to be used to update
  7251. */
  7252. update(world: DeepImmutable<Matrix>): void;
  7253. /**
  7254. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7255. * @param center New center of the bounding info
  7256. * @param extend New extend of the bounding info
  7257. * @returns the current bounding info
  7258. */
  7259. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7260. /**
  7261. * Scale the current bounding info by applying a scale factor
  7262. * @param factor defines the scale factor to apply
  7263. * @returns the current bounding info
  7264. */
  7265. scale(factor: number): BoundingInfo;
  7266. /**
  7267. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7268. * @param frustumPlanes defines the frustum to test
  7269. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7270. * @returns true if the bounding info is in the frustum planes
  7271. */
  7272. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7273. /**
  7274. * Gets the world distance between the min and max points of the bounding box
  7275. */
  7276. get diagonalLength(): number;
  7277. /**
  7278. * Checks if a cullable object (mesh...) is in the camera frustum
  7279. * Unlike isInFrustum this cheks the full bounding box
  7280. * @param frustumPlanes Camera near/planes
  7281. * @returns true if the object is in frustum otherwise false
  7282. */
  7283. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7284. /** @hidden */
  7285. _checkCollision(collider: Collider): boolean;
  7286. /**
  7287. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7288. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7289. * @param point the point to check intersection with
  7290. * @returns if the point intersects
  7291. */
  7292. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7293. /**
  7294. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7295. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7296. * @param boundingInfo the bounding info to check intersection with
  7297. * @param precise if the intersection should be done using OBB
  7298. * @returns if the bounding info intersects
  7299. */
  7300. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7301. }
  7302. }
  7303. declare module "babylonjs/Maths/math.functions" {
  7304. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7305. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7306. /**
  7307. * Extracts minimum and maximum values from a list of indexed positions
  7308. * @param positions defines the positions to use
  7309. * @param indices defines the indices to the positions
  7310. * @param indexStart defines the start index
  7311. * @param indexCount defines the end index
  7312. * @param bias defines bias value to add to the result
  7313. * @return minimum and maximum values
  7314. */
  7315. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7316. minimum: Vector3;
  7317. maximum: Vector3;
  7318. };
  7319. /**
  7320. * Extracts minimum and maximum values from a list of positions
  7321. * @param positions defines the positions to use
  7322. * @param start defines the start index in the positions array
  7323. * @param count defines the number of positions to handle
  7324. * @param bias defines bias value to add to the result
  7325. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7326. * @return minimum and maximum values
  7327. */
  7328. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7329. minimum: Vector3;
  7330. maximum: Vector3;
  7331. };
  7332. }
  7333. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7334. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7335. /** @hidden */
  7336. export class WebGLDataBuffer extends DataBuffer {
  7337. private _buffer;
  7338. constructor(resource: WebGLBuffer);
  7339. get underlyingResource(): any;
  7340. }
  7341. }
  7342. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7343. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7344. import { Nullable } from "babylonjs/types";
  7345. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7346. /** @hidden */
  7347. export class WebGLPipelineContext implements IPipelineContext {
  7348. engine: ThinEngine;
  7349. program: Nullable<WebGLProgram>;
  7350. context?: WebGLRenderingContext;
  7351. vertexShader?: WebGLShader;
  7352. fragmentShader?: WebGLShader;
  7353. isParallelCompiled: boolean;
  7354. onCompiled?: () => void;
  7355. transformFeedback?: WebGLTransformFeedback | null;
  7356. vertexCompilationError: Nullable<string>;
  7357. fragmentCompilationError: Nullable<string>;
  7358. programLinkError: Nullable<string>;
  7359. programValidationError: Nullable<string>;
  7360. get isAsync(): boolean;
  7361. get isReady(): boolean;
  7362. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7363. _getVertexShaderCode(): string | null;
  7364. _getFragmentShaderCode(): string | null;
  7365. }
  7366. }
  7367. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7368. import { FloatArray, Nullable } from "babylonjs/types";
  7369. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7370. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7371. module "babylonjs/Engines/thinEngine" {
  7372. interface ThinEngine {
  7373. /**
  7374. * Create an uniform buffer
  7375. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7376. * @param elements defines the content of the uniform buffer
  7377. * @returns the webGL uniform buffer
  7378. */
  7379. createUniformBuffer(elements: FloatArray): DataBuffer;
  7380. /**
  7381. * Create a dynamic uniform buffer
  7382. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7383. * @param elements defines the content of the uniform buffer
  7384. * @returns the webGL uniform buffer
  7385. */
  7386. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7387. /**
  7388. * Update an existing uniform buffer
  7389. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7390. * @param uniformBuffer defines the target uniform buffer
  7391. * @param elements defines the content to update
  7392. * @param offset defines the offset in the uniform buffer where update should start
  7393. * @param count defines the size of the data to update
  7394. */
  7395. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7396. /**
  7397. * Bind an uniform buffer to the current webGL context
  7398. * @param buffer defines the buffer to bind
  7399. */
  7400. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7401. /**
  7402. * Bind a buffer to the current webGL context at a given location
  7403. * @param buffer defines the buffer to bind
  7404. * @param location defines the index where to bind the buffer
  7405. */
  7406. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7407. /**
  7408. * Bind a specific block at a given index in a specific shader program
  7409. * @param pipelineContext defines the pipeline context to use
  7410. * @param blockName defines the block name
  7411. * @param index defines the index where to bind the block
  7412. */
  7413. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7414. }
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/uniformBuffer" {
  7418. import { Nullable, FloatArray } from "babylonjs/types";
  7419. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7420. import { Engine } from "babylonjs/Engines/engine";
  7421. import { Effect } from "babylonjs/Materials/effect";
  7422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7423. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7424. import { Color3 } from "babylonjs/Maths/math.color";
  7425. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7426. /**
  7427. * Uniform buffer objects.
  7428. *
  7429. * Handles blocks of uniform on the GPU.
  7430. *
  7431. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7432. *
  7433. * For more information, please refer to :
  7434. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7435. */
  7436. export class UniformBuffer {
  7437. private _engine;
  7438. private _buffer;
  7439. private _data;
  7440. private _bufferData;
  7441. private _dynamic?;
  7442. private _uniformLocations;
  7443. private _uniformSizes;
  7444. private _uniformLocationPointer;
  7445. private _needSync;
  7446. private _noUBO;
  7447. private _currentEffect;
  7448. /** @hidden */
  7449. _alreadyBound: boolean;
  7450. private static _MAX_UNIFORM_SIZE;
  7451. private static _tempBuffer;
  7452. /**
  7453. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7454. * This is dynamic to allow compat with webgl 1 and 2.
  7455. * You will need to pass the name of the uniform as well as the value.
  7456. */
  7457. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7458. /**
  7459. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7460. * This is dynamic to allow compat with webgl 1 and 2.
  7461. * You will need to pass the name of the uniform as well as the value.
  7462. */
  7463. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7464. /**
  7465. * Lambda to Update a single float in a uniform buffer.
  7466. * This is dynamic to allow compat with webgl 1 and 2.
  7467. * You will need to pass the name of the uniform as well as the value.
  7468. */
  7469. updateFloat: (name: string, x: number) => void;
  7470. /**
  7471. * Lambda to Update a vec2 of float in a uniform buffer.
  7472. * This is dynamic to allow compat with webgl 1 and 2.
  7473. * You will need to pass the name of the uniform as well as the value.
  7474. */
  7475. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7476. /**
  7477. * Lambda to Update a vec3 of float in a uniform buffer.
  7478. * This is dynamic to allow compat with webgl 1 and 2.
  7479. * You will need to pass the name of the uniform as well as the value.
  7480. */
  7481. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7482. /**
  7483. * Lambda to Update a vec4 of float in a uniform buffer.
  7484. * This is dynamic to allow compat with webgl 1 and 2.
  7485. * You will need to pass the name of the uniform as well as the value.
  7486. */
  7487. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7488. /**
  7489. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7490. * This is dynamic to allow compat with webgl 1 and 2.
  7491. * You will need to pass the name of the uniform as well as the value.
  7492. */
  7493. updateMatrix: (name: string, mat: Matrix) => void;
  7494. /**
  7495. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7496. * This is dynamic to allow compat with webgl 1 and 2.
  7497. * You will need to pass the name of the uniform as well as the value.
  7498. */
  7499. updateVector3: (name: string, vector: Vector3) => void;
  7500. /**
  7501. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7502. * This is dynamic to allow compat with webgl 1 and 2.
  7503. * You will need to pass the name of the uniform as well as the value.
  7504. */
  7505. updateVector4: (name: string, vector: Vector4) => void;
  7506. /**
  7507. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7508. * This is dynamic to allow compat with webgl 1 and 2.
  7509. * You will need to pass the name of the uniform as well as the value.
  7510. */
  7511. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7512. /**
  7513. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7514. * This is dynamic to allow compat with webgl 1 and 2.
  7515. * You will need to pass the name of the uniform as well as the value.
  7516. */
  7517. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7518. /**
  7519. * Instantiates a new Uniform buffer objects.
  7520. *
  7521. * Handles blocks of uniform on the GPU.
  7522. *
  7523. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7524. *
  7525. * For more information, please refer to :
  7526. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7527. * @param engine Define the engine the buffer is associated with
  7528. * @param data Define the data contained in the buffer
  7529. * @param dynamic Define if the buffer is updatable
  7530. */
  7531. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7532. /**
  7533. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7534. * or just falling back on setUniformXXX calls.
  7535. */
  7536. get useUbo(): boolean;
  7537. /**
  7538. * Indicates if the WebGL underlying uniform buffer is in sync
  7539. * with the javascript cache data.
  7540. */
  7541. get isSync(): boolean;
  7542. /**
  7543. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7544. * Also, a dynamic UniformBuffer will disable cache verification and always
  7545. * update the underlying WebGL uniform buffer to the GPU.
  7546. * @returns if Dynamic, otherwise false
  7547. */
  7548. isDynamic(): boolean;
  7549. /**
  7550. * The data cache on JS side.
  7551. * @returns the underlying data as a float array
  7552. */
  7553. getData(): Float32Array;
  7554. /**
  7555. * The underlying WebGL Uniform buffer.
  7556. * @returns the webgl buffer
  7557. */
  7558. getBuffer(): Nullable<DataBuffer>;
  7559. /**
  7560. * std140 layout specifies how to align data within an UBO structure.
  7561. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7562. * for specs.
  7563. */
  7564. private _fillAlignment;
  7565. /**
  7566. * Adds an uniform in the buffer.
  7567. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7568. * for the layout to be correct !
  7569. * @param name Name of the uniform, as used in the uniform block in the shader.
  7570. * @param size Data size, or data directly.
  7571. */
  7572. addUniform(name: string, size: number | number[]): void;
  7573. /**
  7574. * Adds a Matrix 4x4 to the uniform buffer.
  7575. * @param name Name of the uniform, as used in the uniform block in the shader.
  7576. * @param mat A 4x4 matrix.
  7577. */
  7578. addMatrix(name: string, mat: Matrix): void;
  7579. /**
  7580. * Adds a vec2 to the uniform buffer.
  7581. * @param name Name of the uniform, as used in the uniform block in the shader.
  7582. * @param x Define the x component value of the vec2
  7583. * @param y Define the y component value of the vec2
  7584. */
  7585. addFloat2(name: string, x: number, y: number): void;
  7586. /**
  7587. * Adds a vec3 to the uniform buffer.
  7588. * @param name Name of the uniform, as used in the uniform block in the shader.
  7589. * @param x Define the x component value of the vec3
  7590. * @param y Define the y component value of the vec3
  7591. * @param z Define the z component value of the vec3
  7592. */
  7593. addFloat3(name: string, x: number, y: number, z: number): void;
  7594. /**
  7595. * Adds a vec3 to the uniform buffer.
  7596. * @param name Name of the uniform, as used in the uniform block in the shader.
  7597. * @param color Define the vec3 from a Color
  7598. */
  7599. addColor3(name: string, color: Color3): void;
  7600. /**
  7601. * Adds a vec4 to the uniform buffer.
  7602. * @param name Name of the uniform, as used in the uniform block in the shader.
  7603. * @param color Define the rgb components from a Color
  7604. * @param alpha Define the a component of the vec4
  7605. */
  7606. addColor4(name: string, color: Color3, alpha: number): void;
  7607. /**
  7608. * Adds a vec3 to the uniform buffer.
  7609. * @param name Name of the uniform, as used in the uniform block in the shader.
  7610. * @param vector Define the vec3 components from a Vector
  7611. */
  7612. addVector3(name: string, vector: Vector3): void;
  7613. /**
  7614. * Adds a Matrix 3x3 to the uniform buffer.
  7615. * @param name Name of the uniform, as used in the uniform block in the shader.
  7616. */
  7617. addMatrix3x3(name: string): void;
  7618. /**
  7619. * Adds a Matrix 2x2 to the uniform buffer.
  7620. * @param name Name of the uniform, as used in the uniform block in the shader.
  7621. */
  7622. addMatrix2x2(name: string): void;
  7623. /**
  7624. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7625. */
  7626. create(): void;
  7627. /** @hidden */
  7628. _rebuild(): void;
  7629. /**
  7630. * Updates the WebGL Uniform Buffer on the GPU.
  7631. * If the `dynamic` flag is set to true, no cache comparison is done.
  7632. * Otherwise, the buffer will be updated only if the cache differs.
  7633. */
  7634. update(): void;
  7635. /**
  7636. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7637. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7638. * @param data Define the flattened data
  7639. * @param size Define the size of the data.
  7640. */
  7641. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7642. private _valueCache;
  7643. private _cacheMatrix;
  7644. private _updateMatrix3x3ForUniform;
  7645. private _updateMatrix3x3ForEffect;
  7646. private _updateMatrix2x2ForEffect;
  7647. private _updateMatrix2x2ForUniform;
  7648. private _updateFloatForEffect;
  7649. private _updateFloatForUniform;
  7650. private _updateFloat2ForEffect;
  7651. private _updateFloat2ForUniform;
  7652. private _updateFloat3ForEffect;
  7653. private _updateFloat3ForUniform;
  7654. private _updateFloat4ForEffect;
  7655. private _updateFloat4ForUniform;
  7656. private _updateMatrixForEffect;
  7657. private _updateMatrixForUniform;
  7658. private _updateVector3ForEffect;
  7659. private _updateVector3ForUniform;
  7660. private _updateVector4ForEffect;
  7661. private _updateVector4ForUniform;
  7662. private _updateColor3ForEffect;
  7663. private _updateColor3ForUniform;
  7664. private _updateColor4ForEffect;
  7665. private _updateColor4ForUniform;
  7666. /**
  7667. * Sets a sampler uniform on the effect.
  7668. * @param name Define the name of the sampler.
  7669. * @param texture Define the texture to set in the sampler
  7670. */
  7671. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7672. /**
  7673. * Directly updates the value of the uniform in the cache AND on the GPU.
  7674. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7675. * @param data Define the flattened data
  7676. */
  7677. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7678. /**
  7679. * Binds this uniform buffer to an effect.
  7680. * @param effect Define the effect to bind the buffer to
  7681. * @param name Name of the uniform block in the shader.
  7682. */
  7683. bindToEffect(effect: Effect, name: string): void;
  7684. /**
  7685. * Disposes the uniform buffer.
  7686. */
  7687. dispose(): void;
  7688. }
  7689. }
  7690. declare module "babylonjs/Misc/iInspectable" {
  7691. /**
  7692. * Enum that determines the text-wrapping mode to use.
  7693. */
  7694. export enum InspectableType {
  7695. /**
  7696. * Checkbox for booleans
  7697. */
  7698. Checkbox = 0,
  7699. /**
  7700. * Sliders for numbers
  7701. */
  7702. Slider = 1,
  7703. /**
  7704. * Vector3
  7705. */
  7706. Vector3 = 2,
  7707. /**
  7708. * Quaternions
  7709. */
  7710. Quaternion = 3,
  7711. /**
  7712. * Color3
  7713. */
  7714. Color3 = 4,
  7715. /**
  7716. * String
  7717. */
  7718. String = 5
  7719. }
  7720. /**
  7721. * Interface used to define custom inspectable properties.
  7722. * This interface is used by the inspector to display custom property grids
  7723. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7724. */
  7725. export interface IInspectable {
  7726. /**
  7727. * Gets the label to display
  7728. */
  7729. label: string;
  7730. /**
  7731. * Gets the name of the property to edit
  7732. */
  7733. propertyName: string;
  7734. /**
  7735. * Gets the type of the editor to use
  7736. */
  7737. type: InspectableType;
  7738. /**
  7739. * Gets the minimum value of the property when using in "slider" mode
  7740. */
  7741. min?: number;
  7742. /**
  7743. * Gets the maximum value of the property when using in "slider" mode
  7744. */
  7745. max?: number;
  7746. /**
  7747. * Gets the setp to use when using in "slider" mode
  7748. */
  7749. step?: number;
  7750. }
  7751. }
  7752. declare module "babylonjs/Misc/timingTools" {
  7753. /**
  7754. * Class used to provide helper for timing
  7755. */
  7756. export class TimingTools {
  7757. /**
  7758. * Polyfill for setImmediate
  7759. * @param action defines the action to execute after the current execution block
  7760. */
  7761. static SetImmediate(action: () => void): void;
  7762. }
  7763. }
  7764. declare module "babylonjs/Misc/instantiationTools" {
  7765. /**
  7766. * Class used to enable instatition of objects by class name
  7767. */
  7768. export class InstantiationTools {
  7769. /**
  7770. * Use this object to register external classes like custom textures or material
  7771. * to allow the laoders to instantiate them
  7772. */
  7773. static RegisteredExternalClasses: {
  7774. [key: string]: Object;
  7775. };
  7776. /**
  7777. * Tries to instantiate a new object from a given class name
  7778. * @param className defines the class name to instantiate
  7779. * @returns the new object or null if the system was not able to do the instantiation
  7780. */
  7781. static Instantiate(className: string): any;
  7782. }
  7783. }
  7784. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7785. /**
  7786. * Define options used to create a depth texture
  7787. */
  7788. export class DepthTextureCreationOptions {
  7789. /** Specifies whether or not a stencil should be allocated in the texture */
  7790. generateStencil?: boolean;
  7791. /** Specifies whether or not bilinear filtering is enable on the texture */
  7792. bilinearFiltering?: boolean;
  7793. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7794. comparisonFunction?: number;
  7795. /** Specifies if the created texture is a cube texture */
  7796. isCube?: boolean;
  7797. }
  7798. }
  7799. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7800. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7801. import { Nullable } from "babylonjs/types";
  7802. import { Scene } from "babylonjs/scene";
  7803. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7804. module "babylonjs/Engines/thinEngine" {
  7805. interface ThinEngine {
  7806. /**
  7807. * Creates a depth stencil cube texture.
  7808. * This is only available in WebGL 2.
  7809. * @param size The size of face edge in the cube texture.
  7810. * @param options The options defining the cube texture.
  7811. * @returns The cube texture
  7812. */
  7813. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7814. /**
  7815. * Creates a cube texture
  7816. * @param rootUrl defines the url where the files to load is located
  7817. * @param scene defines the current scene
  7818. * @param files defines the list of files to load (1 per face)
  7819. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7820. * @param onLoad defines an optional callback raised when the texture is loaded
  7821. * @param onError defines an optional callback raised if there is an issue to load the texture
  7822. * @param format defines the format of the data
  7823. * @param forcedExtension defines the extension to use to pick the right loader
  7824. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7825. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7826. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7827. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7828. * @returns the cube texture as an InternalTexture
  7829. */
  7830. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7831. /**
  7832. * Creates a cube texture
  7833. * @param rootUrl defines the url where the files to load is located
  7834. * @param scene defines the current scene
  7835. * @param files defines the list of files to load (1 per face)
  7836. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7837. * @param onLoad defines an optional callback raised when the texture is loaded
  7838. * @param onError defines an optional callback raised if there is an issue to load the texture
  7839. * @param format defines the format of the data
  7840. * @param forcedExtension defines the extension to use to pick the right loader
  7841. * @returns the cube texture as an InternalTexture
  7842. */
  7843. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7844. /**
  7845. * Creates a cube texture
  7846. * @param rootUrl defines the url where the files to load is located
  7847. * @param scene defines the current scene
  7848. * @param files defines the list of files to load (1 per face)
  7849. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7850. * @param onLoad defines an optional callback raised when the texture is loaded
  7851. * @param onError defines an optional callback raised if there is an issue to load the texture
  7852. * @param format defines the format of the data
  7853. * @param forcedExtension defines the extension to use to pick the right loader
  7854. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7855. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7856. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7857. * @returns the cube texture as an InternalTexture
  7858. */
  7859. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7860. /** @hidden */
  7861. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7862. /** @hidden */
  7863. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7864. /** @hidden */
  7865. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7866. /** @hidden */
  7867. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7868. /**
  7869. * @hidden
  7870. */
  7871. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7872. }
  7873. }
  7874. }
  7875. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7876. import { Nullable } from "babylonjs/types";
  7877. import { Scene } from "babylonjs/scene";
  7878. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7880. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7881. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7882. import { Observable } from "babylonjs/Misc/observable";
  7883. /**
  7884. * Class for creating a cube texture
  7885. */
  7886. export class CubeTexture extends BaseTexture {
  7887. private _delayedOnLoad;
  7888. /**
  7889. * Observable triggered once the texture has been loaded.
  7890. */
  7891. onLoadObservable: Observable<CubeTexture>;
  7892. /**
  7893. * The url of the texture
  7894. */
  7895. url: string;
  7896. /**
  7897. * Gets or sets the center of the bounding box associated with the cube texture.
  7898. * It must define where the camera used to render the texture was set
  7899. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7900. */
  7901. boundingBoxPosition: Vector3;
  7902. private _boundingBoxSize;
  7903. /**
  7904. * Gets or sets the size of the bounding box associated with the cube texture
  7905. * When defined, the cubemap will switch to local mode
  7906. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7907. * @example https://www.babylonjs-playground.com/#RNASML
  7908. */
  7909. set boundingBoxSize(value: Vector3);
  7910. /**
  7911. * Returns the bounding box size
  7912. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7913. */
  7914. get boundingBoxSize(): Vector3;
  7915. protected _rotationY: number;
  7916. /**
  7917. * Sets texture matrix rotation angle around Y axis in radians.
  7918. */
  7919. set rotationY(value: number);
  7920. /**
  7921. * Gets texture matrix rotation angle around Y axis radians.
  7922. */
  7923. get rotationY(): number;
  7924. /**
  7925. * Are mip maps generated for this texture or not.
  7926. */
  7927. get noMipmap(): boolean;
  7928. private _noMipmap;
  7929. private _files;
  7930. protected _forcedExtension: Nullable<string>;
  7931. private _extensions;
  7932. private _textureMatrix;
  7933. private _format;
  7934. private _createPolynomials;
  7935. /**
  7936. * Creates a cube texture from an array of image urls
  7937. * @param files defines an array of image urls
  7938. * @param scene defines the hosting scene
  7939. * @param noMipmap specifies if mip maps are not used
  7940. * @returns a cube texture
  7941. */
  7942. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7943. /**
  7944. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7945. * @param url defines the url of the prefiltered texture
  7946. * @param scene defines the scene the texture is attached to
  7947. * @param forcedExtension defines the extension of the file if different from the url
  7948. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7949. * @return the prefiltered texture
  7950. */
  7951. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7952. /**
  7953. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7954. * as prefiltered data.
  7955. * @param rootUrl defines the url of the texture or the root name of the six images
  7956. * @param null defines the scene or engine the texture is attached to
  7957. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7958. * @param noMipmap defines if mipmaps should be created or not
  7959. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7960. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7961. * @param onError defines a callback triggered in case of error during load
  7962. * @param format defines the internal format to use for the texture once loaded
  7963. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7964. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7965. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7966. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7967. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7968. * @return the cube texture
  7969. */
  7970. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7971. /**
  7972. * Get the current class name of the texture useful for serialization or dynamic coding.
  7973. * @returns "CubeTexture"
  7974. */
  7975. getClassName(): string;
  7976. /**
  7977. * Update the url (and optional buffer) of this texture if url was null during construction.
  7978. * @param url the url of the texture
  7979. * @param forcedExtension defines the extension to use
  7980. * @param onLoad callback called when the texture is loaded (defaults to null)
  7981. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7982. */
  7983. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7984. /**
  7985. * Delays loading of the cube texture
  7986. * @param forcedExtension defines the extension to use
  7987. */
  7988. delayLoad(forcedExtension?: string): void;
  7989. /**
  7990. * Returns the reflection texture matrix
  7991. * @returns the reflection texture matrix
  7992. */
  7993. getReflectionTextureMatrix(): Matrix;
  7994. /**
  7995. * Sets the reflection texture matrix
  7996. * @param value Reflection texture matrix
  7997. */
  7998. setReflectionTextureMatrix(value: Matrix): void;
  7999. /**
  8000. * Parses text to create a cube texture
  8001. * @param parsedTexture define the serialized text to read from
  8002. * @param scene defines the hosting scene
  8003. * @param rootUrl defines the root url of the cube texture
  8004. * @returns a cube texture
  8005. */
  8006. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8007. /**
  8008. * Makes a clone, or deep copy, of the cube texture
  8009. * @returns a new cube texture
  8010. */
  8011. clone(): CubeTexture;
  8012. }
  8013. }
  8014. declare module "babylonjs/Materials/materialDefines" {
  8015. /**
  8016. * Manages the defines for the Material
  8017. */
  8018. export class MaterialDefines {
  8019. /** @hidden */
  8020. protected _keys: string[];
  8021. private _isDirty;
  8022. /** @hidden */
  8023. _renderId: number;
  8024. /** @hidden */
  8025. _areLightsDirty: boolean;
  8026. /** @hidden */
  8027. _areLightsDisposed: boolean;
  8028. /** @hidden */
  8029. _areAttributesDirty: boolean;
  8030. /** @hidden */
  8031. _areTexturesDirty: boolean;
  8032. /** @hidden */
  8033. _areFresnelDirty: boolean;
  8034. /** @hidden */
  8035. _areMiscDirty: boolean;
  8036. /** @hidden */
  8037. _areImageProcessingDirty: boolean;
  8038. /** @hidden */
  8039. _normals: boolean;
  8040. /** @hidden */
  8041. _uvs: boolean;
  8042. /** @hidden */
  8043. _needNormals: boolean;
  8044. /** @hidden */
  8045. _needUVs: boolean;
  8046. [id: string]: any;
  8047. /**
  8048. * Specifies if the material needs to be re-calculated
  8049. */
  8050. get isDirty(): boolean;
  8051. /**
  8052. * Marks the material to indicate that it has been re-calculated
  8053. */
  8054. markAsProcessed(): void;
  8055. /**
  8056. * Marks the material to indicate that it needs to be re-calculated
  8057. */
  8058. markAsUnprocessed(): void;
  8059. /**
  8060. * Marks the material to indicate all of its defines need to be re-calculated
  8061. */
  8062. markAllAsDirty(): void;
  8063. /**
  8064. * Marks the material to indicate that image processing needs to be re-calculated
  8065. */
  8066. markAsImageProcessingDirty(): void;
  8067. /**
  8068. * Marks the material to indicate the lights need to be re-calculated
  8069. * @param disposed Defines whether the light is dirty due to dispose or not
  8070. */
  8071. markAsLightDirty(disposed?: boolean): void;
  8072. /**
  8073. * Marks the attribute state as changed
  8074. */
  8075. markAsAttributesDirty(): void;
  8076. /**
  8077. * Marks the texture state as changed
  8078. */
  8079. markAsTexturesDirty(): void;
  8080. /**
  8081. * Marks the fresnel state as changed
  8082. */
  8083. markAsFresnelDirty(): void;
  8084. /**
  8085. * Marks the misc state as changed
  8086. */
  8087. markAsMiscDirty(): void;
  8088. /**
  8089. * Rebuilds the material defines
  8090. */
  8091. rebuild(): void;
  8092. /**
  8093. * Specifies if two material defines are equal
  8094. * @param other - A material define instance to compare to
  8095. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8096. */
  8097. isEqual(other: MaterialDefines): boolean;
  8098. /**
  8099. * Clones this instance's defines to another instance
  8100. * @param other - material defines to clone values to
  8101. */
  8102. cloneTo(other: MaterialDefines): void;
  8103. /**
  8104. * Resets the material define values
  8105. */
  8106. reset(): void;
  8107. /**
  8108. * Converts the material define values to a string
  8109. * @returns - String of material define information
  8110. */
  8111. toString(): string;
  8112. }
  8113. }
  8114. declare module "babylonjs/Materials/colorCurves" {
  8115. import { Effect } from "babylonjs/Materials/effect";
  8116. /**
  8117. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8118. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8119. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8120. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8121. */
  8122. export class ColorCurves {
  8123. private _dirty;
  8124. private _tempColor;
  8125. private _globalCurve;
  8126. private _highlightsCurve;
  8127. private _midtonesCurve;
  8128. private _shadowsCurve;
  8129. private _positiveCurve;
  8130. private _negativeCurve;
  8131. private _globalHue;
  8132. private _globalDensity;
  8133. private _globalSaturation;
  8134. private _globalExposure;
  8135. /**
  8136. * Gets the global Hue value.
  8137. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8138. */
  8139. get globalHue(): number;
  8140. /**
  8141. * Sets the global Hue value.
  8142. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8143. */
  8144. set globalHue(value: number);
  8145. /**
  8146. * Gets the global Density value.
  8147. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8148. * Values less than zero provide a filter of opposite hue.
  8149. */
  8150. get globalDensity(): number;
  8151. /**
  8152. * Sets the global Density value.
  8153. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8154. * Values less than zero provide a filter of opposite hue.
  8155. */
  8156. set globalDensity(value: number);
  8157. /**
  8158. * Gets the global Saturation value.
  8159. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8160. */
  8161. get globalSaturation(): number;
  8162. /**
  8163. * Sets the global Saturation value.
  8164. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8165. */
  8166. set globalSaturation(value: number);
  8167. /**
  8168. * Gets the global Exposure value.
  8169. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8170. */
  8171. get globalExposure(): number;
  8172. /**
  8173. * Sets the global Exposure value.
  8174. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8175. */
  8176. set globalExposure(value: number);
  8177. private _highlightsHue;
  8178. private _highlightsDensity;
  8179. private _highlightsSaturation;
  8180. private _highlightsExposure;
  8181. /**
  8182. * Gets the highlights Hue value.
  8183. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8184. */
  8185. get highlightsHue(): number;
  8186. /**
  8187. * Sets the highlights Hue value.
  8188. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8189. */
  8190. set highlightsHue(value: number);
  8191. /**
  8192. * Gets the highlights Density value.
  8193. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8194. * Values less than zero provide a filter of opposite hue.
  8195. */
  8196. get highlightsDensity(): number;
  8197. /**
  8198. * Sets the highlights Density value.
  8199. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8200. * Values less than zero provide a filter of opposite hue.
  8201. */
  8202. set highlightsDensity(value: number);
  8203. /**
  8204. * Gets the highlights Saturation value.
  8205. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8206. */
  8207. get highlightsSaturation(): number;
  8208. /**
  8209. * Sets the highlights Saturation value.
  8210. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8211. */
  8212. set highlightsSaturation(value: number);
  8213. /**
  8214. * Gets the highlights Exposure value.
  8215. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8216. */
  8217. get highlightsExposure(): number;
  8218. /**
  8219. * Sets the highlights Exposure value.
  8220. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8221. */
  8222. set highlightsExposure(value: number);
  8223. private _midtonesHue;
  8224. private _midtonesDensity;
  8225. private _midtonesSaturation;
  8226. private _midtonesExposure;
  8227. /**
  8228. * Gets the midtones Hue value.
  8229. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8230. */
  8231. get midtonesHue(): number;
  8232. /**
  8233. * Sets the midtones Hue value.
  8234. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8235. */
  8236. set midtonesHue(value: number);
  8237. /**
  8238. * Gets the midtones Density value.
  8239. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8240. * Values less than zero provide a filter of opposite hue.
  8241. */
  8242. get midtonesDensity(): number;
  8243. /**
  8244. * Sets the midtones Density value.
  8245. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8246. * Values less than zero provide a filter of opposite hue.
  8247. */
  8248. set midtonesDensity(value: number);
  8249. /**
  8250. * Gets the midtones Saturation value.
  8251. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8252. */
  8253. get midtonesSaturation(): number;
  8254. /**
  8255. * Sets the midtones Saturation value.
  8256. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8257. */
  8258. set midtonesSaturation(value: number);
  8259. /**
  8260. * Gets the midtones Exposure value.
  8261. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8262. */
  8263. get midtonesExposure(): number;
  8264. /**
  8265. * Sets the midtones Exposure value.
  8266. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8267. */
  8268. set midtonesExposure(value: number);
  8269. private _shadowsHue;
  8270. private _shadowsDensity;
  8271. private _shadowsSaturation;
  8272. private _shadowsExposure;
  8273. /**
  8274. * Gets the shadows Hue value.
  8275. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8276. */
  8277. get shadowsHue(): number;
  8278. /**
  8279. * Sets the shadows Hue value.
  8280. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8281. */
  8282. set shadowsHue(value: number);
  8283. /**
  8284. * Gets the shadows Density value.
  8285. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8286. * Values less than zero provide a filter of opposite hue.
  8287. */
  8288. get shadowsDensity(): number;
  8289. /**
  8290. * Sets the shadows Density value.
  8291. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8292. * Values less than zero provide a filter of opposite hue.
  8293. */
  8294. set shadowsDensity(value: number);
  8295. /**
  8296. * Gets the shadows Saturation value.
  8297. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8298. */
  8299. get shadowsSaturation(): number;
  8300. /**
  8301. * Sets the shadows Saturation value.
  8302. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8303. */
  8304. set shadowsSaturation(value: number);
  8305. /**
  8306. * Gets the shadows Exposure value.
  8307. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8308. */
  8309. get shadowsExposure(): number;
  8310. /**
  8311. * Sets the shadows Exposure value.
  8312. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8313. */
  8314. set shadowsExposure(value: number);
  8315. /**
  8316. * Returns the class name
  8317. * @returns The class name
  8318. */
  8319. getClassName(): string;
  8320. /**
  8321. * Binds the color curves to the shader.
  8322. * @param colorCurves The color curve to bind
  8323. * @param effect The effect to bind to
  8324. * @param positiveUniform The positive uniform shader parameter
  8325. * @param neutralUniform The neutral uniform shader parameter
  8326. * @param negativeUniform The negative uniform shader parameter
  8327. */
  8328. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8329. /**
  8330. * Prepare the list of uniforms associated with the ColorCurves effects.
  8331. * @param uniformsList The list of uniforms used in the effect
  8332. */
  8333. static PrepareUniforms(uniformsList: string[]): void;
  8334. /**
  8335. * Returns color grading data based on a hue, density, saturation and exposure value.
  8336. * @param filterHue The hue of the color filter.
  8337. * @param filterDensity The density of the color filter.
  8338. * @param saturation The saturation.
  8339. * @param exposure The exposure.
  8340. * @param result The result data container.
  8341. */
  8342. private getColorGradingDataToRef;
  8343. /**
  8344. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8345. * @param value The input slider value in range [-100,100].
  8346. * @returns Adjusted value.
  8347. */
  8348. private static applyColorGradingSliderNonlinear;
  8349. /**
  8350. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8351. * @param hue The hue (H) input.
  8352. * @param saturation The saturation (S) input.
  8353. * @param brightness The brightness (B) input.
  8354. * @result An RGBA color represented as Vector4.
  8355. */
  8356. private static fromHSBToRef;
  8357. /**
  8358. * Returns a value clamped between min and max
  8359. * @param value The value to clamp
  8360. * @param min The minimum of value
  8361. * @param max The maximum of value
  8362. * @returns The clamped value.
  8363. */
  8364. private static clamp;
  8365. /**
  8366. * Clones the current color curve instance.
  8367. * @return The cloned curves
  8368. */
  8369. clone(): ColorCurves;
  8370. /**
  8371. * Serializes the current color curve instance to a json representation.
  8372. * @return a JSON representation
  8373. */
  8374. serialize(): any;
  8375. /**
  8376. * Parses the color curve from a json representation.
  8377. * @param source the JSON source to parse
  8378. * @return The parsed curves
  8379. */
  8380. static Parse(source: any): ColorCurves;
  8381. }
  8382. }
  8383. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8384. import { Observable } from "babylonjs/Misc/observable";
  8385. import { Nullable } from "babylonjs/types";
  8386. import { Color4 } from "babylonjs/Maths/math.color";
  8387. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8388. import { Effect } from "babylonjs/Materials/effect";
  8389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8390. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8391. /**
  8392. * Interface to follow in your material defines to integrate easily the
  8393. * Image proccessing functions.
  8394. * @hidden
  8395. */
  8396. export interface IImageProcessingConfigurationDefines {
  8397. IMAGEPROCESSING: boolean;
  8398. VIGNETTE: boolean;
  8399. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8400. VIGNETTEBLENDMODEOPAQUE: boolean;
  8401. TONEMAPPING: boolean;
  8402. TONEMAPPING_ACES: boolean;
  8403. CONTRAST: boolean;
  8404. EXPOSURE: boolean;
  8405. COLORCURVES: boolean;
  8406. COLORGRADING: boolean;
  8407. COLORGRADING3D: boolean;
  8408. SAMPLER3DGREENDEPTH: boolean;
  8409. SAMPLER3DBGRMAP: boolean;
  8410. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8411. }
  8412. /**
  8413. * @hidden
  8414. */
  8415. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8416. IMAGEPROCESSING: boolean;
  8417. VIGNETTE: boolean;
  8418. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8419. VIGNETTEBLENDMODEOPAQUE: boolean;
  8420. TONEMAPPING: boolean;
  8421. TONEMAPPING_ACES: boolean;
  8422. CONTRAST: boolean;
  8423. COLORCURVES: boolean;
  8424. COLORGRADING: boolean;
  8425. COLORGRADING3D: boolean;
  8426. SAMPLER3DGREENDEPTH: boolean;
  8427. SAMPLER3DBGRMAP: boolean;
  8428. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8429. EXPOSURE: boolean;
  8430. constructor();
  8431. }
  8432. /**
  8433. * This groups together the common properties used for image processing either in direct forward pass
  8434. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8435. * or not.
  8436. */
  8437. export class ImageProcessingConfiguration {
  8438. /**
  8439. * Default tone mapping applied in BabylonJS.
  8440. */
  8441. static readonly TONEMAPPING_STANDARD: number;
  8442. /**
  8443. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8444. * to other engines rendering to increase portability.
  8445. */
  8446. static readonly TONEMAPPING_ACES: number;
  8447. /**
  8448. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8449. */
  8450. colorCurves: Nullable<ColorCurves>;
  8451. private _colorCurvesEnabled;
  8452. /**
  8453. * Gets wether the color curves effect is enabled.
  8454. */
  8455. get colorCurvesEnabled(): boolean;
  8456. /**
  8457. * Sets wether the color curves effect is enabled.
  8458. */
  8459. set colorCurvesEnabled(value: boolean);
  8460. private _colorGradingTexture;
  8461. /**
  8462. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8463. */
  8464. get colorGradingTexture(): Nullable<BaseTexture>;
  8465. /**
  8466. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8467. */
  8468. set colorGradingTexture(value: Nullable<BaseTexture>);
  8469. private _colorGradingEnabled;
  8470. /**
  8471. * Gets wether the color grading effect is enabled.
  8472. */
  8473. get colorGradingEnabled(): boolean;
  8474. /**
  8475. * Sets wether the color grading effect is enabled.
  8476. */
  8477. set colorGradingEnabled(value: boolean);
  8478. private _colorGradingWithGreenDepth;
  8479. /**
  8480. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8481. */
  8482. get colorGradingWithGreenDepth(): boolean;
  8483. /**
  8484. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8485. */
  8486. set colorGradingWithGreenDepth(value: boolean);
  8487. private _colorGradingBGR;
  8488. /**
  8489. * Gets wether the color grading texture contains BGR values.
  8490. */
  8491. get colorGradingBGR(): boolean;
  8492. /**
  8493. * Sets wether the color grading texture contains BGR values.
  8494. */
  8495. set colorGradingBGR(value: boolean);
  8496. /** @hidden */
  8497. _exposure: number;
  8498. /**
  8499. * Gets the Exposure used in the effect.
  8500. */
  8501. get exposure(): number;
  8502. /**
  8503. * Sets the Exposure used in the effect.
  8504. */
  8505. set exposure(value: number);
  8506. private _toneMappingEnabled;
  8507. /**
  8508. * Gets wether the tone mapping effect is enabled.
  8509. */
  8510. get toneMappingEnabled(): boolean;
  8511. /**
  8512. * Sets wether the tone mapping effect is enabled.
  8513. */
  8514. set toneMappingEnabled(value: boolean);
  8515. private _toneMappingType;
  8516. /**
  8517. * Gets the type of tone mapping effect.
  8518. */
  8519. get toneMappingType(): number;
  8520. /**
  8521. * Sets the type of tone mapping effect used in BabylonJS.
  8522. */
  8523. set toneMappingType(value: number);
  8524. protected _contrast: number;
  8525. /**
  8526. * Gets the contrast used in the effect.
  8527. */
  8528. get contrast(): number;
  8529. /**
  8530. * Sets the contrast used in the effect.
  8531. */
  8532. set contrast(value: number);
  8533. /**
  8534. * Vignette stretch size.
  8535. */
  8536. vignetteStretch: number;
  8537. /**
  8538. * Vignette centre X Offset.
  8539. */
  8540. vignetteCentreX: number;
  8541. /**
  8542. * Vignette centre Y Offset.
  8543. */
  8544. vignetteCentreY: number;
  8545. /**
  8546. * Vignette weight or intensity of the vignette effect.
  8547. */
  8548. vignetteWeight: number;
  8549. /**
  8550. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8551. * if vignetteEnabled is set to true.
  8552. */
  8553. vignetteColor: Color4;
  8554. /**
  8555. * Camera field of view used by the Vignette effect.
  8556. */
  8557. vignetteCameraFov: number;
  8558. private _vignetteBlendMode;
  8559. /**
  8560. * Gets the vignette blend mode allowing different kind of effect.
  8561. */
  8562. get vignetteBlendMode(): number;
  8563. /**
  8564. * Sets the vignette blend mode allowing different kind of effect.
  8565. */
  8566. set vignetteBlendMode(value: number);
  8567. private _vignetteEnabled;
  8568. /**
  8569. * Gets wether the vignette effect is enabled.
  8570. */
  8571. get vignetteEnabled(): boolean;
  8572. /**
  8573. * Sets wether the vignette effect is enabled.
  8574. */
  8575. set vignetteEnabled(value: boolean);
  8576. private _applyByPostProcess;
  8577. /**
  8578. * Gets wether the image processing is applied through a post process or not.
  8579. */
  8580. get applyByPostProcess(): boolean;
  8581. /**
  8582. * Sets wether the image processing is applied through a post process or not.
  8583. */
  8584. set applyByPostProcess(value: boolean);
  8585. private _isEnabled;
  8586. /**
  8587. * Gets wether the image processing is enabled or not.
  8588. */
  8589. get isEnabled(): boolean;
  8590. /**
  8591. * Sets wether the image processing is enabled or not.
  8592. */
  8593. set isEnabled(value: boolean);
  8594. /**
  8595. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8596. */
  8597. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8598. /**
  8599. * Method called each time the image processing information changes requires to recompile the effect.
  8600. */
  8601. protected _updateParameters(): void;
  8602. /**
  8603. * Gets the current class name.
  8604. * @return "ImageProcessingConfiguration"
  8605. */
  8606. getClassName(): string;
  8607. /**
  8608. * Prepare the list of uniforms associated with the Image Processing effects.
  8609. * @param uniforms The list of uniforms used in the effect
  8610. * @param defines the list of defines currently in use
  8611. */
  8612. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8613. /**
  8614. * Prepare the list of samplers associated with the Image Processing effects.
  8615. * @param samplersList The list of uniforms used in the effect
  8616. * @param defines the list of defines currently in use
  8617. */
  8618. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8619. /**
  8620. * Prepare the list of defines associated to the shader.
  8621. * @param defines the list of defines to complete
  8622. * @param forPostProcess Define if we are currently in post process mode or not
  8623. */
  8624. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8625. /**
  8626. * Returns true if all the image processing information are ready.
  8627. * @returns True if ready, otherwise, false
  8628. */
  8629. isReady(): boolean;
  8630. /**
  8631. * Binds the image processing to the shader.
  8632. * @param effect The effect to bind to
  8633. * @param overrideAspectRatio Override the aspect ratio of the effect
  8634. */
  8635. bind(effect: Effect, overrideAspectRatio?: number): void;
  8636. /**
  8637. * Clones the current image processing instance.
  8638. * @return The cloned image processing
  8639. */
  8640. clone(): ImageProcessingConfiguration;
  8641. /**
  8642. * Serializes the current image processing instance to a json representation.
  8643. * @return a JSON representation
  8644. */
  8645. serialize(): any;
  8646. /**
  8647. * Parses the image processing from a json representation.
  8648. * @param source the JSON source to parse
  8649. * @return The parsed image processing
  8650. */
  8651. static Parse(source: any): ImageProcessingConfiguration;
  8652. private static _VIGNETTEMODE_MULTIPLY;
  8653. private static _VIGNETTEMODE_OPAQUE;
  8654. /**
  8655. * Used to apply the vignette as a mix with the pixel color.
  8656. */
  8657. static get VIGNETTEMODE_MULTIPLY(): number;
  8658. /**
  8659. * Used to apply the vignette as a replacement of the pixel color.
  8660. */
  8661. static get VIGNETTEMODE_OPAQUE(): number;
  8662. }
  8663. }
  8664. declare module "babylonjs/Shaders/postprocess.vertex" {
  8665. /** @hidden */
  8666. export var postprocessVertexShader: {
  8667. name: string;
  8668. shader: string;
  8669. };
  8670. }
  8671. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8672. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8673. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8674. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8675. module "babylonjs/Engines/thinEngine" {
  8676. interface ThinEngine {
  8677. /**
  8678. * Creates a new render target texture
  8679. * @param size defines the size of the texture
  8680. * @param options defines the options used to create the texture
  8681. * @returns a new render target texture stored in an InternalTexture
  8682. */
  8683. createRenderTargetTexture(size: number | {
  8684. width: number;
  8685. height: number;
  8686. layers?: number;
  8687. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8688. /**
  8689. * Creates a depth stencil texture.
  8690. * This is only available in WebGL 2 or with the depth texture extension available.
  8691. * @param size The size of face edge in the texture.
  8692. * @param options The options defining the texture.
  8693. * @returns The texture
  8694. */
  8695. createDepthStencilTexture(size: number | {
  8696. width: number;
  8697. height: number;
  8698. layers?: number;
  8699. }, options: DepthTextureCreationOptions): InternalTexture;
  8700. /** @hidden */
  8701. _createDepthStencilTexture(size: number | {
  8702. width: number;
  8703. height: number;
  8704. layers?: number;
  8705. }, options: DepthTextureCreationOptions): InternalTexture;
  8706. }
  8707. }
  8708. }
  8709. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8710. /**
  8711. * Defines the kind of connection point for node based material
  8712. */
  8713. export enum NodeMaterialBlockConnectionPointTypes {
  8714. /** Float */
  8715. Float = 1,
  8716. /** Int */
  8717. Int = 2,
  8718. /** Vector2 */
  8719. Vector2 = 4,
  8720. /** Vector3 */
  8721. Vector3 = 8,
  8722. /** Vector4 */
  8723. Vector4 = 16,
  8724. /** Color3 */
  8725. Color3 = 32,
  8726. /** Color4 */
  8727. Color4 = 64,
  8728. /** Matrix */
  8729. Matrix = 128,
  8730. /** Custom object */
  8731. Object = 256,
  8732. /** Detect type based on connection */
  8733. AutoDetect = 1024,
  8734. /** Output type that will be defined by input type */
  8735. BasedOnInput = 2048
  8736. }
  8737. }
  8738. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8739. /**
  8740. * Enum used to define the target of a block
  8741. */
  8742. export enum NodeMaterialBlockTargets {
  8743. /** Vertex shader */
  8744. Vertex = 1,
  8745. /** Fragment shader */
  8746. Fragment = 2,
  8747. /** Neutral */
  8748. Neutral = 4,
  8749. /** Vertex and Fragment */
  8750. VertexAndFragment = 3
  8751. }
  8752. }
  8753. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8754. /**
  8755. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8756. */
  8757. export enum NodeMaterialBlockConnectionPointMode {
  8758. /** Value is an uniform */
  8759. Uniform = 0,
  8760. /** Value is a mesh attribute */
  8761. Attribute = 1,
  8762. /** Value is a varying between vertex and fragment shaders */
  8763. Varying = 2,
  8764. /** Mode is undefined */
  8765. Undefined = 3
  8766. }
  8767. }
  8768. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8769. /**
  8770. * Enum used to define system values e.g. values automatically provided by the system
  8771. */
  8772. export enum NodeMaterialSystemValues {
  8773. /** World */
  8774. World = 1,
  8775. /** View */
  8776. View = 2,
  8777. /** Projection */
  8778. Projection = 3,
  8779. /** ViewProjection */
  8780. ViewProjection = 4,
  8781. /** WorldView */
  8782. WorldView = 5,
  8783. /** WorldViewProjection */
  8784. WorldViewProjection = 6,
  8785. /** CameraPosition */
  8786. CameraPosition = 7,
  8787. /** Fog Color */
  8788. FogColor = 8,
  8789. /** Delta time */
  8790. DeltaTime = 9
  8791. }
  8792. }
  8793. declare module "babylonjs/Maths/math.axis" {
  8794. import { Vector3 } from "babylonjs/Maths/math.vector";
  8795. /** Defines supported spaces */
  8796. export enum Space {
  8797. /** Local (object) space */
  8798. LOCAL = 0,
  8799. /** World space */
  8800. WORLD = 1,
  8801. /** Bone space */
  8802. BONE = 2
  8803. }
  8804. /** Defines the 3 main axes */
  8805. export class Axis {
  8806. /** X axis */
  8807. static X: Vector3;
  8808. /** Y axis */
  8809. static Y: Vector3;
  8810. /** Z axis */
  8811. static Z: Vector3;
  8812. }
  8813. }
  8814. declare module "babylonjs/Maths/math.frustum" {
  8815. import { Matrix } from "babylonjs/Maths/math.vector";
  8816. import { DeepImmutable } from "babylonjs/types";
  8817. import { Plane } from "babylonjs/Maths/math.plane";
  8818. /**
  8819. * Represents a camera frustum
  8820. */
  8821. export class Frustum {
  8822. /**
  8823. * Gets the planes representing the frustum
  8824. * @param transform matrix to be applied to the returned planes
  8825. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8826. */
  8827. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8828. /**
  8829. * Gets the near frustum plane transformed by the transform matrix
  8830. * @param transform transformation matrix to be applied to the resulting frustum plane
  8831. * @param frustumPlane the resuling frustum plane
  8832. */
  8833. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8834. /**
  8835. * Gets the far frustum plane transformed by the transform matrix
  8836. * @param transform transformation matrix to be applied to the resulting frustum plane
  8837. * @param frustumPlane the resuling frustum plane
  8838. */
  8839. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8840. /**
  8841. * Gets the left frustum plane transformed by the transform matrix
  8842. * @param transform transformation matrix to be applied to the resulting frustum plane
  8843. * @param frustumPlane the resuling frustum plane
  8844. */
  8845. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8846. /**
  8847. * Gets the right frustum plane transformed by the transform matrix
  8848. * @param transform transformation matrix to be applied to the resulting frustum plane
  8849. * @param frustumPlane the resuling frustum plane
  8850. */
  8851. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8852. /**
  8853. * Gets the top frustum plane transformed by the transform matrix
  8854. * @param transform transformation matrix to be applied to the resulting frustum plane
  8855. * @param frustumPlane the resuling frustum plane
  8856. */
  8857. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8858. /**
  8859. * Gets the bottom frustum plane transformed by the transform matrix
  8860. * @param transform transformation matrix to be applied to the resulting frustum plane
  8861. * @param frustumPlane the resuling frustum plane
  8862. */
  8863. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8864. /**
  8865. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8866. * @param transform transformation matrix to be applied to the resulting frustum planes
  8867. * @param frustumPlanes the resuling frustum planes
  8868. */
  8869. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8870. }
  8871. }
  8872. declare module "babylonjs/Maths/math.size" {
  8873. /**
  8874. * Interface for the size containing width and height
  8875. */
  8876. export interface ISize {
  8877. /**
  8878. * Width
  8879. */
  8880. width: number;
  8881. /**
  8882. * Heighht
  8883. */
  8884. height: number;
  8885. }
  8886. /**
  8887. * Size containing widht and height
  8888. */
  8889. export class Size implements ISize {
  8890. /**
  8891. * Width
  8892. */
  8893. width: number;
  8894. /**
  8895. * Height
  8896. */
  8897. height: number;
  8898. /**
  8899. * Creates a Size object from the given width and height (floats).
  8900. * @param width width of the new size
  8901. * @param height height of the new size
  8902. */
  8903. constructor(width: number, height: number);
  8904. /**
  8905. * Returns a string with the Size width and height
  8906. * @returns a string with the Size width and height
  8907. */
  8908. toString(): string;
  8909. /**
  8910. * "Size"
  8911. * @returns the string "Size"
  8912. */
  8913. getClassName(): string;
  8914. /**
  8915. * Returns the Size hash code.
  8916. * @returns a hash code for a unique width and height
  8917. */
  8918. getHashCode(): number;
  8919. /**
  8920. * Updates the current size from the given one.
  8921. * @param src the given size
  8922. */
  8923. copyFrom(src: Size): void;
  8924. /**
  8925. * Updates in place the current Size from the given floats.
  8926. * @param width width of the new size
  8927. * @param height height of the new size
  8928. * @returns the updated Size.
  8929. */
  8930. copyFromFloats(width: number, height: number): Size;
  8931. /**
  8932. * Updates in place the current Size from the given floats.
  8933. * @param width width to set
  8934. * @param height height to set
  8935. * @returns the updated Size.
  8936. */
  8937. set(width: number, height: number): Size;
  8938. /**
  8939. * Multiplies the width and height by numbers
  8940. * @param w factor to multiple the width by
  8941. * @param h factor to multiple the height by
  8942. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8943. */
  8944. multiplyByFloats(w: number, h: number): Size;
  8945. /**
  8946. * Clones the size
  8947. * @returns a new Size copied from the given one.
  8948. */
  8949. clone(): Size;
  8950. /**
  8951. * True if the current Size and the given one width and height are strictly equal.
  8952. * @param other the other size to compare against
  8953. * @returns True if the current Size and the given one width and height are strictly equal.
  8954. */
  8955. equals(other: Size): boolean;
  8956. /**
  8957. * The surface of the Size : width * height (float).
  8958. */
  8959. get surface(): number;
  8960. /**
  8961. * Create a new size of zero
  8962. * @returns a new Size set to (0.0, 0.0)
  8963. */
  8964. static Zero(): Size;
  8965. /**
  8966. * Sums the width and height of two sizes
  8967. * @param otherSize size to add to this size
  8968. * @returns a new Size set as the addition result of the current Size and the given one.
  8969. */
  8970. add(otherSize: Size): Size;
  8971. /**
  8972. * Subtracts the width and height of two
  8973. * @param otherSize size to subtract to this size
  8974. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8975. */
  8976. subtract(otherSize: Size): Size;
  8977. /**
  8978. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8979. * @param start starting size to lerp between
  8980. * @param end end size to lerp between
  8981. * @param amount amount to lerp between the start and end values
  8982. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8983. */
  8984. static Lerp(start: Size, end: Size, amount: number): Size;
  8985. }
  8986. }
  8987. declare module "babylonjs/Maths/math.vertexFormat" {
  8988. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8989. /**
  8990. * Contains position and normal vectors for a vertex
  8991. */
  8992. export class PositionNormalVertex {
  8993. /** the position of the vertex (defaut: 0,0,0) */
  8994. position: Vector3;
  8995. /** the normal of the vertex (defaut: 0,1,0) */
  8996. normal: Vector3;
  8997. /**
  8998. * Creates a PositionNormalVertex
  8999. * @param position the position of the vertex (defaut: 0,0,0)
  9000. * @param normal the normal of the vertex (defaut: 0,1,0)
  9001. */
  9002. constructor(
  9003. /** the position of the vertex (defaut: 0,0,0) */
  9004. position?: Vector3,
  9005. /** the normal of the vertex (defaut: 0,1,0) */
  9006. normal?: Vector3);
  9007. /**
  9008. * Clones the PositionNormalVertex
  9009. * @returns the cloned PositionNormalVertex
  9010. */
  9011. clone(): PositionNormalVertex;
  9012. }
  9013. /**
  9014. * Contains position, normal and uv vectors for a vertex
  9015. */
  9016. export class PositionNormalTextureVertex {
  9017. /** the position of the vertex (defaut: 0,0,0) */
  9018. position: Vector3;
  9019. /** the normal of the vertex (defaut: 0,1,0) */
  9020. normal: Vector3;
  9021. /** the uv of the vertex (default: 0,0) */
  9022. uv: Vector2;
  9023. /**
  9024. * Creates a PositionNormalTextureVertex
  9025. * @param position the position of the vertex (defaut: 0,0,0)
  9026. * @param normal the normal of the vertex (defaut: 0,1,0)
  9027. * @param uv the uv of the vertex (default: 0,0)
  9028. */
  9029. constructor(
  9030. /** the position of the vertex (defaut: 0,0,0) */
  9031. position?: Vector3,
  9032. /** the normal of the vertex (defaut: 0,1,0) */
  9033. normal?: Vector3,
  9034. /** the uv of the vertex (default: 0,0) */
  9035. uv?: Vector2);
  9036. /**
  9037. * Clones the PositionNormalTextureVertex
  9038. * @returns the cloned PositionNormalTextureVertex
  9039. */
  9040. clone(): PositionNormalTextureVertex;
  9041. }
  9042. }
  9043. declare module "babylonjs/Maths/math" {
  9044. export * from "babylonjs/Maths/math.axis";
  9045. export * from "babylonjs/Maths/math.color";
  9046. export * from "babylonjs/Maths/math.constants";
  9047. export * from "babylonjs/Maths/math.frustum";
  9048. export * from "babylonjs/Maths/math.path";
  9049. export * from "babylonjs/Maths/math.plane";
  9050. export * from "babylonjs/Maths/math.size";
  9051. export * from "babylonjs/Maths/math.vector";
  9052. export * from "babylonjs/Maths/math.vertexFormat";
  9053. export * from "babylonjs/Maths/math.viewport";
  9054. }
  9055. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9056. /**
  9057. * Enum defining the type of animations supported by InputBlock
  9058. */
  9059. export enum AnimatedInputBlockTypes {
  9060. /** No animation */
  9061. None = 0,
  9062. /** Time based animation. Will only work for floats */
  9063. Time = 1
  9064. }
  9065. }
  9066. declare module "babylonjs/Lights/shadowLight" {
  9067. import { Camera } from "babylonjs/Cameras/camera";
  9068. import { Scene } from "babylonjs/scene";
  9069. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9071. import { Light } from "babylonjs/Lights/light";
  9072. /**
  9073. * Interface describing all the common properties and methods a shadow light needs to implement.
  9074. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9075. * as well as binding the different shadow properties to the effects.
  9076. */
  9077. export interface IShadowLight extends Light {
  9078. /**
  9079. * The light id in the scene (used in scene.findLighById for instance)
  9080. */
  9081. id: string;
  9082. /**
  9083. * The position the shdow will be casted from.
  9084. */
  9085. position: Vector3;
  9086. /**
  9087. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9088. */
  9089. direction: Vector3;
  9090. /**
  9091. * The transformed position. Position of the light in world space taking parenting in account.
  9092. */
  9093. transformedPosition: Vector3;
  9094. /**
  9095. * The transformed direction. Direction of the light in world space taking parenting in account.
  9096. */
  9097. transformedDirection: Vector3;
  9098. /**
  9099. * The friendly name of the light in the scene.
  9100. */
  9101. name: string;
  9102. /**
  9103. * Defines the shadow projection clipping minimum z value.
  9104. */
  9105. shadowMinZ: number;
  9106. /**
  9107. * Defines the shadow projection clipping maximum z value.
  9108. */
  9109. shadowMaxZ: number;
  9110. /**
  9111. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9112. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9113. */
  9114. computeTransformedInformation(): boolean;
  9115. /**
  9116. * Gets the scene the light belongs to.
  9117. * @returns The scene
  9118. */
  9119. getScene(): Scene;
  9120. /**
  9121. * Callback defining a custom Projection Matrix Builder.
  9122. * This can be used to override the default projection matrix computation.
  9123. */
  9124. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9125. /**
  9126. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9127. * @param matrix The materix to updated with the projection information
  9128. * @param viewMatrix The transform matrix of the light
  9129. * @param renderList The list of mesh to render in the map
  9130. * @returns The current light
  9131. */
  9132. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9133. /**
  9134. * Gets the current depth scale used in ESM.
  9135. * @returns The scale
  9136. */
  9137. getDepthScale(): number;
  9138. /**
  9139. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9140. * @returns true if a cube texture needs to be use
  9141. */
  9142. needCube(): boolean;
  9143. /**
  9144. * Detects if the projection matrix requires to be recomputed this frame.
  9145. * @returns true if it requires to be recomputed otherwise, false.
  9146. */
  9147. needProjectionMatrixCompute(): boolean;
  9148. /**
  9149. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9150. */
  9151. forceProjectionMatrixCompute(): void;
  9152. /**
  9153. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9154. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9155. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9156. */
  9157. getShadowDirection(faceIndex?: number): Vector3;
  9158. /**
  9159. * Gets the minZ used for shadow according to both the scene and the light.
  9160. * @param activeCamera The camera we are returning the min for
  9161. * @returns the depth min z
  9162. */
  9163. getDepthMinZ(activeCamera: Camera): number;
  9164. /**
  9165. * Gets the maxZ used for shadow according to both the scene and the light.
  9166. * @param activeCamera The camera we are returning the max for
  9167. * @returns the depth max z
  9168. */
  9169. getDepthMaxZ(activeCamera: Camera): number;
  9170. }
  9171. /**
  9172. * Base implementation IShadowLight
  9173. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9174. */
  9175. export abstract class ShadowLight extends Light implements IShadowLight {
  9176. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9177. protected _position: Vector3;
  9178. protected _setPosition(value: Vector3): void;
  9179. /**
  9180. * Sets the position the shadow will be casted from. Also use as the light position for both
  9181. * point and spot lights.
  9182. */
  9183. get position(): Vector3;
  9184. /**
  9185. * Sets the position the shadow will be casted from. Also use as the light position for both
  9186. * point and spot lights.
  9187. */
  9188. set position(value: Vector3);
  9189. protected _direction: Vector3;
  9190. protected _setDirection(value: Vector3): void;
  9191. /**
  9192. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9193. * Also use as the light direction on spot and directional lights.
  9194. */
  9195. get direction(): Vector3;
  9196. /**
  9197. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9198. * Also use as the light direction on spot and directional lights.
  9199. */
  9200. set direction(value: Vector3);
  9201. protected _shadowMinZ: number;
  9202. /**
  9203. * Gets the shadow projection clipping minimum z value.
  9204. */
  9205. get shadowMinZ(): number;
  9206. /**
  9207. * Sets the shadow projection clipping minimum z value.
  9208. */
  9209. set shadowMinZ(value: number);
  9210. protected _shadowMaxZ: number;
  9211. /**
  9212. * Sets the shadow projection clipping maximum z value.
  9213. */
  9214. get shadowMaxZ(): number;
  9215. /**
  9216. * Gets the shadow projection clipping maximum z value.
  9217. */
  9218. set shadowMaxZ(value: number);
  9219. /**
  9220. * Callback defining a custom Projection Matrix Builder.
  9221. * This can be used to override the default projection matrix computation.
  9222. */
  9223. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9224. /**
  9225. * The transformed position. Position of the light in world space taking parenting in account.
  9226. */
  9227. transformedPosition: Vector3;
  9228. /**
  9229. * The transformed direction. Direction of the light in world space taking parenting in account.
  9230. */
  9231. transformedDirection: Vector3;
  9232. private _needProjectionMatrixCompute;
  9233. /**
  9234. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9235. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9236. */
  9237. computeTransformedInformation(): boolean;
  9238. /**
  9239. * Return the depth scale used for the shadow map.
  9240. * @returns the depth scale.
  9241. */
  9242. getDepthScale(): number;
  9243. /**
  9244. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9245. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9246. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9247. */
  9248. getShadowDirection(faceIndex?: number): Vector3;
  9249. /**
  9250. * Returns the ShadowLight absolute position in the World.
  9251. * @returns the position vector in world space
  9252. */
  9253. getAbsolutePosition(): Vector3;
  9254. /**
  9255. * Sets the ShadowLight direction toward the passed target.
  9256. * @param target The point to target in local space
  9257. * @returns the updated ShadowLight direction
  9258. */
  9259. setDirectionToTarget(target: Vector3): Vector3;
  9260. /**
  9261. * Returns the light rotation in euler definition.
  9262. * @returns the x y z rotation in local space.
  9263. */
  9264. getRotation(): Vector3;
  9265. /**
  9266. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9267. * @returns true if a cube texture needs to be use
  9268. */
  9269. needCube(): boolean;
  9270. /**
  9271. * Detects if the projection matrix requires to be recomputed this frame.
  9272. * @returns true if it requires to be recomputed otherwise, false.
  9273. */
  9274. needProjectionMatrixCompute(): boolean;
  9275. /**
  9276. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9277. */
  9278. forceProjectionMatrixCompute(): void;
  9279. /** @hidden */
  9280. _initCache(): void;
  9281. /** @hidden */
  9282. _isSynchronized(): boolean;
  9283. /**
  9284. * Computes the world matrix of the node
  9285. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9286. * @returns the world matrix
  9287. */
  9288. computeWorldMatrix(force?: boolean): Matrix;
  9289. /**
  9290. * Gets the minZ used for shadow according to both the scene and the light.
  9291. * @param activeCamera The camera we are returning the min for
  9292. * @returns the depth min z
  9293. */
  9294. getDepthMinZ(activeCamera: Camera): number;
  9295. /**
  9296. * Gets the maxZ used for shadow according to both the scene and the light.
  9297. * @param activeCamera The camera we are returning the max for
  9298. * @returns the depth max z
  9299. */
  9300. getDepthMaxZ(activeCamera: Camera): number;
  9301. /**
  9302. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9303. * @param matrix The materix to updated with the projection information
  9304. * @param viewMatrix The transform matrix of the light
  9305. * @param renderList The list of mesh to render in the map
  9306. * @returns The current light
  9307. */
  9308. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9309. }
  9310. }
  9311. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9312. /** @hidden */
  9313. export var packingFunctions: {
  9314. name: string;
  9315. shader: string;
  9316. };
  9317. }
  9318. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9319. /** @hidden */
  9320. export var bayerDitherFunctions: {
  9321. name: string;
  9322. shader: string;
  9323. };
  9324. }
  9325. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9326. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9327. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9328. /** @hidden */
  9329. export var shadowMapFragmentDeclaration: {
  9330. name: string;
  9331. shader: string;
  9332. };
  9333. }
  9334. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9335. /** @hidden */
  9336. export var clipPlaneFragmentDeclaration: {
  9337. name: string;
  9338. shader: string;
  9339. };
  9340. }
  9341. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9342. /** @hidden */
  9343. export var clipPlaneFragment: {
  9344. name: string;
  9345. shader: string;
  9346. };
  9347. }
  9348. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9349. /** @hidden */
  9350. export var shadowMapFragment: {
  9351. name: string;
  9352. shader: string;
  9353. };
  9354. }
  9355. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9356. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9357. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9358. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9359. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9360. /** @hidden */
  9361. export var shadowMapPixelShader: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9367. /** @hidden */
  9368. export var bonesDeclaration: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9374. /** @hidden */
  9375. export var morphTargetsVertexGlobalDeclaration: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9381. /** @hidden */
  9382. export var morphTargetsVertexDeclaration: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9388. /** @hidden */
  9389. export var instancesDeclaration: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9395. /** @hidden */
  9396. export var helperFunctions: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9402. /** @hidden */
  9403. export var shadowMapVertexDeclaration: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9409. /** @hidden */
  9410. export var clipPlaneVertexDeclaration: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9416. /** @hidden */
  9417. export var morphTargetsVertex: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9423. /** @hidden */
  9424. export var instancesVertex: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9430. /** @hidden */
  9431. export var bonesVertex: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9437. /** @hidden */
  9438. export var shadowMapVertexNormalBias: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9444. /** @hidden */
  9445. export var shadowMapVertexMetric: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9451. /** @hidden */
  9452. export var clipPlaneVertex: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9458. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9459. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9460. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9461. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9462. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9463. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9464. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9465. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9466. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9467. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9468. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9469. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9470. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9471. /** @hidden */
  9472. export var shadowMapVertexShader: {
  9473. name: string;
  9474. shader: string;
  9475. };
  9476. }
  9477. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9478. /** @hidden */
  9479. export var depthBoxBlurPixelShader: {
  9480. name: string;
  9481. shader: string;
  9482. };
  9483. }
  9484. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9485. /** @hidden */
  9486. export var shadowMapFragmentSoftTransparentShadow: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module "babylonjs/Materials/effectFallbacks" {
  9492. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9493. import { Effect } from "babylonjs/Materials/effect";
  9494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9495. /**
  9496. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9497. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9498. */
  9499. export class EffectFallbacks implements IEffectFallbacks {
  9500. private _defines;
  9501. private _currentRank;
  9502. private _maxRank;
  9503. private _mesh;
  9504. /**
  9505. * Removes the fallback from the bound mesh.
  9506. */
  9507. unBindMesh(): void;
  9508. /**
  9509. * Adds a fallback on the specified property.
  9510. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9511. * @param define The name of the define in the shader
  9512. */
  9513. addFallback(rank: number, define: string): void;
  9514. /**
  9515. * Sets the mesh to use CPU skinning when needing to fallback.
  9516. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9517. * @param mesh The mesh to use the fallbacks.
  9518. */
  9519. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9520. /**
  9521. * Checks to see if more fallbacks are still availible.
  9522. */
  9523. get hasMoreFallbacks(): boolean;
  9524. /**
  9525. * Removes the defines that should be removed when falling back.
  9526. * @param currentDefines defines the current define statements for the shader.
  9527. * @param effect defines the current effect we try to compile
  9528. * @returns The resulting defines with defines of the current rank removed.
  9529. */
  9530. reduce(currentDefines: string, effect: Effect): string;
  9531. }
  9532. }
  9533. declare module "babylonjs/Actions/action" {
  9534. import { Observable } from "babylonjs/Misc/observable";
  9535. import { Condition } from "babylonjs/Actions/condition";
  9536. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9537. import { Scene } from "babylonjs/scene";
  9538. import { ActionManager } from "babylonjs/Actions/actionManager";
  9539. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9540. import { Node } from "babylonjs/node";
  9541. /**
  9542. * Interface used to define Action
  9543. */
  9544. export interface IAction {
  9545. /**
  9546. * Trigger for the action
  9547. */
  9548. trigger: number;
  9549. /** Options of the trigger */
  9550. triggerOptions: any;
  9551. /**
  9552. * Gets the trigger parameters
  9553. * @returns the trigger parameters
  9554. */
  9555. getTriggerParameter(): any;
  9556. /**
  9557. * Internal only - executes current action event
  9558. * @hidden
  9559. */
  9560. _executeCurrent(evt?: ActionEvent): void;
  9561. /**
  9562. * Serialize placeholder for child classes
  9563. * @param parent of child
  9564. * @returns the serialized object
  9565. */
  9566. serialize(parent: any): any;
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _prepare(): void;
  9572. /**
  9573. * Internal only - manager for action
  9574. * @hidden
  9575. */
  9576. _actionManager: AbstractActionManager;
  9577. /**
  9578. * Adds action to chain of actions, may be a DoNothingAction
  9579. * @param action defines the next action to execute
  9580. * @returns The action passed in
  9581. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9582. */
  9583. then(action: IAction): IAction;
  9584. }
  9585. /**
  9586. * The action to be carried out following a trigger
  9587. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9588. */
  9589. export class Action implements IAction {
  9590. /** the trigger, with or without parameters, for the action */
  9591. triggerOptions: any;
  9592. /**
  9593. * Trigger for the action
  9594. */
  9595. trigger: number;
  9596. /**
  9597. * Internal only - manager for action
  9598. * @hidden
  9599. */
  9600. _actionManager: ActionManager;
  9601. private _nextActiveAction;
  9602. private _child;
  9603. private _condition?;
  9604. private _triggerParameter;
  9605. /**
  9606. * An event triggered prior to action being executed.
  9607. */
  9608. onBeforeExecuteObservable: Observable<Action>;
  9609. /**
  9610. * Creates a new Action
  9611. * @param triggerOptions the trigger, with or without parameters, for the action
  9612. * @param condition an optional determinant of action
  9613. */
  9614. constructor(
  9615. /** the trigger, with or without parameters, for the action */
  9616. triggerOptions: any, condition?: Condition);
  9617. /**
  9618. * Internal only
  9619. * @hidden
  9620. */
  9621. _prepare(): void;
  9622. /**
  9623. * Gets the trigger parameters
  9624. * @returns the trigger parameters
  9625. */
  9626. getTriggerParameter(): any;
  9627. /**
  9628. * Internal only - executes current action event
  9629. * @hidden
  9630. */
  9631. _executeCurrent(evt?: ActionEvent): void;
  9632. /**
  9633. * Execute placeholder for child classes
  9634. * @param evt optional action event
  9635. */
  9636. execute(evt?: ActionEvent): void;
  9637. /**
  9638. * Skips to next active action
  9639. */
  9640. skipToNextActiveAction(): void;
  9641. /**
  9642. * Adds action to chain of actions, may be a DoNothingAction
  9643. * @param action defines the next action to execute
  9644. * @returns The action passed in
  9645. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9646. */
  9647. then(action: Action): Action;
  9648. /**
  9649. * Internal only
  9650. * @hidden
  9651. */
  9652. _getProperty(propertyPath: string): string;
  9653. /**
  9654. * Internal only
  9655. * @hidden
  9656. */
  9657. _getEffectiveTarget(target: any, propertyPath: string): any;
  9658. /**
  9659. * Serialize placeholder for child classes
  9660. * @param parent of child
  9661. * @returns the serialized object
  9662. */
  9663. serialize(parent: any): any;
  9664. /**
  9665. * Internal only called by serialize
  9666. * @hidden
  9667. */
  9668. protected _serialize(serializedAction: any, parent?: any): any;
  9669. /**
  9670. * Internal only
  9671. * @hidden
  9672. */
  9673. static _SerializeValueAsString: (value: any) => string;
  9674. /**
  9675. * Internal only
  9676. * @hidden
  9677. */
  9678. static _GetTargetProperty: (target: Scene | Node) => {
  9679. name: string;
  9680. targetType: string;
  9681. value: string;
  9682. };
  9683. }
  9684. }
  9685. declare module "babylonjs/Actions/condition" {
  9686. import { ActionManager } from "babylonjs/Actions/actionManager";
  9687. /**
  9688. * A Condition applied to an Action
  9689. */
  9690. export class Condition {
  9691. /**
  9692. * Internal only - manager for action
  9693. * @hidden
  9694. */
  9695. _actionManager: ActionManager;
  9696. /**
  9697. * Internal only
  9698. * @hidden
  9699. */
  9700. _evaluationId: number;
  9701. /**
  9702. * Internal only
  9703. * @hidden
  9704. */
  9705. _currentResult: boolean;
  9706. /**
  9707. * Creates a new Condition
  9708. * @param actionManager the manager of the action the condition is applied to
  9709. */
  9710. constructor(actionManager: ActionManager);
  9711. /**
  9712. * Check if the current condition is valid
  9713. * @returns a boolean
  9714. */
  9715. isValid(): boolean;
  9716. /**
  9717. * Internal only
  9718. * @hidden
  9719. */
  9720. _getProperty(propertyPath: string): string;
  9721. /**
  9722. * Internal only
  9723. * @hidden
  9724. */
  9725. _getEffectiveTarget(target: any, propertyPath: string): any;
  9726. /**
  9727. * Serialize placeholder for child classes
  9728. * @returns the serialized object
  9729. */
  9730. serialize(): any;
  9731. /**
  9732. * Internal only
  9733. * @hidden
  9734. */
  9735. protected _serialize(serializedCondition: any): any;
  9736. }
  9737. /**
  9738. * Defines specific conditional operators as extensions of Condition
  9739. */
  9740. export class ValueCondition extends Condition {
  9741. /** path to specify the property of the target the conditional operator uses */
  9742. propertyPath: string;
  9743. /** the value compared by the conditional operator against the current value of the property */
  9744. value: any;
  9745. /** the conditional operator, default ValueCondition.IsEqual */
  9746. operator: number;
  9747. /**
  9748. * Internal only
  9749. * @hidden
  9750. */
  9751. private static _IsEqual;
  9752. /**
  9753. * Internal only
  9754. * @hidden
  9755. */
  9756. private static _IsDifferent;
  9757. /**
  9758. * Internal only
  9759. * @hidden
  9760. */
  9761. private static _IsGreater;
  9762. /**
  9763. * Internal only
  9764. * @hidden
  9765. */
  9766. private static _IsLesser;
  9767. /**
  9768. * returns the number for IsEqual
  9769. */
  9770. static get IsEqual(): number;
  9771. /**
  9772. * Returns the number for IsDifferent
  9773. */
  9774. static get IsDifferent(): number;
  9775. /**
  9776. * Returns the number for IsGreater
  9777. */
  9778. static get IsGreater(): number;
  9779. /**
  9780. * Returns the number for IsLesser
  9781. */
  9782. static get IsLesser(): number;
  9783. /**
  9784. * Internal only The action manager for the condition
  9785. * @hidden
  9786. */
  9787. _actionManager: ActionManager;
  9788. /**
  9789. * Internal only
  9790. * @hidden
  9791. */
  9792. private _target;
  9793. /**
  9794. * Internal only
  9795. * @hidden
  9796. */
  9797. private _effectiveTarget;
  9798. /**
  9799. * Internal only
  9800. * @hidden
  9801. */
  9802. private _property;
  9803. /**
  9804. * Creates a new ValueCondition
  9805. * @param actionManager manager for the action the condition applies to
  9806. * @param target for the action
  9807. * @param propertyPath path to specify the property of the target the conditional operator uses
  9808. * @param value the value compared by the conditional operator against the current value of the property
  9809. * @param operator the conditional operator, default ValueCondition.IsEqual
  9810. */
  9811. constructor(actionManager: ActionManager, target: any,
  9812. /** path to specify the property of the target the conditional operator uses */
  9813. propertyPath: string,
  9814. /** the value compared by the conditional operator against the current value of the property */
  9815. value: any,
  9816. /** the conditional operator, default ValueCondition.IsEqual */
  9817. operator?: number);
  9818. /**
  9819. * Compares the given value with the property value for the specified conditional operator
  9820. * @returns the result of the comparison
  9821. */
  9822. isValid(): boolean;
  9823. /**
  9824. * Serialize the ValueCondition into a JSON compatible object
  9825. * @returns serialization object
  9826. */
  9827. serialize(): any;
  9828. /**
  9829. * Gets the name of the conditional operator for the ValueCondition
  9830. * @param operator the conditional operator
  9831. * @returns the name
  9832. */
  9833. static GetOperatorName(operator: number): string;
  9834. }
  9835. /**
  9836. * Defines a predicate condition as an extension of Condition
  9837. */
  9838. export class PredicateCondition extends Condition {
  9839. /** defines the predicate function used to validate the condition */
  9840. predicate: () => boolean;
  9841. /**
  9842. * Internal only - manager for action
  9843. * @hidden
  9844. */
  9845. _actionManager: ActionManager;
  9846. /**
  9847. * Creates a new PredicateCondition
  9848. * @param actionManager manager for the action the condition applies to
  9849. * @param predicate defines the predicate function used to validate the condition
  9850. */
  9851. constructor(actionManager: ActionManager,
  9852. /** defines the predicate function used to validate the condition */
  9853. predicate: () => boolean);
  9854. /**
  9855. * @returns the validity of the predicate condition
  9856. */
  9857. isValid(): boolean;
  9858. }
  9859. /**
  9860. * Defines a state condition as an extension of Condition
  9861. */
  9862. export class StateCondition extends Condition {
  9863. /** Value to compare with target state */
  9864. value: string;
  9865. /**
  9866. * Internal only - manager for action
  9867. * @hidden
  9868. */
  9869. _actionManager: ActionManager;
  9870. /**
  9871. * Internal only
  9872. * @hidden
  9873. */
  9874. private _target;
  9875. /**
  9876. * Creates a new StateCondition
  9877. * @param actionManager manager for the action the condition applies to
  9878. * @param target of the condition
  9879. * @param value to compare with target state
  9880. */
  9881. constructor(actionManager: ActionManager, target: any,
  9882. /** Value to compare with target state */
  9883. value: string);
  9884. /**
  9885. * Gets a boolean indicating if the current condition is met
  9886. * @returns the validity of the state
  9887. */
  9888. isValid(): boolean;
  9889. /**
  9890. * Serialize the StateCondition into a JSON compatible object
  9891. * @returns serialization object
  9892. */
  9893. serialize(): any;
  9894. }
  9895. }
  9896. declare module "babylonjs/Actions/directActions" {
  9897. import { Action } from "babylonjs/Actions/action";
  9898. import { Condition } from "babylonjs/Actions/condition";
  9899. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9900. /**
  9901. * This defines an action responsible to toggle a boolean once triggered.
  9902. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9903. */
  9904. export class SwitchBooleanAction extends Action {
  9905. /**
  9906. * The path to the boolean property in the target object
  9907. */
  9908. propertyPath: string;
  9909. private _target;
  9910. private _effectiveTarget;
  9911. private _property;
  9912. /**
  9913. * Instantiate the action
  9914. * @param triggerOptions defines the trigger options
  9915. * @param target defines the object containing the boolean
  9916. * @param propertyPath defines the path to the boolean property in the target object
  9917. * @param condition defines the trigger related conditions
  9918. */
  9919. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9920. /** @hidden */
  9921. _prepare(): void;
  9922. /**
  9923. * Execute the action toggle the boolean value.
  9924. */
  9925. execute(): void;
  9926. /**
  9927. * Serializes the actions and its related information.
  9928. * @param parent defines the object to serialize in
  9929. * @returns the serialized object
  9930. */
  9931. serialize(parent: any): any;
  9932. }
  9933. /**
  9934. * This defines an action responsible to set a the state field of the target
  9935. * to a desired value once triggered.
  9936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9937. */
  9938. export class SetStateAction extends Action {
  9939. /**
  9940. * The value to store in the state field.
  9941. */
  9942. value: string;
  9943. private _target;
  9944. /**
  9945. * Instantiate the action
  9946. * @param triggerOptions defines the trigger options
  9947. * @param target defines the object containing the state property
  9948. * @param value defines the value to store in the state field
  9949. * @param condition defines the trigger related conditions
  9950. */
  9951. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9952. /**
  9953. * Execute the action and store the value on the target state property.
  9954. */
  9955. execute(): void;
  9956. /**
  9957. * Serializes the actions and its related information.
  9958. * @param parent defines the object to serialize in
  9959. * @returns the serialized object
  9960. */
  9961. serialize(parent: any): any;
  9962. }
  9963. /**
  9964. * This defines an action responsible to set a property of the target
  9965. * to a desired value once triggered.
  9966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9967. */
  9968. export class SetValueAction extends Action {
  9969. /**
  9970. * The path of the property to set in the target.
  9971. */
  9972. propertyPath: string;
  9973. /**
  9974. * The value to set in the property
  9975. */
  9976. value: any;
  9977. private _target;
  9978. private _effectiveTarget;
  9979. private _property;
  9980. /**
  9981. * Instantiate the action
  9982. * @param triggerOptions defines the trigger options
  9983. * @param target defines the object containing the property
  9984. * @param propertyPath defines the path of the property to set in the target
  9985. * @param value defines the value to set in the property
  9986. * @param condition defines the trigger related conditions
  9987. */
  9988. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9989. /** @hidden */
  9990. _prepare(): void;
  9991. /**
  9992. * Execute the action and set the targetted property to the desired value.
  9993. */
  9994. execute(): void;
  9995. /**
  9996. * Serializes the actions and its related information.
  9997. * @param parent defines the object to serialize in
  9998. * @returns the serialized object
  9999. */
  10000. serialize(parent: any): any;
  10001. }
  10002. /**
  10003. * This defines an action responsible to increment the target value
  10004. * to a desired value once triggered.
  10005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10006. */
  10007. export class IncrementValueAction extends Action {
  10008. /**
  10009. * The path of the property to increment in the target.
  10010. */
  10011. propertyPath: string;
  10012. /**
  10013. * The value we should increment the property by.
  10014. */
  10015. value: any;
  10016. private _target;
  10017. private _effectiveTarget;
  10018. private _property;
  10019. /**
  10020. * Instantiate the action
  10021. * @param triggerOptions defines the trigger options
  10022. * @param target defines the object containing the property
  10023. * @param propertyPath defines the path of the property to increment in the target
  10024. * @param value defines the value value we should increment the property by
  10025. * @param condition defines the trigger related conditions
  10026. */
  10027. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10028. /** @hidden */
  10029. _prepare(): void;
  10030. /**
  10031. * Execute the action and increment the target of the value amount.
  10032. */
  10033. execute(): void;
  10034. /**
  10035. * Serializes the actions and its related information.
  10036. * @param parent defines the object to serialize in
  10037. * @returns the serialized object
  10038. */
  10039. serialize(parent: any): any;
  10040. }
  10041. /**
  10042. * This defines an action responsible to start an animation once triggered.
  10043. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10044. */
  10045. export class PlayAnimationAction extends Action {
  10046. /**
  10047. * Where the animation should start (animation frame)
  10048. */
  10049. from: number;
  10050. /**
  10051. * Where the animation should stop (animation frame)
  10052. */
  10053. to: number;
  10054. /**
  10055. * Define if the animation should loop or stop after the first play.
  10056. */
  10057. loop?: boolean;
  10058. private _target;
  10059. /**
  10060. * Instantiate the action
  10061. * @param triggerOptions defines the trigger options
  10062. * @param target defines the target animation or animation name
  10063. * @param from defines from where the animation should start (animation frame)
  10064. * @param end defines where the animation should stop (animation frame)
  10065. * @param loop defines if the animation should loop or stop after the first play
  10066. * @param condition defines the trigger related conditions
  10067. */
  10068. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10069. /** @hidden */
  10070. _prepare(): void;
  10071. /**
  10072. * Execute the action and play the animation.
  10073. */
  10074. execute(): void;
  10075. /**
  10076. * Serializes the actions and its related information.
  10077. * @param parent defines the object to serialize in
  10078. * @returns the serialized object
  10079. */
  10080. serialize(parent: any): any;
  10081. }
  10082. /**
  10083. * This defines an action responsible to stop an animation once triggered.
  10084. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10085. */
  10086. export class StopAnimationAction extends Action {
  10087. private _target;
  10088. /**
  10089. * Instantiate the action
  10090. * @param triggerOptions defines the trigger options
  10091. * @param target defines the target animation or animation name
  10092. * @param condition defines the trigger related conditions
  10093. */
  10094. constructor(triggerOptions: any, target: any, condition?: Condition);
  10095. /** @hidden */
  10096. _prepare(): void;
  10097. /**
  10098. * Execute the action and stop the animation.
  10099. */
  10100. execute(): void;
  10101. /**
  10102. * Serializes the actions and its related information.
  10103. * @param parent defines the object to serialize in
  10104. * @returns the serialized object
  10105. */
  10106. serialize(parent: any): any;
  10107. }
  10108. /**
  10109. * This defines an action responsible that does nothing once triggered.
  10110. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10111. */
  10112. export class DoNothingAction extends Action {
  10113. /**
  10114. * Instantiate the action
  10115. * @param triggerOptions defines the trigger options
  10116. * @param condition defines the trigger related conditions
  10117. */
  10118. constructor(triggerOptions?: any, condition?: Condition);
  10119. /**
  10120. * Execute the action and do nothing.
  10121. */
  10122. execute(): void;
  10123. /**
  10124. * Serializes the actions and its related information.
  10125. * @param parent defines the object to serialize in
  10126. * @returns the serialized object
  10127. */
  10128. serialize(parent: any): any;
  10129. }
  10130. /**
  10131. * This defines an action responsible to trigger several actions once triggered.
  10132. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10133. */
  10134. export class CombineAction extends Action {
  10135. /**
  10136. * The list of aggregated animations to run.
  10137. */
  10138. children: Action[];
  10139. /**
  10140. * Instantiate the action
  10141. * @param triggerOptions defines the trigger options
  10142. * @param children defines the list of aggregated animations to run
  10143. * @param condition defines the trigger related conditions
  10144. */
  10145. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10146. /** @hidden */
  10147. _prepare(): void;
  10148. /**
  10149. * Execute the action and executes all the aggregated actions.
  10150. */
  10151. execute(evt: ActionEvent): void;
  10152. /**
  10153. * Serializes the actions and its related information.
  10154. * @param parent defines the object to serialize in
  10155. * @returns the serialized object
  10156. */
  10157. serialize(parent: any): any;
  10158. }
  10159. /**
  10160. * This defines an action responsible to run code (external event) once triggered.
  10161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10162. */
  10163. export class ExecuteCodeAction extends Action {
  10164. /**
  10165. * The callback function to run.
  10166. */
  10167. func: (evt: ActionEvent) => void;
  10168. /**
  10169. * Instantiate the action
  10170. * @param triggerOptions defines the trigger options
  10171. * @param func defines the callback function to run
  10172. * @param condition defines the trigger related conditions
  10173. */
  10174. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10175. /**
  10176. * Execute the action and run the attached code.
  10177. */
  10178. execute(evt: ActionEvent): void;
  10179. }
  10180. /**
  10181. * This defines an action responsible to set the parent property of the target once triggered.
  10182. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10183. */
  10184. export class SetParentAction extends Action {
  10185. private _parent;
  10186. private _target;
  10187. /**
  10188. * Instantiate the action
  10189. * @param triggerOptions defines the trigger options
  10190. * @param target defines the target containing the parent property
  10191. * @param parent defines from where the animation should start (animation frame)
  10192. * @param condition defines the trigger related conditions
  10193. */
  10194. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10195. /** @hidden */
  10196. _prepare(): void;
  10197. /**
  10198. * Execute the action and set the parent property.
  10199. */
  10200. execute(): void;
  10201. /**
  10202. * Serializes the actions and its related information.
  10203. * @param parent defines the object to serialize in
  10204. * @returns the serialized object
  10205. */
  10206. serialize(parent: any): any;
  10207. }
  10208. }
  10209. declare module "babylonjs/Actions/actionManager" {
  10210. import { Nullable } from "babylonjs/types";
  10211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10212. import { Scene } from "babylonjs/scene";
  10213. import { IAction } from "babylonjs/Actions/action";
  10214. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10215. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10216. /**
  10217. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10218. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10219. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10220. */
  10221. export class ActionManager extends AbstractActionManager {
  10222. /**
  10223. * Nothing
  10224. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10225. */
  10226. static readonly NothingTrigger: number;
  10227. /**
  10228. * On pick
  10229. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10230. */
  10231. static readonly OnPickTrigger: number;
  10232. /**
  10233. * On left pick
  10234. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10235. */
  10236. static readonly OnLeftPickTrigger: number;
  10237. /**
  10238. * On right pick
  10239. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10240. */
  10241. static readonly OnRightPickTrigger: number;
  10242. /**
  10243. * On center pick
  10244. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10245. */
  10246. static readonly OnCenterPickTrigger: number;
  10247. /**
  10248. * On pick down
  10249. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10250. */
  10251. static readonly OnPickDownTrigger: number;
  10252. /**
  10253. * On double pick
  10254. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10255. */
  10256. static readonly OnDoublePickTrigger: number;
  10257. /**
  10258. * On pick up
  10259. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10260. */
  10261. static readonly OnPickUpTrigger: number;
  10262. /**
  10263. * On pick out.
  10264. * This trigger will only be raised if you also declared a OnPickDown
  10265. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10266. */
  10267. static readonly OnPickOutTrigger: number;
  10268. /**
  10269. * On long press
  10270. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10271. */
  10272. static readonly OnLongPressTrigger: number;
  10273. /**
  10274. * On pointer over
  10275. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10276. */
  10277. static readonly OnPointerOverTrigger: number;
  10278. /**
  10279. * On pointer out
  10280. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10281. */
  10282. static readonly OnPointerOutTrigger: number;
  10283. /**
  10284. * On every frame
  10285. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10286. */
  10287. static readonly OnEveryFrameTrigger: number;
  10288. /**
  10289. * On intersection enter
  10290. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10291. */
  10292. static readonly OnIntersectionEnterTrigger: number;
  10293. /**
  10294. * On intersection exit
  10295. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10296. */
  10297. static readonly OnIntersectionExitTrigger: number;
  10298. /**
  10299. * On key down
  10300. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10301. */
  10302. static readonly OnKeyDownTrigger: number;
  10303. /**
  10304. * On key up
  10305. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10306. */
  10307. static readonly OnKeyUpTrigger: number;
  10308. private _scene;
  10309. /**
  10310. * Creates a new action manager
  10311. * @param scene defines the hosting scene
  10312. */
  10313. constructor(scene: Scene);
  10314. /**
  10315. * Releases all associated resources
  10316. */
  10317. dispose(): void;
  10318. /**
  10319. * Gets hosting scene
  10320. * @returns the hosting scene
  10321. */
  10322. getScene(): Scene;
  10323. /**
  10324. * Does this action manager handles actions of any of the given triggers
  10325. * @param triggers defines the triggers to be tested
  10326. * @return a boolean indicating whether one (or more) of the triggers is handled
  10327. */
  10328. hasSpecificTriggers(triggers: number[]): boolean;
  10329. /**
  10330. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10331. * speed.
  10332. * @param triggerA defines the trigger to be tested
  10333. * @param triggerB defines the trigger to be tested
  10334. * @return a boolean indicating whether one (or more) of the triggers is handled
  10335. */
  10336. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10337. /**
  10338. * Does this action manager handles actions of a given trigger
  10339. * @param trigger defines the trigger to be tested
  10340. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10341. * @return whether the trigger is handled
  10342. */
  10343. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10344. /**
  10345. * Does this action manager has pointer triggers
  10346. */
  10347. get hasPointerTriggers(): boolean;
  10348. /**
  10349. * Does this action manager has pick triggers
  10350. */
  10351. get hasPickTriggers(): boolean;
  10352. /**
  10353. * Registers an action to this action manager
  10354. * @param action defines the action to be registered
  10355. * @return the action amended (prepared) after registration
  10356. */
  10357. registerAction(action: IAction): Nullable<IAction>;
  10358. /**
  10359. * Unregisters an action to this action manager
  10360. * @param action defines the action to be unregistered
  10361. * @return a boolean indicating whether the action has been unregistered
  10362. */
  10363. unregisterAction(action: IAction): Boolean;
  10364. /**
  10365. * Process a specific trigger
  10366. * @param trigger defines the trigger to process
  10367. * @param evt defines the event details to be processed
  10368. */
  10369. processTrigger(trigger: number, evt?: IActionEvent): void;
  10370. /** @hidden */
  10371. _getEffectiveTarget(target: any, propertyPath: string): any;
  10372. /** @hidden */
  10373. _getProperty(propertyPath: string): string;
  10374. /**
  10375. * Serialize this manager to a JSON object
  10376. * @param name defines the property name to store this manager
  10377. * @returns a JSON representation of this manager
  10378. */
  10379. serialize(name: string): any;
  10380. /**
  10381. * Creates a new ActionManager from a JSON data
  10382. * @param parsedActions defines the JSON data to read from
  10383. * @param object defines the hosting mesh
  10384. * @param scene defines the hosting scene
  10385. */
  10386. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10387. /**
  10388. * Get a trigger name by index
  10389. * @param trigger defines the trigger index
  10390. * @returns a trigger name
  10391. */
  10392. static GetTriggerName(trigger: number): string;
  10393. }
  10394. }
  10395. declare module "babylonjs/Sprites/sprite" {
  10396. import { Vector3 } from "babylonjs/Maths/math.vector";
  10397. import { Nullable } from "babylonjs/types";
  10398. import { ActionManager } from "babylonjs/Actions/actionManager";
  10399. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10400. import { Color4 } from "babylonjs/Maths/math.color";
  10401. import { Observable } from "babylonjs/Misc/observable";
  10402. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10403. import { Animation } from "babylonjs/Animations/animation";
  10404. /**
  10405. * Class used to represent a sprite
  10406. * @see https://doc.babylonjs.com/babylon101/sprites
  10407. */
  10408. export class Sprite implements IAnimatable {
  10409. /** defines the name */
  10410. name: string;
  10411. /** Gets or sets the current world position */
  10412. position: Vector3;
  10413. /** Gets or sets the main color */
  10414. color: Color4;
  10415. /** Gets or sets the width */
  10416. width: number;
  10417. /** Gets or sets the height */
  10418. height: number;
  10419. /** Gets or sets rotation angle */
  10420. angle: number;
  10421. /** Gets or sets the cell index in the sprite sheet */
  10422. cellIndex: number;
  10423. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10424. cellRef: string;
  10425. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10426. invertU: boolean;
  10427. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10428. invertV: boolean;
  10429. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10430. disposeWhenFinishedAnimating: boolean;
  10431. /** Gets the list of attached animations */
  10432. animations: Nullable<Array<Animation>>;
  10433. /** Gets or sets a boolean indicating if the sprite can be picked */
  10434. isPickable: boolean;
  10435. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10436. useAlphaForPicking: boolean;
  10437. /** @hidden */
  10438. _xOffset: number;
  10439. /** @hidden */
  10440. _yOffset: number;
  10441. /** @hidden */
  10442. _xSize: number;
  10443. /** @hidden */
  10444. _ySize: number;
  10445. /**
  10446. * Gets or sets the associated action manager
  10447. */
  10448. actionManager: Nullable<ActionManager>;
  10449. /**
  10450. * An event triggered when the control has been disposed
  10451. */
  10452. onDisposeObservable: Observable<Sprite>;
  10453. private _animationStarted;
  10454. private _loopAnimation;
  10455. private _fromIndex;
  10456. private _toIndex;
  10457. private _delay;
  10458. private _direction;
  10459. private _manager;
  10460. private _time;
  10461. private _onAnimationEnd;
  10462. /**
  10463. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10464. */
  10465. isVisible: boolean;
  10466. /**
  10467. * Gets or sets the sprite size
  10468. */
  10469. get size(): number;
  10470. set size(value: number);
  10471. /**
  10472. * Returns a boolean indicating if the animation is started
  10473. */
  10474. get animationStarted(): boolean;
  10475. /**
  10476. * Gets or sets the unique id of the sprite
  10477. */
  10478. uniqueId: number;
  10479. /**
  10480. * Gets the manager of this sprite
  10481. */
  10482. get manager(): ISpriteManager;
  10483. /**
  10484. * Creates a new Sprite
  10485. * @param name defines the name
  10486. * @param manager defines the manager
  10487. */
  10488. constructor(
  10489. /** defines the name */
  10490. name: string, manager: ISpriteManager);
  10491. /**
  10492. * Returns the string "Sprite"
  10493. * @returns "Sprite"
  10494. */
  10495. getClassName(): string;
  10496. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10497. get fromIndex(): number;
  10498. set fromIndex(value: number);
  10499. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10500. get toIndex(): number;
  10501. set toIndex(value: number);
  10502. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10503. get loopAnimation(): boolean;
  10504. set loopAnimation(value: boolean);
  10505. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10506. get delay(): number;
  10507. set delay(value: number);
  10508. /**
  10509. * Starts an animation
  10510. * @param from defines the initial key
  10511. * @param to defines the end key
  10512. * @param loop defines if the animation must loop
  10513. * @param delay defines the start delay (in ms)
  10514. * @param onAnimationEnd defines a callback to call when animation ends
  10515. */
  10516. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10517. /** Stops current animation (if any) */
  10518. stopAnimation(): void;
  10519. /** @hidden */
  10520. _animate(deltaTime: number): void;
  10521. /** Release associated resources */
  10522. dispose(): void;
  10523. /**
  10524. * Serializes the sprite to a JSON object
  10525. * @returns the JSON object
  10526. */
  10527. serialize(): any;
  10528. /**
  10529. * Parses a JSON object to create a new sprite
  10530. * @param parsedSprite The JSON object to parse
  10531. * @param manager defines the hosting manager
  10532. * @returns the new sprite
  10533. */
  10534. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10535. }
  10536. }
  10537. declare module "babylonjs/Collisions/pickingInfo" {
  10538. import { Nullable } from "babylonjs/types";
  10539. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10541. import { Sprite } from "babylonjs/Sprites/sprite";
  10542. import { Ray } from "babylonjs/Culling/ray";
  10543. /**
  10544. * Information about the result of picking within a scene
  10545. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10546. */
  10547. export class PickingInfo {
  10548. /** @hidden */
  10549. _pickingUnavailable: boolean;
  10550. /**
  10551. * If the pick collided with an object
  10552. */
  10553. hit: boolean;
  10554. /**
  10555. * Distance away where the pick collided
  10556. */
  10557. distance: number;
  10558. /**
  10559. * The location of pick collision
  10560. */
  10561. pickedPoint: Nullable<Vector3>;
  10562. /**
  10563. * The mesh corresponding the the pick collision
  10564. */
  10565. pickedMesh: Nullable<AbstractMesh>;
  10566. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10567. bu: number;
  10568. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10569. bv: number;
  10570. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10571. faceId: number;
  10572. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10573. subMeshFaceId: number;
  10574. /** Id of the the submesh that was picked */
  10575. subMeshId: number;
  10576. /** If a sprite was picked, this will be the sprite the pick collided with */
  10577. pickedSprite: Nullable<Sprite>;
  10578. /**
  10579. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10580. */
  10581. originMesh: Nullable<AbstractMesh>;
  10582. /**
  10583. * The ray that was used to perform the picking.
  10584. */
  10585. ray: Nullable<Ray>;
  10586. /**
  10587. * Gets the normal correspodning to the face the pick collided with
  10588. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10589. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10590. * @returns The normal correspodning to the face the pick collided with
  10591. */
  10592. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10593. /**
  10594. * Gets the texture coordinates of where the pick occured
  10595. * @returns the vector containing the coordnates of the texture
  10596. */
  10597. getTextureCoordinates(): Nullable<Vector2>;
  10598. }
  10599. }
  10600. declare module "babylonjs/Culling/ray" {
  10601. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10602. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10604. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10605. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10606. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10607. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10608. import { Plane } from "babylonjs/Maths/math.plane";
  10609. /**
  10610. * Class representing a ray with position and direction
  10611. */
  10612. export class Ray {
  10613. /** origin point */
  10614. origin: Vector3;
  10615. /** direction */
  10616. direction: Vector3;
  10617. /** length of the ray */
  10618. length: number;
  10619. private static readonly TmpVector3;
  10620. private _tmpRay;
  10621. /**
  10622. * Creates a new ray
  10623. * @param origin origin point
  10624. * @param direction direction
  10625. * @param length length of the ray
  10626. */
  10627. constructor(
  10628. /** origin point */
  10629. origin: Vector3,
  10630. /** direction */
  10631. direction: Vector3,
  10632. /** length of the ray */
  10633. length?: number);
  10634. /**
  10635. * Checks if the ray intersects a box
  10636. * This does not account for the ray lenght by design to improve perfs.
  10637. * @param minimum bound of the box
  10638. * @param maximum bound of the box
  10639. * @param intersectionTreshold extra extend to be added to the box in all direction
  10640. * @returns if the box was hit
  10641. */
  10642. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10643. /**
  10644. * Checks if the ray intersects a box
  10645. * This does not account for the ray lenght by design to improve perfs.
  10646. * @param box the bounding box to check
  10647. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10648. * @returns if the box was hit
  10649. */
  10650. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10651. /**
  10652. * If the ray hits a sphere
  10653. * @param sphere the bounding sphere to check
  10654. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10655. * @returns true if it hits the sphere
  10656. */
  10657. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10658. /**
  10659. * If the ray hits a triange
  10660. * @param vertex0 triangle vertex
  10661. * @param vertex1 triangle vertex
  10662. * @param vertex2 triangle vertex
  10663. * @returns intersection information if hit
  10664. */
  10665. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10666. /**
  10667. * Checks if ray intersects a plane
  10668. * @param plane the plane to check
  10669. * @returns the distance away it was hit
  10670. */
  10671. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10672. /**
  10673. * Calculate the intercept of a ray on a given axis
  10674. * @param axis to check 'x' | 'y' | 'z'
  10675. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10676. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10677. */
  10678. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10679. /**
  10680. * Checks if ray intersects a mesh
  10681. * @param mesh the mesh to check
  10682. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10683. * @returns picking info of the intersecton
  10684. */
  10685. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10686. /**
  10687. * Checks if ray intersects a mesh
  10688. * @param meshes the meshes to check
  10689. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10690. * @param results array to store result in
  10691. * @returns Array of picking infos
  10692. */
  10693. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10694. private _comparePickingInfo;
  10695. private static smallnum;
  10696. private static rayl;
  10697. /**
  10698. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10699. * @param sega the first point of the segment to test the intersection against
  10700. * @param segb the second point of the segment to test the intersection against
  10701. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10702. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10703. */
  10704. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10705. /**
  10706. * Update the ray from viewport position
  10707. * @param x position
  10708. * @param y y position
  10709. * @param viewportWidth viewport width
  10710. * @param viewportHeight viewport height
  10711. * @param world world matrix
  10712. * @param view view matrix
  10713. * @param projection projection matrix
  10714. * @returns this ray updated
  10715. */
  10716. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10717. /**
  10718. * Creates a ray with origin and direction of 0,0,0
  10719. * @returns the new ray
  10720. */
  10721. static Zero(): Ray;
  10722. /**
  10723. * Creates a new ray from screen space and viewport
  10724. * @param x position
  10725. * @param y y position
  10726. * @param viewportWidth viewport width
  10727. * @param viewportHeight viewport height
  10728. * @param world world matrix
  10729. * @param view view matrix
  10730. * @param projection projection matrix
  10731. * @returns new ray
  10732. */
  10733. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10734. /**
  10735. * 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
  10736. * transformed to the given world matrix.
  10737. * @param origin The origin point
  10738. * @param end The end point
  10739. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10740. * @returns the new ray
  10741. */
  10742. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10743. /**
  10744. * Transforms a ray by a matrix
  10745. * @param ray ray to transform
  10746. * @param matrix matrix to apply
  10747. * @returns the resulting new ray
  10748. */
  10749. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10750. /**
  10751. * Transforms a ray by a matrix
  10752. * @param ray ray to transform
  10753. * @param matrix matrix to apply
  10754. * @param result ray to store result in
  10755. */
  10756. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10757. /**
  10758. * Unproject a ray from screen space to object space
  10759. * @param sourceX defines the screen space x coordinate to use
  10760. * @param sourceY defines the screen space y coordinate to use
  10761. * @param viewportWidth defines the current width of the viewport
  10762. * @param viewportHeight defines the current height of the viewport
  10763. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10764. * @param view defines the view matrix to use
  10765. * @param projection defines the projection matrix to use
  10766. */
  10767. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10768. }
  10769. /**
  10770. * Type used to define predicate used to select faces when a mesh intersection is detected
  10771. */
  10772. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10773. module "babylonjs/scene" {
  10774. interface Scene {
  10775. /** @hidden */
  10776. _tempPickingRay: Nullable<Ray>;
  10777. /** @hidden */
  10778. _cachedRayForTransform: Ray;
  10779. /** @hidden */
  10780. _pickWithRayInverseMatrix: Matrix;
  10781. /** @hidden */
  10782. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10783. /** @hidden */
  10784. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10785. }
  10786. }
  10787. }
  10788. declare module "babylonjs/sceneComponent" {
  10789. import { Scene } from "babylonjs/scene";
  10790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10791. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10792. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10793. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10794. import { Nullable } from "babylonjs/types";
  10795. import { Camera } from "babylonjs/Cameras/camera";
  10796. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10797. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10798. import { AbstractScene } from "babylonjs/abstractScene";
  10799. import { Mesh } from "babylonjs/Meshes/mesh";
  10800. /**
  10801. * Groups all the scene component constants in one place to ease maintenance.
  10802. * @hidden
  10803. */
  10804. export class SceneComponentConstants {
  10805. static readonly NAME_EFFECTLAYER: string;
  10806. static readonly NAME_LAYER: string;
  10807. static readonly NAME_LENSFLARESYSTEM: string;
  10808. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10809. static readonly NAME_PARTICLESYSTEM: string;
  10810. static readonly NAME_GAMEPAD: string;
  10811. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10812. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10813. static readonly NAME_PREPASSRENDERER: string;
  10814. static readonly NAME_DEPTHRENDERER: string;
  10815. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10816. static readonly NAME_SPRITE: string;
  10817. static readonly NAME_OUTLINERENDERER: string;
  10818. static readonly NAME_PROCEDURALTEXTURE: string;
  10819. static readonly NAME_SHADOWGENERATOR: string;
  10820. static readonly NAME_OCTREE: string;
  10821. static readonly NAME_PHYSICSENGINE: string;
  10822. static readonly NAME_AUDIO: string;
  10823. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10824. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10825. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10826. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10827. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10828. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10829. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10830. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10831. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10832. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10833. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10834. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10835. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10836. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10837. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10838. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10839. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10840. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10841. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10842. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10843. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10844. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10845. static readonly STEP_AFTERRENDER_AUDIO: number;
  10846. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10847. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10848. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10849. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10850. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10851. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10852. static readonly STEP_POINTERMOVE_SPRITE: number;
  10853. static readonly STEP_POINTERDOWN_SPRITE: number;
  10854. static readonly STEP_POINTERUP_SPRITE: number;
  10855. }
  10856. /**
  10857. * This represents a scene component.
  10858. *
  10859. * This is used to decouple the dependency the scene is having on the different workloads like
  10860. * layers, post processes...
  10861. */
  10862. export interface ISceneComponent {
  10863. /**
  10864. * The name of the component. Each component must have a unique name.
  10865. */
  10866. name: string;
  10867. /**
  10868. * The scene the component belongs to.
  10869. */
  10870. scene: Scene;
  10871. /**
  10872. * Register the component to one instance of a scene.
  10873. */
  10874. register(): void;
  10875. /**
  10876. * Rebuilds the elements related to this component in case of
  10877. * context lost for instance.
  10878. */
  10879. rebuild(): void;
  10880. /**
  10881. * Disposes the component and the associated ressources.
  10882. */
  10883. dispose(): void;
  10884. }
  10885. /**
  10886. * This represents a SERIALIZABLE scene component.
  10887. *
  10888. * This extends Scene Component to add Serialization methods on top.
  10889. */
  10890. export interface ISceneSerializableComponent extends ISceneComponent {
  10891. /**
  10892. * Adds all the elements from the container to the scene
  10893. * @param container the container holding the elements
  10894. */
  10895. addFromContainer(container: AbstractScene): void;
  10896. /**
  10897. * Removes all the elements in the container from the scene
  10898. * @param container contains the elements to remove
  10899. * @param dispose if the removed element should be disposed (default: false)
  10900. */
  10901. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10902. /**
  10903. * Serializes the component data to the specified json object
  10904. * @param serializationObject The object to serialize to
  10905. */
  10906. serialize(serializationObject: any): void;
  10907. }
  10908. /**
  10909. * Strong typing of a Mesh related stage step action
  10910. */
  10911. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10912. /**
  10913. * Strong typing of a Evaluate Sub Mesh related stage step action
  10914. */
  10915. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10916. /**
  10917. * Strong typing of a Active Mesh related stage step action
  10918. */
  10919. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10920. /**
  10921. * Strong typing of a Camera related stage step action
  10922. */
  10923. export type CameraStageAction = (camera: Camera) => void;
  10924. /**
  10925. * Strong typing of a Camera Frame buffer related stage step action
  10926. */
  10927. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10928. /**
  10929. * Strong typing of a Render Target related stage step action
  10930. */
  10931. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10932. /**
  10933. * Strong typing of a RenderingGroup related stage step action
  10934. */
  10935. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10936. /**
  10937. * Strong typing of a Mesh Render related stage step action
  10938. */
  10939. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10940. /**
  10941. * Strong typing of a simple stage step action
  10942. */
  10943. export type SimpleStageAction = () => void;
  10944. /**
  10945. * Strong typing of a render target action.
  10946. */
  10947. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10948. /**
  10949. * Strong typing of a pointer move action.
  10950. */
  10951. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10952. /**
  10953. * Strong typing of a pointer up/down action.
  10954. */
  10955. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10956. /**
  10957. * Representation of a stage in the scene (Basically a list of ordered steps)
  10958. * @hidden
  10959. */
  10960. export class Stage<T extends Function> extends Array<{
  10961. index: number;
  10962. component: ISceneComponent;
  10963. action: T;
  10964. }> {
  10965. /**
  10966. * Hide ctor from the rest of the world.
  10967. * @param items The items to add.
  10968. */
  10969. private constructor();
  10970. /**
  10971. * Creates a new Stage.
  10972. * @returns A new instance of a Stage
  10973. */
  10974. static Create<T extends Function>(): Stage<T>;
  10975. /**
  10976. * Registers a step in an ordered way in the targeted stage.
  10977. * @param index Defines the position to register the step in
  10978. * @param component Defines the component attached to the step
  10979. * @param action Defines the action to launch during the step
  10980. */
  10981. registerStep(index: number, component: ISceneComponent, action: T): void;
  10982. /**
  10983. * Clears all the steps from the stage.
  10984. */
  10985. clear(): void;
  10986. }
  10987. }
  10988. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10989. import { Nullable } from "babylonjs/types";
  10990. import { Observable } from "babylonjs/Misc/observable";
  10991. import { Scene } from "babylonjs/scene";
  10992. import { Sprite } from "babylonjs/Sprites/sprite";
  10993. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10994. import { Ray } from "babylonjs/Culling/ray";
  10995. import { Camera } from "babylonjs/Cameras/camera";
  10996. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10997. import { ISceneComponent } from "babylonjs/sceneComponent";
  10998. module "babylonjs/scene" {
  10999. interface Scene {
  11000. /** @hidden */
  11001. _pointerOverSprite: Nullable<Sprite>;
  11002. /** @hidden */
  11003. _pickedDownSprite: Nullable<Sprite>;
  11004. /** @hidden */
  11005. _tempSpritePickingRay: Nullable<Ray>;
  11006. /**
  11007. * All of the sprite managers added to this scene
  11008. * @see https://doc.babylonjs.com/babylon101/sprites
  11009. */
  11010. spriteManagers: Array<ISpriteManager>;
  11011. /**
  11012. * An event triggered when sprites rendering is about to start
  11013. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11014. */
  11015. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11016. /**
  11017. * An event triggered when sprites rendering is done
  11018. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11019. */
  11020. onAfterSpritesRenderingObservable: Observable<Scene>;
  11021. /** @hidden */
  11022. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11023. /** Launch a ray to try to pick a sprite in the scene
  11024. * @param x position on screen
  11025. * @param y position on screen
  11026. * @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
  11027. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11028. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11029. * @returns a PickingInfo
  11030. */
  11031. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11032. /** Use the given ray to pick a sprite in the scene
  11033. * @param ray The ray (in world space) to use to pick meshes
  11034. * @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
  11035. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11036. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11037. * @returns a PickingInfo
  11038. */
  11039. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11040. /** @hidden */
  11041. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11042. /** Launch a ray to try to pick sprites in the scene
  11043. * @param x position on screen
  11044. * @param y position on screen
  11045. * @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
  11046. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11047. * @returns a PickingInfo array
  11048. */
  11049. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11050. /** Use the given ray to pick sprites in the scene
  11051. * @param ray The ray (in world space) to use to pick meshes
  11052. * @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
  11053. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11054. * @returns a PickingInfo array
  11055. */
  11056. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11057. /**
  11058. * Force the sprite under the pointer
  11059. * @param sprite defines the sprite to use
  11060. */
  11061. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11062. /**
  11063. * Gets the sprite under the pointer
  11064. * @returns a Sprite or null if no sprite is under the pointer
  11065. */
  11066. getPointerOverSprite(): Nullable<Sprite>;
  11067. }
  11068. }
  11069. /**
  11070. * Defines the sprite scene component responsible to manage sprites
  11071. * in a given scene.
  11072. */
  11073. export class SpriteSceneComponent implements ISceneComponent {
  11074. /**
  11075. * The component name helpfull to identify the component in the list of scene components.
  11076. */
  11077. readonly name: string;
  11078. /**
  11079. * The scene the component belongs to.
  11080. */
  11081. scene: Scene;
  11082. /** @hidden */
  11083. private _spritePredicate;
  11084. /**
  11085. * Creates a new instance of the component for the given scene
  11086. * @param scene Defines the scene to register the component in
  11087. */
  11088. constructor(scene: Scene);
  11089. /**
  11090. * Registers the component in a given scene
  11091. */
  11092. register(): void;
  11093. /**
  11094. * Rebuilds the elements related to this component in case of
  11095. * context lost for instance.
  11096. */
  11097. rebuild(): void;
  11098. /**
  11099. * Disposes the component and the associated ressources.
  11100. */
  11101. dispose(): void;
  11102. private _pickSpriteButKeepRay;
  11103. private _pointerMove;
  11104. private _pointerDown;
  11105. private _pointerUp;
  11106. }
  11107. }
  11108. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11109. /** @hidden */
  11110. export var fogFragmentDeclaration: {
  11111. name: string;
  11112. shader: string;
  11113. };
  11114. }
  11115. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11116. /** @hidden */
  11117. export var fogFragment: {
  11118. name: string;
  11119. shader: string;
  11120. };
  11121. }
  11122. declare module "babylonjs/Shaders/sprites.fragment" {
  11123. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11124. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11125. /** @hidden */
  11126. export var spritesPixelShader: {
  11127. name: string;
  11128. shader: string;
  11129. };
  11130. }
  11131. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11132. /** @hidden */
  11133. export var fogVertexDeclaration: {
  11134. name: string;
  11135. shader: string;
  11136. };
  11137. }
  11138. declare module "babylonjs/Shaders/sprites.vertex" {
  11139. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11140. /** @hidden */
  11141. export var spritesVertexShader: {
  11142. name: string;
  11143. shader: string;
  11144. };
  11145. }
  11146. declare module "babylonjs/Sprites/spriteManager" {
  11147. import { IDisposable, Scene } from "babylonjs/scene";
  11148. import { Nullable } from "babylonjs/types";
  11149. import { Observable } from "babylonjs/Misc/observable";
  11150. import { Sprite } from "babylonjs/Sprites/sprite";
  11151. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11152. import { Camera } from "babylonjs/Cameras/camera";
  11153. import { Texture } from "babylonjs/Materials/Textures/texture";
  11154. import "babylonjs/Shaders/sprites.fragment";
  11155. import "babylonjs/Shaders/sprites.vertex";
  11156. import { Ray } from "babylonjs/Culling/ray";
  11157. /**
  11158. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11159. */
  11160. export interface ISpriteManager extends IDisposable {
  11161. /**
  11162. * Gets manager's name
  11163. */
  11164. name: string;
  11165. /**
  11166. * Restricts the camera to viewing objects with the same layerMask.
  11167. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11168. */
  11169. layerMask: number;
  11170. /**
  11171. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11172. */
  11173. isPickable: boolean;
  11174. /**
  11175. * Gets the hosting scene
  11176. */
  11177. scene: Scene;
  11178. /**
  11179. * Specifies the rendering group id for this mesh (0 by default)
  11180. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11181. */
  11182. renderingGroupId: number;
  11183. /**
  11184. * Defines the list of sprites managed by the manager.
  11185. */
  11186. sprites: Array<Sprite>;
  11187. /**
  11188. * Gets or sets the spritesheet texture
  11189. */
  11190. texture: Texture;
  11191. /** Defines the default width of a cell in the spritesheet */
  11192. cellWidth: number;
  11193. /** Defines the default height of a cell in the spritesheet */
  11194. cellHeight: number;
  11195. /**
  11196. * Tests the intersection of a sprite with a specific ray.
  11197. * @param ray The ray we are sending to test the collision
  11198. * @param camera The camera space we are sending rays in
  11199. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11200. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11201. * @returns picking info or null.
  11202. */
  11203. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11204. /**
  11205. * Intersects the sprites with a ray
  11206. * @param ray defines the ray to intersect with
  11207. * @param camera defines the current active camera
  11208. * @param predicate defines a predicate used to select candidate sprites
  11209. * @returns null if no hit or a PickingInfo array
  11210. */
  11211. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11212. /**
  11213. * Renders the list of sprites on screen.
  11214. */
  11215. render(): void;
  11216. }
  11217. /**
  11218. * Class used to manage multiple sprites on the same spritesheet
  11219. * @see https://doc.babylonjs.com/babylon101/sprites
  11220. */
  11221. export class SpriteManager implements ISpriteManager {
  11222. /** defines the manager's name */
  11223. name: string;
  11224. /** Define the Url to load snippets */
  11225. static SnippetUrl: string;
  11226. /** Snippet ID if the manager was created from the snippet server */
  11227. snippetId: string;
  11228. /** Gets the list of sprites */
  11229. sprites: Sprite[];
  11230. /** Gets or sets the rendering group id (0 by default) */
  11231. renderingGroupId: number;
  11232. /** Gets or sets camera layer mask */
  11233. layerMask: number;
  11234. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11235. fogEnabled: boolean;
  11236. /** Gets or sets a boolean indicating if the sprites are pickable */
  11237. isPickable: boolean;
  11238. /** Defines the default width of a cell in the spritesheet */
  11239. cellWidth: number;
  11240. /** Defines the default height of a cell in the spritesheet */
  11241. cellHeight: number;
  11242. /** Associative array from JSON sprite data file */
  11243. private _cellData;
  11244. /** Array of sprite names from JSON sprite data file */
  11245. private _spriteMap;
  11246. /** True when packed cell data from JSON file is ready*/
  11247. private _packedAndReady;
  11248. private _textureContent;
  11249. /**
  11250. * An event triggered when the manager is disposed.
  11251. */
  11252. onDisposeObservable: Observable<SpriteManager>;
  11253. private _onDisposeObserver;
  11254. /**
  11255. * Callback called when the manager is disposed
  11256. */
  11257. set onDispose(callback: () => void);
  11258. private _capacity;
  11259. private _fromPacked;
  11260. private _spriteTexture;
  11261. private _epsilon;
  11262. private _scene;
  11263. private _vertexData;
  11264. private _buffer;
  11265. private _vertexBuffers;
  11266. private _indexBuffer;
  11267. private _effectBase;
  11268. private _effectFog;
  11269. /**
  11270. * Gets or sets the unique id of the sprite
  11271. */
  11272. uniqueId: number;
  11273. /**
  11274. * Gets the array of sprites
  11275. */
  11276. get children(): Sprite[];
  11277. /**
  11278. * Gets the hosting scene
  11279. */
  11280. get scene(): Scene;
  11281. /**
  11282. * Gets the capacity of the manager
  11283. */
  11284. get capacity(): number;
  11285. /**
  11286. * Gets or sets the spritesheet texture
  11287. */
  11288. get texture(): Texture;
  11289. set texture(value: Texture);
  11290. private _blendMode;
  11291. /**
  11292. * Blend mode use to render the particle, it can be any of
  11293. * the static Constants.ALPHA_x properties provided in this class.
  11294. * Default value is Constants.ALPHA_COMBINE
  11295. */
  11296. get blendMode(): number;
  11297. set blendMode(blendMode: number);
  11298. /** Disables writing to the depth buffer when rendering the sprites.
  11299. * It can be handy to disable depth writing when using textures without alpha channel
  11300. * and setting some specific blend modes.
  11301. */
  11302. disableDepthWrite: boolean;
  11303. /**
  11304. * Creates a new sprite manager
  11305. * @param name defines the manager's name
  11306. * @param imgUrl defines the sprite sheet url
  11307. * @param capacity defines the maximum allowed number of sprites
  11308. * @param cellSize defines the size of a sprite cell
  11309. * @param scene defines the hosting scene
  11310. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11311. * @param samplingMode defines the smapling mode to use with spritesheet
  11312. * @param fromPacked set to false; do not alter
  11313. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11314. */
  11315. constructor(
  11316. /** defines the manager's name */
  11317. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11318. /**
  11319. * Returns the string "SpriteManager"
  11320. * @returns "SpriteManager"
  11321. */
  11322. getClassName(): string;
  11323. private _makePacked;
  11324. private _appendSpriteVertex;
  11325. private _checkTextureAlpha;
  11326. /**
  11327. * Intersects the sprites with a ray
  11328. * @param ray defines the ray to intersect with
  11329. * @param camera defines the current active camera
  11330. * @param predicate defines a predicate used to select candidate sprites
  11331. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11332. * @returns null if no hit or a PickingInfo
  11333. */
  11334. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11335. /**
  11336. * Intersects the sprites with a ray
  11337. * @param ray defines the ray to intersect with
  11338. * @param camera defines the current active camera
  11339. * @param predicate defines a predicate used to select candidate sprites
  11340. * @returns null if no hit or a PickingInfo array
  11341. */
  11342. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11343. /**
  11344. * Render all child sprites
  11345. */
  11346. render(): void;
  11347. /**
  11348. * Release associated resources
  11349. */
  11350. dispose(): void;
  11351. /**
  11352. * Serializes the sprite manager to a JSON object
  11353. * @param serializeTexture defines if the texture must be serialized as well
  11354. * @returns the JSON object
  11355. */
  11356. serialize(serializeTexture?: boolean): any;
  11357. /**
  11358. * Parses a JSON object to create a new sprite manager.
  11359. * @param parsedManager The JSON object to parse
  11360. * @param scene The scene to create the sprite managerin
  11361. * @param rootUrl The root url to use to load external dependencies like texture
  11362. * @returns the new sprite manager
  11363. */
  11364. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11365. /**
  11366. * Creates a sprite manager from a snippet saved in a remote file
  11367. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11368. * @param url defines the url to load from
  11369. * @param scene defines the hosting scene
  11370. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11371. * @returns a promise that will resolve to the new sprite manager
  11372. */
  11373. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11374. /**
  11375. * Creates a sprite manager from a snippet saved by the sprite editor
  11376. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11377. * @param scene defines the hosting scene
  11378. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11379. * @returns a promise that will resolve to the new sprite manager
  11380. */
  11381. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11382. }
  11383. }
  11384. declare module "babylonjs/Misc/gradients" {
  11385. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11386. /** Interface used by value gradients (color, factor, ...) */
  11387. export interface IValueGradient {
  11388. /**
  11389. * Gets or sets the gradient value (between 0 and 1)
  11390. */
  11391. gradient: number;
  11392. }
  11393. /** Class used to store color4 gradient */
  11394. export class ColorGradient implements IValueGradient {
  11395. /**
  11396. * Gets or sets the gradient value (between 0 and 1)
  11397. */
  11398. gradient: number;
  11399. /**
  11400. * Gets or sets first associated color
  11401. */
  11402. color1: Color4;
  11403. /**
  11404. * Gets or sets second associated color
  11405. */
  11406. color2?: Color4 | undefined;
  11407. /**
  11408. * Creates a new color4 gradient
  11409. * @param gradient gets or sets the gradient value (between 0 and 1)
  11410. * @param color1 gets or sets first associated color
  11411. * @param color2 gets or sets first second color
  11412. */
  11413. constructor(
  11414. /**
  11415. * Gets or sets the gradient value (between 0 and 1)
  11416. */
  11417. gradient: number,
  11418. /**
  11419. * Gets or sets first associated color
  11420. */
  11421. color1: Color4,
  11422. /**
  11423. * Gets or sets second associated color
  11424. */
  11425. color2?: Color4 | undefined);
  11426. /**
  11427. * Will get a color picked randomly between color1 and color2.
  11428. * If color2 is undefined then color1 will be used
  11429. * @param result defines the target Color4 to store the result in
  11430. */
  11431. getColorToRef(result: Color4): void;
  11432. }
  11433. /** Class used to store color 3 gradient */
  11434. export class Color3Gradient implements IValueGradient {
  11435. /**
  11436. * Gets or sets the gradient value (between 0 and 1)
  11437. */
  11438. gradient: number;
  11439. /**
  11440. * Gets or sets the associated color
  11441. */
  11442. color: Color3;
  11443. /**
  11444. * Creates a new color3 gradient
  11445. * @param gradient gets or sets the gradient value (between 0 and 1)
  11446. * @param color gets or sets associated color
  11447. */
  11448. constructor(
  11449. /**
  11450. * Gets or sets the gradient value (between 0 and 1)
  11451. */
  11452. gradient: number,
  11453. /**
  11454. * Gets or sets the associated color
  11455. */
  11456. color: Color3);
  11457. }
  11458. /** Class used to store factor gradient */
  11459. export class FactorGradient 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 factor
  11466. */
  11467. factor1: number;
  11468. /**
  11469. * Gets or sets second associated factor
  11470. */
  11471. factor2?: number | undefined;
  11472. /**
  11473. * Creates a new factor gradient
  11474. * @param gradient gets or sets the gradient value (between 0 and 1)
  11475. * @param factor1 gets or sets first associated factor
  11476. * @param factor2 gets or sets second associated factor
  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 factor
  11485. */
  11486. factor1: number,
  11487. /**
  11488. * Gets or sets second associated factor
  11489. */
  11490. factor2?: number | undefined);
  11491. /**
  11492. * Will get a number picked randomly between factor1 and factor2.
  11493. * If factor2 is undefined then factor1 will be used
  11494. * @returns the picked number
  11495. */
  11496. getFactor(): number;
  11497. }
  11498. /**
  11499. * Helper used to simplify some generic gradient tasks
  11500. */
  11501. export class GradientHelper {
  11502. /**
  11503. * Gets the current gradient from an array of IValueGradient
  11504. * @param ratio defines the current ratio to get
  11505. * @param gradients defines the array of IValueGradient
  11506. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11507. */
  11508. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11509. }
  11510. }
  11511. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11512. import { Nullable } from "babylonjs/types";
  11513. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11514. import { Scene } from "babylonjs/scene";
  11515. module "babylonjs/Engines/thinEngine" {
  11516. interface ThinEngine {
  11517. /**
  11518. * Creates a raw texture
  11519. * @param data defines the data to store in the texture
  11520. * @param width defines the width of the texture
  11521. * @param height defines the height of the texture
  11522. * @param format defines the format of the data
  11523. * @param generateMipMaps defines if the engine should generate the mip levels
  11524. * @param invertY defines if data must be stored with Y axis inverted
  11525. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11526. * @param compression defines the compression used (null by default)
  11527. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11528. * @returns the raw texture inside an InternalTexture
  11529. */
  11530. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11531. /**
  11532. * Update a raw texture
  11533. * @param texture defines the texture to update
  11534. * @param data defines the data to store in the texture
  11535. * @param format defines the format of the data
  11536. * @param invertY defines if data must be stored with Y axis inverted
  11537. */
  11538. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11539. /**
  11540. * Update a raw texture
  11541. * @param texture defines the texture to update
  11542. * @param data defines the data to store in the texture
  11543. * @param format defines the format of the data
  11544. * @param invertY defines if data must be stored with Y axis inverted
  11545. * @param compression defines the compression used (null by default)
  11546. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11547. */
  11548. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11549. /**
  11550. * Creates a new raw cube texture
  11551. * @param data defines the array of data to use to create each face
  11552. * @param size defines the size of the textures
  11553. * @param format defines the format of the data
  11554. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11555. * @param generateMipMaps defines if the engine should generate the mip levels
  11556. * @param invertY defines if data must be stored with Y axis inverted
  11557. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11558. * @param compression defines the compression used (null by default)
  11559. * @returns the cube texture as an InternalTexture
  11560. */
  11561. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11562. /**
  11563. * Update a raw cube texture
  11564. * @param texture defines the texture to udpdate
  11565. * @param data defines the data to store
  11566. * @param format defines the data format
  11567. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11568. * @param invertY defines if data must be stored with Y axis inverted
  11569. */
  11570. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11571. /**
  11572. * Update a raw cube texture
  11573. * @param texture defines the texture to udpdate
  11574. * @param data defines the data to store
  11575. * @param format defines the data format
  11576. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11577. * @param invertY defines if data must be stored with Y axis inverted
  11578. * @param compression defines the compression used (null by default)
  11579. */
  11580. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11581. /**
  11582. * Update a raw cube texture
  11583. * @param texture defines the texture to udpdate
  11584. * @param data defines the data to store
  11585. * @param format defines the data format
  11586. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11587. * @param invertY defines if data must be stored with Y axis inverted
  11588. * @param compression defines the compression used (null by default)
  11589. * @param level defines which level of the texture to update
  11590. */
  11591. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11592. /**
  11593. * Creates a new raw cube texture from a specified url
  11594. * @param url defines the url where the data is located
  11595. * @param scene defines the current scene
  11596. * @param size defines the size of the textures
  11597. * @param format defines the format of the data
  11598. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11599. * @param noMipmap defines if the engine should avoid generating the mip levels
  11600. * @param callback defines a callback used to extract texture data from loaded data
  11601. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11602. * @param onLoad defines a callback called when texture is loaded
  11603. * @param onError defines a callback called if there is an error
  11604. * @returns the cube texture as an InternalTexture
  11605. */
  11606. 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;
  11607. /**
  11608. * Creates a new raw cube texture from a specified url
  11609. * @param url defines the url where the data is located
  11610. * @param scene defines the current scene
  11611. * @param size defines the size of the textures
  11612. * @param format defines the format of the data
  11613. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11614. * @param noMipmap defines if the engine should avoid generating the mip levels
  11615. * @param callback defines a callback used to extract texture data from loaded data
  11616. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11617. * @param onLoad defines a callback called when texture is loaded
  11618. * @param onError defines a callback called if there is an error
  11619. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11620. * @param invertY defines if data must be stored with Y axis inverted
  11621. * @returns the cube texture as an InternalTexture
  11622. */
  11623. 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;
  11624. /**
  11625. * Creates a new raw 3D texture
  11626. * @param data defines the data used to create the texture
  11627. * @param width defines the width of the texture
  11628. * @param height defines the height of the texture
  11629. * @param depth defines the depth of the texture
  11630. * @param format defines the format of the texture
  11631. * @param generateMipMaps defines if the engine must generate mip levels
  11632. * @param invertY defines if data must be stored with Y axis inverted
  11633. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11634. * @param compression defines the compressed used (can be null)
  11635. * @param textureType defines the compressed used (can be null)
  11636. * @returns a new raw 3D texture (stored in an InternalTexture)
  11637. */
  11638. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11639. /**
  11640. * Update a raw 3D texture
  11641. * @param texture defines the texture to update
  11642. * @param data defines the data to store
  11643. * @param format defines the data format
  11644. * @param invertY defines if data must be stored with Y axis inverted
  11645. */
  11646. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11647. /**
  11648. * Update a raw 3D texture
  11649. * @param texture defines the texture to update
  11650. * @param data defines the data to store
  11651. * @param format defines the data format
  11652. * @param invertY defines if data must be stored with Y axis inverted
  11653. * @param compression defines the used compression (can be null)
  11654. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11655. */
  11656. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11657. /**
  11658. * Creates a new raw 2D array texture
  11659. * @param data defines the data used to create the texture
  11660. * @param width defines the width of the texture
  11661. * @param height defines the height of the texture
  11662. * @param depth defines the number of layers of the texture
  11663. * @param format defines the format of the texture
  11664. * @param generateMipMaps defines if the engine must generate mip levels
  11665. * @param invertY defines if data must be stored with Y axis inverted
  11666. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11667. * @param compression defines the compressed used (can be null)
  11668. * @param textureType defines the compressed used (can be null)
  11669. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11670. */
  11671. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11672. /**
  11673. * Update a raw 2D array texture
  11674. * @param texture defines the texture to update
  11675. * @param data defines the data to store
  11676. * @param format defines the data format
  11677. * @param invertY defines if data must be stored with Y axis inverted
  11678. */
  11679. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11680. /**
  11681. * Update a raw 2D array texture
  11682. * @param texture defines the texture to update
  11683. * @param data defines the data to store
  11684. * @param format defines the data format
  11685. * @param invertY defines if data must be stored with Y axis inverted
  11686. * @param compression defines the used compression (can be null)
  11687. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11688. */
  11689. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11690. }
  11691. }
  11692. }
  11693. declare module "babylonjs/Materials/Textures/rawTexture" {
  11694. import { Scene } from "babylonjs/scene";
  11695. import { Texture } from "babylonjs/Materials/Textures/texture";
  11696. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11697. /**
  11698. * Raw texture can help creating a texture directly from an array of data.
  11699. * This can be super useful if you either get the data from an uncompressed source or
  11700. * if you wish to create your texture pixel by pixel.
  11701. */
  11702. export class RawTexture extends Texture {
  11703. /**
  11704. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11705. */
  11706. format: number;
  11707. /**
  11708. * Instantiates a new RawTexture.
  11709. * Raw texture can help creating a texture directly from an array of data.
  11710. * This can be super useful if you either get the data from an uncompressed source or
  11711. * if you wish to create your texture pixel by pixel.
  11712. * @param data define the array of data to use to create the texture
  11713. * @param width define the width of the texture
  11714. * @param height define the height of the texture
  11715. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11716. * @param scene define the scene the texture belongs to
  11717. * @param generateMipMaps define whether mip maps should be generated or not
  11718. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11719. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11720. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11721. */
  11722. constructor(data: ArrayBufferView, width: number, height: number,
  11723. /**
  11724. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11725. */
  11726. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11727. /**
  11728. * Updates the texture underlying data.
  11729. * @param data Define the new data of the texture
  11730. */
  11731. update(data: ArrayBufferView): void;
  11732. /**
  11733. * Creates a luminance texture from some data.
  11734. * @param data Define the texture data
  11735. * @param width Define the width of the texture
  11736. * @param height Define the height of the texture
  11737. * @param scene Define the scene the texture belongs to
  11738. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11739. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11740. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11741. * @returns the luminance texture
  11742. */
  11743. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11744. /**
  11745. * Creates a luminance alpha texture from some data.
  11746. * @param data Define the texture data
  11747. * @param width Define the width of the texture
  11748. * @param height Define the height of the texture
  11749. * @param scene Define the scene the texture belongs to
  11750. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11751. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11752. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11753. * @returns the luminance alpha texture
  11754. */
  11755. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11756. /**
  11757. * Creates an alpha texture from some data.
  11758. * @param data Define the texture data
  11759. * @param width Define the width of the texture
  11760. * @param height Define the height of the texture
  11761. * @param scene Define the scene the texture belongs to
  11762. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11763. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11764. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11765. * @returns the alpha texture
  11766. */
  11767. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11768. /**
  11769. * Creates a RGB texture from some data.
  11770. * @param data Define the texture data
  11771. * @param width Define the width of the texture
  11772. * @param height Define the height of the texture
  11773. * @param scene Define the scene the texture belongs to
  11774. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11775. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11776. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11777. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11778. * @returns the RGB alpha texture
  11779. */
  11780. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11781. /**
  11782. * Creates a RGBA texture from some data.
  11783. * @param data Define the texture data
  11784. * @param width Define the width of the texture
  11785. * @param height Define the height of the texture
  11786. * @param scene Define the scene the texture belongs to
  11787. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11788. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11789. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11790. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11791. * @returns the RGBA texture
  11792. */
  11793. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11794. /**
  11795. * Creates a R texture from some data.
  11796. * @param data Define the texture data
  11797. * @param width Define the width of the texture
  11798. * @param height Define the height of the texture
  11799. * @param scene Define the scene the texture belongs to
  11800. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11801. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11802. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11803. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11804. * @returns the R texture
  11805. */
  11806. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11807. }
  11808. }
  11809. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11810. import { Scene } from "babylonjs/scene";
  11811. import { ISceneComponent } from "babylonjs/sceneComponent";
  11812. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11813. module "babylonjs/abstractScene" {
  11814. interface AbstractScene {
  11815. /**
  11816. * The list of procedural textures added to the scene
  11817. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11818. */
  11819. proceduralTextures: Array<ProceduralTexture>;
  11820. }
  11821. }
  11822. /**
  11823. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11824. * in a given scene.
  11825. */
  11826. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11827. /**
  11828. * The component name helpfull to identify the component in the list of scene components.
  11829. */
  11830. readonly name: string;
  11831. /**
  11832. * The scene the component belongs to.
  11833. */
  11834. scene: Scene;
  11835. /**
  11836. * Creates a new instance of the component for the given scene
  11837. * @param scene Defines the scene to register the component in
  11838. */
  11839. constructor(scene: Scene);
  11840. /**
  11841. * Registers the component in a given scene
  11842. */
  11843. register(): void;
  11844. /**
  11845. * Rebuilds the elements related to this component in case of
  11846. * context lost for instance.
  11847. */
  11848. rebuild(): void;
  11849. /**
  11850. * Disposes the component and the associated ressources.
  11851. */
  11852. dispose(): void;
  11853. private _beforeClear;
  11854. }
  11855. }
  11856. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11857. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11858. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11859. module "babylonjs/Engines/thinEngine" {
  11860. interface ThinEngine {
  11861. /**
  11862. * Creates a new render target cube texture
  11863. * @param size defines the size of the texture
  11864. * @param options defines the options used to create the texture
  11865. * @returns a new render target cube texture stored in an InternalTexture
  11866. */
  11867. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11868. }
  11869. }
  11870. }
  11871. declare module "babylonjs/Shaders/procedural.vertex" {
  11872. /** @hidden */
  11873. export var proceduralVertexShader: {
  11874. name: string;
  11875. shader: string;
  11876. };
  11877. }
  11878. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11879. import { Observable } from "babylonjs/Misc/observable";
  11880. import { Nullable } from "babylonjs/types";
  11881. import { Scene } from "babylonjs/scene";
  11882. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11883. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11884. import { Effect } from "babylonjs/Materials/effect";
  11885. import { Texture } from "babylonjs/Materials/Textures/texture";
  11886. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11887. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11888. import "babylonjs/Shaders/procedural.vertex";
  11889. /**
  11890. * 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.
  11891. * This is the base class of any Procedural texture and contains most of the shareable code.
  11892. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11893. */
  11894. export class ProceduralTexture extends Texture {
  11895. isCube: boolean;
  11896. /**
  11897. * Define if the texture is enabled or not (disabled texture will not render)
  11898. */
  11899. isEnabled: boolean;
  11900. /**
  11901. * Define if the texture must be cleared before rendering (default is true)
  11902. */
  11903. autoClear: boolean;
  11904. /**
  11905. * Callback called when the texture is generated
  11906. */
  11907. onGenerated: () => void;
  11908. /**
  11909. * Event raised when the texture is generated
  11910. */
  11911. onGeneratedObservable: Observable<ProceduralTexture>;
  11912. /** @hidden */
  11913. _generateMipMaps: boolean;
  11914. /** @hidden **/
  11915. _effect: Effect;
  11916. /** @hidden */
  11917. _textures: {
  11918. [key: string]: Texture;
  11919. };
  11920. /** @hidden */
  11921. protected _fallbackTexture: Nullable<Texture>;
  11922. private _size;
  11923. private _currentRefreshId;
  11924. private _frameId;
  11925. private _refreshRate;
  11926. private _vertexBuffers;
  11927. private _indexBuffer;
  11928. private _uniforms;
  11929. private _samplers;
  11930. private _fragment;
  11931. private _floats;
  11932. private _ints;
  11933. private _floatsArrays;
  11934. private _colors3;
  11935. private _colors4;
  11936. private _vectors2;
  11937. private _vectors3;
  11938. private _matrices;
  11939. private _fallbackTextureUsed;
  11940. private _fullEngine;
  11941. private _cachedDefines;
  11942. private _contentUpdateId;
  11943. private _contentData;
  11944. /**
  11945. * Instantiates a new procedural texture.
  11946. * 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.
  11947. * This is the base class of any Procedural texture and contains most of the shareable code.
  11948. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11949. * @param name Define the name of the texture
  11950. * @param size Define the size of the texture to create
  11951. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11952. * @param scene Define the scene the texture belongs to
  11953. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11954. * @param generateMipMaps Define if the texture should creates mip maps or not
  11955. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11956. */
  11957. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11958. /**
  11959. * The effect that is created when initializing the post process.
  11960. * @returns The created effect corresponding the the postprocess.
  11961. */
  11962. getEffect(): Effect;
  11963. /**
  11964. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11965. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11966. */
  11967. getContent(): Nullable<ArrayBufferView>;
  11968. private _createIndexBuffer;
  11969. /** @hidden */
  11970. _rebuild(): void;
  11971. /**
  11972. * Resets the texture in order to recreate its associated resources.
  11973. * This can be called in case of context loss
  11974. */
  11975. reset(): void;
  11976. protected _getDefines(): string;
  11977. /**
  11978. * Is the texture ready to be used ? (rendered at least once)
  11979. * @returns true if ready, otherwise, false.
  11980. */
  11981. isReady(): boolean;
  11982. /**
  11983. * Resets the refresh counter of the texture and start bak from scratch.
  11984. * Could be useful to regenerate the texture if it is setup to render only once.
  11985. */
  11986. resetRefreshCounter(): void;
  11987. /**
  11988. * Set the fragment shader to use in order to render the texture.
  11989. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11990. */
  11991. setFragment(fragment: any): void;
  11992. /**
  11993. * Define the refresh rate of the texture or the rendering frequency.
  11994. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11995. */
  11996. get refreshRate(): number;
  11997. set refreshRate(value: number);
  11998. /** @hidden */
  11999. _shouldRender(): boolean;
  12000. /**
  12001. * Get the size the texture is rendering at.
  12002. * @returns the size (texture is always squared)
  12003. */
  12004. getRenderSize(): number;
  12005. /**
  12006. * Resize the texture to new value.
  12007. * @param size Define the new size the texture should have
  12008. * @param generateMipMaps Define whether the new texture should create mip maps
  12009. */
  12010. resize(size: number, generateMipMaps: boolean): void;
  12011. private _checkUniform;
  12012. /**
  12013. * Set a texture in the shader program used to render.
  12014. * @param name Define the name of the uniform samplers as defined in the shader
  12015. * @param texture Define the texture to bind to this sampler
  12016. * @return the texture itself allowing "fluent" like uniform updates
  12017. */
  12018. setTexture(name: string, texture: Texture): ProceduralTexture;
  12019. /**
  12020. * Set a float in the shader.
  12021. * @param name Define the name of the uniform as defined in the shader
  12022. * @param value Define the value to give to the uniform
  12023. * @return the texture itself allowing "fluent" like uniform updates
  12024. */
  12025. setFloat(name: string, value: number): ProceduralTexture;
  12026. /**
  12027. * Set a int in the shader.
  12028. * @param name Define the name of the uniform as defined in the shader
  12029. * @param value Define the value to give to the uniform
  12030. * @return the texture itself allowing "fluent" like uniform updates
  12031. */
  12032. setInt(name: string, value: number): ProceduralTexture;
  12033. /**
  12034. * Set an array of floats in the shader.
  12035. * @param name Define the name of the uniform as defined in the shader
  12036. * @param value Define the value to give to the uniform
  12037. * @return the texture itself allowing "fluent" like uniform updates
  12038. */
  12039. setFloats(name: string, value: number[]): ProceduralTexture;
  12040. /**
  12041. * Set a vec3 in the shader from a Color3.
  12042. * @param name Define the name of the uniform as defined in the shader
  12043. * @param value Define the value to give to the uniform
  12044. * @return the texture itself allowing "fluent" like uniform updates
  12045. */
  12046. setColor3(name: string, value: Color3): ProceduralTexture;
  12047. /**
  12048. * Set a vec4 in the shader from a Color4.
  12049. * @param name Define the name of the uniform as defined in the shader
  12050. * @param value Define the value to give to the uniform
  12051. * @return the texture itself allowing "fluent" like uniform updates
  12052. */
  12053. setColor4(name: string, value: Color4): ProceduralTexture;
  12054. /**
  12055. * Set a vec2 in the shader from a Vector2.
  12056. * @param name Define the name of the uniform as defined in the shader
  12057. * @param value Define the value to give to the uniform
  12058. * @return the texture itself allowing "fluent" like uniform updates
  12059. */
  12060. setVector2(name: string, value: Vector2): ProceduralTexture;
  12061. /**
  12062. * Set a vec3 in the shader from a Vector3.
  12063. * @param name Define the name of the uniform as defined in the shader
  12064. * @param value Define the value to give to the uniform
  12065. * @return the texture itself allowing "fluent" like uniform updates
  12066. */
  12067. setVector3(name: string, value: Vector3): ProceduralTexture;
  12068. /**
  12069. * Set a mat4 in the shader from a MAtrix.
  12070. * @param name Define the name of the uniform as defined in the shader
  12071. * @param value Define the value to give to the uniform
  12072. * @return the texture itself allowing "fluent" like uniform updates
  12073. */
  12074. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12075. /**
  12076. * Render the texture to its associated render target.
  12077. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12078. */
  12079. render(useCameraPostProcess?: boolean): void;
  12080. /**
  12081. * Clone the texture.
  12082. * @returns the cloned texture
  12083. */
  12084. clone(): ProceduralTexture;
  12085. /**
  12086. * Dispose the texture and release its asoociated resources.
  12087. */
  12088. dispose(): void;
  12089. }
  12090. }
  12091. declare module "babylonjs/Particles/baseParticleSystem" {
  12092. import { Nullable } from "babylonjs/types";
  12093. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12095. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12096. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12097. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12098. import { Scene } from "babylonjs/scene";
  12099. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12100. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12101. import { Texture } from "babylonjs/Materials/Textures/texture";
  12102. import { Color4 } from "babylonjs/Maths/math.color";
  12103. import { Animation } from "babylonjs/Animations/animation";
  12104. /**
  12105. * This represents the base class for particle system in Babylon.
  12106. * 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.
  12107. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12108. * @example https://doc.babylonjs.com/babylon101/particles
  12109. */
  12110. export class BaseParticleSystem {
  12111. /**
  12112. * Source color is added to the destination color without alpha affecting the result
  12113. */
  12114. static BLENDMODE_ONEONE: number;
  12115. /**
  12116. * Blend current color and particle color using particle’s alpha
  12117. */
  12118. static BLENDMODE_STANDARD: number;
  12119. /**
  12120. * Add current color and particle color multiplied by particle’s alpha
  12121. */
  12122. static BLENDMODE_ADD: number;
  12123. /**
  12124. * Multiply current color with particle color
  12125. */
  12126. static BLENDMODE_MULTIPLY: number;
  12127. /**
  12128. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12129. */
  12130. static BLENDMODE_MULTIPLYADD: number;
  12131. /**
  12132. * List of animations used by the particle system.
  12133. */
  12134. animations: Animation[];
  12135. /**
  12136. * Gets or sets the unique id of the particle system
  12137. */
  12138. uniqueId: number;
  12139. /**
  12140. * The id of the Particle system.
  12141. */
  12142. id: string;
  12143. /**
  12144. * The friendly name of the Particle system.
  12145. */
  12146. name: string;
  12147. /**
  12148. * Snippet ID if the particle system was created from the snippet server
  12149. */
  12150. snippetId: string;
  12151. /**
  12152. * The rendering group used by the Particle system to chose when to render.
  12153. */
  12154. renderingGroupId: number;
  12155. /**
  12156. * The emitter represents the Mesh or position we are attaching the particle system to.
  12157. */
  12158. emitter: Nullable<AbstractMesh | Vector3>;
  12159. /**
  12160. * The maximum number of particles to emit per frame
  12161. */
  12162. emitRate: number;
  12163. /**
  12164. * If you want to launch only a few particles at once, that can be done, as well.
  12165. */
  12166. manualEmitCount: number;
  12167. /**
  12168. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12169. */
  12170. updateSpeed: number;
  12171. /**
  12172. * The amount of time the particle system is running (depends of the overall update speed).
  12173. */
  12174. targetStopDuration: number;
  12175. /**
  12176. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12177. */
  12178. disposeOnStop: boolean;
  12179. /**
  12180. * Minimum power of emitting particles.
  12181. */
  12182. minEmitPower: number;
  12183. /**
  12184. * Maximum power of emitting particles.
  12185. */
  12186. maxEmitPower: number;
  12187. /**
  12188. * Minimum life time of emitting particles.
  12189. */
  12190. minLifeTime: number;
  12191. /**
  12192. * Maximum life time of emitting particles.
  12193. */
  12194. maxLifeTime: number;
  12195. /**
  12196. * Minimum Size of emitting particles.
  12197. */
  12198. minSize: number;
  12199. /**
  12200. * Maximum Size of emitting particles.
  12201. */
  12202. maxSize: number;
  12203. /**
  12204. * Minimum scale of emitting particles on X axis.
  12205. */
  12206. minScaleX: number;
  12207. /**
  12208. * Maximum scale of emitting particles on X axis.
  12209. */
  12210. maxScaleX: number;
  12211. /**
  12212. * Minimum scale of emitting particles on Y axis.
  12213. */
  12214. minScaleY: number;
  12215. /**
  12216. * Maximum scale of emitting particles on Y axis.
  12217. */
  12218. maxScaleY: number;
  12219. /**
  12220. * Gets or sets the minimal initial rotation in radians.
  12221. */
  12222. minInitialRotation: number;
  12223. /**
  12224. * Gets or sets the maximal initial rotation in radians.
  12225. */
  12226. maxInitialRotation: number;
  12227. /**
  12228. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12229. */
  12230. minAngularSpeed: number;
  12231. /**
  12232. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12233. */
  12234. maxAngularSpeed: number;
  12235. /**
  12236. * The texture used to render each particle. (this can be a spritesheet)
  12237. */
  12238. particleTexture: Nullable<Texture>;
  12239. /**
  12240. * The layer mask we are rendering the particles through.
  12241. */
  12242. layerMask: number;
  12243. /**
  12244. * This can help using your own shader to render the particle system.
  12245. * The according effect will be created
  12246. */
  12247. customShader: any;
  12248. /**
  12249. * By default particle system starts as soon as they are created. This prevents the
  12250. * automatic start to happen and let you decide when to start emitting particles.
  12251. */
  12252. preventAutoStart: boolean;
  12253. private _noiseTexture;
  12254. /**
  12255. * Gets or sets a texture used to add random noise to particle positions
  12256. */
  12257. get noiseTexture(): Nullable<ProceduralTexture>;
  12258. set noiseTexture(value: Nullable<ProceduralTexture>);
  12259. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12260. noiseStrength: Vector3;
  12261. /**
  12262. * Callback triggered when the particle animation is ending.
  12263. */
  12264. onAnimationEnd: Nullable<() => void>;
  12265. /**
  12266. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12267. */
  12268. blendMode: number;
  12269. /**
  12270. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12271. * to override the particles.
  12272. */
  12273. forceDepthWrite: boolean;
  12274. /** 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 */
  12275. preWarmCycles: number;
  12276. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12277. preWarmStepOffset: number;
  12278. /**
  12279. * 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)
  12280. */
  12281. spriteCellChangeSpeed: number;
  12282. /**
  12283. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12284. */
  12285. startSpriteCellID: number;
  12286. /**
  12287. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12288. */
  12289. endSpriteCellID: number;
  12290. /**
  12291. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12292. */
  12293. spriteCellWidth: number;
  12294. /**
  12295. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12296. */
  12297. spriteCellHeight: number;
  12298. /**
  12299. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12300. */
  12301. spriteRandomStartCell: boolean;
  12302. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12303. translationPivot: Vector2;
  12304. /** @hidden */
  12305. protected _isAnimationSheetEnabled: boolean;
  12306. /**
  12307. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12308. */
  12309. beginAnimationOnStart: boolean;
  12310. /**
  12311. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12312. */
  12313. beginAnimationFrom: number;
  12314. /**
  12315. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12316. */
  12317. beginAnimationTo: number;
  12318. /**
  12319. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12320. */
  12321. beginAnimationLoop: boolean;
  12322. /**
  12323. * Gets or sets a world offset applied to all particles
  12324. */
  12325. worldOffset: Vector3;
  12326. /**
  12327. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12328. */
  12329. get isAnimationSheetEnabled(): boolean;
  12330. set isAnimationSheetEnabled(value: boolean);
  12331. /**
  12332. * Get hosting scene
  12333. * @returns the scene
  12334. */
  12335. getScene(): Scene;
  12336. /**
  12337. * You can use gravity if you want to give an orientation to your particles.
  12338. */
  12339. gravity: Vector3;
  12340. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12341. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12342. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12343. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12344. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12345. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12346. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12347. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12348. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12349. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12350. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12351. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12352. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12353. /**
  12354. * Defines the delay in milliseconds before starting the system (0 by default)
  12355. */
  12356. startDelay: number;
  12357. /**
  12358. * Gets the current list of drag gradients.
  12359. * You must use addDragGradient and removeDragGradient to udpate this list
  12360. * @returns the list of drag gradients
  12361. */
  12362. getDragGradients(): Nullable<Array<FactorGradient>>;
  12363. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12364. limitVelocityDamping: number;
  12365. /**
  12366. * Gets the current list of limit velocity gradients.
  12367. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12368. * @returns the list of limit velocity gradients
  12369. */
  12370. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12371. /**
  12372. * Gets the current list of color gradients.
  12373. * You must use addColorGradient and removeColorGradient to udpate this list
  12374. * @returns the list of color gradients
  12375. */
  12376. getColorGradients(): Nullable<Array<ColorGradient>>;
  12377. /**
  12378. * Gets the current list of size gradients.
  12379. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12380. * @returns the list of size gradients
  12381. */
  12382. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12383. /**
  12384. * Gets the current list of color remap gradients.
  12385. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12386. * @returns the list of color remap gradients
  12387. */
  12388. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12389. /**
  12390. * Gets the current list of alpha remap gradients.
  12391. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12392. * @returns the list of alpha remap gradients
  12393. */
  12394. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12395. /**
  12396. * Gets the current list of life time gradients.
  12397. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12398. * @returns the list of life time gradients
  12399. */
  12400. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12401. /**
  12402. * Gets the current list of angular speed gradients.
  12403. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12404. * @returns the list of angular speed gradients
  12405. */
  12406. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12407. /**
  12408. * Gets the current list of velocity gradients.
  12409. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12410. * @returns the list of velocity gradients
  12411. */
  12412. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12413. /**
  12414. * Gets the current list of start size gradients.
  12415. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12416. * @returns the list of start size gradients
  12417. */
  12418. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12419. /**
  12420. * Gets the current list of emit rate gradients.
  12421. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12422. * @returns the list of emit rate gradients
  12423. */
  12424. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12425. /**
  12426. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12427. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12428. */
  12429. get direction1(): Vector3;
  12430. set direction1(value: Vector3);
  12431. /**
  12432. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12433. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12434. */
  12435. get direction2(): Vector3;
  12436. set direction2(value: Vector3);
  12437. /**
  12438. * 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.
  12439. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12440. */
  12441. get minEmitBox(): Vector3;
  12442. set minEmitBox(value: Vector3);
  12443. /**
  12444. * 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.
  12445. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12446. */
  12447. get maxEmitBox(): Vector3;
  12448. set maxEmitBox(value: Vector3);
  12449. /**
  12450. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12451. */
  12452. color1: Color4;
  12453. /**
  12454. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12455. */
  12456. color2: Color4;
  12457. /**
  12458. * Color the particle will have at the end of its lifetime
  12459. */
  12460. colorDead: Color4;
  12461. /**
  12462. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12463. */
  12464. textureMask: Color4;
  12465. /**
  12466. * The particle emitter type defines the emitter used by the particle system.
  12467. * It can be for example box, sphere, or cone...
  12468. */
  12469. particleEmitterType: IParticleEmitterType;
  12470. /** @hidden */
  12471. _isSubEmitter: boolean;
  12472. /**
  12473. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12474. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12475. */
  12476. billboardMode: number;
  12477. protected _isBillboardBased: boolean;
  12478. /**
  12479. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12480. */
  12481. get isBillboardBased(): boolean;
  12482. set isBillboardBased(value: boolean);
  12483. /**
  12484. * The scene the particle system belongs to.
  12485. */
  12486. protected _scene: Scene;
  12487. /**
  12488. * Local cache of defines for image processing.
  12489. */
  12490. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12491. /**
  12492. * Default configuration related to image processing available in the standard Material.
  12493. */
  12494. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12495. /**
  12496. * Gets the image processing configuration used either in this material.
  12497. */
  12498. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12499. /**
  12500. * Sets the Default image processing configuration used either in the this material.
  12501. *
  12502. * If sets to null, the scene one is in use.
  12503. */
  12504. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12505. /**
  12506. * Attaches a new image processing configuration to the Standard Material.
  12507. * @param configuration
  12508. */
  12509. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12510. /** @hidden */
  12511. protected _reset(): void;
  12512. /** @hidden */
  12513. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12514. /**
  12515. * Instantiates a particle system.
  12516. * 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.
  12517. * @param name The name of the particle system
  12518. */
  12519. constructor(name: string);
  12520. /**
  12521. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12522. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12523. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12524. * @returns the emitter
  12525. */
  12526. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12527. /**
  12528. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12529. * @param radius The radius of the hemisphere to emit from
  12530. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12531. * @returns the emitter
  12532. */
  12533. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12534. /**
  12535. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12536. * @param radius The radius of the sphere to emit from
  12537. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12538. * @returns the emitter
  12539. */
  12540. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12541. /**
  12542. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12543. * @param radius The radius of the sphere to emit from
  12544. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12545. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12546. * @returns the emitter
  12547. */
  12548. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12549. /**
  12550. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12551. * @param radius The radius of the emission cylinder
  12552. * @param height The height of the emission cylinder
  12553. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12554. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12555. * @returns the emitter
  12556. */
  12557. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12558. /**
  12559. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12560. * @param radius The radius of the cylinder to emit from
  12561. * @param height The height of the emission cylinder
  12562. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12563. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12564. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12565. * @returns the emitter
  12566. */
  12567. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12568. /**
  12569. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12570. * @param radius The radius of the cone to emit from
  12571. * @param angle The base angle of the cone
  12572. * @returns the emitter
  12573. */
  12574. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12575. /**
  12576. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12577. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12578. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12579. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12580. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12581. * @returns the emitter
  12582. */
  12583. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12584. }
  12585. }
  12586. declare module "babylonjs/Particles/subEmitter" {
  12587. import { Scene } from "babylonjs/scene";
  12588. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12589. /**
  12590. * Type of sub emitter
  12591. */
  12592. export enum SubEmitterType {
  12593. /**
  12594. * Attached to the particle over it's lifetime
  12595. */
  12596. ATTACHED = 0,
  12597. /**
  12598. * Created when the particle dies
  12599. */
  12600. END = 1
  12601. }
  12602. /**
  12603. * Sub emitter class used to emit particles from an existing particle
  12604. */
  12605. export class SubEmitter {
  12606. /**
  12607. * the particle system to be used by the sub emitter
  12608. */
  12609. particleSystem: ParticleSystem;
  12610. /**
  12611. * Type of the submitter (Default: END)
  12612. */
  12613. type: SubEmitterType;
  12614. /**
  12615. * 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)
  12616. * Note: This only is supported when using an emitter of type Mesh
  12617. */
  12618. inheritDirection: boolean;
  12619. /**
  12620. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12621. */
  12622. inheritedVelocityAmount: number;
  12623. /**
  12624. * Creates a sub emitter
  12625. * @param particleSystem the particle system to be used by the sub emitter
  12626. */
  12627. constructor(
  12628. /**
  12629. * the particle system to be used by the sub emitter
  12630. */
  12631. particleSystem: ParticleSystem);
  12632. /**
  12633. * Clones the sub emitter
  12634. * @returns the cloned sub emitter
  12635. */
  12636. clone(): SubEmitter;
  12637. /**
  12638. * Serialize current object to a JSON object
  12639. * @returns the serialized object
  12640. */
  12641. serialize(): any;
  12642. /** @hidden */
  12643. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12644. /**
  12645. * Creates a new SubEmitter from a serialized JSON version
  12646. * @param serializationObject defines the JSON object to read from
  12647. * @param scene defines the hosting scene
  12648. * @param rootUrl defines the rootUrl for data loading
  12649. * @returns a new SubEmitter
  12650. */
  12651. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12652. /** Release associated resources */
  12653. dispose(): void;
  12654. }
  12655. }
  12656. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12657. /** @hidden */
  12658. export var imageProcessingDeclaration: {
  12659. name: string;
  12660. shader: string;
  12661. };
  12662. }
  12663. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12664. /** @hidden */
  12665. export var imageProcessingFunctions: {
  12666. name: string;
  12667. shader: string;
  12668. };
  12669. }
  12670. declare module "babylonjs/Shaders/particles.fragment" {
  12671. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12672. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12673. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12674. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12675. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12676. /** @hidden */
  12677. export var particlesPixelShader: {
  12678. name: string;
  12679. shader: string;
  12680. };
  12681. }
  12682. declare module "babylonjs/Shaders/particles.vertex" {
  12683. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12684. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12685. /** @hidden */
  12686. export var particlesVertexShader: {
  12687. name: string;
  12688. shader: string;
  12689. };
  12690. }
  12691. declare module "babylonjs/Particles/particleSystem" {
  12692. import { Nullable } from "babylonjs/types";
  12693. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12694. import { Observable } from "babylonjs/Misc/observable";
  12695. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12696. import { Effect } from "babylonjs/Materials/effect";
  12697. import { Scene, IDisposable } from "babylonjs/scene";
  12698. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12699. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12700. import { Particle } from "babylonjs/Particles/particle";
  12701. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12702. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12703. import "babylonjs/Shaders/particles.fragment";
  12704. import "babylonjs/Shaders/particles.vertex";
  12705. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12706. /**
  12707. * This represents a particle system in Babylon.
  12708. * 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.
  12709. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12710. * @example https://doc.babylonjs.com/babylon101/particles
  12711. */
  12712. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12713. /**
  12714. * Billboard mode will only apply to Y axis
  12715. */
  12716. static readonly BILLBOARDMODE_Y: number;
  12717. /**
  12718. * Billboard mode will apply to all axes
  12719. */
  12720. static readonly BILLBOARDMODE_ALL: number;
  12721. /**
  12722. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12723. */
  12724. static readonly BILLBOARDMODE_STRETCHED: number;
  12725. /**
  12726. * This function can be defined to provide custom update for active particles.
  12727. * This function will be called instead of regular update (age, position, color, etc.).
  12728. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12729. */
  12730. updateFunction: (particles: Particle[]) => void;
  12731. private _emitterWorldMatrix;
  12732. /**
  12733. * This function can be defined to specify initial direction for every new particle.
  12734. * It by default use the emitterType defined function
  12735. */
  12736. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12737. /**
  12738. * This function can be defined to specify initial position for every new particle.
  12739. * It by default use the emitterType defined function
  12740. */
  12741. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12742. /**
  12743. * @hidden
  12744. */
  12745. _inheritedVelocityOffset: Vector3;
  12746. /**
  12747. * An event triggered when the system is disposed
  12748. */
  12749. onDisposeObservable: Observable<IParticleSystem>;
  12750. private _onDisposeObserver;
  12751. /**
  12752. * Sets a callback that will be triggered when the system is disposed
  12753. */
  12754. set onDispose(callback: () => void);
  12755. private _particles;
  12756. private _epsilon;
  12757. private _capacity;
  12758. private _stockParticles;
  12759. private _newPartsExcess;
  12760. private _vertexData;
  12761. private _vertexBuffer;
  12762. private _vertexBuffers;
  12763. private _spriteBuffer;
  12764. private _indexBuffer;
  12765. private _effect;
  12766. private _customEffect;
  12767. private _cachedDefines;
  12768. private _scaledColorStep;
  12769. private _colorDiff;
  12770. private _scaledDirection;
  12771. private _scaledGravity;
  12772. private _currentRenderId;
  12773. private _alive;
  12774. private _useInstancing;
  12775. private _started;
  12776. private _stopped;
  12777. private _actualFrame;
  12778. private _scaledUpdateSpeed;
  12779. private _vertexBufferSize;
  12780. /** @hidden */
  12781. _currentEmitRateGradient: Nullable<FactorGradient>;
  12782. /** @hidden */
  12783. _currentEmitRate1: number;
  12784. /** @hidden */
  12785. _currentEmitRate2: number;
  12786. /** @hidden */
  12787. _currentStartSizeGradient: Nullable<FactorGradient>;
  12788. /** @hidden */
  12789. _currentStartSize1: number;
  12790. /** @hidden */
  12791. _currentStartSize2: number;
  12792. private readonly _rawTextureWidth;
  12793. private _rampGradientsTexture;
  12794. private _useRampGradients;
  12795. /** Gets or sets a boolean indicating that ramp gradients must be used
  12796. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12797. */
  12798. get useRampGradients(): boolean;
  12799. set useRampGradients(value: boolean);
  12800. /**
  12801. * 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.
  12802. * 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: [])
  12803. */
  12804. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12805. private _subEmitters;
  12806. /**
  12807. * @hidden
  12808. * If the particle systems emitter should be disposed when the particle system is disposed
  12809. */
  12810. _disposeEmitterOnDispose: boolean;
  12811. /**
  12812. * The current active Sub-systems, this property is used by the root particle system only.
  12813. */
  12814. activeSubSystems: Array<ParticleSystem>;
  12815. /**
  12816. * Specifies if the particles are updated in emitter local space or world space
  12817. */
  12818. isLocal: boolean;
  12819. private _rootParticleSystem;
  12820. /**
  12821. * Gets the current list of active particles
  12822. */
  12823. get particles(): Particle[];
  12824. /**
  12825. * Gets the number of particles active at the same time.
  12826. * @returns The number of active particles.
  12827. */
  12828. getActiveCount(): number;
  12829. /**
  12830. * Returns the string "ParticleSystem"
  12831. * @returns a string containing the class name
  12832. */
  12833. getClassName(): string;
  12834. /**
  12835. * Gets a boolean indicating that the system is stopping
  12836. * @returns true if the system is currently stopping
  12837. */
  12838. isStopping(): boolean;
  12839. /**
  12840. * Gets the custom effect used to render the particles
  12841. * @param blendMode Blend mode for which the effect should be retrieved
  12842. * @returns The effect
  12843. */
  12844. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12845. /**
  12846. * Sets the custom effect used to render the particles
  12847. * @param effect The effect to set
  12848. * @param blendMode Blend mode for which the effect should be set
  12849. */
  12850. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12851. /** @hidden */
  12852. private _onBeforeDrawParticlesObservable;
  12853. /**
  12854. * Observable that will be called just before the particles are drawn
  12855. */
  12856. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12857. /**
  12858. * Gets the name of the particle vertex shader
  12859. */
  12860. get vertexShaderName(): string;
  12861. /**
  12862. * Instantiates a particle system.
  12863. * 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.
  12864. * @param name The name of the particle system
  12865. * @param capacity The max number of particles alive at the same time
  12866. * @param scene The scene the particle system belongs to
  12867. * @param customEffect a custom effect used to change the way particles are rendered by default
  12868. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12869. * @param epsilon Offset used to render the particles
  12870. */
  12871. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12872. private _addFactorGradient;
  12873. private _removeFactorGradient;
  12874. /**
  12875. * Adds a new life time gradient
  12876. * @param gradient defines the gradient to use (between 0 and 1)
  12877. * @param factor defines the life time factor to affect to the specified gradient
  12878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12879. * @returns the current particle system
  12880. */
  12881. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12882. /**
  12883. * Remove a specific life time gradient
  12884. * @param gradient defines the gradient to remove
  12885. * @returns the current particle system
  12886. */
  12887. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12888. /**
  12889. * Adds a new size gradient
  12890. * @param gradient defines the gradient to use (between 0 and 1)
  12891. * @param factor defines the size factor to affect to the specified gradient
  12892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12893. * @returns the current particle system
  12894. */
  12895. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12896. /**
  12897. * Remove a specific size gradient
  12898. * @param gradient defines the gradient to remove
  12899. * @returns the current particle system
  12900. */
  12901. removeSizeGradient(gradient: number): IParticleSystem;
  12902. /**
  12903. * Adds a new color remap gradient
  12904. * @param gradient defines the gradient to use (between 0 and 1)
  12905. * @param min defines the color remap minimal range
  12906. * @param max defines the color remap maximal range
  12907. * @returns the current particle system
  12908. */
  12909. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12910. /**
  12911. * Remove a specific color remap gradient
  12912. * @param gradient defines the gradient to remove
  12913. * @returns the current particle system
  12914. */
  12915. removeColorRemapGradient(gradient: number): IParticleSystem;
  12916. /**
  12917. * Adds a new alpha remap gradient
  12918. * @param gradient defines the gradient to use (between 0 and 1)
  12919. * @param min defines the alpha remap minimal range
  12920. * @param max defines the alpha remap maximal range
  12921. * @returns the current particle system
  12922. */
  12923. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12924. /**
  12925. * Remove a specific alpha remap gradient
  12926. * @param gradient defines the gradient to remove
  12927. * @returns the current particle system
  12928. */
  12929. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12930. /**
  12931. * Adds a new angular speed gradient
  12932. * @param gradient defines the gradient to use (between 0 and 1)
  12933. * @param factor defines the angular speed to affect to the specified gradient
  12934. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12935. * @returns the current particle system
  12936. */
  12937. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12938. /**
  12939. * Remove a specific angular speed gradient
  12940. * @param gradient defines the gradient to remove
  12941. * @returns the current particle system
  12942. */
  12943. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12944. /**
  12945. * Adds a new velocity gradient
  12946. * @param gradient defines the gradient to use (between 0 and 1)
  12947. * @param factor defines the velocity to affect to the specified gradient
  12948. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12949. * @returns the current particle system
  12950. */
  12951. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12952. /**
  12953. * Remove a specific velocity gradient
  12954. * @param gradient defines the gradient to remove
  12955. * @returns the current particle system
  12956. */
  12957. removeVelocityGradient(gradient: number): IParticleSystem;
  12958. /**
  12959. * Adds a new limit velocity gradient
  12960. * @param gradient defines the gradient to use (between 0 and 1)
  12961. * @param factor defines the limit velocity value to affect to the specified gradient
  12962. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12963. * @returns the current particle system
  12964. */
  12965. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12966. /**
  12967. * Remove a specific limit velocity gradient
  12968. * @param gradient defines the gradient to remove
  12969. * @returns the current particle system
  12970. */
  12971. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12972. /**
  12973. * Adds a new drag gradient
  12974. * @param gradient defines the gradient to use (between 0 and 1)
  12975. * @param factor defines the drag value to affect to the specified gradient
  12976. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12977. * @returns the current particle system
  12978. */
  12979. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12980. /**
  12981. * Remove a specific drag gradient
  12982. * @param gradient defines the gradient to remove
  12983. * @returns the current particle system
  12984. */
  12985. removeDragGradient(gradient: number): IParticleSystem;
  12986. /**
  12987. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12988. * @param gradient defines the gradient to use (between 0 and 1)
  12989. * @param factor defines the emit rate value to affect to the specified gradient
  12990. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12991. * @returns the current particle system
  12992. */
  12993. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12994. /**
  12995. * Remove a specific emit rate gradient
  12996. * @param gradient defines the gradient to remove
  12997. * @returns the current particle system
  12998. */
  12999. removeEmitRateGradient(gradient: number): IParticleSystem;
  13000. /**
  13001. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13002. * @param gradient defines the gradient to use (between 0 and 1)
  13003. * @param factor defines the start size value to affect to the specified gradient
  13004. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13005. * @returns the current particle system
  13006. */
  13007. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13008. /**
  13009. * Remove a specific start size gradient
  13010. * @param gradient defines the gradient to remove
  13011. * @returns the current particle system
  13012. */
  13013. removeStartSizeGradient(gradient: number): IParticleSystem;
  13014. private _createRampGradientTexture;
  13015. /**
  13016. * Gets the current list of ramp gradients.
  13017. * You must use addRampGradient and removeRampGradient to udpate this list
  13018. * @returns the list of ramp gradients
  13019. */
  13020. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13021. /** Force the system to rebuild all gradients that need to be resync */
  13022. forceRefreshGradients(): void;
  13023. private _syncRampGradientTexture;
  13024. /**
  13025. * Adds a new ramp gradient used to remap particle colors
  13026. * @param gradient defines the gradient to use (between 0 and 1)
  13027. * @param color defines the color to affect to the specified gradient
  13028. * @returns the current particle system
  13029. */
  13030. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13031. /**
  13032. * Remove a specific ramp gradient
  13033. * @param gradient defines the gradient to remove
  13034. * @returns the current particle system
  13035. */
  13036. removeRampGradient(gradient: number): ParticleSystem;
  13037. /**
  13038. * Adds a new color gradient
  13039. * @param gradient defines the gradient to use (between 0 and 1)
  13040. * @param color1 defines the color to affect to the specified gradient
  13041. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13042. * @returns this particle system
  13043. */
  13044. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13045. /**
  13046. * Remove a specific color gradient
  13047. * @param gradient defines the gradient to remove
  13048. * @returns this particle system
  13049. */
  13050. removeColorGradient(gradient: number): IParticleSystem;
  13051. private _fetchR;
  13052. protected _reset(): void;
  13053. private _resetEffect;
  13054. private _createVertexBuffers;
  13055. private _createIndexBuffer;
  13056. /**
  13057. * Gets the maximum number of particles active at the same time.
  13058. * @returns The max number of active particles.
  13059. */
  13060. getCapacity(): number;
  13061. /**
  13062. * Gets whether there are still active particles in the system.
  13063. * @returns True if it is alive, otherwise false.
  13064. */
  13065. isAlive(): boolean;
  13066. /**
  13067. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13068. * @returns True if it has been started, otherwise false.
  13069. */
  13070. isStarted(): boolean;
  13071. private _prepareSubEmitterInternalArray;
  13072. /**
  13073. * Starts the particle system and begins to emit
  13074. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13075. */
  13076. start(delay?: number): void;
  13077. /**
  13078. * Stops the particle system.
  13079. * @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.
  13080. */
  13081. stop(stopSubEmitters?: boolean): void;
  13082. /**
  13083. * Remove all active particles
  13084. */
  13085. reset(): void;
  13086. /**
  13087. * @hidden (for internal use only)
  13088. */
  13089. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13090. /**
  13091. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13092. * Its lifetime will start back at 0.
  13093. */
  13094. recycleParticle: (particle: Particle) => void;
  13095. private _stopSubEmitters;
  13096. private _createParticle;
  13097. private _removeFromRoot;
  13098. private _emitFromParticle;
  13099. private _update;
  13100. /** @hidden */
  13101. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13102. /** @hidden */
  13103. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13104. /**
  13105. * Fill the defines array according to the current settings of the particle system
  13106. * @param defines Array to be updated
  13107. * @param blendMode blend mode to take into account when updating the array
  13108. */
  13109. fillDefines(defines: Array<string>, blendMode: number): void;
  13110. /**
  13111. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13112. * @param uniforms Uniforms array to fill
  13113. * @param attributes Attributes array to fill
  13114. * @param samplers Samplers array to fill
  13115. */
  13116. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13117. /** @hidden */
  13118. private _getEffect;
  13119. /**
  13120. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13121. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13122. */
  13123. animate(preWarmOnly?: boolean): void;
  13124. private _appendParticleVertices;
  13125. /**
  13126. * Rebuilds the particle system.
  13127. */
  13128. rebuild(): void;
  13129. /**
  13130. * Is this system ready to be used/rendered
  13131. * @return true if the system is ready
  13132. */
  13133. isReady(): boolean;
  13134. private _render;
  13135. /**
  13136. * Renders the particle system in its current state.
  13137. * @returns the current number of particles
  13138. */
  13139. render(): number;
  13140. /**
  13141. * Disposes the particle system and free the associated resources
  13142. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13143. */
  13144. dispose(disposeTexture?: boolean): void;
  13145. /**
  13146. * Clones the particle system.
  13147. * @param name The name of the cloned object
  13148. * @param newEmitter The new emitter to use
  13149. * @returns the cloned particle system
  13150. */
  13151. clone(name: string, newEmitter: any): ParticleSystem;
  13152. /**
  13153. * Serializes the particle system to a JSON object
  13154. * @param serializeTexture defines if the texture must be serialized as well
  13155. * @returns the JSON object
  13156. */
  13157. serialize(serializeTexture?: boolean): any;
  13158. /** @hidden */
  13159. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13160. /** @hidden */
  13161. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13162. /**
  13163. * Parses a JSON object to create a particle system.
  13164. * @param parsedParticleSystem The JSON object to parse
  13165. * @param scene The scene to create the particle system in
  13166. * @param rootUrl The root url to use to load external dependencies like texture
  13167. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13168. * @returns the Parsed particle system
  13169. */
  13170. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13171. }
  13172. }
  13173. declare module "babylonjs/Particles/particle" {
  13174. import { Nullable } from "babylonjs/types";
  13175. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13176. import { Color4 } from "babylonjs/Maths/math.color";
  13177. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13178. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13179. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13180. /**
  13181. * A particle represents one of the element emitted by a particle system.
  13182. * This is mainly define by its coordinates, direction, velocity and age.
  13183. */
  13184. export class Particle {
  13185. /**
  13186. * The particle system the particle belongs to.
  13187. */
  13188. particleSystem: ParticleSystem;
  13189. private static _Count;
  13190. /**
  13191. * Unique ID of the particle
  13192. */
  13193. id: number;
  13194. /**
  13195. * The world position of the particle in the scene.
  13196. */
  13197. position: Vector3;
  13198. /**
  13199. * The world direction of the particle in the scene.
  13200. */
  13201. direction: Vector3;
  13202. /**
  13203. * The color of the particle.
  13204. */
  13205. color: Color4;
  13206. /**
  13207. * The color change of the particle per step.
  13208. */
  13209. colorStep: Color4;
  13210. /**
  13211. * Defines how long will the life of the particle be.
  13212. */
  13213. lifeTime: number;
  13214. /**
  13215. * The current age of the particle.
  13216. */
  13217. age: number;
  13218. /**
  13219. * The current size of the particle.
  13220. */
  13221. size: number;
  13222. /**
  13223. * The current scale of the particle.
  13224. */
  13225. scale: Vector2;
  13226. /**
  13227. * The current angle of the particle.
  13228. */
  13229. angle: number;
  13230. /**
  13231. * Defines how fast is the angle changing.
  13232. */
  13233. angularSpeed: number;
  13234. /**
  13235. * Defines the cell index used by the particle to be rendered from a sprite.
  13236. */
  13237. cellIndex: number;
  13238. /**
  13239. * The information required to support color remapping
  13240. */
  13241. remapData: Vector4;
  13242. /** @hidden */
  13243. _randomCellOffset?: number;
  13244. /** @hidden */
  13245. _initialDirection: Nullable<Vector3>;
  13246. /** @hidden */
  13247. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13248. /** @hidden */
  13249. _initialStartSpriteCellID: number;
  13250. /** @hidden */
  13251. _initialEndSpriteCellID: number;
  13252. /** @hidden */
  13253. _currentColorGradient: Nullable<ColorGradient>;
  13254. /** @hidden */
  13255. _currentColor1: Color4;
  13256. /** @hidden */
  13257. _currentColor2: Color4;
  13258. /** @hidden */
  13259. _currentSizeGradient: Nullable<FactorGradient>;
  13260. /** @hidden */
  13261. _currentSize1: number;
  13262. /** @hidden */
  13263. _currentSize2: number;
  13264. /** @hidden */
  13265. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13266. /** @hidden */
  13267. _currentAngularSpeed1: number;
  13268. /** @hidden */
  13269. _currentAngularSpeed2: number;
  13270. /** @hidden */
  13271. _currentVelocityGradient: Nullable<FactorGradient>;
  13272. /** @hidden */
  13273. _currentVelocity1: number;
  13274. /** @hidden */
  13275. _currentVelocity2: number;
  13276. /** @hidden */
  13277. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13278. /** @hidden */
  13279. _currentLimitVelocity1: number;
  13280. /** @hidden */
  13281. _currentLimitVelocity2: number;
  13282. /** @hidden */
  13283. _currentDragGradient: Nullable<FactorGradient>;
  13284. /** @hidden */
  13285. _currentDrag1: number;
  13286. /** @hidden */
  13287. _currentDrag2: number;
  13288. /** @hidden */
  13289. _randomNoiseCoordinates1: Vector3;
  13290. /** @hidden */
  13291. _randomNoiseCoordinates2: Vector3;
  13292. /** @hidden */
  13293. _localPosition?: Vector3;
  13294. /**
  13295. * Creates a new instance Particle
  13296. * @param particleSystem the particle system the particle belongs to
  13297. */
  13298. constructor(
  13299. /**
  13300. * The particle system the particle belongs to.
  13301. */
  13302. particleSystem: ParticleSystem);
  13303. private updateCellInfoFromSystem;
  13304. /**
  13305. * Defines how the sprite cell index is updated for the particle
  13306. */
  13307. updateCellIndex(): void;
  13308. /** @hidden */
  13309. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13310. /** @hidden */
  13311. _inheritParticleInfoToSubEmitters(): void;
  13312. /** @hidden */
  13313. _reset(): void;
  13314. /**
  13315. * Copy the properties of particle to another one.
  13316. * @param other the particle to copy the information to.
  13317. */
  13318. copyTo(other: Particle): void;
  13319. }
  13320. }
  13321. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13322. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13323. import { Effect } from "babylonjs/Materials/effect";
  13324. import { Particle } from "babylonjs/Particles/particle";
  13325. import { Scene } from "babylonjs/scene";
  13326. /**
  13327. * Particle emitter represents a volume emitting particles.
  13328. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13329. */
  13330. export interface IParticleEmitterType {
  13331. /**
  13332. * Called by the particle System when the direction is computed for the created particle.
  13333. * @param worldMatrix is the world matrix of the particle system
  13334. * @param directionToUpdate is the direction vector to update with the result
  13335. * @param particle is the particle we are computed the direction for
  13336. * @param isLocal defines if the direction should be set in local space
  13337. */
  13338. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13339. /**
  13340. * Called by the particle System when the position is computed for the created particle.
  13341. * @param worldMatrix is the world matrix of the particle system
  13342. * @param positionToUpdate is the position vector to update with the result
  13343. * @param particle is the particle we are computed the position for
  13344. * @param isLocal defines if the position should be set in local space
  13345. */
  13346. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13347. /**
  13348. * Clones the current emitter and returns a copy of it
  13349. * @returns the new emitter
  13350. */
  13351. clone(): IParticleEmitterType;
  13352. /**
  13353. * Called by the GPUParticleSystem to setup the update shader
  13354. * @param effect defines the update shader
  13355. */
  13356. applyToShader(effect: Effect): void;
  13357. /**
  13358. * Returns a string to use to update the GPU particles update shader
  13359. * @returns the effect defines string
  13360. */
  13361. getEffectDefines(): string;
  13362. /**
  13363. * Returns a string representing the class name
  13364. * @returns a string containing the class name
  13365. */
  13366. getClassName(): string;
  13367. /**
  13368. * Serializes the particle system to a JSON object.
  13369. * @returns the JSON object
  13370. */
  13371. serialize(): any;
  13372. /**
  13373. * Parse properties from a JSON object
  13374. * @param serializationObject defines the JSON object
  13375. * @param scene defines the hosting scene
  13376. */
  13377. parse(serializationObject: any, scene: Scene): void;
  13378. }
  13379. }
  13380. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13381. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13382. import { Effect } from "babylonjs/Materials/effect";
  13383. import { Particle } from "babylonjs/Particles/particle";
  13384. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13385. /**
  13386. * Particle emitter emitting particles from the inside of a box.
  13387. * It emits the particles randomly between 2 given directions.
  13388. */
  13389. export class BoxParticleEmitter implements IParticleEmitterType {
  13390. /**
  13391. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13392. */
  13393. direction1: Vector3;
  13394. /**
  13395. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13396. */
  13397. direction2: Vector3;
  13398. /**
  13399. * 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.
  13400. */
  13401. minEmitBox: Vector3;
  13402. /**
  13403. * 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.
  13404. */
  13405. maxEmitBox: Vector3;
  13406. /**
  13407. * Creates a new instance BoxParticleEmitter
  13408. */
  13409. constructor();
  13410. /**
  13411. * Called by the particle System when the direction is computed for the created particle.
  13412. * @param worldMatrix is the world matrix of the particle system
  13413. * @param directionToUpdate is the direction vector to update with the result
  13414. * @param particle is the particle we are computed the direction for
  13415. * @param isLocal defines if the direction should be set in local space
  13416. */
  13417. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13418. /**
  13419. * Called by the particle System when the position is computed for the created particle.
  13420. * @param worldMatrix is the world matrix of the particle system
  13421. * @param positionToUpdate is the position vector to update with the result
  13422. * @param particle is the particle we are computed the position for
  13423. * @param isLocal defines if the position should be set in local space
  13424. */
  13425. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13426. /**
  13427. * Clones the current emitter and returns a copy of it
  13428. * @returns the new emitter
  13429. */
  13430. clone(): BoxParticleEmitter;
  13431. /**
  13432. * Called by the GPUParticleSystem to setup the update shader
  13433. * @param effect defines the update shader
  13434. */
  13435. applyToShader(effect: Effect): void;
  13436. /**
  13437. * Returns a string to use to update the GPU particles update shader
  13438. * @returns a string containng the defines string
  13439. */
  13440. getEffectDefines(): string;
  13441. /**
  13442. * Returns the string "BoxParticleEmitter"
  13443. * @returns a string containing the class name
  13444. */
  13445. getClassName(): string;
  13446. /**
  13447. * Serializes the particle system to a JSON object.
  13448. * @returns the JSON object
  13449. */
  13450. serialize(): any;
  13451. /**
  13452. * Parse properties from a JSON object
  13453. * @param serializationObject defines the JSON object
  13454. */
  13455. parse(serializationObject: any): void;
  13456. }
  13457. }
  13458. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13459. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13460. import { Effect } from "babylonjs/Materials/effect";
  13461. import { Particle } from "babylonjs/Particles/particle";
  13462. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13463. /**
  13464. * Particle emitter emitting particles from the inside of a cone.
  13465. * It emits the particles alongside the cone volume from the base to the particle.
  13466. * The emission direction might be randomized.
  13467. */
  13468. export class ConeParticleEmitter implements IParticleEmitterType {
  13469. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13470. directionRandomizer: number;
  13471. private _radius;
  13472. private _angle;
  13473. private _height;
  13474. /**
  13475. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13476. */
  13477. radiusRange: number;
  13478. /**
  13479. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13480. */
  13481. heightRange: number;
  13482. /**
  13483. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13484. */
  13485. emitFromSpawnPointOnly: boolean;
  13486. /**
  13487. * Gets or sets the radius of the emission cone
  13488. */
  13489. get radius(): number;
  13490. set radius(value: number);
  13491. /**
  13492. * Gets or sets the angle of the emission cone
  13493. */
  13494. get angle(): number;
  13495. set angle(value: number);
  13496. private _buildHeight;
  13497. /**
  13498. * Creates a new instance ConeParticleEmitter
  13499. * @param radius the radius of the emission cone (1 by default)
  13500. * @param angle the cone base angle (PI by default)
  13501. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13502. */
  13503. constructor(radius?: number, angle?: number,
  13504. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13505. directionRandomizer?: number);
  13506. /**
  13507. * Called by the particle System when the direction is computed for the created particle.
  13508. * @param worldMatrix is the world matrix of the particle system
  13509. * @param directionToUpdate is the direction vector to update with the result
  13510. * @param particle is the particle we are computed the direction for
  13511. * @param isLocal defines if the direction should be set in local space
  13512. */
  13513. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13514. /**
  13515. * Called by the particle System when the position is computed for the created particle.
  13516. * @param worldMatrix is the world matrix of the particle system
  13517. * @param positionToUpdate is the position vector to update with the result
  13518. * @param particle is the particle we are computed the position for
  13519. * @param isLocal defines if the position should be set in local space
  13520. */
  13521. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13522. /**
  13523. * Clones the current emitter and returns a copy of it
  13524. * @returns the new emitter
  13525. */
  13526. clone(): ConeParticleEmitter;
  13527. /**
  13528. * Called by the GPUParticleSystem to setup the update shader
  13529. * @param effect defines the update shader
  13530. */
  13531. applyToShader(effect: Effect): void;
  13532. /**
  13533. * Returns a string to use to update the GPU particles update shader
  13534. * @returns a string containng the defines string
  13535. */
  13536. getEffectDefines(): string;
  13537. /**
  13538. * Returns the string "ConeParticleEmitter"
  13539. * @returns a string containing the class name
  13540. */
  13541. getClassName(): string;
  13542. /**
  13543. * Serializes the particle system to a JSON object.
  13544. * @returns the JSON object
  13545. */
  13546. serialize(): any;
  13547. /**
  13548. * Parse properties from a JSON object
  13549. * @param serializationObject defines the JSON object
  13550. */
  13551. parse(serializationObject: any): void;
  13552. }
  13553. }
  13554. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13555. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13556. import { Effect } from "babylonjs/Materials/effect";
  13557. import { Particle } from "babylonjs/Particles/particle";
  13558. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13559. /**
  13560. * Particle emitter emitting particles from the inside of a cylinder.
  13561. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13562. */
  13563. export class CylinderParticleEmitter implements IParticleEmitterType {
  13564. /**
  13565. * The radius of the emission cylinder.
  13566. */
  13567. radius: number;
  13568. /**
  13569. * The height of the emission cylinder.
  13570. */
  13571. height: number;
  13572. /**
  13573. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13574. */
  13575. radiusRange: number;
  13576. /**
  13577. * How much to randomize the particle direction [0-1].
  13578. */
  13579. directionRandomizer: number;
  13580. /**
  13581. * Creates a new instance CylinderParticleEmitter
  13582. * @param radius the radius of the emission cylinder (1 by default)
  13583. * @param height the height of the emission cylinder (1 by default)
  13584. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13585. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13586. */
  13587. constructor(
  13588. /**
  13589. * The radius of the emission cylinder.
  13590. */
  13591. radius?: number,
  13592. /**
  13593. * The height of the emission cylinder.
  13594. */
  13595. height?: number,
  13596. /**
  13597. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13598. */
  13599. radiusRange?: number,
  13600. /**
  13601. * How much to randomize the particle direction [0-1].
  13602. */
  13603. directionRandomizer?: number);
  13604. /**
  13605. * Called by the particle System when the direction is computed for the created particle.
  13606. * @param worldMatrix is the world matrix of the particle system
  13607. * @param directionToUpdate is the direction vector to update with the result
  13608. * @param particle is the particle we are computed the direction for
  13609. * @param isLocal defines if the direction should be set in local space
  13610. */
  13611. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13612. /**
  13613. * Called by the particle System when the position is computed for the created particle.
  13614. * @param worldMatrix is the world matrix of the particle system
  13615. * @param positionToUpdate is the position vector to update with the result
  13616. * @param particle is the particle we are computed the position for
  13617. * @param isLocal defines if the position should be set in local space
  13618. */
  13619. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13620. /**
  13621. * Clones the current emitter and returns a copy of it
  13622. * @returns the new emitter
  13623. */
  13624. clone(): CylinderParticleEmitter;
  13625. /**
  13626. * Called by the GPUParticleSystem to setup the update shader
  13627. * @param effect defines the update shader
  13628. */
  13629. applyToShader(effect: Effect): void;
  13630. /**
  13631. * Returns a string to use to update the GPU particles update shader
  13632. * @returns a string containng the defines string
  13633. */
  13634. getEffectDefines(): string;
  13635. /**
  13636. * Returns the string "CylinderParticleEmitter"
  13637. * @returns a string containing the class name
  13638. */
  13639. getClassName(): string;
  13640. /**
  13641. * Serializes the particle system to a JSON object.
  13642. * @returns the JSON object
  13643. */
  13644. serialize(): any;
  13645. /**
  13646. * Parse properties from a JSON object
  13647. * @param serializationObject defines the JSON object
  13648. */
  13649. parse(serializationObject: any): void;
  13650. }
  13651. /**
  13652. * Particle emitter emitting particles from the inside of a cylinder.
  13653. * It emits the particles randomly between two vectors.
  13654. */
  13655. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13656. /**
  13657. * The min limit of the emission direction.
  13658. */
  13659. direction1: Vector3;
  13660. /**
  13661. * The max limit of the emission direction.
  13662. */
  13663. direction2: Vector3;
  13664. /**
  13665. * Creates a new instance CylinderDirectedParticleEmitter
  13666. * @param radius the radius of the emission cylinder (1 by default)
  13667. * @param height the height of the emission cylinder (1 by default)
  13668. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13669. * @param direction1 the min limit of the emission direction (up vector by default)
  13670. * @param direction2 the max limit of the emission direction (up vector by default)
  13671. */
  13672. constructor(radius?: number, height?: number, radiusRange?: number,
  13673. /**
  13674. * The min limit of the emission direction.
  13675. */
  13676. direction1?: Vector3,
  13677. /**
  13678. * The max limit of the emission direction.
  13679. */
  13680. direction2?: Vector3);
  13681. /**
  13682. * Called by the particle System when the direction is computed for the created particle.
  13683. * @param worldMatrix is the world matrix of the particle system
  13684. * @param directionToUpdate is the direction vector to update with the result
  13685. * @param particle is the particle we are computed the direction for
  13686. */
  13687. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13688. /**
  13689. * Clones the current emitter and returns a copy of it
  13690. * @returns the new emitter
  13691. */
  13692. clone(): CylinderDirectedParticleEmitter;
  13693. /**
  13694. * Called by the GPUParticleSystem to setup the update shader
  13695. * @param effect defines the update shader
  13696. */
  13697. applyToShader(effect: Effect): void;
  13698. /**
  13699. * Returns a string to use to update the GPU particles update shader
  13700. * @returns a string containng the defines string
  13701. */
  13702. getEffectDefines(): string;
  13703. /**
  13704. * Returns the string "CylinderDirectedParticleEmitter"
  13705. * @returns a string containing the class name
  13706. */
  13707. getClassName(): string;
  13708. /**
  13709. * Serializes the particle system to a JSON object.
  13710. * @returns the JSON object
  13711. */
  13712. serialize(): any;
  13713. /**
  13714. * Parse properties from a JSON object
  13715. * @param serializationObject defines the JSON object
  13716. */
  13717. parse(serializationObject: any): void;
  13718. }
  13719. }
  13720. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13721. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13722. import { Effect } from "babylonjs/Materials/effect";
  13723. import { Particle } from "babylonjs/Particles/particle";
  13724. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13725. /**
  13726. * Particle emitter emitting particles from the inside of a hemisphere.
  13727. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13728. */
  13729. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13730. /**
  13731. * The radius of the emission hemisphere.
  13732. */
  13733. radius: number;
  13734. /**
  13735. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13736. */
  13737. radiusRange: number;
  13738. /**
  13739. * How much to randomize the particle direction [0-1].
  13740. */
  13741. directionRandomizer: number;
  13742. /**
  13743. * Creates a new instance HemisphericParticleEmitter
  13744. * @param radius the radius of the emission hemisphere (1 by default)
  13745. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13746. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13747. */
  13748. constructor(
  13749. /**
  13750. * The radius of the emission hemisphere.
  13751. */
  13752. radius?: number,
  13753. /**
  13754. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13755. */
  13756. radiusRange?: number,
  13757. /**
  13758. * How much to randomize the particle direction [0-1].
  13759. */
  13760. directionRandomizer?: number);
  13761. /**
  13762. * Called by the particle System when the direction is computed for the created particle.
  13763. * @param worldMatrix is the world matrix of the particle system
  13764. * @param directionToUpdate is the direction vector to update with the result
  13765. * @param particle is the particle we are computed the direction for
  13766. * @param isLocal defines if the direction should be set in local space
  13767. */
  13768. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13769. /**
  13770. * Called by the particle System when the position is computed for the created particle.
  13771. * @param worldMatrix is the world matrix of the particle system
  13772. * @param positionToUpdate is the position vector to update with the result
  13773. * @param particle is the particle we are computed the position for
  13774. * @param isLocal defines if the position should be set in local space
  13775. */
  13776. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13777. /**
  13778. * Clones the current emitter and returns a copy of it
  13779. * @returns the new emitter
  13780. */
  13781. clone(): HemisphericParticleEmitter;
  13782. /**
  13783. * Called by the GPUParticleSystem to setup the update shader
  13784. * @param effect defines the update shader
  13785. */
  13786. applyToShader(effect: Effect): void;
  13787. /**
  13788. * Returns a string to use to update the GPU particles update shader
  13789. * @returns a string containng the defines string
  13790. */
  13791. getEffectDefines(): string;
  13792. /**
  13793. * Returns the string "HemisphericParticleEmitter"
  13794. * @returns a string containing the class name
  13795. */
  13796. getClassName(): string;
  13797. /**
  13798. * Serializes the particle system to a JSON object.
  13799. * @returns the JSON object
  13800. */
  13801. serialize(): any;
  13802. /**
  13803. * Parse properties from a JSON object
  13804. * @param serializationObject defines the JSON object
  13805. */
  13806. parse(serializationObject: any): void;
  13807. }
  13808. }
  13809. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13810. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13811. import { Effect } from "babylonjs/Materials/effect";
  13812. import { Particle } from "babylonjs/Particles/particle";
  13813. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13814. /**
  13815. * Particle emitter emitting particles from a point.
  13816. * It emits the particles randomly between 2 given directions.
  13817. */
  13818. export class PointParticleEmitter implements IParticleEmitterType {
  13819. /**
  13820. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13821. */
  13822. direction1: Vector3;
  13823. /**
  13824. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13825. */
  13826. direction2: Vector3;
  13827. /**
  13828. * Creates a new instance PointParticleEmitter
  13829. */
  13830. constructor();
  13831. /**
  13832. * Called by the particle System when the direction is computed for the created particle.
  13833. * @param worldMatrix is the world matrix of the particle system
  13834. * @param directionToUpdate is the direction vector to update with the result
  13835. * @param particle is the particle we are computed the direction for
  13836. * @param isLocal defines if the direction should be set in local space
  13837. */
  13838. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13839. /**
  13840. * Called by the particle System when the position is computed for the created particle.
  13841. * @param worldMatrix is the world matrix of the particle system
  13842. * @param positionToUpdate is the position vector to update with the result
  13843. * @param particle is the particle we are computed the position for
  13844. * @param isLocal defines if the position should be set in local space
  13845. */
  13846. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13847. /**
  13848. * Clones the current emitter and returns a copy of it
  13849. * @returns the new emitter
  13850. */
  13851. clone(): PointParticleEmitter;
  13852. /**
  13853. * Called by the GPUParticleSystem to setup the update shader
  13854. * @param effect defines the update shader
  13855. */
  13856. applyToShader(effect: Effect): void;
  13857. /**
  13858. * Returns a string to use to update the GPU particles update shader
  13859. * @returns a string containng the defines string
  13860. */
  13861. getEffectDefines(): string;
  13862. /**
  13863. * Returns the string "PointParticleEmitter"
  13864. * @returns a string containing the class name
  13865. */
  13866. getClassName(): string;
  13867. /**
  13868. * Serializes the particle system to a JSON object.
  13869. * @returns the JSON object
  13870. */
  13871. serialize(): any;
  13872. /**
  13873. * Parse properties from a JSON object
  13874. * @param serializationObject defines the JSON object
  13875. */
  13876. parse(serializationObject: any): void;
  13877. }
  13878. }
  13879. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13880. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13881. import { Effect } from "babylonjs/Materials/effect";
  13882. import { Particle } from "babylonjs/Particles/particle";
  13883. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13884. /**
  13885. * Particle emitter emitting particles from the inside of a sphere.
  13886. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13887. */
  13888. export class SphereParticleEmitter implements IParticleEmitterType {
  13889. /**
  13890. * The radius of the emission sphere.
  13891. */
  13892. radius: number;
  13893. /**
  13894. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13895. */
  13896. radiusRange: number;
  13897. /**
  13898. * How much to randomize the particle direction [0-1].
  13899. */
  13900. directionRandomizer: number;
  13901. /**
  13902. * Creates a new instance SphereParticleEmitter
  13903. * @param radius the radius of the emission sphere (1 by default)
  13904. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13905. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13906. */
  13907. constructor(
  13908. /**
  13909. * The radius of the emission sphere.
  13910. */
  13911. radius?: number,
  13912. /**
  13913. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13914. */
  13915. radiusRange?: number,
  13916. /**
  13917. * How much to randomize the particle direction [0-1].
  13918. */
  13919. directionRandomizer?: number);
  13920. /**
  13921. * Called by the particle System when the direction is computed for the created particle.
  13922. * @param worldMatrix is the world matrix of the particle system
  13923. * @param directionToUpdate is the direction vector to update with the result
  13924. * @param particle is the particle we are computed the direction for
  13925. * @param isLocal defines if the direction should be set in local space
  13926. */
  13927. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13928. /**
  13929. * Called by the particle System when the position is computed for the created particle.
  13930. * @param worldMatrix is the world matrix of the particle system
  13931. * @param positionToUpdate is the position vector to update with the result
  13932. * @param particle is the particle we are computed the position for
  13933. * @param isLocal defines if the position should be set in local space
  13934. */
  13935. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13936. /**
  13937. * Clones the current emitter and returns a copy of it
  13938. * @returns the new emitter
  13939. */
  13940. clone(): SphereParticleEmitter;
  13941. /**
  13942. * Called by the GPUParticleSystem to setup the update shader
  13943. * @param effect defines the update shader
  13944. */
  13945. applyToShader(effect: Effect): void;
  13946. /**
  13947. * Returns a string to use to update the GPU particles update shader
  13948. * @returns a string containng the defines string
  13949. */
  13950. getEffectDefines(): string;
  13951. /**
  13952. * Returns the string "SphereParticleEmitter"
  13953. * @returns a string containing the class name
  13954. */
  13955. getClassName(): string;
  13956. /**
  13957. * Serializes the particle system to a JSON object.
  13958. * @returns the JSON object
  13959. */
  13960. serialize(): any;
  13961. /**
  13962. * Parse properties from a JSON object
  13963. * @param serializationObject defines the JSON object
  13964. */
  13965. parse(serializationObject: any): void;
  13966. }
  13967. /**
  13968. * Particle emitter emitting particles from the inside of a sphere.
  13969. * It emits the particles randomly between two vectors.
  13970. */
  13971. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13972. /**
  13973. * The min limit of the emission direction.
  13974. */
  13975. direction1: Vector3;
  13976. /**
  13977. * The max limit of the emission direction.
  13978. */
  13979. direction2: Vector3;
  13980. /**
  13981. * Creates a new instance SphereDirectedParticleEmitter
  13982. * @param radius the radius of the emission sphere (1 by default)
  13983. * @param direction1 the min limit of the emission direction (up vector by default)
  13984. * @param direction2 the max limit of the emission direction (up vector by default)
  13985. */
  13986. constructor(radius?: number,
  13987. /**
  13988. * The min limit of the emission direction.
  13989. */
  13990. direction1?: Vector3,
  13991. /**
  13992. * The max limit of the emission direction.
  13993. */
  13994. direction2?: Vector3);
  13995. /**
  13996. * Called by the particle System when the direction is computed for the created particle.
  13997. * @param worldMatrix is the world matrix of the particle system
  13998. * @param directionToUpdate is the direction vector to update with the result
  13999. * @param particle is the particle we are computed the direction for
  14000. */
  14001. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14002. /**
  14003. * Clones the current emitter and returns a copy of it
  14004. * @returns the new emitter
  14005. */
  14006. clone(): SphereDirectedParticleEmitter;
  14007. /**
  14008. * Called by the GPUParticleSystem to setup the update shader
  14009. * @param effect defines the update shader
  14010. */
  14011. applyToShader(effect: Effect): void;
  14012. /**
  14013. * Returns a string to use to update the GPU particles update shader
  14014. * @returns a string containng the defines string
  14015. */
  14016. getEffectDefines(): string;
  14017. /**
  14018. * Returns the string "SphereDirectedParticleEmitter"
  14019. * @returns a string containing the class name
  14020. */
  14021. getClassName(): string;
  14022. /**
  14023. * Serializes the particle system to a JSON object.
  14024. * @returns the JSON object
  14025. */
  14026. serialize(): any;
  14027. /**
  14028. * Parse properties from a JSON object
  14029. * @param serializationObject defines the JSON object
  14030. */
  14031. parse(serializationObject: any): void;
  14032. }
  14033. }
  14034. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14035. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14036. import { Effect } from "babylonjs/Materials/effect";
  14037. import { Particle } from "babylonjs/Particles/particle";
  14038. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14039. import { Nullable } from "babylonjs/types";
  14040. /**
  14041. * Particle emitter emitting particles from a custom list of positions.
  14042. */
  14043. export class CustomParticleEmitter implements IParticleEmitterType {
  14044. /**
  14045. * Gets or sets the position generator that will create the inital position of each particle.
  14046. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14047. */
  14048. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14049. /**
  14050. * Gets or sets the destination generator that will create the final destination of each particle.
  14051. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14052. */
  14053. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14054. /**
  14055. * Creates a new instance CustomParticleEmitter
  14056. */
  14057. constructor();
  14058. /**
  14059. * Called by the particle System when the direction is computed for the created particle.
  14060. * @param worldMatrix is the world matrix of the particle system
  14061. * @param directionToUpdate is the direction vector to update with the result
  14062. * @param particle is the particle we are computed the direction for
  14063. * @param isLocal defines if the direction should be set in local space
  14064. */
  14065. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14066. /**
  14067. * Called by the particle System when the position is computed for the created particle.
  14068. * @param worldMatrix is the world matrix of the particle system
  14069. * @param positionToUpdate is the position vector to update with the result
  14070. * @param particle is the particle we are computed the position for
  14071. * @param isLocal defines if the position should be set in local space
  14072. */
  14073. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14074. /**
  14075. * Clones the current emitter and returns a copy of it
  14076. * @returns the new emitter
  14077. */
  14078. clone(): CustomParticleEmitter;
  14079. /**
  14080. * Called by the GPUParticleSystem to setup the update shader
  14081. * @param effect defines the update shader
  14082. */
  14083. applyToShader(effect: Effect): void;
  14084. /**
  14085. * Returns a string to use to update the GPU particles update shader
  14086. * @returns a string containng the defines string
  14087. */
  14088. getEffectDefines(): string;
  14089. /**
  14090. * Returns the string "PointParticleEmitter"
  14091. * @returns a string containing the class name
  14092. */
  14093. getClassName(): string;
  14094. /**
  14095. * Serializes the particle system to a JSON object.
  14096. * @returns the JSON object
  14097. */
  14098. serialize(): any;
  14099. /**
  14100. * Parse properties from a JSON object
  14101. * @param serializationObject defines the JSON object
  14102. */
  14103. parse(serializationObject: any): void;
  14104. }
  14105. }
  14106. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14107. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14108. import { Effect } from "babylonjs/Materials/effect";
  14109. import { Particle } from "babylonjs/Particles/particle";
  14110. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14111. import { Nullable } from "babylonjs/types";
  14112. import { Scene } from "babylonjs/scene";
  14113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14114. /**
  14115. * Particle emitter emitting particles from the inside of a box.
  14116. * It emits the particles randomly between 2 given directions.
  14117. */
  14118. export class MeshParticleEmitter implements IParticleEmitterType {
  14119. private _indices;
  14120. private _positions;
  14121. private _normals;
  14122. private _storedNormal;
  14123. private _mesh;
  14124. /**
  14125. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14126. */
  14127. direction1: Vector3;
  14128. /**
  14129. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14130. */
  14131. direction2: Vector3;
  14132. /**
  14133. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14134. */
  14135. useMeshNormalsForDirection: boolean;
  14136. /** Defines the mesh to use as source */
  14137. get mesh(): Nullable<AbstractMesh>;
  14138. set mesh(value: Nullable<AbstractMesh>);
  14139. /**
  14140. * Creates a new instance MeshParticleEmitter
  14141. * @param mesh defines the mesh to use as source
  14142. */
  14143. constructor(mesh?: Nullable<AbstractMesh>);
  14144. /**
  14145. * Called by the particle System when the direction is computed for the created particle.
  14146. * @param worldMatrix is the world matrix of the particle system
  14147. * @param directionToUpdate is the direction vector to update with the result
  14148. * @param particle is the particle we are computed the direction for
  14149. * @param isLocal defines if the direction should be set in local space
  14150. */
  14151. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14152. /**
  14153. * Called by the particle System when the position is computed for the created particle.
  14154. * @param worldMatrix is the world matrix of the particle system
  14155. * @param positionToUpdate is the position vector to update with the result
  14156. * @param particle is the particle we are computed the position for
  14157. * @param isLocal defines if the position should be set in local space
  14158. */
  14159. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14160. /**
  14161. * Clones the current emitter and returns a copy of it
  14162. * @returns the new emitter
  14163. */
  14164. clone(): MeshParticleEmitter;
  14165. /**
  14166. * Called by the GPUParticleSystem to setup the update shader
  14167. * @param effect defines the update shader
  14168. */
  14169. applyToShader(effect: Effect): void;
  14170. /**
  14171. * Returns a string to use to update the GPU particles update shader
  14172. * @returns a string containng the defines string
  14173. */
  14174. getEffectDefines(): string;
  14175. /**
  14176. * Returns the string "BoxParticleEmitter"
  14177. * @returns a string containing the class name
  14178. */
  14179. getClassName(): string;
  14180. /**
  14181. * Serializes the particle system to a JSON object.
  14182. * @returns the JSON object
  14183. */
  14184. serialize(): any;
  14185. /**
  14186. * Parse properties from a JSON object
  14187. * @param serializationObject defines the JSON object
  14188. * @param scene defines the hosting scene
  14189. */
  14190. parse(serializationObject: any, scene: Scene): void;
  14191. }
  14192. }
  14193. declare module "babylonjs/Particles/EmitterTypes/index" {
  14194. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14195. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14196. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14197. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14198. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14199. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14200. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14201. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14202. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14203. }
  14204. declare module "babylonjs/Particles/IParticleSystem" {
  14205. import { Nullable } from "babylonjs/types";
  14206. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14207. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14209. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14210. import { Texture } from "babylonjs/Materials/Textures/texture";
  14211. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14212. import { Scene } from "babylonjs/scene";
  14213. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14214. import { Effect } from "babylonjs/Materials/effect";
  14215. import { Observable } from "babylonjs/Misc/observable";
  14216. import { Animation } from "babylonjs/Animations/animation";
  14217. /**
  14218. * Interface representing a particle system in Babylon.js.
  14219. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14220. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14221. */
  14222. export interface IParticleSystem {
  14223. /**
  14224. * List of animations used by the particle system.
  14225. */
  14226. animations: Animation[];
  14227. /**
  14228. * The id of the Particle system.
  14229. */
  14230. id: string;
  14231. /**
  14232. * The name of the Particle system.
  14233. */
  14234. name: string;
  14235. /**
  14236. * The emitter represents the Mesh or position we are attaching the particle system to.
  14237. */
  14238. emitter: Nullable<AbstractMesh | Vector3>;
  14239. /**
  14240. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14241. */
  14242. isBillboardBased: boolean;
  14243. /**
  14244. * The rendering group used by the Particle system to chose when to render.
  14245. */
  14246. renderingGroupId: number;
  14247. /**
  14248. * The layer mask we are rendering the particles through.
  14249. */
  14250. layerMask: number;
  14251. /**
  14252. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14253. */
  14254. updateSpeed: number;
  14255. /**
  14256. * The amount of time the particle system is running (depends of the overall update speed).
  14257. */
  14258. targetStopDuration: number;
  14259. /**
  14260. * The texture used to render each particle. (this can be a spritesheet)
  14261. */
  14262. particleTexture: Nullable<Texture>;
  14263. /**
  14264. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14265. */
  14266. blendMode: number;
  14267. /**
  14268. * Minimum life time of emitting particles.
  14269. */
  14270. minLifeTime: number;
  14271. /**
  14272. * Maximum life time of emitting particles.
  14273. */
  14274. maxLifeTime: number;
  14275. /**
  14276. * Minimum Size of emitting particles.
  14277. */
  14278. minSize: number;
  14279. /**
  14280. * Maximum Size of emitting particles.
  14281. */
  14282. maxSize: number;
  14283. /**
  14284. * Minimum scale of emitting particles on X axis.
  14285. */
  14286. minScaleX: number;
  14287. /**
  14288. * Maximum scale of emitting particles on X axis.
  14289. */
  14290. maxScaleX: number;
  14291. /**
  14292. * Minimum scale of emitting particles on Y axis.
  14293. */
  14294. minScaleY: number;
  14295. /**
  14296. * Maximum scale of emitting particles on Y axis.
  14297. */
  14298. maxScaleY: number;
  14299. /**
  14300. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14301. */
  14302. color1: Color4;
  14303. /**
  14304. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14305. */
  14306. color2: Color4;
  14307. /**
  14308. * Color the particle will have at the end of its lifetime.
  14309. */
  14310. colorDead: Color4;
  14311. /**
  14312. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14313. */
  14314. emitRate: number;
  14315. /**
  14316. * You can use gravity if you want to give an orientation to your particles.
  14317. */
  14318. gravity: Vector3;
  14319. /**
  14320. * Minimum power of emitting particles.
  14321. */
  14322. minEmitPower: number;
  14323. /**
  14324. * Maximum power of emitting particles.
  14325. */
  14326. maxEmitPower: number;
  14327. /**
  14328. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14329. */
  14330. minAngularSpeed: number;
  14331. /**
  14332. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14333. */
  14334. maxAngularSpeed: number;
  14335. /**
  14336. * Gets or sets the minimal initial rotation in radians.
  14337. */
  14338. minInitialRotation: number;
  14339. /**
  14340. * Gets or sets the maximal initial rotation in radians.
  14341. */
  14342. maxInitialRotation: number;
  14343. /**
  14344. * The particle emitter type defines the emitter used by the particle system.
  14345. * It can be for example box, sphere, or cone...
  14346. */
  14347. particleEmitterType: Nullable<IParticleEmitterType>;
  14348. /**
  14349. * Defines the delay in milliseconds before starting the system (0 by default)
  14350. */
  14351. startDelay: number;
  14352. /**
  14353. * 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
  14354. */
  14355. preWarmCycles: number;
  14356. /**
  14357. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14358. */
  14359. preWarmStepOffset: number;
  14360. /**
  14361. * 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)
  14362. */
  14363. spriteCellChangeSpeed: number;
  14364. /**
  14365. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14366. */
  14367. startSpriteCellID: number;
  14368. /**
  14369. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14370. */
  14371. endSpriteCellID: number;
  14372. /**
  14373. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14374. */
  14375. spriteCellWidth: number;
  14376. /**
  14377. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14378. */
  14379. spriteCellHeight: number;
  14380. /**
  14381. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14382. */
  14383. spriteRandomStartCell: boolean;
  14384. /**
  14385. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14386. */
  14387. isAnimationSheetEnabled: boolean;
  14388. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14389. translationPivot: Vector2;
  14390. /**
  14391. * Gets or sets a texture used to add random noise to particle positions
  14392. */
  14393. noiseTexture: Nullable<BaseTexture>;
  14394. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14395. noiseStrength: Vector3;
  14396. /**
  14397. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14398. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14399. */
  14400. billboardMode: number;
  14401. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14402. limitVelocityDamping: number;
  14403. /**
  14404. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14405. */
  14406. beginAnimationOnStart: boolean;
  14407. /**
  14408. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14409. */
  14410. beginAnimationFrom: number;
  14411. /**
  14412. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14413. */
  14414. beginAnimationTo: number;
  14415. /**
  14416. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14417. */
  14418. beginAnimationLoop: boolean;
  14419. /**
  14420. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14421. */
  14422. disposeOnStop: boolean;
  14423. /**
  14424. * Specifies if the particles are updated in emitter local space or world space
  14425. */
  14426. isLocal: boolean;
  14427. /** Snippet ID if the particle system was created from the snippet server */
  14428. snippetId: string;
  14429. /**
  14430. * Gets the maximum number of particles active at the same time.
  14431. * @returns The max number of active particles.
  14432. */
  14433. getCapacity(): number;
  14434. /**
  14435. * Gets the number of particles active at the same time.
  14436. * @returns The number of active particles.
  14437. */
  14438. getActiveCount(): number;
  14439. /**
  14440. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14441. * @returns True if it has been started, otherwise false.
  14442. */
  14443. isStarted(): boolean;
  14444. /**
  14445. * Animates the particle system for this frame.
  14446. */
  14447. animate(): void;
  14448. /**
  14449. * Renders the particle system in its current state.
  14450. * @returns the current number of particles
  14451. */
  14452. render(): number;
  14453. /**
  14454. * Dispose the particle system and frees its associated resources.
  14455. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14456. */
  14457. dispose(disposeTexture?: boolean): void;
  14458. /**
  14459. * An event triggered when the system is disposed
  14460. */
  14461. onDisposeObservable: Observable<IParticleSystem>;
  14462. /**
  14463. * Clones the particle system.
  14464. * @param name The name of the cloned object
  14465. * @param newEmitter The new emitter to use
  14466. * @returns the cloned particle system
  14467. */
  14468. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14469. /**
  14470. * Serializes the particle system to a JSON object
  14471. * @param serializeTexture defines if the texture must be serialized as well
  14472. * @returns the JSON object
  14473. */
  14474. serialize(serializeTexture: boolean): any;
  14475. /**
  14476. * Rebuild the particle system
  14477. */
  14478. rebuild(): void;
  14479. /** Force the system to rebuild all gradients that need to be resync */
  14480. forceRefreshGradients(): void;
  14481. /**
  14482. * Starts the particle system and begins to emit
  14483. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14484. */
  14485. start(delay?: number): void;
  14486. /**
  14487. * Stops the particle system.
  14488. */
  14489. stop(): void;
  14490. /**
  14491. * Remove all active particles
  14492. */
  14493. reset(): void;
  14494. /**
  14495. * Gets a boolean indicating that the system is stopping
  14496. * @returns true if the system is currently stopping
  14497. */
  14498. isStopping(): boolean;
  14499. /**
  14500. * Is this system ready to be used/rendered
  14501. * @return true if the system is ready
  14502. */
  14503. isReady(): boolean;
  14504. /**
  14505. * Returns the string "ParticleSystem"
  14506. * @returns a string containing the class name
  14507. */
  14508. getClassName(): string;
  14509. /**
  14510. * Gets the custom effect used to render the particles
  14511. * @param blendMode Blend mode for which the effect should be retrieved
  14512. * @returns The effect
  14513. */
  14514. getCustomEffect(blendMode: number): Nullable<Effect>;
  14515. /**
  14516. * Sets the custom effect used to render the particles
  14517. * @param effect The effect to set
  14518. * @param blendMode Blend mode for which the effect should be set
  14519. */
  14520. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14521. /**
  14522. * Fill the defines array according to the current settings of the particle system
  14523. * @param defines Array to be updated
  14524. * @param blendMode blend mode to take into account when updating the array
  14525. */
  14526. fillDefines(defines: Array<string>, blendMode: number): void;
  14527. /**
  14528. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14529. * @param uniforms Uniforms array to fill
  14530. * @param attributes Attributes array to fill
  14531. * @param samplers Samplers array to fill
  14532. */
  14533. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14534. /**
  14535. * Observable that will be called just before the particles are drawn
  14536. */
  14537. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14538. /**
  14539. * Gets the name of the particle vertex shader
  14540. */
  14541. vertexShaderName: string;
  14542. /**
  14543. * Adds a new color gradient
  14544. * @param gradient defines the gradient to use (between 0 and 1)
  14545. * @param color1 defines the color to affect to the specified gradient
  14546. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14547. * @returns the current particle system
  14548. */
  14549. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14550. /**
  14551. * Remove a specific color gradient
  14552. * @param gradient defines the gradient to remove
  14553. * @returns the current particle system
  14554. */
  14555. removeColorGradient(gradient: number): IParticleSystem;
  14556. /**
  14557. * Adds a new size gradient
  14558. * @param gradient defines the gradient to use (between 0 and 1)
  14559. * @param factor defines the size factor to affect to the specified gradient
  14560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14561. * @returns the current particle system
  14562. */
  14563. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14564. /**
  14565. * Remove a specific size gradient
  14566. * @param gradient defines the gradient to remove
  14567. * @returns the current particle system
  14568. */
  14569. removeSizeGradient(gradient: number): IParticleSystem;
  14570. /**
  14571. * Gets the current list of color gradients.
  14572. * You must use addColorGradient and removeColorGradient to udpate this list
  14573. * @returns the list of color gradients
  14574. */
  14575. getColorGradients(): Nullable<Array<ColorGradient>>;
  14576. /**
  14577. * Gets the current list of size gradients.
  14578. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14579. * @returns the list of size gradients
  14580. */
  14581. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14582. /**
  14583. * Gets the current list of angular speed gradients.
  14584. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14585. * @returns the list of angular speed gradients
  14586. */
  14587. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14588. /**
  14589. * Adds a new angular speed gradient
  14590. * @param gradient defines the gradient to use (between 0 and 1)
  14591. * @param factor defines the angular speed to affect to the specified gradient
  14592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14593. * @returns the current particle system
  14594. */
  14595. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14596. /**
  14597. * Remove a specific angular speed gradient
  14598. * @param gradient defines the gradient to remove
  14599. * @returns the current particle system
  14600. */
  14601. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14602. /**
  14603. * Gets the current list of velocity gradients.
  14604. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14605. * @returns the list of velocity gradients
  14606. */
  14607. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14608. /**
  14609. * Adds a new velocity gradient
  14610. * @param gradient defines the gradient to use (between 0 and 1)
  14611. * @param factor defines the velocity to affect to the specified gradient
  14612. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14613. * @returns the current particle system
  14614. */
  14615. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14616. /**
  14617. * Remove a specific velocity gradient
  14618. * @param gradient defines the gradient to remove
  14619. * @returns the current particle system
  14620. */
  14621. removeVelocityGradient(gradient: number): IParticleSystem;
  14622. /**
  14623. * Gets the current list of limit velocity gradients.
  14624. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14625. * @returns the list of limit velocity gradients
  14626. */
  14627. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14628. /**
  14629. * Adds a new limit velocity gradient
  14630. * @param gradient defines the gradient to use (between 0 and 1)
  14631. * @param factor defines the limit velocity to affect to the specified gradient
  14632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14633. * @returns the current particle system
  14634. */
  14635. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14636. /**
  14637. * Remove a specific limit velocity gradient
  14638. * @param gradient defines the gradient to remove
  14639. * @returns the current particle system
  14640. */
  14641. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14642. /**
  14643. * Adds a new drag gradient
  14644. * @param gradient defines the gradient to use (between 0 and 1)
  14645. * @param factor defines the drag to affect to the specified gradient
  14646. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14647. * @returns the current particle system
  14648. */
  14649. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14650. /**
  14651. * Remove a specific drag gradient
  14652. * @param gradient defines the gradient to remove
  14653. * @returns the current particle system
  14654. */
  14655. removeDragGradient(gradient: number): IParticleSystem;
  14656. /**
  14657. * Gets the current list of drag gradients.
  14658. * You must use addDragGradient and removeDragGradient to udpate this list
  14659. * @returns the list of drag gradients
  14660. */
  14661. getDragGradients(): Nullable<Array<FactorGradient>>;
  14662. /**
  14663. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14664. * @param gradient defines the gradient to use (between 0 and 1)
  14665. * @param factor defines the emit rate to affect to the specified gradient
  14666. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14667. * @returns the current particle system
  14668. */
  14669. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14670. /**
  14671. * Remove a specific emit rate gradient
  14672. * @param gradient defines the gradient to remove
  14673. * @returns the current particle system
  14674. */
  14675. removeEmitRateGradient(gradient: number): IParticleSystem;
  14676. /**
  14677. * Gets the current list of emit rate gradients.
  14678. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14679. * @returns the list of emit rate gradients
  14680. */
  14681. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14682. /**
  14683. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14684. * @param gradient defines the gradient to use (between 0 and 1)
  14685. * @param factor defines the start size to affect to the specified gradient
  14686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14687. * @returns the current particle system
  14688. */
  14689. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14690. /**
  14691. * Remove a specific start size gradient
  14692. * @param gradient defines the gradient to remove
  14693. * @returns the current particle system
  14694. */
  14695. removeStartSizeGradient(gradient: number): IParticleSystem;
  14696. /**
  14697. * Gets the current list of start size gradients.
  14698. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14699. * @returns the list of start size gradients
  14700. */
  14701. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14702. /**
  14703. * Adds a new life time gradient
  14704. * @param gradient defines the gradient to use (between 0 and 1)
  14705. * @param factor defines the life time factor to affect to the specified gradient
  14706. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14707. * @returns the current particle system
  14708. */
  14709. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14710. /**
  14711. * Remove a specific life time gradient
  14712. * @param gradient defines the gradient to remove
  14713. * @returns the current particle system
  14714. */
  14715. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14716. /**
  14717. * Gets the current list of life time gradients.
  14718. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14719. * @returns the list of life time gradients
  14720. */
  14721. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14722. /**
  14723. * Gets the current list of color gradients.
  14724. * You must use addColorGradient and removeColorGradient to udpate this list
  14725. * @returns the list of color gradients
  14726. */
  14727. getColorGradients(): Nullable<Array<ColorGradient>>;
  14728. /**
  14729. * Adds a new ramp gradient used to remap particle colors
  14730. * @param gradient defines the gradient to use (between 0 and 1)
  14731. * @param color defines the color to affect to the specified gradient
  14732. * @returns the current particle system
  14733. */
  14734. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14735. /**
  14736. * Gets the current list of ramp gradients.
  14737. * You must use addRampGradient and removeRampGradient to udpate this list
  14738. * @returns the list of ramp gradients
  14739. */
  14740. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14741. /** Gets or sets a boolean indicating that ramp gradients must be used
  14742. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14743. */
  14744. useRampGradients: boolean;
  14745. /**
  14746. * Adds a new color remap gradient
  14747. * @param gradient defines the gradient to use (between 0 and 1)
  14748. * @param min defines the color remap minimal range
  14749. * @param max defines the color remap maximal range
  14750. * @returns the current particle system
  14751. */
  14752. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14753. /**
  14754. * Gets the current list of color remap gradients.
  14755. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14756. * @returns the list of color remap gradients
  14757. */
  14758. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14759. /**
  14760. * Adds a new alpha remap gradient
  14761. * @param gradient defines the gradient to use (between 0 and 1)
  14762. * @param min defines the alpha remap minimal range
  14763. * @param max defines the alpha remap maximal range
  14764. * @returns the current particle system
  14765. */
  14766. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14767. /**
  14768. * Gets the current list of alpha remap gradients.
  14769. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14770. * @returns the list of alpha remap gradients
  14771. */
  14772. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14773. /**
  14774. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14775. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14776. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14777. * @returns the emitter
  14778. */
  14779. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14780. /**
  14781. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14782. * @param radius The radius of the hemisphere to emit from
  14783. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14784. * @returns the emitter
  14785. */
  14786. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14787. /**
  14788. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14789. * @param radius The radius of the sphere to emit from
  14790. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14791. * @returns the emitter
  14792. */
  14793. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14794. /**
  14795. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14796. * @param radius The radius of the sphere to emit from
  14797. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14798. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14799. * @returns the emitter
  14800. */
  14801. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14802. /**
  14803. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14804. * @param radius The radius of the emission cylinder
  14805. * @param height The height of the emission cylinder
  14806. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14807. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14808. * @returns the emitter
  14809. */
  14810. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14811. /**
  14812. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14813. * @param radius The radius of the cylinder to emit from
  14814. * @param height The height of the emission cylinder
  14815. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14816. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14817. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14818. * @returns the emitter
  14819. */
  14820. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14821. /**
  14822. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14823. * @param radius The radius of the cone to emit from
  14824. * @param angle The base angle of the cone
  14825. * @returns the emitter
  14826. */
  14827. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14828. /**
  14829. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14830. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14831. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14832. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14833. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14834. * @returns the emitter
  14835. */
  14836. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14837. /**
  14838. * Get hosting scene
  14839. * @returns the scene
  14840. */
  14841. getScene(): Scene;
  14842. }
  14843. }
  14844. declare module "babylonjs/Meshes/transformNode" {
  14845. import { DeepImmutable } from "babylonjs/types";
  14846. import { Observable } from "babylonjs/Misc/observable";
  14847. import { Nullable } from "babylonjs/types";
  14848. import { Camera } from "babylonjs/Cameras/camera";
  14849. import { Scene } from "babylonjs/scene";
  14850. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14851. import { Node } from "babylonjs/node";
  14852. import { Bone } from "babylonjs/Bones/bone";
  14853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14854. import { Space } from "babylonjs/Maths/math.axis";
  14855. /**
  14856. * 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.
  14857. * @see https://doc.babylonjs.com/how_to/transformnode
  14858. */
  14859. export class TransformNode extends Node {
  14860. /**
  14861. * Object will not rotate to face the camera
  14862. */
  14863. static BILLBOARDMODE_NONE: number;
  14864. /**
  14865. * Object will rotate to face the camera but only on the x axis
  14866. */
  14867. static BILLBOARDMODE_X: number;
  14868. /**
  14869. * Object will rotate to face the camera but only on the y axis
  14870. */
  14871. static BILLBOARDMODE_Y: number;
  14872. /**
  14873. * Object will rotate to face the camera but only on the z axis
  14874. */
  14875. static BILLBOARDMODE_Z: number;
  14876. /**
  14877. * Object will rotate to face the camera
  14878. */
  14879. static BILLBOARDMODE_ALL: number;
  14880. /**
  14881. * Object will rotate to face the camera's position instead of orientation
  14882. */
  14883. static BILLBOARDMODE_USE_POSITION: number;
  14884. private static _TmpRotation;
  14885. private static _TmpScaling;
  14886. private static _TmpTranslation;
  14887. private _forward;
  14888. private _forwardInverted;
  14889. private _up;
  14890. private _right;
  14891. private _rightInverted;
  14892. private _position;
  14893. private _rotation;
  14894. private _rotationQuaternion;
  14895. protected _scaling: Vector3;
  14896. protected _isDirty: boolean;
  14897. private _transformToBoneReferal;
  14898. private _isAbsoluteSynced;
  14899. private _billboardMode;
  14900. /**
  14901. * Gets or sets the billboard mode. Default is 0.
  14902. *
  14903. * | Value | Type | Description |
  14904. * | --- | --- | --- |
  14905. * | 0 | BILLBOARDMODE_NONE | |
  14906. * | 1 | BILLBOARDMODE_X | |
  14907. * | 2 | BILLBOARDMODE_Y | |
  14908. * | 4 | BILLBOARDMODE_Z | |
  14909. * | 7 | BILLBOARDMODE_ALL | |
  14910. *
  14911. */
  14912. get billboardMode(): number;
  14913. set billboardMode(value: number);
  14914. private _preserveParentRotationForBillboard;
  14915. /**
  14916. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14917. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14918. */
  14919. get preserveParentRotationForBillboard(): boolean;
  14920. set preserveParentRotationForBillboard(value: boolean);
  14921. /**
  14922. * 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
  14923. */
  14924. scalingDeterminant: number;
  14925. private _infiniteDistance;
  14926. /**
  14927. * Gets or sets the distance of the object to max, often used by skybox
  14928. */
  14929. get infiniteDistance(): boolean;
  14930. set infiniteDistance(value: boolean);
  14931. /**
  14932. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14933. * By default the system will update normals to compensate
  14934. */
  14935. ignoreNonUniformScaling: boolean;
  14936. /**
  14937. * 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
  14938. */
  14939. reIntegrateRotationIntoRotationQuaternion: boolean;
  14940. /** @hidden */
  14941. _poseMatrix: Nullable<Matrix>;
  14942. /** @hidden */
  14943. _localMatrix: Matrix;
  14944. private _usePivotMatrix;
  14945. private _absolutePosition;
  14946. private _absoluteScaling;
  14947. private _absoluteRotationQuaternion;
  14948. private _pivotMatrix;
  14949. private _pivotMatrixInverse;
  14950. protected _postMultiplyPivotMatrix: boolean;
  14951. protected _isWorldMatrixFrozen: boolean;
  14952. /** @hidden */
  14953. _indexInSceneTransformNodesArray: number;
  14954. /**
  14955. * An event triggered after the world matrix is updated
  14956. */
  14957. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14958. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14959. /**
  14960. * Gets a string identifying the name of the class
  14961. * @returns "TransformNode" string
  14962. */
  14963. getClassName(): string;
  14964. /**
  14965. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14966. */
  14967. get position(): Vector3;
  14968. set position(newPosition: Vector3);
  14969. /**
  14970. * 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)).
  14971. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14972. */
  14973. get rotation(): Vector3;
  14974. set rotation(newRotation: Vector3);
  14975. /**
  14976. * 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)).
  14977. */
  14978. get scaling(): Vector3;
  14979. set scaling(newScaling: Vector3);
  14980. /**
  14981. * 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).
  14982. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14983. */
  14984. get rotationQuaternion(): Nullable<Quaternion>;
  14985. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14986. /**
  14987. * The forward direction of that transform in world space.
  14988. */
  14989. get forward(): Vector3;
  14990. /**
  14991. * The up direction of that transform in world space.
  14992. */
  14993. get up(): Vector3;
  14994. /**
  14995. * The right direction of that transform in world space.
  14996. */
  14997. get right(): Vector3;
  14998. /**
  14999. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15000. * @param matrix the matrix to copy the pose from
  15001. * @returns this TransformNode.
  15002. */
  15003. updatePoseMatrix(matrix: Matrix): TransformNode;
  15004. /**
  15005. * Returns the mesh Pose matrix.
  15006. * @returns the pose matrix
  15007. */
  15008. getPoseMatrix(): Matrix;
  15009. /** @hidden */
  15010. _isSynchronized(): boolean;
  15011. /** @hidden */
  15012. _initCache(): void;
  15013. /**
  15014. * Flag the transform node as dirty (Forcing it to update everything)
  15015. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15016. * @returns this transform node
  15017. */
  15018. markAsDirty(property: string): TransformNode;
  15019. /**
  15020. * Returns the current mesh absolute position.
  15021. * Returns a Vector3.
  15022. */
  15023. get absolutePosition(): Vector3;
  15024. /**
  15025. * Returns the current mesh absolute scaling.
  15026. * Returns a Vector3.
  15027. */
  15028. get absoluteScaling(): Vector3;
  15029. /**
  15030. * Returns the current mesh absolute rotation.
  15031. * Returns a Quaternion.
  15032. */
  15033. get absoluteRotationQuaternion(): Quaternion;
  15034. /**
  15035. * Sets a new matrix to apply before all other transformation
  15036. * @param matrix defines the transform matrix
  15037. * @returns the current TransformNode
  15038. */
  15039. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15040. /**
  15041. * Sets a new pivot matrix to the current node
  15042. * @param matrix defines the new pivot matrix to use
  15043. * @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
  15044. * @returns the current TransformNode
  15045. */
  15046. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15047. /**
  15048. * Returns the mesh pivot matrix.
  15049. * Default : Identity.
  15050. * @returns the matrix
  15051. */
  15052. getPivotMatrix(): Matrix;
  15053. /**
  15054. * Instantiate (when possible) or clone that node with its hierarchy
  15055. * @param newParent defines the new parent to use for the instance (or clone)
  15056. * @param options defines options to configure how copy is done
  15057. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15058. * @returns an instance (or a clone) of the current node with its hiearchy
  15059. */
  15060. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15061. doNotInstantiate: boolean;
  15062. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15063. /**
  15064. * Prevents the World matrix to be computed any longer
  15065. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15066. * @returns the TransformNode.
  15067. */
  15068. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15069. /**
  15070. * Allows back the World matrix computation.
  15071. * @returns the TransformNode.
  15072. */
  15073. unfreezeWorldMatrix(): this;
  15074. /**
  15075. * True if the World matrix has been frozen.
  15076. */
  15077. get isWorldMatrixFrozen(): boolean;
  15078. /**
  15079. * Retuns the mesh absolute position in the World.
  15080. * @returns a Vector3.
  15081. */
  15082. getAbsolutePosition(): Vector3;
  15083. /**
  15084. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15085. * @param absolutePosition the absolute position to set
  15086. * @returns the TransformNode.
  15087. */
  15088. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15089. /**
  15090. * Sets the mesh position in its local space.
  15091. * @param vector3 the position to set in localspace
  15092. * @returns the TransformNode.
  15093. */
  15094. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15095. /**
  15096. * Returns the mesh position in the local space from the current World matrix values.
  15097. * @returns a new Vector3.
  15098. */
  15099. getPositionExpressedInLocalSpace(): Vector3;
  15100. /**
  15101. * Translates the mesh along the passed Vector3 in its local space.
  15102. * @param vector3 the distance to translate in localspace
  15103. * @returns the TransformNode.
  15104. */
  15105. locallyTranslate(vector3: Vector3): TransformNode;
  15106. private static _lookAtVectorCache;
  15107. /**
  15108. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15109. * @param targetPoint the position (must be in same space as current mesh) to look at
  15110. * @param yawCor optional yaw (y-axis) correction in radians
  15111. * @param pitchCor optional pitch (x-axis) correction in radians
  15112. * @param rollCor optional roll (z-axis) correction in radians
  15113. * @param space the choosen space of the target
  15114. * @returns the TransformNode.
  15115. */
  15116. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15117. /**
  15118. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15119. * This Vector3 is expressed in the World space.
  15120. * @param localAxis axis to rotate
  15121. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15122. */
  15123. getDirection(localAxis: Vector3): Vector3;
  15124. /**
  15125. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15126. * localAxis is expressed in the mesh local space.
  15127. * result is computed in the Wordl space from the mesh World matrix.
  15128. * @param localAxis axis to rotate
  15129. * @param result the resulting transformnode
  15130. * @returns this TransformNode.
  15131. */
  15132. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15133. /**
  15134. * Sets this transform node rotation to the given local axis.
  15135. * @param localAxis the axis in local space
  15136. * @param yawCor optional yaw (y-axis) correction in radians
  15137. * @param pitchCor optional pitch (x-axis) correction in radians
  15138. * @param rollCor optional roll (z-axis) correction in radians
  15139. * @returns this TransformNode
  15140. */
  15141. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15142. /**
  15143. * Sets a new pivot point to the current node
  15144. * @param point defines the new pivot point to use
  15145. * @param space defines if the point is in world or local space (local by default)
  15146. * @returns the current TransformNode
  15147. */
  15148. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15149. /**
  15150. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15151. * @returns the pivot point
  15152. */
  15153. getPivotPoint(): Vector3;
  15154. /**
  15155. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15156. * @param result the vector3 to store the result
  15157. * @returns this TransformNode.
  15158. */
  15159. getPivotPointToRef(result: Vector3): TransformNode;
  15160. /**
  15161. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15162. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15163. */
  15164. getAbsolutePivotPoint(): Vector3;
  15165. /**
  15166. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15167. * @param result vector3 to store the result
  15168. * @returns this TransformNode.
  15169. */
  15170. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15171. /**
  15172. * Defines the passed node as the parent of the current node.
  15173. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15174. * @see https://doc.babylonjs.com/how_to/parenting
  15175. * @param node the node ot set as the parent
  15176. * @returns this TransformNode.
  15177. */
  15178. setParent(node: Nullable<Node>): TransformNode;
  15179. private _nonUniformScaling;
  15180. /**
  15181. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15182. */
  15183. get nonUniformScaling(): boolean;
  15184. /** @hidden */
  15185. _updateNonUniformScalingState(value: boolean): boolean;
  15186. /**
  15187. * Attach the current TransformNode to another TransformNode associated with a bone
  15188. * @param bone Bone affecting the TransformNode
  15189. * @param affectedTransformNode TransformNode associated with the bone
  15190. * @returns this object
  15191. */
  15192. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15193. /**
  15194. * Detach the transform node if its associated with a bone
  15195. * @returns this object
  15196. */
  15197. detachFromBone(): TransformNode;
  15198. private static _rotationAxisCache;
  15199. /**
  15200. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15201. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15202. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15203. * The passed axis is also normalized.
  15204. * @param axis the axis to rotate around
  15205. * @param amount the amount to rotate in radians
  15206. * @param space Space to rotate in (Default: local)
  15207. * @returns the TransformNode.
  15208. */
  15209. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15210. /**
  15211. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15212. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15213. * The passed axis is also normalized. .
  15214. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15215. * @param point the point to rotate around
  15216. * @param axis the axis to rotate around
  15217. * @param amount the amount to rotate in radians
  15218. * @returns the TransformNode
  15219. */
  15220. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15221. /**
  15222. * Translates the mesh along the axis vector for the passed distance in the given space.
  15223. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15224. * @param axis the axis to translate in
  15225. * @param distance the distance to translate
  15226. * @param space Space to rotate in (Default: local)
  15227. * @returns the TransformNode.
  15228. */
  15229. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15230. /**
  15231. * Adds a rotation step to the mesh current rotation.
  15232. * x, y, z are Euler angles expressed in radians.
  15233. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15234. * This means this rotation is made in the mesh local space only.
  15235. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15236. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15237. * ```javascript
  15238. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15239. * ```
  15240. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15241. * 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.
  15242. * @param x Rotation to add
  15243. * @param y Rotation to add
  15244. * @param z Rotation to add
  15245. * @returns the TransformNode.
  15246. */
  15247. addRotation(x: number, y: number, z: number): TransformNode;
  15248. /**
  15249. * @hidden
  15250. */
  15251. protected _getEffectiveParent(): Nullable<Node>;
  15252. /**
  15253. * Computes the world matrix of the node
  15254. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15255. * @returns the world matrix
  15256. */
  15257. computeWorldMatrix(force?: boolean): Matrix;
  15258. /**
  15259. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15260. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15261. */
  15262. resetLocalMatrix(independentOfChildren?: boolean): void;
  15263. protected _afterComputeWorldMatrix(): void;
  15264. /**
  15265. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15266. * @param func callback function to add
  15267. *
  15268. * @returns the TransformNode.
  15269. */
  15270. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15271. /**
  15272. * Removes a registered callback function.
  15273. * @param func callback function to remove
  15274. * @returns the TransformNode.
  15275. */
  15276. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15277. /**
  15278. * Gets the position of the current mesh in camera space
  15279. * @param camera defines the camera to use
  15280. * @returns a position
  15281. */
  15282. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15283. /**
  15284. * Returns the distance from the mesh to the active camera
  15285. * @param camera defines the camera to use
  15286. * @returns the distance
  15287. */
  15288. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15289. /**
  15290. * Clone the current transform node
  15291. * @param name Name of the new clone
  15292. * @param newParent New parent for the clone
  15293. * @param doNotCloneChildren Do not clone children hierarchy
  15294. * @returns the new transform node
  15295. */
  15296. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15297. /**
  15298. * Serializes the objects information.
  15299. * @param currentSerializationObject defines the object to serialize in
  15300. * @returns the serialized object
  15301. */
  15302. serialize(currentSerializationObject?: any): any;
  15303. /**
  15304. * Returns a new TransformNode object parsed from the source provided.
  15305. * @param parsedTransformNode is the source.
  15306. * @param scene the scne the object belongs to
  15307. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15308. * @returns a new TransformNode object parsed from the source provided.
  15309. */
  15310. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15311. /**
  15312. * Get all child-transformNodes of this node
  15313. * @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
  15314. * @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
  15315. * @returns an array of TransformNode
  15316. */
  15317. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15318. /**
  15319. * Releases resources associated with this transform node.
  15320. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15321. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15322. */
  15323. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15324. /**
  15325. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15326. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15327. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15328. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15329. * @returns the current mesh
  15330. */
  15331. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15332. private _syncAbsoluteScalingAndRotation;
  15333. }
  15334. }
  15335. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15336. /**
  15337. * Class used to override all child animations of a given target
  15338. */
  15339. export class AnimationPropertiesOverride {
  15340. /**
  15341. * Gets or sets a value indicating if animation blending must be used
  15342. */
  15343. enableBlending: boolean;
  15344. /**
  15345. * Gets or sets the blending speed to use when enableBlending is true
  15346. */
  15347. blendingSpeed: number;
  15348. /**
  15349. * Gets or sets the default loop mode to use
  15350. */
  15351. loopMode: number;
  15352. }
  15353. }
  15354. declare module "babylonjs/Bones/bone" {
  15355. import { Skeleton } from "babylonjs/Bones/skeleton";
  15356. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15357. import { Nullable } from "babylonjs/types";
  15358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15359. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15360. import { Node } from "babylonjs/node";
  15361. import { Space } from "babylonjs/Maths/math.axis";
  15362. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15363. /**
  15364. * Class used to store bone information
  15365. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15366. */
  15367. export class Bone extends Node {
  15368. /**
  15369. * defines the bone name
  15370. */
  15371. name: string;
  15372. private static _tmpVecs;
  15373. private static _tmpQuat;
  15374. private static _tmpMats;
  15375. /**
  15376. * Gets the list of child bones
  15377. */
  15378. children: Bone[];
  15379. /** Gets the animations associated with this bone */
  15380. animations: import("babylonjs/Animations/animation").Animation[];
  15381. /**
  15382. * Gets or sets bone length
  15383. */
  15384. length: number;
  15385. /**
  15386. * @hidden Internal only
  15387. * Set this value to map this bone to a different index in the transform matrices
  15388. * Set this value to -1 to exclude the bone from the transform matrices
  15389. */
  15390. _index: Nullable<number>;
  15391. private _skeleton;
  15392. private _localMatrix;
  15393. private _restPose;
  15394. private _baseMatrix;
  15395. private _absoluteTransform;
  15396. private _invertedAbsoluteTransform;
  15397. private _parent;
  15398. private _scalingDeterminant;
  15399. private _worldTransform;
  15400. private _localScaling;
  15401. private _localRotation;
  15402. private _localPosition;
  15403. private _needToDecompose;
  15404. private _needToCompose;
  15405. /** @hidden */
  15406. _linkedTransformNode: Nullable<TransformNode>;
  15407. /** @hidden */
  15408. _waitingTransformNodeId: Nullable<string>;
  15409. /** @hidden */
  15410. get _matrix(): Matrix;
  15411. /** @hidden */
  15412. set _matrix(value: Matrix);
  15413. /**
  15414. * Create a new bone
  15415. * @param name defines the bone name
  15416. * @param skeleton defines the parent skeleton
  15417. * @param parentBone defines the parent (can be null if the bone is the root)
  15418. * @param localMatrix defines the local matrix
  15419. * @param restPose defines the rest pose matrix
  15420. * @param baseMatrix defines the base matrix
  15421. * @param index defines index of the bone in the hiearchy
  15422. */
  15423. constructor(
  15424. /**
  15425. * defines the bone name
  15426. */
  15427. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15428. /**
  15429. * Gets the current object class name.
  15430. * @return the class name
  15431. */
  15432. getClassName(): string;
  15433. /**
  15434. * Gets the parent skeleton
  15435. * @returns a skeleton
  15436. */
  15437. getSkeleton(): Skeleton;
  15438. /**
  15439. * Gets parent bone
  15440. * @returns a bone or null if the bone is the root of the bone hierarchy
  15441. */
  15442. getParent(): Nullable<Bone>;
  15443. /**
  15444. * Returns an array containing the root bones
  15445. * @returns an array containing the root bones
  15446. */
  15447. getChildren(): Array<Bone>;
  15448. /**
  15449. * Gets the node index in matrix array generated for rendering
  15450. * @returns the node index
  15451. */
  15452. getIndex(): number;
  15453. /**
  15454. * Sets the parent bone
  15455. * @param parent defines the parent (can be null if the bone is the root)
  15456. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15457. */
  15458. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15459. /**
  15460. * Gets the local matrix
  15461. * @returns a matrix
  15462. */
  15463. getLocalMatrix(): Matrix;
  15464. /**
  15465. * Gets the base matrix (initial matrix which remains unchanged)
  15466. * @returns a matrix
  15467. */
  15468. getBaseMatrix(): Matrix;
  15469. /**
  15470. * Gets the rest pose matrix
  15471. * @returns a matrix
  15472. */
  15473. getRestPose(): Matrix;
  15474. /**
  15475. * Sets the rest pose matrix
  15476. * @param matrix the local-space rest pose to set for this bone
  15477. */
  15478. setRestPose(matrix: Matrix): void;
  15479. /**
  15480. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15481. */
  15482. getWorldMatrix(): Matrix;
  15483. /**
  15484. * Sets the local matrix to rest pose matrix
  15485. */
  15486. returnToRest(): void;
  15487. /**
  15488. * Gets the inverse of the absolute transform matrix.
  15489. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15490. * @returns a matrix
  15491. */
  15492. getInvertedAbsoluteTransform(): Matrix;
  15493. /**
  15494. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15495. * @returns a matrix
  15496. */
  15497. getAbsoluteTransform(): Matrix;
  15498. /**
  15499. * Links with the given transform node.
  15500. * The local matrix of this bone is copied from the transform node every frame.
  15501. * @param transformNode defines the transform node to link to
  15502. */
  15503. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15504. /**
  15505. * Gets the node used to drive the bone's transformation
  15506. * @returns a transform node or null
  15507. */
  15508. getTransformNode(): Nullable<TransformNode>;
  15509. /** Gets or sets current position (in local space) */
  15510. get position(): Vector3;
  15511. set position(newPosition: Vector3);
  15512. /** Gets or sets current rotation (in local space) */
  15513. get rotation(): Vector3;
  15514. set rotation(newRotation: Vector3);
  15515. /** Gets or sets current rotation quaternion (in local space) */
  15516. get rotationQuaternion(): Quaternion;
  15517. set rotationQuaternion(newRotation: Quaternion);
  15518. /** Gets or sets current scaling (in local space) */
  15519. get scaling(): Vector3;
  15520. set scaling(newScaling: Vector3);
  15521. /**
  15522. * Gets the animation properties override
  15523. */
  15524. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15525. private _decompose;
  15526. private _compose;
  15527. /**
  15528. * Update the base and local matrices
  15529. * @param matrix defines the new base or local matrix
  15530. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15531. * @param updateLocalMatrix defines if the local matrix should be updated
  15532. */
  15533. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15534. /** @hidden */
  15535. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15536. /**
  15537. * Flag the bone as dirty (Forcing it to update everything)
  15538. */
  15539. markAsDirty(): void;
  15540. /** @hidden */
  15541. _markAsDirtyAndCompose(): void;
  15542. private _markAsDirtyAndDecompose;
  15543. /**
  15544. * Translate the bone in local or world space
  15545. * @param vec The amount to translate the bone
  15546. * @param space The space that the translation is in
  15547. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15548. */
  15549. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15550. /**
  15551. * Set the postion of the bone in local or world space
  15552. * @param position The position to set the bone
  15553. * @param space The space that the position is in
  15554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15555. */
  15556. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15557. /**
  15558. * Set the absolute position of the bone (world space)
  15559. * @param position The position to set the bone
  15560. * @param mesh The mesh that this bone is attached to
  15561. */
  15562. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15563. /**
  15564. * Scale the bone on the x, y and z axes (in local space)
  15565. * @param x The amount to scale the bone on the x axis
  15566. * @param y The amount to scale the bone on the y axis
  15567. * @param z The amount to scale the bone on the z axis
  15568. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15569. */
  15570. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15571. /**
  15572. * Set the bone scaling in local space
  15573. * @param scale defines the scaling vector
  15574. */
  15575. setScale(scale: Vector3): void;
  15576. /**
  15577. * Gets the current scaling in local space
  15578. * @returns the current scaling vector
  15579. */
  15580. getScale(): Vector3;
  15581. /**
  15582. * Gets the current scaling in local space and stores it in a target vector
  15583. * @param result defines the target vector
  15584. */
  15585. getScaleToRef(result: Vector3): void;
  15586. /**
  15587. * Set the yaw, pitch, and roll of the bone in local or world space
  15588. * @param yaw The rotation of the bone on the y axis
  15589. * @param pitch The rotation of the bone on the x axis
  15590. * @param roll The rotation of the bone on the z axis
  15591. * @param space The space that the axes of rotation are in
  15592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15593. */
  15594. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15595. /**
  15596. * Add a rotation to the bone on an axis in local or world space
  15597. * @param axis The axis to rotate the bone on
  15598. * @param amount The amount to rotate the bone
  15599. * @param space The space that the axis is in
  15600. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15601. */
  15602. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15603. /**
  15604. * Set the rotation of the bone to a particular axis angle in local or world space
  15605. * @param axis The axis to rotate the bone on
  15606. * @param angle The angle that the bone should be rotated to
  15607. * @param space The space that the axis is in
  15608. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15609. */
  15610. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15611. /**
  15612. * Set the euler rotation of the bone in local of world space
  15613. * @param rotation The euler rotation that the bone should be set to
  15614. * @param space The space that the rotation is in
  15615. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15616. */
  15617. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15618. /**
  15619. * Set the quaternion rotation of the bone in local of world space
  15620. * @param quat The quaternion rotation that the bone should be set to
  15621. * @param space The space that the rotation is in
  15622. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15623. */
  15624. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15625. /**
  15626. * Set the rotation matrix of the bone in local of world space
  15627. * @param rotMat The rotation matrix that the bone should be set to
  15628. * @param space The space that the rotation is in
  15629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15630. */
  15631. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15632. private _rotateWithMatrix;
  15633. private _getNegativeRotationToRef;
  15634. /**
  15635. * Get the position of the bone in local or world space
  15636. * @param space The space that the returned position is in
  15637. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15638. * @returns The position of the bone
  15639. */
  15640. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15641. /**
  15642. * Copy the position of the bone to a vector3 in local or world space
  15643. * @param space The space that the returned position is in
  15644. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15645. * @param result The vector3 to copy the position to
  15646. */
  15647. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15648. /**
  15649. * Get the absolute position of the bone (world space)
  15650. * @param mesh The mesh that this bone is attached to
  15651. * @returns The absolute position of the bone
  15652. */
  15653. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15654. /**
  15655. * Copy the absolute position of the bone (world space) to the result param
  15656. * @param mesh The mesh that this bone is attached to
  15657. * @param result The vector3 to copy the absolute position to
  15658. */
  15659. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15660. /**
  15661. * Compute the absolute transforms of this bone and its children
  15662. */
  15663. computeAbsoluteTransforms(): void;
  15664. /**
  15665. * Get the world direction from an axis that is in the local space of the bone
  15666. * @param localAxis The local direction that is used to compute the world direction
  15667. * @param mesh The mesh that this bone is attached to
  15668. * @returns The world direction
  15669. */
  15670. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15671. /**
  15672. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15673. * @param localAxis The local direction that is used to compute the world direction
  15674. * @param mesh The mesh that this bone is attached to
  15675. * @param result The vector3 that the world direction will be copied to
  15676. */
  15677. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15678. /**
  15679. * Get the euler rotation of the bone in local or world space
  15680. * @param space The space that the rotation should be in
  15681. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15682. * @returns The euler rotation
  15683. */
  15684. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15685. /**
  15686. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15687. * @param space The space that the rotation should be in
  15688. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15689. * @param result The vector3 that the rotation should be copied to
  15690. */
  15691. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15692. /**
  15693. * Get the quaternion rotation of the bone in either local or world space
  15694. * @param space The space that the rotation should be in
  15695. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15696. * @returns The quaternion rotation
  15697. */
  15698. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15699. /**
  15700. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15701. * @param space The space that the rotation should be in
  15702. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15703. * @param result The quaternion that the rotation should be copied to
  15704. */
  15705. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15706. /**
  15707. * Get the rotation matrix of the bone in local or world space
  15708. * @param space The space that the rotation should be in
  15709. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15710. * @returns The rotation matrix
  15711. */
  15712. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15713. /**
  15714. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15715. * @param space The space that the rotation should be in
  15716. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15717. * @param result The quaternion that the rotation should be copied to
  15718. */
  15719. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15720. /**
  15721. * Get the world position of a point that is in the local space of the bone
  15722. * @param position The local position
  15723. * @param mesh The mesh that this bone is attached to
  15724. * @returns The world position
  15725. */
  15726. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15727. /**
  15728. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15729. * @param position The local position
  15730. * @param mesh The mesh that this bone is attached to
  15731. * @param result The vector3 that the world position should be copied to
  15732. */
  15733. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15734. /**
  15735. * Get the local position of a point that is in world space
  15736. * @param position The world position
  15737. * @param mesh The mesh that this bone is attached to
  15738. * @returns The local position
  15739. */
  15740. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15741. /**
  15742. * Get the local position of a point that is in world space and copy it to the result param
  15743. * @param position The world position
  15744. * @param mesh The mesh that this bone is attached to
  15745. * @param result The vector3 that the local position should be copied to
  15746. */
  15747. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15748. }
  15749. }
  15750. declare module "babylonjs/Animations/runtimeAnimation" {
  15751. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15752. import { Animatable } from "babylonjs/Animations/animatable";
  15753. import { Scene } from "babylonjs/scene";
  15754. /**
  15755. * Defines a runtime animation
  15756. */
  15757. export class RuntimeAnimation {
  15758. private _events;
  15759. /**
  15760. * The current frame of the runtime animation
  15761. */
  15762. private _currentFrame;
  15763. /**
  15764. * The animation used by the runtime animation
  15765. */
  15766. private _animation;
  15767. /**
  15768. * The target of the runtime animation
  15769. */
  15770. private _target;
  15771. /**
  15772. * The initiating animatable
  15773. */
  15774. private _host;
  15775. /**
  15776. * The original value of the runtime animation
  15777. */
  15778. private _originalValue;
  15779. /**
  15780. * The original blend value of the runtime animation
  15781. */
  15782. private _originalBlendValue;
  15783. /**
  15784. * The offsets cache of the runtime animation
  15785. */
  15786. private _offsetsCache;
  15787. /**
  15788. * The high limits cache of the runtime animation
  15789. */
  15790. private _highLimitsCache;
  15791. /**
  15792. * Specifies if the runtime animation has been stopped
  15793. */
  15794. private _stopped;
  15795. /**
  15796. * The blending factor of the runtime animation
  15797. */
  15798. private _blendingFactor;
  15799. /**
  15800. * The BabylonJS scene
  15801. */
  15802. private _scene;
  15803. /**
  15804. * The current value of the runtime animation
  15805. */
  15806. private _currentValue;
  15807. /** @hidden */
  15808. _animationState: _IAnimationState;
  15809. /**
  15810. * The active target of the runtime animation
  15811. */
  15812. private _activeTargets;
  15813. private _currentActiveTarget;
  15814. private _directTarget;
  15815. /**
  15816. * The target path of the runtime animation
  15817. */
  15818. private _targetPath;
  15819. /**
  15820. * The weight of the runtime animation
  15821. */
  15822. private _weight;
  15823. /**
  15824. * The ratio offset of the runtime animation
  15825. */
  15826. private _ratioOffset;
  15827. /**
  15828. * The previous delay of the runtime animation
  15829. */
  15830. private _previousDelay;
  15831. /**
  15832. * The previous ratio of the runtime animation
  15833. */
  15834. private _previousRatio;
  15835. private _enableBlending;
  15836. private _keys;
  15837. private _minFrame;
  15838. private _maxFrame;
  15839. private _minValue;
  15840. private _maxValue;
  15841. private _targetIsArray;
  15842. /**
  15843. * Gets the current frame of the runtime animation
  15844. */
  15845. get currentFrame(): number;
  15846. /**
  15847. * Gets the weight of the runtime animation
  15848. */
  15849. get weight(): number;
  15850. /**
  15851. * Gets the current value of the runtime animation
  15852. */
  15853. get currentValue(): any;
  15854. /**
  15855. * Gets the target path of the runtime animation
  15856. */
  15857. get targetPath(): string;
  15858. /**
  15859. * Gets the actual target of the runtime animation
  15860. */
  15861. get target(): any;
  15862. /**
  15863. * Gets the additive state of the runtime animation
  15864. */
  15865. get isAdditive(): boolean;
  15866. /** @hidden */
  15867. _onLoop: () => void;
  15868. /**
  15869. * Create a new RuntimeAnimation object
  15870. * @param target defines the target of the animation
  15871. * @param animation defines the source animation object
  15872. * @param scene defines the hosting scene
  15873. * @param host defines the initiating Animatable
  15874. */
  15875. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15876. private _preparePath;
  15877. /**
  15878. * Gets the animation from the runtime animation
  15879. */
  15880. get animation(): Animation;
  15881. /**
  15882. * Resets the runtime animation to the beginning
  15883. * @param restoreOriginal defines whether to restore the target property to the original value
  15884. */
  15885. reset(restoreOriginal?: boolean): void;
  15886. /**
  15887. * Specifies if the runtime animation is stopped
  15888. * @returns Boolean specifying if the runtime animation is stopped
  15889. */
  15890. isStopped(): boolean;
  15891. /**
  15892. * Disposes of the runtime animation
  15893. */
  15894. dispose(): void;
  15895. /**
  15896. * Apply the interpolated value to the target
  15897. * @param currentValue defines the value computed by the animation
  15898. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15899. */
  15900. setValue(currentValue: any, weight: number): void;
  15901. private _getOriginalValues;
  15902. private _setValue;
  15903. /**
  15904. * Gets the loop pmode of the runtime animation
  15905. * @returns Loop Mode
  15906. */
  15907. private _getCorrectLoopMode;
  15908. /**
  15909. * Move the current animation to a given frame
  15910. * @param frame defines the frame to move to
  15911. */
  15912. goToFrame(frame: number): void;
  15913. /**
  15914. * @hidden Internal use only
  15915. */
  15916. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15917. /**
  15918. * Execute the current animation
  15919. * @param delay defines the delay to add to the current frame
  15920. * @param from defines the lower bound of the animation range
  15921. * @param to defines the upper bound of the animation range
  15922. * @param loop defines if the current animation must loop
  15923. * @param speedRatio defines the current speed ratio
  15924. * @param weight defines the weight of the animation (default is -1 so no weight)
  15925. * @param onLoop optional callback called when animation loops
  15926. * @returns a boolean indicating if the animation is running
  15927. */
  15928. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15929. }
  15930. }
  15931. declare module "babylonjs/Animations/animatable" {
  15932. import { Animation } from "babylonjs/Animations/animation";
  15933. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15934. import { Nullable } from "babylonjs/types";
  15935. import { Observable } from "babylonjs/Misc/observable";
  15936. import { Scene } from "babylonjs/scene";
  15937. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15938. import { Node } from "babylonjs/node";
  15939. /**
  15940. * Class used to store an actual running animation
  15941. */
  15942. export class Animatable {
  15943. /** defines the target object */
  15944. target: any;
  15945. /** defines the starting frame number (default is 0) */
  15946. fromFrame: number;
  15947. /** defines the ending frame number (default is 100) */
  15948. toFrame: number;
  15949. /** defines if the animation must loop (default is false) */
  15950. loopAnimation: boolean;
  15951. /** defines a callback to call when animation ends if it is not looping */
  15952. onAnimationEnd?: (() => void) | null | undefined;
  15953. /** defines a callback to call when animation loops */
  15954. onAnimationLoop?: (() => void) | null | undefined;
  15955. /** defines whether the animation should be evaluated additively */
  15956. isAdditive: boolean;
  15957. private _localDelayOffset;
  15958. private _pausedDelay;
  15959. private _runtimeAnimations;
  15960. private _paused;
  15961. private _scene;
  15962. private _speedRatio;
  15963. private _weight;
  15964. private _syncRoot;
  15965. /**
  15966. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15967. * This will only apply for non looping animation (default is true)
  15968. */
  15969. disposeOnEnd: boolean;
  15970. /**
  15971. * Gets a boolean indicating if the animation has started
  15972. */
  15973. animationStarted: boolean;
  15974. /**
  15975. * Observer raised when the animation ends
  15976. */
  15977. onAnimationEndObservable: Observable<Animatable>;
  15978. /**
  15979. * Observer raised when the animation loops
  15980. */
  15981. onAnimationLoopObservable: Observable<Animatable>;
  15982. /**
  15983. * Gets the root Animatable used to synchronize and normalize animations
  15984. */
  15985. get syncRoot(): Nullable<Animatable>;
  15986. /**
  15987. * Gets the current frame of the first RuntimeAnimation
  15988. * Used to synchronize Animatables
  15989. */
  15990. get masterFrame(): number;
  15991. /**
  15992. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15993. */
  15994. get weight(): number;
  15995. set weight(value: number);
  15996. /**
  15997. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15998. */
  15999. get speedRatio(): number;
  16000. set speedRatio(value: number);
  16001. /**
  16002. * Creates a new Animatable
  16003. * @param scene defines the hosting scene
  16004. * @param target defines the target object
  16005. * @param fromFrame defines the starting frame number (default is 0)
  16006. * @param toFrame defines the ending frame number (default is 100)
  16007. * @param loopAnimation defines if the animation must loop (default is false)
  16008. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16009. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16010. * @param animations defines a group of animation to add to the new Animatable
  16011. * @param onAnimationLoop defines a callback to call when animation loops
  16012. * @param isAdditive defines whether the animation should be evaluated additively
  16013. */
  16014. constructor(scene: Scene,
  16015. /** defines the target object */
  16016. target: any,
  16017. /** defines the starting frame number (default is 0) */
  16018. fromFrame?: number,
  16019. /** defines the ending frame number (default is 100) */
  16020. toFrame?: number,
  16021. /** defines if the animation must loop (default is false) */
  16022. loopAnimation?: boolean, speedRatio?: number,
  16023. /** defines a callback to call when animation ends if it is not looping */
  16024. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16025. /** defines a callback to call when animation loops */
  16026. onAnimationLoop?: (() => void) | null | undefined,
  16027. /** defines whether the animation should be evaluated additively */
  16028. isAdditive?: boolean);
  16029. /**
  16030. * Synchronize and normalize current Animatable with a source Animatable
  16031. * This is useful when using animation weights and when animations are not of the same length
  16032. * @param root defines the root Animatable to synchronize with
  16033. * @returns the current Animatable
  16034. */
  16035. syncWith(root: Animatable): Animatable;
  16036. /**
  16037. * Gets the list of runtime animations
  16038. * @returns an array of RuntimeAnimation
  16039. */
  16040. getAnimations(): RuntimeAnimation[];
  16041. /**
  16042. * Adds more animations to the current animatable
  16043. * @param target defines the target of the animations
  16044. * @param animations defines the new animations to add
  16045. */
  16046. appendAnimations(target: any, animations: Animation[]): void;
  16047. /**
  16048. * Gets the source animation for a specific property
  16049. * @param property defines the propertyu to look for
  16050. * @returns null or the source animation for the given property
  16051. */
  16052. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16053. /**
  16054. * Gets the runtime animation for a specific property
  16055. * @param property defines the propertyu to look for
  16056. * @returns null or the runtime animation for the given property
  16057. */
  16058. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16059. /**
  16060. * Resets the animatable to its original state
  16061. */
  16062. reset(): void;
  16063. /**
  16064. * Allows the animatable to blend with current running animations
  16065. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16066. * @param blendingSpeed defines the blending speed to use
  16067. */
  16068. enableBlending(blendingSpeed: number): void;
  16069. /**
  16070. * Disable animation blending
  16071. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16072. */
  16073. disableBlending(): void;
  16074. /**
  16075. * Jump directly to a given frame
  16076. * @param frame defines the frame to jump to
  16077. */
  16078. goToFrame(frame: number): void;
  16079. /**
  16080. * Pause the animation
  16081. */
  16082. pause(): void;
  16083. /**
  16084. * Restart the animation
  16085. */
  16086. restart(): void;
  16087. private _raiseOnAnimationEnd;
  16088. /**
  16089. * Stop and delete the current animation
  16090. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16091. * @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)
  16092. */
  16093. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16094. /**
  16095. * Wait asynchronously for the animation to end
  16096. * @returns a promise which will be fullfilled when the animation ends
  16097. */
  16098. waitAsync(): Promise<Animatable>;
  16099. /** @hidden */
  16100. _animate(delay: number): boolean;
  16101. }
  16102. module "babylonjs/scene" {
  16103. interface Scene {
  16104. /** @hidden */
  16105. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16106. /** @hidden */
  16107. _processLateAnimationBindingsForMatrices(holder: {
  16108. totalWeight: number;
  16109. totalAdditiveWeight: number;
  16110. animations: RuntimeAnimation[];
  16111. additiveAnimations: RuntimeAnimation[];
  16112. originalValue: Matrix;
  16113. }): any;
  16114. /** @hidden */
  16115. _processLateAnimationBindingsForQuaternions(holder: {
  16116. totalWeight: number;
  16117. totalAdditiveWeight: number;
  16118. animations: RuntimeAnimation[];
  16119. additiveAnimations: RuntimeAnimation[];
  16120. originalValue: Quaternion;
  16121. }, refQuaternion: Quaternion): Quaternion;
  16122. /** @hidden */
  16123. _processLateAnimationBindings(): void;
  16124. /**
  16125. * Will start the animation sequence of a given target
  16126. * @param target defines the target
  16127. * @param from defines from which frame should animation start
  16128. * @param to defines until which frame should animation run.
  16129. * @param weight defines the weight to apply to the animation (1.0 by default)
  16130. * @param loop defines if the animation loops
  16131. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16132. * @param onAnimationEnd defines the function to be executed when the animation ends
  16133. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16134. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16135. * @param onAnimationLoop defines the callback to call when an animation loops
  16136. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16137. * @returns the animatable object created for this animation
  16138. */
  16139. 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;
  16140. /**
  16141. * Will start the animation sequence of a given target
  16142. * @param target defines the target
  16143. * @param from defines from which frame should animation start
  16144. * @param to defines until which frame should animation run.
  16145. * @param loop defines if the animation loops
  16146. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16147. * @param onAnimationEnd defines the function to be executed when the animation ends
  16148. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16149. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16150. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16151. * @param onAnimationLoop defines the callback to call when an animation loops
  16152. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16153. * @returns the animatable object created for this animation
  16154. */
  16155. 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;
  16156. /**
  16157. * Will start the animation sequence of a given target and its hierarchy
  16158. * @param target defines the target
  16159. * @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.
  16160. * @param from defines from which frame should animation start
  16161. * @param to defines until which frame should animation run.
  16162. * @param loop defines if the animation loops
  16163. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16164. * @param onAnimationEnd defines the function to be executed when the animation ends
  16165. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16166. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16167. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16168. * @param onAnimationLoop defines the callback to call when an animation loops
  16169. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16170. * @returns the list of created animatables
  16171. */
  16172. 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[];
  16173. /**
  16174. * Begin a new animation on a given node
  16175. * @param target defines the target where the animation will take place
  16176. * @param animations defines the list of animations to start
  16177. * @param from defines the initial value
  16178. * @param to defines the final value
  16179. * @param loop defines if you want animation to loop (off by default)
  16180. * @param speedRatio defines the speed ratio to apply to all animations
  16181. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16182. * @param onAnimationLoop defines the callback to call when an animation loops
  16183. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16184. * @returns the list of created animatables
  16185. */
  16186. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16187. /**
  16188. * Begin a new animation on a given node and its hierarchy
  16189. * @param target defines the root node where the animation will take place
  16190. * @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.
  16191. * @param animations defines the list of animations to start
  16192. * @param from defines the initial value
  16193. * @param to defines the final value
  16194. * @param loop defines if you want animation to loop (off by default)
  16195. * @param speedRatio defines the speed ratio to apply to all animations
  16196. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16197. * @param onAnimationLoop defines the callback to call when an animation loops
  16198. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16199. * @returns the list of animatables created for all nodes
  16200. */
  16201. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16202. /**
  16203. * Gets the animatable associated with a specific target
  16204. * @param target defines the target of the animatable
  16205. * @returns the required animatable if found
  16206. */
  16207. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16208. /**
  16209. * Gets all animatables associated with a given target
  16210. * @param target defines the target to look animatables for
  16211. * @returns an array of Animatables
  16212. */
  16213. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16214. /**
  16215. * Stops and removes all animations that have been applied to the scene
  16216. */
  16217. stopAllAnimations(): void;
  16218. /**
  16219. * Gets the current delta time used by animation engine
  16220. */
  16221. deltaTime: number;
  16222. }
  16223. }
  16224. module "babylonjs/Bones/bone" {
  16225. interface Bone {
  16226. /**
  16227. * Copy an animation range from another bone
  16228. * @param source defines the source bone
  16229. * @param rangeName defines the range name to copy
  16230. * @param frameOffset defines the frame offset
  16231. * @param rescaleAsRequired defines if rescaling must be applied if required
  16232. * @param skelDimensionsRatio defines the scaling ratio
  16233. * @returns true if operation was successful
  16234. */
  16235. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16236. }
  16237. }
  16238. }
  16239. declare module "babylonjs/Bones/skeleton" {
  16240. import { Bone } from "babylonjs/Bones/bone";
  16241. import { Observable } from "babylonjs/Misc/observable";
  16242. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16243. import { Scene } from "babylonjs/scene";
  16244. import { Nullable } from "babylonjs/types";
  16245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16246. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16247. import { Animatable } from "babylonjs/Animations/animatable";
  16248. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16249. import { Animation } from "babylonjs/Animations/animation";
  16250. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16251. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16252. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16253. /**
  16254. * Class used to handle skinning animations
  16255. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16256. */
  16257. export class Skeleton implements IAnimatable {
  16258. /** defines the skeleton name */
  16259. name: string;
  16260. /** defines the skeleton Id */
  16261. id: string;
  16262. /**
  16263. * Defines the list of child bones
  16264. */
  16265. bones: Bone[];
  16266. /**
  16267. * Defines an estimate of the dimension of the skeleton at rest
  16268. */
  16269. dimensionsAtRest: Vector3;
  16270. /**
  16271. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16272. */
  16273. needInitialSkinMatrix: boolean;
  16274. /**
  16275. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16276. */
  16277. overrideMesh: Nullable<AbstractMesh>;
  16278. /**
  16279. * Gets the list of animations attached to this skeleton
  16280. */
  16281. animations: Array<Animation>;
  16282. private _scene;
  16283. private _isDirty;
  16284. private _transformMatrices;
  16285. private _transformMatrixTexture;
  16286. private _meshesWithPoseMatrix;
  16287. private _animatables;
  16288. private _identity;
  16289. private _synchronizedWithMesh;
  16290. private _ranges;
  16291. private _lastAbsoluteTransformsUpdateId;
  16292. private _canUseTextureForBones;
  16293. private _uniqueId;
  16294. /** @hidden */
  16295. _numBonesWithLinkedTransformNode: number;
  16296. /** @hidden */
  16297. _hasWaitingData: Nullable<boolean>;
  16298. /**
  16299. * Specifies if the skeleton should be serialized
  16300. */
  16301. doNotSerialize: boolean;
  16302. private _useTextureToStoreBoneMatrices;
  16303. /**
  16304. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16305. * Please note that this option is not available if the hardware does not support it
  16306. */
  16307. get useTextureToStoreBoneMatrices(): boolean;
  16308. set useTextureToStoreBoneMatrices(value: boolean);
  16309. private _animationPropertiesOverride;
  16310. /**
  16311. * Gets or sets the animation properties override
  16312. */
  16313. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16314. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16315. /**
  16316. * List of inspectable custom properties (used by the Inspector)
  16317. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16318. */
  16319. inspectableCustomProperties: IInspectable[];
  16320. /**
  16321. * An observable triggered before computing the skeleton's matrices
  16322. */
  16323. onBeforeComputeObservable: Observable<Skeleton>;
  16324. /**
  16325. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16326. */
  16327. get isUsingTextureForMatrices(): boolean;
  16328. /**
  16329. * Gets the unique ID of this skeleton
  16330. */
  16331. get uniqueId(): number;
  16332. /**
  16333. * Creates a new skeleton
  16334. * @param name defines the skeleton name
  16335. * @param id defines the skeleton Id
  16336. * @param scene defines the hosting scene
  16337. */
  16338. constructor(
  16339. /** defines the skeleton name */
  16340. name: string,
  16341. /** defines the skeleton Id */
  16342. id: string, scene: Scene);
  16343. /**
  16344. * Gets the current object class name.
  16345. * @return the class name
  16346. */
  16347. getClassName(): string;
  16348. /**
  16349. * Returns an array containing the root bones
  16350. * @returns an array containing the root bones
  16351. */
  16352. getChildren(): Array<Bone>;
  16353. /**
  16354. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16355. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16356. * @returns a Float32Array containing matrices data
  16357. */
  16358. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16359. /**
  16360. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16361. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16362. * @returns a raw texture containing the data
  16363. */
  16364. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16365. /**
  16366. * Gets the current hosting scene
  16367. * @returns a scene object
  16368. */
  16369. getScene(): Scene;
  16370. /**
  16371. * Gets a string representing the current skeleton data
  16372. * @param fullDetails defines a boolean indicating if we want a verbose version
  16373. * @returns a string representing the current skeleton data
  16374. */
  16375. toString(fullDetails?: boolean): string;
  16376. /**
  16377. * Get bone's index searching by name
  16378. * @param name defines bone's name to search for
  16379. * @return the indice of the bone. Returns -1 if not found
  16380. */
  16381. getBoneIndexByName(name: string): number;
  16382. /**
  16383. * Creater a new animation range
  16384. * @param name defines the name of the range
  16385. * @param from defines the start key
  16386. * @param to defines the end key
  16387. */
  16388. createAnimationRange(name: string, from: number, to: number): void;
  16389. /**
  16390. * Delete a specific animation range
  16391. * @param name defines the name of the range
  16392. * @param deleteFrames defines if frames must be removed as well
  16393. */
  16394. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16395. /**
  16396. * Gets a specific animation range
  16397. * @param name defines the name of the range to look for
  16398. * @returns the requested animation range or null if not found
  16399. */
  16400. getAnimationRange(name: string): Nullable<AnimationRange>;
  16401. /**
  16402. * Gets the list of all animation ranges defined on this skeleton
  16403. * @returns an array
  16404. */
  16405. getAnimationRanges(): Nullable<AnimationRange>[];
  16406. /**
  16407. * Copy animation range from a source skeleton.
  16408. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16409. * @param source defines the source skeleton
  16410. * @param name defines the name of the range to copy
  16411. * @param rescaleAsRequired defines if rescaling must be applied if required
  16412. * @returns true if operation was successful
  16413. */
  16414. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16415. /**
  16416. * Forces the skeleton to go to rest pose
  16417. */
  16418. returnToRest(): void;
  16419. private _getHighestAnimationFrame;
  16420. /**
  16421. * Begin a specific animation range
  16422. * @param name defines the name of the range to start
  16423. * @param loop defines if looping must be turned on (false by default)
  16424. * @param speedRatio defines the speed ratio to apply (1 by default)
  16425. * @param onAnimationEnd defines a callback which will be called when animation will end
  16426. * @returns a new animatable
  16427. */
  16428. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16429. /**
  16430. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16431. * @param skeleton defines the Skeleton containing the animation range to convert
  16432. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16433. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16434. * @returns the original skeleton
  16435. */
  16436. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16437. /** @hidden */
  16438. _markAsDirty(): void;
  16439. /** @hidden */
  16440. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16441. /** @hidden */
  16442. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16443. private _computeTransformMatrices;
  16444. /**
  16445. * Build all resources required to render a skeleton
  16446. */
  16447. prepare(): void;
  16448. /**
  16449. * Gets the list of animatables currently running for this skeleton
  16450. * @returns an array of animatables
  16451. */
  16452. getAnimatables(): IAnimatable[];
  16453. /**
  16454. * Clone the current skeleton
  16455. * @param name defines the name of the new skeleton
  16456. * @param id defines the id of the new skeleton
  16457. * @returns the new skeleton
  16458. */
  16459. clone(name: string, id?: string): Skeleton;
  16460. /**
  16461. * Enable animation blending for this skeleton
  16462. * @param blendingSpeed defines the blending speed to apply
  16463. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16464. */
  16465. enableBlending(blendingSpeed?: number): void;
  16466. /**
  16467. * Releases all resources associated with the current skeleton
  16468. */
  16469. dispose(): void;
  16470. /**
  16471. * Serialize the skeleton in a JSON object
  16472. * @returns a JSON object
  16473. */
  16474. serialize(): any;
  16475. /**
  16476. * Creates a new skeleton from serialized data
  16477. * @param parsedSkeleton defines the serialized data
  16478. * @param scene defines the hosting scene
  16479. * @returns a new skeleton
  16480. */
  16481. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16482. /**
  16483. * Compute all node absolute transforms
  16484. * @param forceUpdate defines if computation must be done even if cache is up to date
  16485. */
  16486. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16487. /**
  16488. * Gets the root pose matrix
  16489. * @returns a matrix
  16490. */
  16491. getPoseMatrix(): Nullable<Matrix>;
  16492. /**
  16493. * Sorts bones per internal index
  16494. */
  16495. sortBones(): void;
  16496. private _sortBones;
  16497. }
  16498. }
  16499. declare module "babylonjs/Meshes/instancedMesh" {
  16500. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16501. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16502. import { Camera } from "babylonjs/Cameras/camera";
  16503. import { Node } from "babylonjs/node";
  16504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16505. import { Mesh } from "babylonjs/Meshes/mesh";
  16506. import { Material } from "babylonjs/Materials/material";
  16507. import { Skeleton } from "babylonjs/Bones/skeleton";
  16508. import { Light } from "babylonjs/Lights/light";
  16509. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16510. /**
  16511. * Creates an instance based on a source mesh.
  16512. */
  16513. export class InstancedMesh extends AbstractMesh {
  16514. private _sourceMesh;
  16515. private _currentLOD;
  16516. /** @hidden */
  16517. _indexInSourceMeshInstanceArray: number;
  16518. constructor(name: string, source: Mesh);
  16519. /**
  16520. * Returns the string "InstancedMesh".
  16521. */
  16522. getClassName(): string;
  16523. /** Gets the list of lights affecting that mesh */
  16524. get lightSources(): Light[];
  16525. _resyncLightSources(): void;
  16526. _resyncLightSource(light: Light): void;
  16527. _removeLightSource(light: Light, dispose: boolean): void;
  16528. /**
  16529. * If the source mesh receives shadows
  16530. */
  16531. get receiveShadows(): boolean;
  16532. /**
  16533. * The material of the source mesh
  16534. */
  16535. get material(): Nullable<Material>;
  16536. /**
  16537. * Visibility of the source mesh
  16538. */
  16539. get visibility(): number;
  16540. /**
  16541. * Skeleton of the source mesh
  16542. */
  16543. get skeleton(): Nullable<Skeleton>;
  16544. /**
  16545. * Rendering ground id of the source mesh
  16546. */
  16547. get renderingGroupId(): number;
  16548. set renderingGroupId(value: number);
  16549. /**
  16550. * Returns the total number of vertices (integer).
  16551. */
  16552. getTotalVertices(): number;
  16553. /**
  16554. * Returns a positive integer : the total number of indices in this mesh geometry.
  16555. * @returns the numner of indices or zero if the mesh has no geometry.
  16556. */
  16557. getTotalIndices(): number;
  16558. /**
  16559. * The source mesh of the instance
  16560. */
  16561. get sourceMesh(): Mesh;
  16562. /**
  16563. * Creates a new InstancedMesh object from the mesh model.
  16564. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16565. * @param name defines the name of the new instance
  16566. * @returns a new InstancedMesh
  16567. */
  16568. createInstance(name: string): InstancedMesh;
  16569. /**
  16570. * Is this node ready to be used/rendered
  16571. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16572. * @return {boolean} is it ready
  16573. */
  16574. isReady(completeCheck?: boolean): boolean;
  16575. /**
  16576. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16577. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16578. * @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.
  16579. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16580. */
  16581. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16582. /**
  16583. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16584. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16585. * The `data` are either a numeric array either a Float32Array.
  16586. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16587. * 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).
  16588. * Note that a new underlying VertexBuffer object is created each call.
  16589. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16590. *
  16591. * Possible `kind` values :
  16592. * - VertexBuffer.PositionKind
  16593. * - VertexBuffer.UVKind
  16594. * - VertexBuffer.UV2Kind
  16595. * - VertexBuffer.UV3Kind
  16596. * - VertexBuffer.UV4Kind
  16597. * - VertexBuffer.UV5Kind
  16598. * - VertexBuffer.UV6Kind
  16599. * - VertexBuffer.ColorKind
  16600. * - VertexBuffer.MatricesIndicesKind
  16601. * - VertexBuffer.MatricesIndicesExtraKind
  16602. * - VertexBuffer.MatricesWeightsKind
  16603. * - VertexBuffer.MatricesWeightsExtraKind
  16604. *
  16605. * Returns the Mesh.
  16606. */
  16607. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16608. /**
  16609. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16610. * If the mesh has no geometry, it is simply returned as it is.
  16611. * The `data` are either a numeric array either a Float32Array.
  16612. * No new underlying VertexBuffer object is created.
  16613. * 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.
  16614. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16615. *
  16616. * Possible `kind` values :
  16617. * - VertexBuffer.PositionKind
  16618. * - VertexBuffer.UVKind
  16619. * - VertexBuffer.UV2Kind
  16620. * - VertexBuffer.UV3Kind
  16621. * - VertexBuffer.UV4Kind
  16622. * - VertexBuffer.UV5Kind
  16623. * - VertexBuffer.UV6Kind
  16624. * - VertexBuffer.ColorKind
  16625. * - VertexBuffer.MatricesIndicesKind
  16626. * - VertexBuffer.MatricesIndicesExtraKind
  16627. * - VertexBuffer.MatricesWeightsKind
  16628. * - VertexBuffer.MatricesWeightsExtraKind
  16629. *
  16630. * Returns the Mesh.
  16631. */
  16632. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16633. /**
  16634. * Sets the mesh indices.
  16635. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16636. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16637. * This method creates a new index buffer each call.
  16638. * Returns the Mesh.
  16639. */
  16640. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16641. /**
  16642. * Boolean : True if the mesh owns the requested kind of data.
  16643. */
  16644. isVerticesDataPresent(kind: string): boolean;
  16645. /**
  16646. * Returns an array of indices (IndicesArray).
  16647. */
  16648. getIndices(): Nullable<IndicesArray>;
  16649. get _positions(): Nullable<Vector3[]>;
  16650. /**
  16651. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16652. * This means the mesh underlying bounding box and sphere are recomputed.
  16653. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16654. * @returns the current mesh
  16655. */
  16656. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16657. /** @hidden */
  16658. _preActivate(): InstancedMesh;
  16659. /** @hidden */
  16660. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16661. /** @hidden */
  16662. _postActivate(): void;
  16663. getWorldMatrix(): Matrix;
  16664. get isAnInstance(): boolean;
  16665. /**
  16666. * Returns the current associated LOD AbstractMesh.
  16667. */
  16668. getLOD(camera: Camera): AbstractMesh;
  16669. /** @hidden */
  16670. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16671. /** @hidden */
  16672. _syncSubMeshes(): InstancedMesh;
  16673. /** @hidden */
  16674. _generatePointsArray(): boolean;
  16675. /**
  16676. * Creates a new InstancedMesh from the current mesh.
  16677. * - name (string) : the cloned mesh name
  16678. * - newParent (optional Node) : the optional Node to parent the clone to.
  16679. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16680. *
  16681. * Returns the clone.
  16682. */
  16683. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16684. /**
  16685. * Disposes the InstancedMesh.
  16686. * Returns nothing.
  16687. */
  16688. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16689. }
  16690. module "babylonjs/Meshes/mesh" {
  16691. interface Mesh {
  16692. /**
  16693. * Register a custom buffer that will be instanced
  16694. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16695. * @param kind defines the buffer kind
  16696. * @param stride defines the stride in floats
  16697. */
  16698. registerInstancedBuffer(kind: string, stride: number): void;
  16699. /**
  16700. * true to use the edge renderer for all instances of this mesh
  16701. */
  16702. edgesShareWithInstances: boolean;
  16703. /** @hidden */
  16704. _userInstancedBuffersStorage: {
  16705. data: {
  16706. [key: string]: Float32Array;
  16707. };
  16708. sizes: {
  16709. [key: string]: number;
  16710. };
  16711. vertexBuffers: {
  16712. [key: string]: Nullable<VertexBuffer>;
  16713. };
  16714. strides: {
  16715. [key: string]: number;
  16716. };
  16717. };
  16718. }
  16719. }
  16720. module "babylonjs/Meshes/abstractMesh" {
  16721. interface AbstractMesh {
  16722. /**
  16723. * Object used to store instanced buffers defined by user
  16724. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16725. */
  16726. instancedBuffers: {
  16727. [key: string]: any;
  16728. };
  16729. }
  16730. }
  16731. }
  16732. declare module "babylonjs/Materials/shaderMaterial" {
  16733. import { Nullable } from "babylonjs/types";
  16734. import { Scene } from "babylonjs/scene";
  16735. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16737. import { Mesh } from "babylonjs/Meshes/mesh";
  16738. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16739. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16740. import { Effect } from "babylonjs/Materials/effect";
  16741. import { Material } from "babylonjs/Materials/material";
  16742. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16743. /**
  16744. * Defines the options associated with the creation of a shader material.
  16745. */
  16746. export interface IShaderMaterialOptions {
  16747. /**
  16748. * Does the material work in alpha blend mode
  16749. */
  16750. needAlphaBlending: boolean;
  16751. /**
  16752. * Does the material work in alpha test mode
  16753. */
  16754. needAlphaTesting: boolean;
  16755. /**
  16756. * The list of attribute names used in the shader
  16757. */
  16758. attributes: string[];
  16759. /**
  16760. * The list of unifrom names used in the shader
  16761. */
  16762. uniforms: string[];
  16763. /**
  16764. * The list of UBO names used in the shader
  16765. */
  16766. uniformBuffers: string[];
  16767. /**
  16768. * The list of sampler names used in the shader
  16769. */
  16770. samplers: string[];
  16771. /**
  16772. * The list of defines used in the shader
  16773. */
  16774. defines: string[];
  16775. }
  16776. /**
  16777. * 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.
  16778. *
  16779. * This returned material effects how the mesh will look based on the code in the shaders.
  16780. *
  16781. * @see https://doc.babylonjs.com/how_to/shader_material
  16782. */
  16783. export class ShaderMaterial extends Material {
  16784. private _shaderPath;
  16785. private _options;
  16786. private _textures;
  16787. private _textureArrays;
  16788. private _floats;
  16789. private _ints;
  16790. private _floatsArrays;
  16791. private _colors3;
  16792. private _colors3Arrays;
  16793. private _colors4;
  16794. private _colors4Arrays;
  16795. private _vectors2;
  16796. private _vectors3;
  16797. private _vectors4;
  16798. private _matrices;
  16799. private _matrixArrays;
  16800. private _matrices3x3;
  16801. private _matrices2x2;
  16802. private _vectors2Arrays;
  16803. private _vectors3Arrays;
  16804. private _vectors4Arrays;
  16805. private _cachedWorldViewMatrix;
  16806. private _cachedWorldViewProjectionMatrix;
  16807. private _renderId;
  16808. private _multiview;
  16809. private _cachedDefines;
  16810. /** Define the Url to load snippets */
  16811. static SnippetUrl: string;
  16812. /** Snippet ID if the material was created from the snippet server */
  16813. snippetId: string;
  16814. /**
  16815. * Instantiate a new shader material.
  16816. * 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.
  16817. * This returned material effects how the mesh will look based on the code in the shaders.
  16818. * @see https://doc.babylonjs.com/how_to/shader_material
  16819. * @param name Define the name of the material in the scene
  16820. * @param scene Define the scene the material belongs to
  16821. * @param shaderPath Defines the route to the shader code in one of three ways:
  16822. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16823. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16824. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16825. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16826. * @param options Define the options used to create the shader
  16827. */
  16828. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16829. /**
  16830. * Gets the shader path used to define the shader code
  16831. * It can be modified to trigger a new compilation
  16832. */
  16833. get shaderPath(): any;
  16834. /**
  16835. * Sets the shader path used to define the shader code
  16836. * It can be modified to trigger a new compilation
  16837. */
  16838. set shaderPath(shaderPath: any);
  16839. /**
  16840. * Gets the options used to compile the shader.
  16841. * They can be modified to trigger a new compilation
  16842. */
  16843. get options(): IShaderMaterialOptions;
  16844. /**
  16845. * Gets the current class name of the material e.g. "ShaderMaterial"
  16846. * Mainly use in serialization.
  16847. * @returns the class name
  16848. */
  16849. getClassName(): string;
  16850. /**
  16851. * Specifies if the material will require alpha blending
  16852. * @returns a boolean specifying if alpha blending is needed
  16853. */
  16854. needAlphaBlending(): boolean;
  16855. /**
  16856. * Specifies if this material should be rendered in alpha test mode
  16857. * @returns a boolean specifying if an alpha test is needed.
  16858. */
  16859. needAlphaTesting(): boolean;
  16860. private _checkUniform;
  16861. /**
  16862. * Set a texture in the shader.
  16863. * @param name Define the name of the uniform samplers as defined in the shader
  16864. * @param texture Define the texture to bind to this sampler
  16865. * @return the material itself allowing "fluent" like uniform updates
  16866. */
  16867. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16868. /**
  16869. * Set a texture array in the shader.
  16870. * @param name Define the name of the uniform sampler array as defined in the shader
  16871. * @param textures Define the list of textures to bind to this sampler
  16872. * @return the material itself allowing "fluent" like uniform updates
  16873. */
  16874. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16875. /**
  16876. * Set a float in the shader.
  16877. * @param name Define the name of the uniform as defined in the shader
  16878. * @param value Define the value to give to the uniform
  16879. * @return the material itself allowing "fluent" like uniform updates
  16880. */
  16881. setFloat(name: string, value: number): ShaderMaterial;
  16882. /**
  16883. * Set a int in the shader.
  16884. * @param name Define the name of the uniform as defined in the shader
  16885. * @param value Define the value to give to the uniform
  16886. * @return the material itself allowing "fluent" like uniform updates
  16887. */
  16888. setInt(name: string, value: number): ShaderMaterial;
  16889. /**
  16890. * Set an array of floats in the shader.
  16891. * @param name Define the name of the uniform as defined in the shader
  16892. * @param value Define the value to give to the uniform
  16893. * @return the material itself allowing "fluent" like uniform updates
  16894. */
  16895. setFloats(name: string, value: number[]): ShaderMaterial;
  16896. /**
  16897. * Set a vec3 in the shader from a Color3.
  16898. * @param name Define the name of the uniform as defined in the shader
  16899. * @param value Define the value to give to the uniform
  16900. * @return the material itself allowing "fluent" like uniform updates
  16901. */
  16902. setColor3(name: string, value: Color3): ShaderMaterial;
  16903. /**
  16904. * Set a vec3 array in the shader from a Color3 array.
  16905. * @param name Define the name of the uniform as defined in the shader
  16906. * @param value Define the value to give to the uniform
  16907. * @return the material itself allowing "fluent" like uniform updates
  16908. */
  16909. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16910. /**
  16911. * Set a vec4 in the shader from a Color4.
  16912. * @param name Define the name of the uniform as defined in the shader
  16913. * @param value Define the value to give to the uniform
  16914. * @return the material itself allowing "fluent" like uniform updates
  16915. */
  16916. setColor4(name: string, value: Color4): ShaderMaterial;
  16917. /**
  16918. * Set a vec4 array in the shader from a Color4 array.
  16919. * @param name Define the name of the uniform as defined in the shader
  16920. * @param value Define the value to give to the uniform
  16921. * @return the material itself allowing "fluent" like uniform updates
  16922. */
  16923. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16924. /**
  16925. * Set a vec2 in the shader from a Vector2.
  16926. * @param name Define the name of the uniform as defined in the shader
  16927. * @param value Define the value to give to the uniform
  16928. * @return the material itself allowing "fluent" like uniform updates
  16929. */
  16930. setVector2(name: string, value: Vector2): ShaderMaterial;
  16931. /**
  16932. * Set a vec3 in the shader from a Vector3.
  16933. * @param name Define the name of the uniform as defined in the shader
  16934. * @param value Define the value to give to the uniform
  16935. * @return the material itself allowing "fluent" like uniform updates
  16936. */
  16937. setVector3(name: string, value: Vector3): ShaderMaterial;
  16938. /**
  16939. * Set a vec4 in the shader from a Vector4.
  16940. * @param name Define the name of the uniform as defined in the shader
  16941. * @param value Define the value to give to the uniform
  16942. * @return the material itself allowing "fluent" like uniform updates
  16943. */
  16944. setVector4(name: string, value: Vector4): ShaderMaterial;
  16945. /**
  16946. * Set a mat4 in the shader from a Matrix.
  16947. * @param name Define the name of the uniform as defined in the shader
  16948. * @param value Define the value to give to the uniform
  16949. * @return the material itself allowing "fluent" like uniform updates
  16950. */
  16951. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16952. /**
  16953. * Set a float32Array in the shader from a matrix array.
  16954. * @param name Define the name of the uniform as defined in the shader
  16955. * @param value Define the value to give to the uniform
  16956. * @return the material itself allowing "fluent" like uniform updates
  16957. */
  16958. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16959. /**
  16960. * Set a mat3 in the shader from a Float32Array.
  16961. * @param name Define the name of the uniform as defined in the shader
  16962. * @param value Define the value to give to the uniform
  16963. * @return the material itself allowing "fluent" like uniform updates
  16964. */
  16965. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16966. /**
  16967. * Set a mat2 in the shader from a Float32Array.
  16968. * @param name Define the name of the uniform as defined in the shader
  16969. * @param value Define the value to give to the uniform
  16970. * @return the material itself allowing "fluent" like uniform updates
  16971. */
  16972. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16973. /**
  16974. * Set a vec2 array in the shader from a number array.
  16975. * @param name Define the name of the uniform as defined in the shader
  16976. * @param value Define the value to give to the uniform
  16977. * @return the material itself allowing "fluent" like uniform updates
  16978. */
  16979. setArray2(name: string, value: number[]): ShaderMaterial;
  16980. /**
  16981. * Set a vec3 array in the shader from a number array.
  16982. * @param name Define the name of the uniform as defined in the shader
  16983. * @param value Define the value to give to the uniform
  16984. * @return the material itself allowing "fluent" like uniform updates
  16985. */
  16986. setArray3(name: string, value: number[]): ShaderMaterial;
  16987. /**
  16988. * Set a vec4 array in the shader from a number array.
  16989. * @param name Define the name of the uniform as defined in the shader
  16990. * @param value Define the value to give to the uniform
  16991. * @return the material itself allowing "fluent" like uniform updates
  16992. */
  16993. setArray4(name: string, value: number[]): ShaderMaterial;
  16994. private _checkCache;
  16995. /**
  16996. * Specifies that the submesh is ready to be used
  16997. * @param mesh defines the mesh to check
  16998. * @param subMesh defines which submesh to check
  16999. * @param useInstances specifies that instances should be used
  17000. * @returns a boolean indicating that the submesh is ready or not
  17001. */
  17002. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17003. /**
  17004. * Checks if the material is ready to render the requested mesh
  17005. * @param mesh Define the mesh to render
  17006. * @param useInstances Define whether or not the material is used with instances
  17007. * @returns true if ready, otherwise false
  17008. */
  17009. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17010. /**
  17011. * Binds the world matrix to the material
  17012. * @param world defines the world transformation matrix
  17013. * @param effectOverride - If provided, use this effect instead of internal effect
  17014. */
  17015. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17016. /**
  17017. * Binds the submesh to this material by preparing the effect and shader to draw
  17018. * @param world defines the world transformation matrix
  17019. * @param mesh defines the mesh containing the submesh
  17020. * @param subMesh defines the submesh to bind the material to
  17021. */
  17022. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17023. /**
  17024. * Binds the material to the mesh
  17025. * @param world defines the world transformation matrix
  17026. * @param mesh defines the mesh to bind the material to
  17027. * @param effectOverride - If provided, use this effect instead of internal effect
  17028. */
  17029. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17030. protected _afterBind(mesh?: Mesh): void;
  17031. /**
  17032. * Gets the active textures from the material
  17033. * @returns an array of textures
  17034. */
  17035. getActiveTextures(): BaseTexture[];
  17036. /**
  17037. * Specifies if the material uses a texture
  17038. * @param texture defines the texture to check against the material
  17039. * @returns a boolean specifying if the material uses the texture
  17040. */
  17041. hasTexture(texture: BaseTexture): boolean;
  17042. /**
  17043. * Makes a duplicate of the material, and gives it a new name
  17044. * @param name defines the new name for the duplicated material
  17045. * @returns the cloned material
  17046. */
  17047. clone(name: string): ShaderMaterial;
  17048. /**
  17049. * Disposes the material
  17050. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17051. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17052. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17053. */
  17054. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17055. /**
  17056. * Serializes this material in a JSON representation
  17057. * @returns the serialized material object
  17058. */
  17059. serialize(): any;
  17060. /**
  17061. * Creates a shader material from parsed shader material data
  17062. * @param source defines the JSON represnetation of the material
  17063. * @param scene defines the hosting scene
  17064. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17065. * @returns a new material
  17066. */
  17067. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17068. /**
  17069. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17070. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17071. * @param url defines the url to load from
  17072. * @param scene defines the hosting scene
  17073. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17074. * @returns a promise that will resolve to the new ShaderMaterial
  17075. */
  17076. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17077. /**
  17078. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17079. * @param snippetId defines the snippet to load
  17080. * @param scene defines the hosting scene
  17081. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17082. * @returns a promise that will resolve to the new ShaderMaterial
  17083. */
  17084. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17085. }
  17086. }
  17087. declare module "babylonjs/Shaders/color.fragment" {
  17088. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17089. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17090. /** @hidden */
  17091. export var colorPixelShader: {
  17092. name: string;
  17093. shader: string;
  17094. };
  17095. }
  17096. declare module "babylonjs/Shaders/color.vertex" {
  17097. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17098. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17099. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17100. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17101. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17102. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17103. /** @hidden */
  17104. export var colorVertexShader: {
  17105. name: string;
  17106. shader: string;
  17107. };
  17108. }
  17109. declare module "babylonjs/Meshes/linesMesh" {
  17110. import { Nullable } from "babylonjs/types";
  17111. import { Scene } from "babylonjs/scene";
  17112. import { Color3 } from "babylonjs/Maths/math.color";
  17113. import { Node } from "babylonjs/node";
  17114. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17115. import { Mesh } from "babylonjs/Meshes/mesh";
  17116. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17117. import { Effect } from "babylonjs/Materials/effect";
  17118. import { Material } from "babylonjs/Materials/material";
  17119. import "babylonjs/Shaders/color.fragment";
  17120. import "babylonjs/Shaders/color.vertex";
  17121. /**
  17122. * Line mesh
  17123. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17124. */
  17125. export class LinesMesh extends Mesh {
  17126. /**
  17127. * If vertex color should be applied to the mesh
  17128. */
  17129. readonly useVertexColor?: boolean | undefined;
  17130. /**
  17131. * If vertex alpha should be applied to the mesh
  17132. */
  17133. readonly useVertexAlpha?: boolean | undefined;
  17134. /**
  17135. * Color of the line (Default: White)
  17136. */
  17137. color: Color3;
  17138. /**
  17139. * Alpha of the line (Default: 1)
  17140. */
  17141. alpha: number;
  17142. /**
  17143. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17144. * This margin is expressed in world space coordinates, so its value may vary.
  17145. * Default value is 0.1
  17146. */
  17147. intersectionThreshold: number;
  17148. private _colorShader;
  17149. private color4;
  17150. /**
  17151. * Creates a new LinesMesh
  17152. * @param name defines the name
  17153. * @param scene defines the hosting scene
  17154. * @param parent defines the parent mesh if any
  17155. * @param source defines the optional source LinesMesh used to clone data from
  17156. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17157. * When false, achieved by calling a clone(), also passing False.
  17158. * This will make creation of children, recursive.
  17159. * @param useVertexColor defines if this LinesMesh supports vertex color
  17160. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17161. */
  17162. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17163. /**
  17164. * If vertex color should be applied to the mesh
  17165. */
  17166. useVertexColor?: boolean | undefined,
  17167. /**
  17168. * If vertex alpha should be applied to the mesh
  17169. */
  17170. useVertexAlpha?: boolean | undefined);
  17171. private _addClipPlaneDefine;
  17172. private _removeClipPlaneDefine;
  17173. isReady(): boolean;
  17174. /**
  17175. * Returns the string "LineMesh"
  17176. */
  17177. getClassName(): string;
  17178. /**
  17179. * @hidden
  17180. */
  17181. get material(): Material;
  17182. /**
  17183. * @hidden
  17184. */
  17185. set material(value: Material);
  17186. /**
  17187. * @hidden
  17188. */
  17189. get checkCollisions(): boolean;
  17190. /** @hidden */
  17191. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17192. /** @hidden */
  17193. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17194. /**
  17195. * Disposes of the line mesh
  17196. * @param doNotRecurse If children should be disposed
  17197. */
  17198. dispose(doNotRecurse?: boolean): void;
  17199. /**
  17200. * Returns a new LineMesh object cloned from the current one.
  17201. */
  17202. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17203. /**
  17204. * Creates a new InstancedLinesMesh object from the mesh model.
  17205. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17206. * @param name defines the name of the new instance
  17207. * @returns a new InstancedLinesMesh
  17208. */
  17209. createInstance(name: string): InstancedLinesMesh;
  17210. }
  17211. /**
  17212. * Creates an instance based on a source LinesMesh
  17213. */
  17214. export class InstancedLinesMesh extends InstancedMesh {
  17215. /**
  17216. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17217. * This margin is expressed in world space coordinates, so its value may vary.
  17218. * Initilized with the intersectionThreshold value of the source LinesMesh
  17219. */
  17220. intersectionThreshold: number;
  17221. constructor(name: string, source: LinesMesh);
  17222. /**
  17223. * Returns the string "InstancedLinesMesh".
  17224. */
  17225. getClassName(): string;
  17226. }
  17227. }
  17228. declare module "babylonjs/Shaders/line.fragment" {
  17229. /** @hidden */
  17230. export var linePixelShader: {
  17231. name: string;
  17232. shader: string;
  17233. };
  17234. }
  17235. declare module "babylonjs/Shaders/line.vertex" {
  17236. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17237. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17238. /** @hidden */
  17239. export var lineVertexShader: {
  17240. name: string;
  17241. shader: string;
  17242. };
  17243. }
  17244. declare module "babylonjs/Rendering/edgesRenderer" {
  17245. import { Nullable } from "babylonjs/types";
  17246. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17248. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17249. import { IDisposable } from "babylonjs/scene";
  17250. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17251. import "babylonjs/Shaders/line.fragment";
  17252. import "babylonjs/Shaders/line.vertex";
  17253. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17254. import { SmartArray } from "babylonjs/Misc/smartArray";
  17255. module "babylonjs/scene" {
  17256. interface Scene {
  17257. /** @hidden */
  17258. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17259. }
  17260. }
  17261. module "babylonjs/Meshes/abstractMesh" {
  17262. interface AbstractMesh {
  17263. /**
  17264. * Gets the edgesRenderer associated with the mesh
  17265. */
  17266. edgesRenderer: Nullable<EdgesRenderer>;
  17267. }
  17268. }
  17269. module "babylonjs/Meshes/linesMesh" {
  17270. interface LinesMesh {
  17271. /**
  17272. * Enables the edge rendering mode on the mesh.
  17273. * This mode makes the mesh edges visible
  17274. * @param epsilon defines the maximal distance between two angles to detect a face
  17275. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17276. * @returns the currentAbstractMesh
  17277. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17278. */
  17279. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17280. }
  17281. }
  17282. module "babylonjs/Meshes/linesMesh" {
  17283. interface InstancedLinesMesh {
  17284. /**
  17285. * Enables the edge rendering mode on the mesh.
  17286. * This mode makes the mesh edges visible
  17287. * @param epsilon defines the maximal distance between two angles to detect a face
  17288. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17289. * @returns the current InstancedLinesMesh
  17290. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17291. */
  17292. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17293. }
  17294. }
  17295. /**
  17296. * Defines the minimum contract an Edges renderer should follow.
  17297. */
  17298. export interface IEdgesRenderer extends IDisposable {
  17299. /**
  17300. * Gets or sets a boolean indicating if the edgesRenderer is active
  17301. */
  17302. isEnabled: boolean;
  17303. /**
  17304. * Renders the edges of the attached mesh,
  17305. */
  17306. render(): void;
  17307. /**
  17308. * Checks wether or not the edges renderer is ready to render.
  17309. * @return true if ready, otherwise false.
  17310. */
  17311. isReady(): boolean;
  17312. /**
  17313. * List of instances to render in case the source mesh has instances
  17314. */
  17315. customInstances: SmartArray<Matrix>;
  17316. }
  17317. /**
  17318. * Defines the additional options of the edges renderer
  17319. */
  17320. export interface IEdgesRendererOptions {
  17321. /**
  17322. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17323. * If not defined, the default value is true
  17324. */
  17325. useAlternateEdgeFinder?: boolean;
  17326. /**
  17327. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17328. * If not defined, the default value is true.
  17329. * 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)
  17330. * This option is used only if useAlternateEdgeFinder = true
  17331. */
  17332. useFastVertexMerger?: boolean;
  17333. /**
  17334. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17335. * The default value is 1e-6
  17336. * This option is used only if useAlternateEdgeFinder = true
  17337. */
  17338. epsilonVertexMerge?: number;
  17339. /**
  17340. * 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
  17341. * 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.
  17342. * This option is used only if useAlternateEdgeFinder = true
  17343. */
  17344. applyTessellation?: boolean;
  17345. /**
  17346. * 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
  17347. * The default value is 1e-6
  17348. * This option is used only if useAlternateEdgeFinder = true
  17349. */
  17350. epsilonVertexAligned?: number;
  17351. }
  17352. /**
  17353. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17354. */
  17355. export class EdgesRenderer implements IEdgesRenderer {
  17356. /**
  17357. * Define the size of the edges with an orthographic camera
  17358. */
  17359. edgesWidthScalerForOrthographic: number;
  17360. /**
  17361. * Define the size of the edges with a perspective camera
  17362. */
  17363. edgesWidthScalerForPerspective: number;
  17364. protected _source: AbstractMesh;
  17365. protected _linesPositions: number[];
  17366. protected _linesNormals: number[];
  17367. protected _linesIndices: number[];
  17368. protected _epsilon: number;
  17369. protected _indicesCount: number;
  17370. protected _lineShader: ShaderMaterial;
  17371. protected _ib: DataBuffer;
  17372. protected _buffers: {
  17373. [key: string]: Nullable<VertexBuffer>;
  17374. };
  17375. protected _buffersForInstances: {
  17376. [key: string]: Nullable<VertexBuffer>;
  17377. };
  17378. protected _checkVerticesInsteadOfIndices: boolean;
  17379. protected _options: Nullable<IEdgesRendererOptions>;
  17380. private _meshRebuildObserver;
  17381. private _meshDisposeObserver;
  17382. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17383. isEnabled: boolean;
  17384. /**
  17385. * List of instances to render in case the source mesh has instances
  17386. */
  17387. customInstances: SmartArray<Matrix>;
  17388. private static GetShader;
  17389. /**
  17390. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17391. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17392. * @param source Mesh used to create edges
  17393. * @param epsilon sum of angles in adjacency to check for edge
  17394. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17395. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17396. * @param options The options to apply when generating the edges
  17397. */
  17398. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17399. protected _prepareRessources(): void;
  17400. /** @hidden */
  17401. _rebuild(): void;
  17402. /**
  17403. * Releases the required resources for the edges renderer
  17404. */
  17405. dispose(): void;
  17406. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17407. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17408. /**
  17409. * Checks if the pair of p0 and p1 is en edge
  17410. * @param faceIndex
  17411. * @param edge
  17412. * @param faceNormals
  17413. * @param p0
  17414. * @param p1
  17415. * @private
  17416. */
  17417. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17418. /**
  17419. * push line into the position, normal and index buffer
  17420. * @protected
  17421. */
  17422. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17423. /**
  17424. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17425. */
  17426. private _tessellateTriangle;
  17427. private _generateEdgesLinesAlternate;
  17428. /**
  17429. * Generates lines edges from adjacencjes
  17430. * @private
  17431. */
  17432. _generateEdgesLines(): void;
  17433. /**
  17434. * Checks wether or not the edges renderer is ready to render.
  17435. * @return true if ready, otherwise false.
  17436. */
  17437. isReady(): boolean;
  17438. /**
  17439. * Renders the edges of the attached mesh,
  17440. */
  17441. render(): void;
  17442. }
  17443. /**
  17444. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17445. */
  17446. export class LineEdgesRenderer extends EdgesRenderer {
  17447. /**
  17448. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17449. * @param source LineMesh used to generate edges
  17450. * @param epsilon not important (specified angle for edge detection)
  17451. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17452. */
  17453. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17454. /**
  17455. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17456. */
  17457. _generateEdgesLines(): void;
  17458. }
  17459. }
  17460. declare module "babylonjs/Rendering/renderingGroup" {
  17461. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17462. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17464. import { Nullable } from "babylonjs/types";
  17465. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17466. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17467. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17468. import { Material } from "babylonjs/Materials/material";
  17469. import { Scene } from "babylonjs/scene";
  17470. /**
  17471. * This represents the object necessary to create a rendering group.
  17472. * This is exclusively used and created by the rendering manager.
  17473. * To modify the behavior, you use the available helpers in your scene or meshes.
  17474. * @hidden
  17475. */
  17476. export class RenderingGroup {
  17477. index: number;
  17478. private static _zeroVector;
  17479. private _scene;
  17480. private _opaqueSubMeshes;
  17481. private _transparentSubMeshes;
  17482. private _alphaTestSubMeshes;
  17483. private _depthOnlySubMeshes;
  17484. private _particleSystems;
  17485. private _spriteManagers;
  17486. private _opaqueSortCompareFn;
  17487. private _alphaTestSortCompareFn;
  17488. private _transparentSortCompareFn;
  17489. private _renderOpaque;
  17490. private _renderAlphaTest;
  17491. private _renderTransparent;
  17492. /** @hidden */
  17493. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17494. onBeforeTransparentRendering: () => void;
  17495. /**
  17496. * Set the opaque sort comparison function.
  17497. * If null the sub meshes will be render in the order they were created
  17498. */
  17499. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17500. /**
  17501. * Set the alpha test sort comparison function.
  17502. * If null the sub meshes will be render in the order they were created
  17503. */
  17504. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17505. /**
  17506. * Set the transparent sort comparison function.
  17507. * If null the sub meshes will be render in the order they were created
  17508. */
  17509. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17510. /**
  17511. * Creates a new rendering group.
  17512. * @param index The rendering group index
  17513. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17514. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17515. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17516. */
  17517. 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>);
  17518. /**
  17519. * Render all the sub meshes contained in the group.
  17520. * @param customRenderFunction Used to override the default render behaviour of the group.
  17521. * @returns true if rendered some submeshes.
  17522. */
  17523. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17524. /**
  17525. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17526. * @param subMeshes The submeshes to render
  17527. */
  17528. private renderOpaqueSorted;
  17529. /**
  17530. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17531. * @param subMeshes The submeshes to render
  17532. */
  17533. private renderAlphaTestSorted;
  17534. /**
  17535. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17536. * @param subMeshes The submeshes to render
  17537. */
  17538. private renderTransparentSorted;
  17539. /**
  17540. * Renders the submeshes in a specified order.
  17541. * @param subMeshes The submeshes to sort before render
  17542. * @param sortCompareFn The comparison function use to sort
  17543. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17544. * @param transparent Specifies to activate blending if true
  17545. */
  17546. private static renderSorted;
  17547. /**
  17548. * Renders the submeshes in the order they were dispatched (no sort applied).
  17549. * @param subMeshes The submeshes to render
  17550. */
  17551. private static renderUnsorted;
  17552. /**
  17553. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17554. * are rendered back to front if in the same alpha index.
  17555. *
  17556. * @param a The first submesh
  17557. * @param b The second submesh
  17558. * @returns The result of the comparison
  17559. */
  17560. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17561. /**
  17562. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17563. * are rendered back to front.
  17564. *
  17565. * @param a The first submesh
  17566. * @param b The second submesh
  17567. * @returns The result of the comparison
  17568. */
  17569. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17570. /**
  17571. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17572. * are rendered front to back (prevent overdraw).
  17573. *
  17574. * @param a The first submesh
  17575. * @param b The second submesh
  17576. * @returns The result of the comparison
  17577. */
  17578. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17579. /**
  17580. * Resets the different lists of submeshes to prepare a new frame.
  17581. */
  17582. prepare(): void;
  17583. dispose(): void;
  17584. /**
  17585. * Inserts the submesh in its correct queue depending on its material.
  17586. * @param subMesh The submesh to dispatch
  17587. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17588. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17589. */
  17590. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17591. dispatchSprites(spriteManager: ISpriteManager): void;
  17592. dispatchParticles(particleSystem: IParticleSystem): void;
  17593. private _renderParticles;
  17594. private _renderSprites;
  17595. }
  17596. }
  17597. declare module "babylonjs/Rendering/renderingManager" {
  17598. import { Nullable } from "babylonjs/types";
  17599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17600. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17601. import { SmartArray } from "babylonjs/Misc/smartArray";
  17602. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17603. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17604. import { Material } from "babylonjs/Materials/material";
  17605. import { Scene } from "babylonjs/scene";
  17606. import { Camera } from "babylonjs/Cameras/camera";
  17607. /**
  17608. * Interface describing the different options available in the rendering manager
  17609. * regarding Auto Clear between groups.
  17610. */
  17611. export interface IRenderingManagerAutoClearSetup {
  17612. /**
  17613. * Defines whether or not autoclear is enable.
  17614. */
  17615. autoClear: boolean;
  17616. /**
  17617. * Defines whether or not to autoclear the depth buffer.
  17618. */
  17619. depth: boolean;
  17620. /**
  17621. * Defines whether or not to autoclear the stencil buffer.
  17622. */
  17623. stencil: boolean;
  17624. }
  17625. /**
  17626. * This class is used by the onRenderingGroupObservable
  17627. */
  17628. export class RenderingGroupInfo {
  17629. /**
  17630. * The Scene that being rendered
  17631. */
  17632. scene: Scene;
  17633. /**
  17634. * The camera currently used for the rendering pass
  17635. */
  17636. camera: Nullable<Camera>;
  17637. /**
  17638. * The ID of the renderingGroup being processed
  17639. */
  17640. renderingGroupId: number;
  17641. }
  17642. /**
  17643. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17644. * It is enable to manage the different groups as well as the different necessary sort functions.
  17645. * This should not be used directly aside of the few static configurations
  17646. */
  17647. export class RenderingManager {
  17648. /**
  17649. * The max id used for rendering groups (not included)
  17650. */
  17651. static MAX_RENDERINGGROUPS: number;
  17652. /**
  17653. * The min id used for rendering groups (included)
  17654. */
  17655. static MIN_RENDERINGGROUPS: number;
  17656. /**
  17657. * Used to globally prevent autoclearing scenes.
  17658. */
  17659. static AUTOCLEAR: boolean;
  17660. /**
  17661. * @hidden
  17662. */
  17663. _useSceneAutoClearSetup: boolean;
  17664. private _scene;
  17665. private _renderingGroups;
  17666. private _depthStencilBufferAlreadyCleaned;
  17667. private _autoClearDepthStencil;
  17668. private _customOpaqueSortCompareFn;
  17669. private _customAlphaTestSortCompareFn;
  17670. private _customTransparentSortCompareFn;
  17671. private _renderingGroupInfo;
  17672. /**
  17673. * Instantiates a new rendering group for a particular scene
  17674. * @param scene Defines the scene the groups belongs to
  17675. */
  17676. constructor(scene: Scene);
  17677. private _clearDepthStencilBuffer;
  17678. /**
  17679. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17680. * @hidden
  17681. */
  17682. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17683. /**
  17684. * Resets the different information of the group to prepare a new frame
  17685. * @hidden
  17686. */
  17687. reset(): void;
  17688. /**
  17689. * Dispose and release the group and its associated resources.
  17690. * @hidden
  17691. */
  17692. dispose(): void;
  17693. /**
  17694. * Clear the info related to rendering groups preventing retention points during dispose.
  17695. */
  17696. freeRenderingGroups(): void;
  17697. private _prepareRenderingGroup;
  17698. /**
  17699. * Add a sprite manager to the rendering manager in order to render it this frame.
  17700. * @param spriteManager Define the sprite manager to render
  17701. */
  17702. dispatchSprites(spriteManager: ISpriteManager): void;
  17703. /**
  17704. * Add a particle system to the rendering manager in order to render it this frame.
  17705. * @param particleSystem Define the particle system to render
  17706. */
  17707. dispatchParticles(particleSystem: IParticleSystem): void;
  17708. /**
  17709. * Add a submesh to the manager in order to render it this frame
  17710. * @param subMesh The submesh to dispatch
  17711. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17712. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17713. */
  17714. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17715. /**
  17716. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17717. * This allowed control for front to back rendering or reversly depending of the special needs.
  17718. *
  17719. * @param renderingGroupId The rendering group id corresponding to its index
  17720. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17721. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17722. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17723. */
  17724. 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;
  17725. /**
  17726. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17727. *
  17728. * @param renderingGroupId The rendering group id corresponding to its index
  17729. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17730. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17731. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17732. */
  17733. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17734. /**
  17735. * Gets the current auto clear configuration for one rendering group of the rendering
  17736. * manager.
  17737. * @param index the rendering group index to get the information for
  17738. * @returns The auto clear setup for the requested rendering group
  17739. */
  17740. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17741. }
  17742. }
  17743. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17744. import { SmartArray } from "babylonjs/Misc/smartArray";
  17745. import { Nullable } from "babylonjs/types";
  17746. import { Scene } from "babylonjs/scene";
  17747. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17748. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17750. import { Mesh } from "babylonjs/Meshes/mesh";
  17751. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17752. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17753. import { Effect } from "babylonjs/Materials/effect";
  17754. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17755. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17756. import "babylonjs/Shaders/shadowMap.fragment";
  17757. import "babylonjs/Shaders/shadowMap.vertex";
  17758. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17759. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17760. import { Observable } from "babylonjs/Misc/observable";
  17761. /**
  17762. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17763. */
  17764. export interface ICustomShaderOptions {
  17765. /**
  17766. * Gets or sets the custom shader name to use
  17767. */
  17768. shaderName: string;
  17769. /**
  17770. * The list of attribute names used in the shader
  17771. */
  17772. attributes?: string[];
  17773. /**
  17774. * The list of unifrom names used in the shader
  17775. */
  17776. uniforms?: string[];
  17777. /**
  17778. * The list of sampler names used in the shader
  17779. */
  17780. samplers?: string[];
  17781. /**
  17782. * The list of defines used in the shader
  17783. */
  17784. defines?: string[];
  17785. }
  17786. /**
  17787. * Interface to implement to create a shadow generator compatible with BJS.
  17788. */
  17789. export interface IShadowGenerator {
  17790. /**
  17791. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17792. * @returns The render target texture if present otherwise, null
  17793. */
  17794. getShadowMap(): Nullable<RenderTargetTexture>;
  17795. /**
  17796. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17797. * @param subMesh The submesh we want to render in the shadow map
  17798. * @param useInstances Defines wether will draw in the map using instances
  17799. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17800. * @returns true if ready otherwise, false
  17801. */
  17802. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17803. /**
  17804. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17805. * @param defines Defines of the material we want to update
  17806. * @param lightIndex Index of the light in the enabled light list of the material
  17807. */
  17808. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17809. /**
  17810. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17811. * defined in the generator but impacting the effect).
  17812. * It implies the unifroms available on the materials are the standard BJS ones.
  17813. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17814. * @param effect The effect we are binfing the information for
  17815. */
  17816. bindShadowLight(lightIndex: string, effect: Effect): void;
  17817. /**
  17818. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17819. * (eq to shadow prjection matrix * light transform matrix)
  17820. * @returns The transform matrix used to create the shadow map
  17821. */
  17822. getTransformMatrix(): Matrix;
  17823. /**
  17824. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17825. * Cube and 2D textures for instance.
  17826. */
  17827. recreateShadowMap(): void;
  17828. /**
  17829. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17830. * @param onCompiled Callback triggered at the and of the effects compilation
  17831. * @param options Sets of optional options forcing the compilation with different modes
  17832. */
  17833. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17834. useInstances: boolean;
  17835. }>): void;
  17836. /**
  17837. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17838. * @param options Sets of optional options forcing the compilation with different modes
  17839. * @returns A promise that resolves when the compilation completes
  17840. */
  17841. forceCompilationAsync(options?: Partial<{
  17842. useInstances: boolean;
  17843. }>): Promise<void>;
  17844. /**
  17845. * Serializes the shadow generator setup to a json object.
  17846. * @returns The serialized JSON object
  17847. */
  17848. serialize(): any;
  17849. /**
  17850. * Disposes the Shadow map and related Textures and effects.
  17851. */
  17852. dispose(): void;
  17853. }
  17854. /**
  17855. * Default implementation IShadowGenerator.
  17856. * This is the main object responsible of generating shadows in the framework.
  17857. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17858. */
  17859. export class ShadowGenerator implements IShadowGenerator {
  17860. /**
  17861. * Name of the shadow generator class
  17862. */
  17863. static CLASSNAME: string;
  17864. /**
  17865. * Shadow generator mode None: no filtering applied.
  17866. */
  17867. static readonly FILTER_NONE: number;
  17868. /**
  17869. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17870. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17871. */
  17872. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17873. /**
  17874. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17875. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17876. */
  17877. static readonly FILTER_POISSONSAMPLING: number;
  17878. /**
  17879. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17880. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17881. */
  17882. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17883. /**
  17884. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17885. * edge artifacts on steep falloff.
  17886. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17887. */
  17888. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17889. /**
  17890. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17891. * edge artifacts on steep falloff.
  17892. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17893. */
  17894. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17895. /**
  17896. * Shadow generator mode PCF: Percentage Closer Filtering
  17897. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17898. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17899. */
  17900. static readonly FILTER_PCF: number;
  17901. /**
  17902. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17903. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17904. * Contact Hardening
  17905. */
  17906. static readonly FILTER_PCSS: number;
  17907. /**
  17908. * Reserved for PCF and PCSS
  17909. * Highest Quality.
  17910. *
  17911. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17912. *
  17913. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17914. */
  17915. static readonly QUALITY_HIGH: number;
  17916. /**
  17917. * Reserved for PCF and PCSS
  17918. * Good tradeoff for quality/perf cross devices
  17919. *
  17920. * Execute PCF on a 3*3 kernel.
  17921. *
  17922. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17923. */
  17924. static readonly QUALITY_MEDIUM: number;
  17925. /**
  17926. * Reserved for PCF and PCSS
  17927. * The lowest quality but the fastest.
  17928. *
  17929. * Execute PCF on a 1*1 kernel.
  17930. *
  17931. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17932. */
  17933. static readonly QUALITY_LOW: number;
  17934. /** Gets or sets the custom shader name to use */
  17935. customShaderOptions: ICustomShaderOptions;
  17936. /**
  17937. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17938. */
  17939. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17940. /**
  17941. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17942. */
  17943. onAfterShadowMapRenderObservable: Observable<Effect>;
  17944. /**
  17945. * Observable triggered before a mesh is rendered in the shadow map.
  17946. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17947. */
  17948. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17949. /**
  17950. * Observable triggered after a mesh is rendered in the shadow map.
  17951. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17952. */
  17953. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17954. protected _bias: number;
  17955. /**
  17956. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17957. */
  17958. get bias(): number;
  17959. /**
  17960. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17961. */
  17962. set bias(bias: number);
  17963. protected _normalBias: number;
  17964. /**
  17965. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17966. */
  17967. get normalBias(): number;
  17968. /**
  17969. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17970. */
  17971. set normalBias(normalBias: number);
  17972. protected _blurBoxOffset: number;
  17973. /**
  17974. * Gets the blur box offset: offset applied during the blur pass.
  17975. * Only useful if useKernelBlur = false
  17976. */
  17977. get blurBoxOffset(): number;
  17978. /**
  17979. * Sets the blur box offset: offset applied during the blur pass.
  17980. * Only useful if useKernelBlur = false
  17981. */
  17982. set blurBoxOffset(value: number);
  17983. protected _blurScale: number;
  17984. /**
  17985. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17986. * 2 means half of the size.
  17987. */
  17988. get blurScale(): number;
  17989. /**
  17990. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17991. * 2 means half of the size.
  17992. */
  17993. set blurScale(value: number);
  17994. protected _blurKernel: number;
  17995. /**
  17996. * Gets the blur kernel: kernel size of the blur pass.
  17997. * Only useful if useKernelBlur = true
  17998. */
  17999. get blurKernel(): number;
  18000. /**
  18001. * Sets the blur kernel: kernel size of the blur pass.
  18002. * Only useful if useKernelBlur = true
  18003. */
  18004. set blurKernel(value: number);
  18005. protected _useKernelBlur: boolean;
  18006. /**
  18007. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18008. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18009. */
  18010. get useKernelBlur(): boolean;
  18011. /**
  18012. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18013. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18014. */
  18015. set useKernelBlur(value: boolean);
  18016. protected _depthScale: number;
  18017. /**
  18018. * Gets the depth scale used in ESM mode.
  18019. */
  18020. get depthScale(): number;
  18021. /**
  18022. * Sets the depth scale used in ESM mode.
  18023. * This can override the scale stored on the light.
  18024. */
  18025. set depthScale(value: number);
  18026. protected _validateFilter(filter: number): number;
  18027. protected _filter: number;
  18028. /**
  18029. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18030. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18031. */
  18032. get filter(): number;
  18033. /**
  18034. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18035. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18036. */
  18037. set filter(value: number);
  18038. /**
  18039. * Gets if the current filter is set to Poisson Sampling.
  18040. */
  18041. get usePoissonSampling(): boolean;
  18042. /**
  18043. * Sets the current filter to Poisson Sampling.
  18044. */
  18045. set usePoissonSampling(value: boolean);
  18046. /**
  18047. * Gets if the current filter is set to ESM.
  18048. */
  18049. get useExponentialShadowMap(): boolean;
  18050. /**
  18051. * Sets the current filter is to ESM.
  18052. */
  18053. set useExponentialShadowMap(value: boolean);
  18054. /**
  18055. * Gets if the current filter is set to filtered ESM.
  18056. */
  18057. get useBlurExponentialShadowMap(): boolean;
  18058. /**
  18059. * Gets if the current filter is set to filtered ESM.
  18060. */
  18061. set useBlurExponentialShadowMap(value: boolean);
  18062. /**
  18063. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18064. * exponential to prevent steep falloff artifacts).
  18065. */
  18066. get useCloseExponentialShadowMap(): boolean;
  18067. /**
  18068. * Sets the current filter to "close ESM" (using the inverse of the
  18069. * exponential to prevent steep falloff artifacts).
  18070. */
  18071. set useCloseExponentialShadowMap(value: boolean);
  18072. /**
  18073. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18074. * exponential to prevent steep falloff artifacts).
  18075. */
  18076. get useBlurCloseExponentialShadowMap(): boolean;
  18077. /**
  18078. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18079. * exponential to prevent steep falloff artifacts).
  18080. */
  18081. set useBlurCloseExponentialShadowMap(value: boolean);
  18082. /**
  18083. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18084. */
  18085. get usePercentageCloserFiltering(): boolean;
  18086. /**
  18087. * Sets the current filter to "PCF" (percentage closer filtering).
  18088. */
  18089. set usePercentageCloserFiltering(value: boolean);
  18090. protected _filteringQuality: number;
  18091. /**
  18092. * Gets the PCF or PCSS Quality.
  18093. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18094. */
  18095. get filteringQuality(): number;
  18096. /**
  18097. * Sets the PCF or PCSS Quality.
  18098. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18099. */
  18100. set filteringQuality(filteringQuality: number);
  18101. /**
  18102. * Gets if the current filter is set to "PCSS" (contact hardening).
  18103. */
  18104. get useContactHardeningShadow(): boolean;
  18105. /**
  18106. * Sets the current filter to "PCSS" (contact hardening).
  18107. */
  18108. set useContactHardeningShadow(value: boolean);
  18109. protected _contactHardeningLightSizeUVRatio: number;
  18110. /**
  18111. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18112. * Using a ratio helps keeping shape stability independently of the map size.
  18113. *
  18114. * It does not account for the light projection as it was having too much
  18115. * instability during the light setup or during light position changes.
  18116. *
  18117. * Only valid if useContactHardeningShadow is true.
  18118. */
  18119. get contactHardeningLightSizeUVRatio(): number;
  18120. /**
  18121. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18122. * Using a ratio helps keeping shape stability independently of the map size.
  18123. *
  18124. * It does not account for the light projection as it was having too much
  18125. * instability during the light setup or during light position changes.
  18126. *
  18127. * Only valid if useContactHardeningShadow is true.
  18128. */
  18129. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18130. protected _darkness: number;
  18131. /** Gets or sets the actual darkness of a shadow */
  18132. get darkness(): number;
  18133. set darkness(value: number);
  18134. /**
  18135. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18136. * 0 means strongest and 1 would means no shadow.
  18137. * @returns the darkness.
  18138. */
  18139. getDarkness(): number;
  18140. /**
  18141. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18142. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18143. * @returns the shadow generator allowing fluent coding.
  18144. */
  18145. setDarkness(darkness: number): ShadowGenerator;
  18146. protected _transparencyShadow: boolean;
  18147. /** Gets or sets the ability to have transparent shadow */
  18148. get transparencyShadow(): boolean;
  18149. set transparencyShadow(value: boolean);
  18150. /**
  18151. * Sets the ability to have transparent shadow (boolean).
  18152. * @param transparent True if transparent else False
  18153. * @returns the shadow generator allowing fluent coding
  18154. */
  18155. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18156. /**
  18157. * Enables or disables shadows with varying strength based on the transparency
  18158. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18159. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18160. * mesh.visibility * alphaTexture.a
  18161. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18162. */
  18163. enableSoftTransparentShadow: boolean;
  18164. protected _shadowMap: Nullable<RenderTargetTexture>;
  18165. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18166. /**
  18167. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18168. * @returns The render target texture if present otherwise, null
  18169. */
  18170. getShadowMap(): Nullable<RenderTargetTexture>;
  18171. /**
  18172. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18173. * @returns The render target texture if the shadow map is present otherwise, null
  18174. */
  18175. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18176. /**
  18177. * Gets the class name of that object
  18178. * @returns "ShadowGenerator"
  18179. */
  18180. getClassName(): string;
  18181. /**
  18182. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18183. * @param mesh Mesh to add
  18184. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18185. * @returns the Shadow Generator itself
  18186. */
  18187. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18188. /**
  18189. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18190. * @param mesh Mesh to remove
  18191. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18192. * @returns the Shadow Generator itself
  18193. */
  18194. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18195. /**
  18196. * Controls the extent to which the shadows fade out at the edge of the frustum
  18197. */
  18198. frustumEdgeFalloff: number;
  18199. protected _light: IShadowLight;
  18200. /**
  18201. * Returns the associated light object.
  18202. * @returns the light generating the shadow
  18203. */
  18204. getLight(): IShadowLight;
  18205. /**
  18206. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18207. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18208. * It might on the other hand introduce peter panning.
  18209. */
  18210. forceBackFacesOnly: boolean;
  18211. protected _scene: Scene;
  18212. protected _lightDirection: Vector3;
  18213. protected _effect: Effect;
  18214. protected _viewMatrix: Matrix;
  18215. protected _projectionMatrix: Matrix;
  18216. protected _transformMatrix: Matrix;
  18217. protected _cachedPosition: Vector3;
  18218. protected _cachedDirection: Vector3;
  18219. protected _cachedDefines: string;
  18220. protected _currentRenderID: number;
  18221. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18222. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18223. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18224. protected _blurPostProcesses: PostProcess[];
  18225. protected _mapSize: number;
  18226. protected _currentFaceIndex: number;
  18227. protected _currentFaceIndexCache: number;
  18228. protected _textureType: number;
  18229. protected _defaultTextureMatrix: Matrix;
  18230. protected _storedUniqueId: Nullable<number>;
  18231. /** @hidden */
  18232. static _SceneComponentInitialization: (scene: Scene) => void;
  18233. /**
  18234. * Creates a ShadowGenerator object.
  18235. * A ShadowGenerator is the required tool to use the shadows.
  18236. * Each light casting shadows needs to use its own ShadowGenerator.
  18237. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18238. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18239. * @param light The light object generating the shadows.
  18240. * @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.
  18241. */
  18242. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18243. protected _initializeGenerator(): void;
  18244. protected _createTargetRenderTexture(): void;
  18245. protected _initializeShadowMap(): void;
  18246. protected _initializeBlurRTTAndPostProcesses(): void;
  18247. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18248. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18249. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18250. protected _applyFilterValues(): void;
  18251. /**
  18252. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18253. * @param onCompiled Callback triggered at the and of the effects compilation
  18254. * @param options Sets of optional options forcing the compilation with different modes
  18255. */
  18256. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18257. useInstances: boolean;
  18258. }>): void;
  18259. /**
  18260. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18261. * @param options Sets of optional options forcing the compilation with different modes
  18262. * @returns A promise that resolves when the compilation completes
  18263. */
  18264. forceCompilationAsync(options?: Partial<{
  18265. useInstances: boolean;
  18266. }>): Promise<void>;
  18267. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18268. private _prepareShadowDefines;
  18269. /**
  18270. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18271. * @param subMesh The submesh we want to render in the shadow map
  18272. * @param useInstances Defines wether will draw in the map using instances
  18273. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18274. * @returns true if ready otherwise, false
  18275. */
  18276. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18277. /**
  18278. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18279. * @param defines Defines of the material we want to update
  18280. * @param lightIndex Index of the light in the enabled light list of the material
  18281. */
  18282. prepareDefines(defines: any, lightIndex: number): void;
  18283. /**
  18284. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18285. * defined in the generator but impacting the effect).
  18286. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18287. * @param effect The effect we are binfing the information for
  18288. */
  18289. bindShadowLight(lightIndex: string, effect: Effect): void;
  18290. /**
  18291. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18292. * (eq to shadow prjection matrix * light transform matrix)
  18293. * @returns The transform matrix used to create the shadow map
  18294. */
  18295. getTransformMatrix(): Matrix;
  18296. /**
  18297. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18298. * Cube and 2D textures for instance.
  18299. */
  18300. recreateShadowMap(): void;
  18301. protected _disposeBlurPostProcesses(): void;
  18302. protected _disposeRTTandPostProcesses(): void;
  18303. /**
  18304. * Disposes the ShadowGenerator.
  18305. * Returns nothing.
  18306. */
  18307. dispose(): void;
  18308. /**
  18309. * Serializes the shadow generator setup to a json object.
  18310. * @returns The serialized JSON object
  18311. */
  18312. serialize(): any;
  18313. /**
  18314. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18315. * @param parsedShadowGenerator The JSON object to parse
  18316. * @param scene The scene to create the shadow map for
  18317. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18318. * @returns The parsed shadow generator
  18319. */
  18320. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18321. }
  18322. }
  18323. declare module "babylonjs/Lights/light" {
  18324. import { Nullable } from "babylonjs/types";
  18325. import { Scene } from "babylonjs/scene";
  18326. import { Vector3 } from "babylonjs/Maths/math.vector";
  18327. import { Color3 } from "babylonjs/Maths/math.color";
  18328. import { Node } from "babylonjs/node";
  18329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18330. import { Effect } from "babylonjs/Materials/effect";
  18331. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18332. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18333. /**
  18334. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18335. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18336. * 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.
  18337. */
  18338. export abstract class Light extends Node {
  18339. /**
  18340. * Falloff Default: light is falling off following the material specification:
  18341. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18342. */
  18343. static readonly FALLOFF_DEFAULT: number;
  18344. /**
  18345. * Falloff Physical: light is falling off following the inverse squared distance law.
  18346. */
  18347. static readonly FALLOFF_PHYSICAL: number;
  18348. /**
  18349. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18350. * to enhance interoperability with other engines.
  18351. */
  18352. static readonly FALLOFF_GLTF: number;
  18353. /**
  18354. * Falloff Standard: light is falling off like in the standard material
  18355. * to enhance interoperability with other materials.
  18356. */
  18357. static readonly FALLOFF_STANDARD: number;
  18358. /**
  18359. * If every light affecting the material is in this lightmapMode,
  18360. * material.lightmapTexture adds or multiplies
  18361. * (depends on material.useLightmapAsShadowmap)
  18362. * after every other light calculations.
  18363. */
  18364. static readonly LIGHTMAP_DEFAULT: number;
  18365. /**
  18366. * material.lightmapTexture as only diffuse lighting from this light
  18367. * adds only specular lighting from this light
  18368. * adds dynamic shadows
  18369. */
  18370. static readonly LIGHTMAP_SPECULAR: number;
  18371. /**
  18372. * material.lightmapTexture as only lighting
  18373. * no light calculation from this light
  18374. * only adds dynamic shadows from this light
  18375. */
  18376. static readonly LIGHTMAP_SHADOWSONLY: number;
  18377. /**
  18378. * Each light type uses the default quantity according to its type:
  18379. * point/spot lights use luminous intensity
  18380. * directional lights use illuminance
  18381. */
  18382. static readonly INTENSITYMODE_AUTOMATIC: number;
  18383. /**
  18384. * lumen (lm)
  18385. */
  18386. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18387. /**
  18388. * candela (lm/sr)
  18389. */
  18390. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18391. /**
  18392. * lux (lm/m^2)
  18393. */
  18394. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18395. /**
  18396. * nit (cd/m^2)
  18397. */
  18398. static readonly INTENSITYMODE_LUMINANCE: number;
  18399. /**
  18400. * Light type const id of the point light.
  18401. */
  18402. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18403. /**
  18404. * Light type const id of the directional light.
  18405. */
  18406. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18407. /**
  18408. * Light type const id of the spot light.
  18409. */
  18410. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18411. /**
  18412. * Light type const id of the hemispheric light.
  18413. */
  18414. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18415. /**
  18416. * Diffuse gives the basic color to an object.
  18417. */
  18418. diffuse: Color3;
  18419. /**
  18420. * Specular produces a highlight color on an object.
  18421. * Note: This is note affecting PBR materials.
  18422. */
  18423. specular: Color3;
  18424. /**
  18425. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18426. * falling off base on range or angle.
  18427. * This can be set to any values in Light.FALLOFF_x.
  18428. *
  18429. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18430. * other types of materials.
  18431. */
  18432. falloffType: number;
  18433. /**
  18434. * Strength of the light.
  18435. * Note: By default it is define in the framework own unit.
  18436. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18437. */
  18438. intensity: number;
  18439. private _range;
  18440. protected _inverseSquaredRange: number;
  18441. /**
  18442. * Defines how far from the source the light is impacting in scene units.
  18443. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18444. */
  18445. get range(): number;
  18446. /**
  18447. * Defines how far from the source the light is impacting in scene units.
  18448. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18449. */
  18450. set range(value: number);
  18451. /**
  18452. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18453. * of light.
  18454. */
  18455. private _photometricScale;
  18456. private _intensityMode;
  18457. /**
  18458. * Gets the photometric scale used to interpret the intensity.
  18459. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18460. */
  18461. get intensityMode(): number;
  18462. /**
  18463. * Sets the photometric scale used to interpret the intensity.
  18464. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18465. */
  18466. set intensityMode(value: number);
  18467. private _radius;
  18468. /**
  18469. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18470. */
  18471. get radius(): number;
  18472. /**
  18473. * sets the light radius used by PBR Materials to simulate soft area lights.
  18474. */
  18475. set radius(value: number);
  18476. private _renderPriority;
  18477. /**
  18478. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18479. * exceeding the number allowed of the materials.
  18480. */
  18481. renderPriority: number;
  18482. private _shadowEnabled;
  18483. /**
  18484. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18485. * the current shadow generator.
  18486. */
  18487. get shadowEnabled(): boolean;
  18488. /**
  18489. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18490. * the current shadow generator.
  18491. */
  18492. set shadowEnabled(value: boolean);
  18493. private _includedOnlyMeshes;
  18494. /**
  18495. * Gets the only meshes impacted by this light.
  18496. */
  18497. get includedOnlyMeshes(): AbstractMesh[];
  18498. /**
  18499. * Sets the only meshes impacted by this light.
  18500. */
  18501. set includedOnlyMeshes(value: AbstractMesh[]);
  18502. private _excludedMeshes;
  18503. /**
  18504. * Gets the meshes not impacted by this light.
  18505. */
  18506. get excludedMeshes(): AbstractMesh[];
  18507. /**
  18508. * Sets the meshes not impacted by this light.
  18509. */
  18510. set excludedMeshes(value: AbstractMesh[]);
  18511. private _excludeWithLayerMask;
  18512. /**
  18513. * Gets the layer id use to find what meshes are not impacted by the light.
  18514. * Inactive if 0
  18515. */
  18516. get excludeWithLayerMask(): number;
  18517. /**
  18518. * Sets the layer id use to find what meshes are not impacted by the light.
  18519. * Inactive if 0
  18520. */
  18521. set excludeWithLayerMask(value: number);
  18522. private _includeOnlyWithLayerMask;
  18523. /**
  18524. * Gets the layer id use to find what meshes are impacted by the light.
  18525. * Inactive if 0
  18526. */
  18527. get includeOnlyWithLayerMask(): number;
  18528. /**
  18529. * Sets the layer id use to find what meshes are impacted by the light.
  18530. * Inactive if 0
  18531. */
  18532. set includeOnlyWithLayerMask(value: number);
  18533. private _lightmapMode;
  18534. /**
  18535. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18536. */
  18537. get lightmapMode(): number;
  18538. /**
  18539. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18540. */
  18541. set lightmapMode(value: number);
  18542. /**
  18543. * Shadow generator associted to the light.
  18544. * @hidden Internal use only.
  18545. */
  18546. _shadowGenerator: Nullable<IShadowGenerator>;
  18547. /**
  18548. * @hidden Internal use only.
  18549. */
  18550. _excludedMeshesIds: string[];
  18551. /**
  18552. * @hidden Internal use only.
  18553. */
  18554. _includedOnlyMeshesIds: string[];
  18555. /**
  18556. * The current light unifom buffer.
  18557. * @hidden Internal use only.
  18558. */
  18559. _uniformBuffer: UniformBuffer;
  18560. /** @hidden */
  18561. _renderId: number;
  18562. /**
  18563. * Creates a Light object in the scene.
  18564. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18565. * @param name The firendly name of the light
  18566. * @param scene The scene the light belongs too
  18567. */
  18568. constructor(name: string, scene: Scene);
  18569. protected abstract _buildUniformLayout(): void;
  18570. /**
  18571. * Sets the passed Effect "effect" with the Light information.
  18572. * @param effect The effect to update
  18573. * @param lightIndex The index of the light in the effect to update
  18574. * @returns The light
  18575. */
  18576. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18577. /**
  18578. * Sets the passed Effect "effect" with the Light textures.
  18579. * @param effect The effect to update
  18580. * @param lightIndex The index of the light in the effect to update
  18581. * @returns The light
  18582. */
  18583. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18584. /**
  18585. * Binds the lights information from the scene to the effect for the given mesh.
  18586. * @param lightIndex Light index
  18587. * @param scene The scene where the light belongs to
  18588. * @param effect The effect we are binding the data to
  18589. * @param useSpecular Defines if specular is supported
  18590. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18591. */
  18592. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18593. /**
  18594. * Sets the passed Effect "effect" with the Light information.
  18595. * @param effect The effect to update
  18596. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18597. * @returns The light
  18598. */
  18599. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18600. /**
  18601. * Returns the string "Light".
  18602. * @returns the class name
  18603. */
  18604. getClassName(): string;
  18605. /** @hidden */
  18606. readonly _isLight: boolean;
  18607. /**
  18608. * Converts the light information to a readable string for debug purpose.
  18609. * @param fullDetails Supports for multiple levels of logging within scene loading
  18610. * @returns the human readable light info
  18611. */
  18612. toString(fullDetails?: boolean): string;
  18613. /** @hidden */
  18614. protected _syncParentEnabledState(): void;
  18615. /**
  18616. * Set the enabled state of this node.
  18617. * @param value - the new enabled state
  18618. */
  18619. setEnabled(value: boolean): void;
  18620. /**
  18621. * Returns the Light associated shadow generator if any.
  18622. * @return the associated shadow generator.
  18623. */
  18624. getShadowGenerator(): Nullable<IShadowGenerator>;
  18625. /**
  18626. * Returns a Vector3, the absolute light position in the World.
  18627. * @returns the world space position of the light
  18628. */
  18629. getAbsolutePosition(): Vector3;
  18630. /**
  18631. * Specifies if the light will affect the passed mesh.
  18632. * @param mesh The mesh to test against the light
  18633. * @return true the mesh is affected otherwise, false.
  18634. */
  18635. canAffectMesh(mesh: AbstractMesh): boolean;
  18636. /**
  18637. * Sort function to order lights for rendering.
  18638. * @param a First Light object to compare to second.
  18639. * @param b Second Light object to compare first.
  18640. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18641. */
  18642. static CompareLightsPriority(a: Light, b: Light): number;
  18643. /**
  18644. * Releases resources associated with this node.
  18645. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18646. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18647. */
  18648. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18649. /**
  18650. * Returns the light type ID (integer).
  18651. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18652. */
  18653. getTypeID(): number;
  18654. /**
  18655. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18656. * @returns the scaled intensity in intensity mode unit
  18657. */
  18658. getScaledIntensity(): number;
  18659. /**
  18660. * Returns a new Light object, named "name", from the current one.
  18661. * @param name The name of the cloned light
  18662. * @param newParent The parent of this light, if it has one
  18663. * @returns the new created light
  18664. */
  18665. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18666. /**
  18667. * Serializes the current light into a Serialization object.
  18668. * @returns the serialized object.
  18669. */
  18670. serialize(): any;
  18671. /**
  18672. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18673. * This new light is named "name" and added to the passed scene.
  18674. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18675. * @param name The friendly name of the light
  18676. * @param scene The scene the new light will belong to
  18677. * @returns the constructor function
  18678. */
  18679. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18680. /**
  18681. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18682. * @param parsedLight The JSON representation of the light
  18683. * @param scene The scene to create the parsed light in
  18684. * @returns the created light after parsing
  18685. */
  18686. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18687. private _hookArrayForExcluded;
  18688. private _hookArrayForIncludedOnly;
  18689. private _resyncMeshes;
  18690. /**
  18691. * Forces the meshes to update their light related information in their rendering used effects
  18692. * @hidden Internal Use Only
  18693. */
  18694. _markMeshesAsLightDirty(): void;
  18695. /**
  18696. * Recomputes the cached photometric scale if needed.
  18697. */
  18698. private _computePhotometricScale;
  18699. /**
  18700. * Returns the Photometric Scale according to the light type and intensity mode.
  18701. */
  18702. private _getPhotometricScale;
  18703. /**
  18704. * Reorder the light in the scene according to their defined priority.
  18705. * @hidden Internal Use Only
  18706. */
  18707. _reorderLightsInScene(): void;
  18708. /**
  18709. * Prepares the list of defines specific to the light type.
  18710. * @param defines the list of defines
  18711. * @param lightIndex defines the index of the light for the effect
  18712. */
  18713. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18714. }
  18715. }
  18716. declare module "babylonjs/Cameras/targetCamera" {
  18717. import { Nullable } from "babylonjs/types";
  18718. import { Camera } from "babylonjs/Cameras/camera";
  18719. import { Scene } from "babylonjs/scene";
  18720. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18721. /**
  18722. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18723. * This is the base of the follow, arc rotate cameras and Free camera
  18724. * @see https://doc.babylonjs.com/features/cameras
  18725. */
  18726. export class TargetCamera extends Camera {
  18727. private static _RigCamTransformMatrix;
  18728. private static _TargetTransformMatrix;
  18729. private static _TargetFocalPoint;
  18730. private _tmpUpVector;
  18731. private _tmpTargetVector;
  18732. /**
  18733. * Define the current direction the camera is moving to
  18734. */
  18735. cameraDirection: Vector3;
  18736. /**
  18737. * Define the current rotation the camera is rotating to
  18738. */
  18739. cameraRotation: Vector2;
  18740. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18741. ignoreParentScaling: boolean;
  18742. /**
  18743. * When set, the up vector of the camera will be updated by the rotation of the camera
  18744. */
  18745. updateUpVectorFromRotation: boolean;
  18746. private _tmpQuaternion;
  18747. /**
  18748. * Define the current rotation of the camera
  18749. */
  18750. rotation: Vector3;
  18751. /**
  18752. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18753. */
  18754. rotationQuaternion: Quaternion;
  18755. /**
  18756. * Define the current speed of the camera
  18757. */
  18758. speed: number;
  18759. /**
  18760. * Add constraint to the camera to prevent it to move freely in all directions and
  18761. * around all axis.
  18762. */
  18763. noRotationConstraint: boolean;
  18764. /**
  18765. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18766. * panning
  18767. */
  18768. invertRotation: boolean;
  18769. /**
  18770. * Speed multiplier for inverse camera panning
  18771. */
  18772. inverseRotationSpeed: number;
  18773. /**
  18774. * Define the current target of the camera as an object or a position.
  18775. */
  18776. lockedTarget: any;
  18777. /** @hidden */
  18778. _currentTarget: Vector3;
  18779. /** @hidden */
  18780. _initialFocalDistance: number;
  18781. /** @hidden */
  18782. _viewMatrix: Matrix;
  18783. /** @hidden */
  18784. _camMatrix: Matrix;
  18785. /** @hidden */
  18786. _cameraTransformMatrix: Matrix;
  18787. /** @hidden */
  18788. _cameraRotationMatrix: Matrix;
  18789. /** @hidden */
  18790. _referencePoint: Vector3;
  18791. /** @hidden */
  18792. _transformedReferencePoint: Vector3;
  18793. /** @hidden */
  18794. _reset: () => void;
  18795. private _defaultUp;
  18796. /**
  18797. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18798. * This is the base of the follow, arc rotate cameras and Free camera
  18799. * @see https://doc.babylonjs.com/features/cameras
  18800. * @param name Defines the name of the camera in the scene
  18801. * @param position Defines the start position of the camera in the scene
  18802. * @param scene Defines the scene the camera belongs to
  18803. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18804. */
  18805. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18806. /**
  18807. * Gets the position in front of the camera at a given distance.
  18808. * @param distance The distance from the camera we want the position to be
  18809. * @returns the position
  18810. */
  18811. getFrontPosition(distance: number): Vector3;
  18812. /** @hidden */
  18813. _getLockedTargetPosition(): Nullable<Vector3>;
  18814. private _storedPosition;
  18815. private _storedRotation;
  18816. private _storedRotationQuaternion;
  18817. /**
  18818. * Store current camera state of the camera (fov, position, rotation, etc..)
  18819. * @returns the camera
  18820. */
  18821. storeState(): Camera;
  18822. /**
  18823. * Restored camera state. You must call storeState() first
  18824. * @returns whether it was successful or not
  18825. * @hidden
  18826. */
  18827. _restoreStateValues(): boolean;
  18828. /** @hidden */
  18829. _initCache(): void;
  18830. /** @hidden */
  18831. _updateCache(ignoreParentClass?: boolean): void;
  18832. /** @hidden */
  18833. _isSynchronizedViewMatrix(): boolean;
  18834. /** @hidden */
  18835. _computeLocalCameraSpeed(): number;
  18836. /**
  18837. * Defines the target the camera should look at.
  18838. * @param target Defines the new target as a Vector or a mesh
  18839. */
  18840. setTarget(target: Vector3): void;
  18841. /**
  18842. * Return the current target position of the camera. This value is expressed in local space.
  18843. * @returns the target position
  18844. */
  18845. getTarget(): Vector3;
  18846. /** @hidden */
  18847. _decideIfNeedsToMove(): boolean;
  18848. /** @hidden */
  18849. _updatePosition(): void;
  18850. /** @hidden */
  18851. _checkInputs(): void;
  18852. protected _updateCameraRotationMatrix(): void;
  18853. /**
  18854. * 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)
  18855. * @returns the current camera
  18856. */
  18857. private _rotateUpVectorWithCameraRotationMatrix;
  18858. private _cachedRotationZ;
  18859. private _cachedQuaternionRotationZ;
  18860. /** @hidden */
  18861. _getViewMatrix(): Matrix;
  18862. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18863. /**
  18864. * @hidden
  18865. */
  18866. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18867. /**
  18868. * @hidden
  18869. */
  18870. _updateRigCameras(): void;
  18871. private _getRigCamPositionAndTarget;
  18872. /**
  18873. * Gets the current object class name.
  18874. * @return the class name
  18875. */
  18876. getClassName(): string;
  18877. }
  18878. }
  18879. declare module "babylonjs/Events/keyboardEvents" {
  18880. /**
  18881. * Gather the list of keyboard event types as constants.
  18882. */
  18883. export class KeyboardEventTypes {
  18884. /**
  18885. * The keydown event is fired when a key becomes active (pressed).
  18886. */
  18887. static readonly KEYDOWN: number;
  18888. /**
  18889. * The keyup event is fired when a key has been released.
  18890. */
  18891. static readonly KEYUP: number;
  18892. }
  18893. /**
  18894. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18895. */
  18896. export class KeyboardInfo {
  18897. /**
  18898. * Defines the type of event (KeyboardEventTypes)
  18899. */
  18900. type: number;
  18901. /**
  18902. * Defines the related dom event
  18903. */
  18904. event: KeyboardEvent;
  18905. /**
  18906. * Instantiates a new keyboard info.
  18907. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18908. * @param type Defines the type of event (KeyboardEventTypes)
  18909. * @param event Defines the related dom event
  18910. */
  18911. constructor(
  18912. /**
  18913. * Defines the type of event (KeyboardEventTypes)
  18914. */
  18915. type: number,
  18916. /**
  18917. * Defines the related dom event
  18918. */
  18919. event: KeyboardEvent);
  18920. }
  18921. /**
  18922. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18923. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18924. */
  18925. export class KeyboardInfoPre extends KeyboardInfo {
  18926. /**
  18927. * Defines the type of event (KeyboardEventTypes)
  18928. */
  18929. type: number;
  18930. /**
  18931. * Defines the related dom event
  18932. */
  18933. event: KeyboardEvent;
  18934. /**
  18935. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18936. */
  18937. skipOnPointerObservable: boolean;
  18938. /**
  18939. * Instantiates a new keyboard pre info.
  18940. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18941. * @param type Defines the type of event (KeyboardEventTypes)
  18942. * @param event Defines the related dom event
  18943. */
  18944. constructor(
  18945. /**
  18946. * Defines the type of event (KeyboardEventTypes)
  18947. */
  18948. type: number,
  18949. /**
  18950. * Defines the related dom event
  18951. */
  18952. event: KeyboardEvent);
  18953. }
  18954. }
  18955. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18956. import { Nullable } from "babylonjs/types";
  18957. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18958. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18959. /**
  18960. * Manage the keyboard inputs to control the movement of a free camera.
  18961. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18962. */
  18963. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18964. /**
  18965. * Defines the camera the input is attached to.
  18966. */
  18967. camera: FreeCamera;
  18968. /**
  18969. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18970. */
  18971. keysUp: number[];
  18972. /**
  18973. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18974. */
  18975. keysUpward: number[];
  18976. /**
  18977. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18978. */
  18979. keysDown: number[];
  18980. /**
  18981. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18982. */
  18983. keysDownward: number[];
  18984. /**
  18985. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18986. */
  18987. keysLeft: number[];
  18988. /**
  18989. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18990. */
  18991. keysRight: number[];
  18992. private _keys;
  18993. private _onCanvasBlurObserver;
  18994. private _onKeyboardObserver;
  18995. private _engine;
  18996. private _scene;
  18997. /**
  18998. * Attach the input controls to a specific dom element to get the input from.
  18999. * @param element Defines the element the controls should be listened from
  19000. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19001. */
  19002. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19003. /**
  19004. * Detach the current controls from the specified dom element.
  19005. * @param element Defines the element to stop listening the inputs from
  19006. */
  19007. detachControl(element: Nullable<HTMLElement>): void;
  19008. /**
  19009. * Update the current camera state depending on the inputs that have been used this frame.
  19010. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19011. */
  19012. checkInputs(): void;
  19013. /**
  19014. * Gets the class name of the current intput.
  19015. * @returns the class name
  19016. */
  19017. getClassName(): string;
  19018. /** @hidden */
  19019. _onLostFocus(): void;
  19020. /**
  19021. * Get the friendly name associated with the input class.
  19022. * @returns the input friendly name
  19023. */
  19024. getSimpleName(): string;
  19025. }
  19026. }
  19027. declare module "babylonjs/Events/pointerEvents" {
  19028. import { Nullable } from "babylonjs/types";
  19029. import { Vector2 } from "babylonjs/Maths/math.vector";
  19030. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19031. import { Ray } from "babylonjs/Culling/ray";
  19032. /**
  19033. * Gather the list of pointer event types as constants.
  19034. */
  19035. export class PointerEventTypes {
  19036. /**
  19037. * 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.
  19038. */
  19039. static readonly POINTERDOWN: number;
  19040. /**
  19041. * The pointerup event is fired when a pointer is no longer active.
  19042. */
  19043. static readonly POINTERUP: number;
  19044. /**
  19045. * The pointermove event is fired when a pointer changes coordinates.
  19046. */
  19047. static readonly POINTERMOVE: number;
  19048. /**
  19049. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19050. */
  19051. static readonly POINTERWHEEL: number;
  19052. /**
  19053. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19054. */
  19055. static readonly POINTERPICK: number;
  19056. /**
  19057. * The pointertap event is fired when a the object has been touched and released without drag.
  19058. */
  19059. static readonly POINTERTAP: number;
  19060. /**
  19061. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19062. */
  19063. static readonly POINTERDOUBLETAP: number;
  19064. }
  19065. /**
  19066. * Base class of pointer info types.
  19067. */
  19068. export class PointerInfoBase {
  19069. /**
  19070. * Defines the type of event (PointerEventTypes)
  19071. */
  19072. type: number;
  19073. /**
  19074. * Defines the related dom event
  19075. */
  19076. event: PointerEvent | MouseWheelEvent;
  19077. /**
  19078. * Instantiates the base class of pointers info.
  19079. * @param type Defines the type of event (PointerEventTypes)
  19080. * @param event Defines the related dom event
  19081. */
  19082. constructor(
  19083. /**
  19084. * Defines the type of event (PointerEventTypes)
  19085. */
  19086. type: number,
  19087. /**
  19088. * Defines the related dom event
  19089. */
  19090. event: PointerEvent | MouseWheelEvent);
  19091. }
  19092. /**
  19093. * This class is used to store pointer related info for the onPrePointerObservable event.
  19094. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19095. */
  19096. export class PointerInfoPre extends PointerInfoBase {
  19097. /**
  19098. * Ray from a pointer if availible (eg. 6dof controller)
  19099. */
  19100. ray: Nullable<Ray>;
  19101. /**
  19102. * Defines the local position of the pointer on the canvas.
  19103. */
  19104. localPosition: Vector2;
  19105. /**
  19106. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19107. */
  19108. skipOnPointerObservable: boolean;
  19109. /**
  19110. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19111. * @param type Defines the type of event (PointerEventTypes)
  19112. * @param event Defines the related dom event
  19113. * @param localX Defines the local x coordinates of the pointer when the event occured
  19114. * @param localY Defines the local y coordinates of the pointer when the event occured
  19115. */
  19116. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19117. }
  19118. /**
  19119. * This type contains all the data related to a pointer event in Babylon.js.
  19120. * 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.
  19121. */
  19122. export class PointerInfo extends PointerInfoBase {
  19123. /**
  19124. * Defines the picking info associated to the info (if any)\
  19125. */
  19126. pickInfo: Nullable<PickingInfo>;
  19127. /**
  19128. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19129. * @param type Defines the type of event (PointerEventTypes)
  19130. * @param event Defines the related dom event
  19131. * @param pickInfo Defines the picking info associated to the info (if any)\
  19132. */
  19133. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19134. /**
  19135. * Defines the picking info associated to the info (if any)\
  19136. */
  19137. pickInfo: Nullable<PickingInfo>);
  19138. }
  19139. /**
  19140. * Data relating to a touch event on the screen.
  19141. */
  19142. export interface PointerTouch {
  19143. /**
  19144. * X coordinate of touch.
  19145. */
  19146. x: number;
  19147. /**
  19148. * Y coordinate of touch.
  19149. */
  19150. y: number;
  19151. /**
  19152. * Id of touch. Unique for each finger.
  19153. */
  19154. pointerId: number;
  19155. /**
  19156. * Event type passed from DOM.
  19157. */
  19158. type: any;
  19159. }
  19160. }
  19161. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19162. import { Observable } from "babylonjs/Misc/observable";
  19163. import { Nullable } from "babylonjs/types";
  19164. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19165. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19166. /**
  19167. * Manage the mouse inputs to control the movement of a free camera.
  19168. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19169. */
  19170. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19171. /**
  19172. * Define if touch is enabled in the mouse input
  19173. */
  19174. touchEnabled: boolean;
  19175. /**
  19176. * Defines the camera the input is attached to.
  19177. */
  19178. camera: FreeCamera;
  19179. /**
  19180. * Defines the buttons associated with the input to handle camera move.
  19181. */
  19182. buttons: number[];
  19183. /**
  19184. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19185. */
  19186. angularSensibility: number;
  19187. private _pointerInput;
  19188. private _onMouseMove;
  19189. private _observer;
  19190. private previousPosition;
  19191. /**
  19192. * Observable for when a pointer move event occurs containing the move offset
  19193. */
  19194. onPointerMovedObservable: Observable<{
  19195. offsetX: number;
  19196. offsetY: number;
  19197. }>;
  19198. /**
  19199. * @hidden
  19200. * If the camera should be rotated automatically based on pointer movement
  19201. */
  19202. _allowCameraRotation: boolean;
  19203. /**
  19204. * Manage the mouse inputs to control the movement of a free camera.
  19205. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19206. * @param touchEnabled Defines if touch is enabled or not
  19207. */
  19208. constructor(
  19209. /**
  19210. * Define if touch is enabled in the mouse input
  19211. */
  19212. touchEnabled?: boolean);
  19213. /**
  19214. * Attach the input controls to a specific dom element to get the input from.
  19215. * @param element Defines the element the controls should be listened from
  19216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19217. */
  19218. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19219. /**
  19220. * Called on JS contextmenu event.
  19221. * Override this method to provide functionality.
  19222. */
  19223. protected onContextMenu(evt: PointerEvent): void;
  19224. /**
  19225. * Detach the current controls from the specified dom element.
  19226. * @param element Defines the element to stop listening the inputs from
  19227. */
  19228. detachControl(element: Nullable<HTMLElement>): void;
  19229. /**
  19230. * Gets the class name of the current intput.
  19231. * @returns the class name
  19232. */
  19233. getClassName(): string;
  19234. /**
  19235. * Get the friendly name associated with the input class.
  19236. * @returns the input friendly name
  19237. */
  19238. getSimpleName(): string;
  19239. }
  19240. }
  19241. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19242. import { Nullable } from "babylonjs/types";
  19243. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19244. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19245. /**
  19246. * Manage the touch inputs to control the movement of a free camera.
  19247. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19248. */
  19249. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19250. /**
  19251. * Defines the camera the input is attached to.
  19252. */
  19253. camera: FreeCamera;
  19254. /**
  19255. * Defines the touch sensibility for rotation.
  19256. * The higher the faster.
  19257. */
  19258. touchAngularSensibility: number;
  19259. /**
  19260. * Defines the touch sensibility for move.
  19261. * The higher the faster.
  19262. */
  19263. touchMoveSensibility: number;
  19264. private _offsetX;
  19265. private _offsetY;
  19266. private _pointerPressed;
  19267. private _pointerInput;
  19268. private _observer;
  19269. private _onLostFocus;
  19270. /**
  19271. * Attach the input controls to a specific dom element to get the input from.
  19272. * @param element Defines the element the controls should be listened from
  19273. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19274. */
  19275. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19276. /**
  19277. * Detach the current controls from the specified dom element.
  19278. * @param element Defines the element to stop listening the inputs from
  19279. */
  19280. detachControl(element: Nullable<HTMLElement>): void;
  19281. /**
  19282. * Update the current camera state depending on the inputs that have been used this frame.
  19283. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19284. */
  19285. checkInputs(): void;
  19286. /**
  19287. * Gets the class name of the current intput.
  19288. * @returns the class name
  19289. */
  19290. getClassName(): string;
  19291. /**
  19292. * Get the friendly name associated with the input class.
  19293. * @returns the input friendly name
  19294. */
  19295. getSimpleName(): string;
  19296. }
  19297. }
  19298. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19299. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19300. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19301. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19302. import { Nullable } from "babylonjs/types";
  19303. /**
  19304. * Default Inputs manager for the FreeCamera.
  19305. * It groups all the default supported inputs for ease of use.
  19306. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19307. */
  19308. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19309. /**
  19310. * @hidden
  19311. */
  19312. _mouseInput: Nullable<FreeCameraMouseInput>;
  19313. /**
  19314. * Instantiates a new FreeCameraInputsManager.
  19315. * @param camera Defines the camera the inputs belong to
  19316. */
  19317. constructor(camera: FreeCamera);
  19318. /**
  19319. * Add keyboard input support to the input manager.
  19320. * @returns the current input manager
  19321. */
  19322. addKeyboard(): FreeCameraInputsManager;
  19323. /**
  19324. * Add mouse input support to the input manager.
  19325. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19326. * @returns the current input manager
  19327. */
  19328. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19329. /**
  19330. * Removes the mouse input support from the manager
  19331. * @returns the current input manager
  19332. */
  19333. removeMouse(): FreeCameraInputsManager;
  19334. /**
  19335. * Add touch input support to the input manager.
  19336. * @returns the current input manager
  19337. */
  19338. addTouch(): FreeCameraInputsManager;
  19339. /**
  19340. * Remove all attached input methods from a camera
  19341. */
  19342. clear(): void;
  19343. }
  19344. }
  19345. declare module "babylonjs/Cameras/freeCamera" {
  19346. import { Vector3 } from "babylonjs/Maths/math.vector";
  19347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19348. import { Scene } from "babylonjs/scene";
  19349. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19350. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19351. /**
  19352. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19353. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19354. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19355. */
  19356. export class FreeCamera extends TargetCamera {
  19357. /**
  19358. * Define the collision ellipsoid of the camera.
  19359. * This is helpful to simulate a camera body like the player body around the camera
  19360. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19361. */
  19362. ellipsoid: Vector3;
  19363. /**
  19364. * Define an offset for the position of the ellipsoid around the camera.
  19365. * This can be helpful to determine the center of the body near the gravity center of the body
  19366. * instead of its head.
  19367. */
  19368. ellipsoidOffset: Vector3;
  19369. /**
  19370. * Enable or disable collisions of the camera with the rest of the scene objects.
  19371. */
  19372. checkCollisions: boolean;
  19373. /**
  19374. * Enable or disable gravity on the camera.
  19375. */
  19376. applyGravity: boolean;
  19377. /**
  19378. * Define the input manager associated to the camera.
  19379. */
  19380. inputs: FreeCameraInputsManager;
  19381. /**
  19382. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19383. * Higher values reduce sensitivity.
  19384. */
  19385. get angularSensibility(): number;
  19386. /**
  19387. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19388. * Higher values reduce sensitivity.
  19389. */
  19390. set angularSensibility(value: number);
  19391. /**
  19392. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19393. */
  19394. get keysUp(): number[];
  19395. set keysUp(value: number[]);
  19396. /**
  19397. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19398. */
  19399. get keysUpward(): number[];
  19400. set keysUpward(value: number[]);
  19401. /**
  19402. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19403. */
  19404. get keysDown(): number[];
  19405. set keysDown(value: number[]);
  19406. /**
  19407. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19408. */
  19409. get keysDownward(): number[];
  19410. set keysDownward(value: number[]);
  19411. /**
  19412. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19413. */
  19414. get keysLeft(): number[];
  19415. set keysLeft(value: number[]);
  19416. /**
  19417. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19418. */
  19419. get keysRight(): number[];
  19420. set keysRight(value: number[]);
  19421. /**
  19422. * Event raised when the camera collide with a mesh in the scene.
  19423. */
  19424. onCollide: (collidedMesh: AbstractMesh) => void;
  19425. private _collider;
  19426. private _needMoveForGravity;
  19427. private _oldPosition;
  19428. private _diffPosition;
  19429. private _newPosition;
  19430. /** @hidden */
  19431. _localDirection: Vector3;
  19432. /** @hidden */
  19433. _transformedDirection: Vector3;
  19434. /**
  19435. * Instantiates a Free Camera.
  19436. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19437. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19438. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19439. * @param name Define the name of the camera in the scene
  19440. * @param position Define the start position of the camera in the scene
  19441. * @param scene Define the scene the camera belongs to
  19442. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19443. */
  19444. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19445. /**
  19446. * Attached controls to the current camera.
  19447. * @param element Defines the element the controls should be listened from
  19448. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19449. */
  19450. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19451. /**
  19452. * Detach the current controls from the camera.
  19453. * The camera will stop reacting to inputs.
  19454. * @param element Defines the element to stop listening the inputs from
  19455. */
  19456. detachControl(element: HTMLElement): void;
  19457. private _collisionMask;
  19458. /**
  19459. * Define a collision mask to limit the list of object the camera can collide with
  19460. */
  19461. get collisionMask(): number;
  19462. set collisionMask(mask: number);
  19463. /** @hidden */
  19464. _collideWithWorld(displacement: Vector3): void;
  19465. private _onCollisionPositionChange;
  19466. /** @hidden */
  19467. _checkInputs(): void;
  19468. /** @hidden */
  19469. _decideIfNeedsToMove(): boolean;
  19470. /** @hidden */
  19471. _updatePosition(): void;
  19472. /**
  19473. * Destroy the camera and release the current resources hold by it.
  19474. */
  19475. dispose(): void;
  19476. /**
  19477. * Gets the current object class name.
  19478. * @return the class name
  19479. */
  19480. getClassName(): string;
  19481. }
  19482. }
  19483. declare module "babylonjs/Gamepads/gamepad" {
  19484. import { Observable } from "babylonjs/Misc/observable";
  19485. /**
  19486. * Represents a gamepad control stick position
  19487. */
  19488. export class StickValues {
  19489. /**
  19490. * The x component of the control stick
  19491. */
  19492. x: number;
  19493. /**
  19494. * The y component of the control stick
  19495. */
  19496. y: number;
  19497. /**
  19498. * Initializes the gamepad x and y control stick values
  19499. * @param x The x component of the gamepad control stick value
  19500. * @param y The y component of the gamepad control stick value
  19501. */
  19502. constructor(
  19503. /**
  19504. * The x component of the control stick
  19505. */
  19506. x: number,
  19507. /**
  19508. * The y component of the control stick
  19509. */
  19510. y: number);
  19511. }
  19512. /**
  19513. * An interface which manages callbacks for gamepad button changes
  19514. */
  19515. export interface GamepadButtonChanges {
  19516. /**
  19517. * Called when a gamepad has been changed
  19518. */
  19519. changed: boolean;
  19520. /**
  19521. * Called when a gamepad press event has been triggered
  19522. */
  19523. pressChanged: boolean;
  19524. /**
  19525. * Called when a touch event has been triggered
  19526. */
  19527. touchChanged: boolean;
  19528. /**
  19529. * Called when a value has changed
  19530. */
  19531. valueChanged: boolean;
  19532. }
  19533. /**
  19534. * Represents a gamepad
  19535. */
  19536. export class Gamepad {
  19537. /**
  19538. * The id of the gamepad
  19539. */
  19540. id: string;
  19541. /**
  19542. * The index of the gamepad
  19543. */
  19544. index: number;
  19545. /**
  19546. * The browser gamepad
  19547. */
  19548. browserGamepad: any;
  19549. /**
  19550. * Specifies what type of gamepad this represents
  19551. */
  19552. type: number;
  19553. private _leftStick;
  19554. private _rightStick;
  19555. /** @hidden */
  19556. _isConnected: boolean;
  19557. private _leftStickAxisX;
  19558. private _leftStickAxisY;
  19559. private _rightStickAxisX;
  19560. private _rightStickAxisY;
  19561. /**
  19562. * Triggered when the left control stick has been changed
  19563. */
  19564. private _onleftstickchanged;
  19565. /**
  19566. * Triggered when the right control stick has been changed
  19567. */
  19568. private _onrightstickchanged;
  19569. /**
  19570. * Represents a gamepad controller
  19571. */
  19572. static GAMEPAD: number;
  19573. /**
  19574. * Represents a generic controller
  19575. */
  19576. static GENERIC: number;
  19577. /**
  19578. * Represents an XBox controller
  19579. */
  19580. static XBOX: number;
  19581. /**
  19582. * Represents a pose-enabled controller
  19583. */
  19584. static POSE_ENABLED: number;
  19585. /**
  19586. * Represents an Dual Shock controller
  19587. */
  19588. static DUALSHOCK: number;
  19589. /**
  19590. * Specifies whether the left control stick should be Y-inverted
  19591. */
  19592. protected _invertLeftStickY: boolean;
  19593. /**
  19594. * Specifies if the gamepad has been connected
  19595. */
  19596. get isConnected(): boolean;
  19597. /**
  19598. * Initializes the gamepad
  19599. * @param id The id of the gamepad
  19600. * @param index The index of the gamepad
  19601. * @param browserGamepad The browser gamepad
  19602. * @param leftStickX The x component of the left joystick
  19603. * @param leftStickY The y component of the left joystick
  19604. * @param rightStickX The x component of the right joystick
  19605. * @param rightStickY The y component of the right joystick
  19606. */
  19607. constructor(
  19608. /**
  19609. * The id of the gamepad
  19610. */
  19611. id: string,
  19612. /**
  19613. * The index of the gamepad
  19614. */
  19615. index: number,
  19616. /**
  19617. * The browser gamepad
  19618. */
  19619. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19620. /**
  19621. * Callback triggered when the left joystick has changed
  19622. * @param callback
  19623. */
  19624. onleftstickchanged(callback: (values: StickValues) => void): void;
  19625. /**
  19626. * Callback triggered when the right joystick has changed
  19627. * @param callback
  19628. */
  19629. onrightstickchanged(callback: (values: StickValues) => void): void;
  19630. /**
  19631. * Gets the left joystick
  19632. */
  19633. get leftStick(): StickValues;
  19634. /**
  19635. * Sets the left joystick values
  19636. */
  19637. set leftStick(newValues: StickValues);
  19638. /**
  19639. * Gets the right joystick
  19640. */
  19641. get rightStick(): StickValues;
  19642. /**
  19643. * Sets the right joystick value
  19644. */
  19645. set rightStick(newValues: StickValues);
  19646. /**
  19647. * Updates the gamepad joystick positions
  19648. */
  19649. update(): void;
  19650. /**
  19651. * Disposes the gamepad
  19652. */
  19653. dispose(): void;
  19654. }
  19655. /**
  19656. * Represents a generic gamepad
  19657. */
  19658. export class GenericPad extends Gamepad {
  19659. private _buttons;
  19660. private _onbuttondown;
  19661. private _onbuttonup;
  19662. /**
  19663. * Observable triggered when a button has been pressed
  19664. */
  19665. onButtonDownObservable: Observable<number>;
  19666. /**
  19667. * Observable triggered when a button has been released
  19668. */
  19669. onButtonUpObservable: Observable<number>;
  19670. /**
  19671. * Callback triggered when a button has been pressed
  19672. * @param callback Called when a button has been pressed
  19673. */
  19674. onbuttondown(callback: (buttonPressed: number) => void): void;
  19675. /**
  19676. * Callback triggered when a button has been released
  19677. * @param callback Called when a button has been released
  19678. */
  19679. onbuttonup(callback: (buttonReleased: number) => void): void;
  19680. /**
  19681. * Initializes the generic gamepad
  19682. * @param id The id of the generic gamepad
  19683. * @param index The index of the generic gamepad
  19684. * @param browserGamepad The browser gamepad
  19685. */
  19686. constructor(id: string, index: number, browserGamepad: any);
  19687. private _setButtonValue;
  19688. /**
  19689. * Updates the generic gamepad
  19690. */
  19691. update(): void;
  19692. /**
  19693. * Disposes the generic gamepad
  19694. */
  19695. dispose(): void;
  19696. }
  19697. }
  19698. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19699. import { Observable } from "babylonjs/Misc/observable";
  19700. import { Nullable } from "babylonjs/types";
  19701. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19702. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19704. import { Ray } from "babylonjs/Culling/ray";
  19705. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19706. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19707. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19708. /**
  19709. * Defines the types of pose enabled controllers that are supported
  19710. */
  19711. export enum PoseEnabledControllerType {
  19712. /**
  19713. * HTC Vive
  19714. */
  19715. VIVE = 0,
  19716. /**
  19717. * Oculus Rift
  19718. */
  19719. OCULUS = 1,
  19720. /**
  19721. * Windows mixed reality
  19722. */
  19723. WINDOWS = 2,
  19724. /**
  19725. * Samsung gear VR
  19726. */
  19727. GEAR_VR = 3,
  19728. /**
  19729. * Google Daydream
  19730. */
  19731. DAYDREAM = 4,
  19732. /**
  19733. * Generic
  19734. */
  19735. GENERIC = 5
  19736. }
  19737. /**
  19738. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19739. */
  19740. export interface MutableGamepadButton {
  19741. /**
  19742. * Value of the button/trigger
  19743. */
  19744. value: number;
  19745. /**
  19746. * If the button/trigger is currently touched
  19747. */
  19748. touched: boolean;
  19749. /**
  19750. * If the button/trigger is currently pressed
  19751. */
  19752. pressed: boolean;
  19753. }
  19754. /**
  19755. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19756. * @hidden
  19757. */
  19758. export interface ExtendedGamepadButton extends GamepadButton {
  19759. /**
  19760. * If the button/trigger is currently pressed
  19761. */
  19762. readonly pressed: boolean;
  19763. /**
  19764. * If the button/trigger is currently touched
  19765. */
  19766. readonly touched: boolean;
  19767. /**
  19768. * Value of the button/trigger
  19769. */
  19770. readonly value: number;
  19771. }
  19772. /** @hidden */
  19773. export interface _GamePadFactory {
  19774. /**
  19775. * Returns whether or not the current gamepad can be created for this type of controller.
  19776. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19777. * @returns true if it can be created, otherwise false
  19778. */
  19779. canCreate(gamepadInfo: any): boolean;
  19780. /**
  19781. * Creates a new instance of the Gamepad.
  19782. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19783. * @returns the new gamepad instance
  19784. */
  19785. create(gamepadInfo: any): Gamepad;
  19786. }
  19787. /**
  19788. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19789. */
  19790. export class PoseEnabledControllerHelper {
  19791. /** @hidden */
  19792. static _ControllerFactories: _GamePadFactory[];
  19793. /** @hidden */
  19794. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19795. /**
  19796. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19797. * @param vrGamepad the gamepad to initialized
  19798. * @returns a vr controller of the type the gamepad identified as
  19799. */
  19800. static InitiateController(vrGamepad: any): Gamepad;
  19801. }
  19802. /**
  19803. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19804. */
  19805. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19806. /**
  19807. * If the controller is used in a webXR session
  19808. */
  19809. isXR: boolean;
  19810. private _deviceRoomPosition;
  19811. private _deviceRoomRotationQuaternion;
  19812. /**
  19813. * The device position in babylon space
  19814. */
  19815. devicePosition: Vector3;
  19816. /**
  19817. * The device rotation in babylon space
  19818. */
  19819. deviceRotationQuaternion: Quaternion;
  19820. /**
  19821. * The scale factor of the device in babylon space
  19822. */
  19823. deviceScaleFactor: number;
  19824. /**
  19825. * (Likely devicePosition should be used instead) The device position in its room space
  19826. */
  19827. position: Vector3;
  19828. /**
  19829. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19830. */
  19831. rotationQuaternion: Quaternion;
  19832. /**
  19833. * The type of controller (Eg. Windows mixed reality)
  19834. */
  19835. controllerType: PoseEnabledControllerType;
  19836. protected _calculatedPosition: Vector3;
  19837. private _calculatedRotation;
  19838. /**
  19839. * The raw pose from the device
  19840. */
  19841. rawPose: DevicePose;
  19842. private _trackPosition;
  19843. private _maxRotationDistFromHeadset;
  19844. private _draggedRoomRotation;
  19845. /**
  19846. * @hidden
  19847. */
  19848. _disableTrackPosition(fixedPosition: Vector3): void;
  19849. /**
  19850. * Internal, the mesh attached to the controller
  19851. * @hidden
  19852. */
  19853. _mesh: Nullable<AbstractMesh>;
  19854. private _poseControlledCamera;
  19855. private _leftHandSystemQuaternion;
  19856. /**
  19857. * Internal, matrix used to convert room space to babylon space
  19858. * @hidden
  19859. */
  19860. _deviceToWorld: Matrix;
  19861. /**
  19862. * Node to be used when casting a ray from the controller
  19863. * @hidden
  19864. */
  19865. _pointingPoseNode: Nullable<TransformNode>;
  19866. /**
  19867. * Name of the child mesh that can be used to cast a ray from the controller
  19868. */
  19869. static readonly POINTING_POSE: string;
  19870. /**
  19871. * Creates a new PoseEnabledController from a gamepad
  19872. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19873. */
  19874. constructor(browserGamepad: any);
  19875. private _workingMatrix;
  19876. /**
  19877. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19878. */
  19879. update(): void;
  19880. /**
  19881. * Updates only the pose device and mesh without doing any button event checking
  19882. */
  19883. protected _updatePoseAndMesh(): void;
  19884. /**
  19885. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19886. * @param poseData raw pose fromthe device
  19887. */
  19888. updateFromDevice(poseData: DevicePose): void;
  19889. /**
  19890. * @hidden
  19891. */
  19892. _meshAttachedObservable: Observable<AbstractMesh>;
  19893. /**
  19894. * Attaches a mesh to the controller
  19895. * @param mesh the mesh to be attached
  19896. */
  19897. attachToMesh(mesh: AbstractMesh): void;
  19898. /**
  19899. * Attaches the controllers mesh to a camera
  19900. * @param camera the camera the mesh should be attached to
  19901. */
  19902. attachToPoseControlledCamera(camera: TargetCamera): void;
  19903. /**
  19904. * Disposes of the controller
  19905. */
  19906. dispose(): void;
  19907. /**
  19908. * The mesh that is attached to the controller
  19909. */
  19910. get mesh(): Nullable<AbstractMesh>;
  19911. /**
  19912. * Gets the ray of the controller in the direction the controller is pointing
  19913. * @param length the length the resulting ray should be
  19914. * @returns a ray in the direction the controller is pointing
  19915. */
  19916. getForwardRay(length?: number): Ray;
  19917. }
  19918. }
  19919. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19920. import { Observable } from "babylonjs/Misc/observable";
  19921. import { Scene } from "babylonjs/scene";
  19922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19923. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19924. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19925. import { Nullable } from "babylonjs/types";
  19926. /**
  19927. * Defines the WebVRController object that represents controllers tracked in 3D space
  19928. */
  19929. export abstract class WebVRController extends PoseEnabledController {
  19930. /**
  19931. * Internal, the default controller model for the controller
  19932. */
  19933. protected _defaultModel: Nullable<AbstractMesh>;
  19934. /**
  19935. * Fired when the trigger state has changed
  19936. */
  19937. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19938. /**
  19939. * Fired when the main button state has changed
  19940. */
  19941. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19942. /**
  19943. * Fired when the secondary button state has changed
  19944. */
  19945. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19946. /**
  19947. * Fired when the pad state has changed
  19948. */
  19949. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19950. /**
  19951. * Fired when controllers stick values have changed
  19952. */
  19953. onPadValuesChangedObservable: Observable<StickValues>;
  19954. /**
  19955. * Array of button availible on the controller
  19956. */
  19957. protected _buttons: Array<MutableGamepadButton>;
  19958. private _onButtonStateChange;
  19959. /**
  19960. * Fired when a controller button's state has changed
  19961. * @param callback the callback containing the button that was modified
  19962. */
  19963. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19964. /**
  19965. * X and Y axis corresponding to the controllers joystick
  19966. */
  19967. pad: StickValues;
  19968. /**
  19969. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19970. */
  19971. hand: string;
  19972. /**
  19973. * The default controller model for the controller
  19974. */
  19975. get defaultModel(): Nullable<AbstractMesh>;
  19976. /**
  19977. * Creates a new WebVRController from a gamepad
  19978. * @param vrGamepad the gamepad that the WebVRController should be created from
  19979. */
  19980. constructor(vrGamepad: any);
  19981. /**
  19982. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19983. */
  19984. update(): void;
  19985. /**
  19986. * Function to be called when a button is modified
  19987. */
  19988. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19989. /**
  19990. * Loads a mesh and attaches it to the controller
  19991. * @param scene the scene the mesh should be added to
  19992. * @param meshLoaded callback for when the mesh has been loaded
  19993. */
  19994. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19995. private _setButtonValue;
  19996. private _changes;
  19997. private _checkChanges;
  19998. /**
  19999. * Disposes of th webVRCOntroller
  20000. */
  20001. dispose(): void;
  20002. }
  20003. }
  20004. declare module "babylonjs/Lights/hemisphericLight" {
  20005. import { Nullable } from "babylonjs/types";
  20006. import { Scene } from "babylonjs/scene";
  20007. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20008. import { Color3 } from "babylonjs/Maths/math.color";
  20009. import { Effect } from "babylonjs/Materials/effect";
  20010. import { Light } from "babylonjs/Lights/light";
  20011. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20012. /**
  20013. * The HemisphericLight simulates the ambient environment light,
  20014. * so the passed direction is the light reflection direction, not the incoming direction.
  20015. */
  20016. export class HemisphericLight extends Light {
  20017. /**
  20018. * The groundColor is the light in the opposite direction to the one specified during creation.
  20019. * 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.
  20020. */
  20021. groundColor: Color3;
  20022. /**
  20023. * The light reflection direction, not the incoming direction.
  20024. */
  20025. direction: Vector3;
  20026. /**
  20027. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20028. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20029. * The HemisphericLight can't cast shadows.
  20030. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20031. * @param name The friendly name of the light
  20032. * @param direction The direction of the light reflection
  20033. * @param scene The scene the light belongs to
  20034. */
  20035. constructor(name: string, direction: Vector3, scene: Scene);
  20036. protected _buildUniformLayout(): void;
  20037. /**
  20038. * Returns the string "HemisphericLight".
  20039. * @return The class name
  20040. */
  20041. getClassName(): string;
  20042. /**
  20043. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20044. * Returns the updated direction.
  20045. * @param target The target the direction should point to
  20046. * @return The computed direction
  20047. */
  20048. setDirectionToTarget(target: Vector3): Vector3;
  20049. /**
  20050. * Returns the shadow generator associated to the light.
  20051. * @returns Always null for hemispheric lights because it does not support shadows.
  20052. */
  20053. getShadowGenerator(): Nullable<IShadowGenerator>;
  20054. /**
  20055. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20056. * @param effect The effect to update
  20057. * @param lightIndex The index of the light in the effect to update
  20058. * @returns The hemispheric light
  20059. */
  20060. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20061. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20062. /**
  20063. * Computes the world matrix of the node
  20064. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20065. * @param useWasUpdatedFlag defines a reserved property
  20066. * @returns the world matrix
  20067. */
  20068. computeWorldMatrix(): Matrix;
  20069. /**
  20070. * Returns the integer 3.
  20071. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20072. */
  20073. getTypeID(): number;
  20074. /**
  20075. * Prepares the list of defines specific to the light type.
  20076. * @param defines the list of defines
  20077. * @param lightIndex defines the index of the light for the effect
  20078. */
  20079. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20080. }
  20081. }
  20082. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20083. /** @hidden */
  20084. export var vrMultiviewToSingleviewPixelShader: {
  20085. name: string;
  20086. shader: string;
  20087. };
  20088. }
  20089. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20090. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20091. import { Scene } from "babylonjs/scene";
  20092. /**
  20093. * Renders to multiple views with a single draw call
  20094. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20095. */
  20096. export class MultiviewRenderTarget extends RenderTargetTexture {
  20097. /**
  20098. * Creates a multiview render target
  20099. * @param scene scene used with the render target
  20100. * @param size the size of the render target (used for each view)
  20101. */
  20102. constructor(scene: Scene, size?: number | {
  20103. width: number;
  20104. height: number;
  20105. } | {
  20106. ratio: number;
  20107. });
  20108. /**
  20109. * @hidden
  20110. * @param faceIndex the face index, if its a cube texture
  20111. */
  20112. _bindFrameBuffer(faceIndex?: number): void;
  20113. /**
  20114. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20115. * @returns the view count
  20116. */
  20117. getViewCount(): number;
  20118. }
  20119. }
  20120. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20121. import { Camera } from "babylonjs/Cameras/camera";
  20122. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20123. import { Nullable } from "babylonjs/types";
  20124. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20125. import { Matrix } from "babylonjs/Maths/math.vector";
  20126. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20127. module "babylonjs/Engines/engine" {
  20128. interface Engine {
  20129. /**
  20130. * Creates a new multiview render target
  20131. * @param width defines the width of the texture
  20132. * @param height defines the height of the texture
  20133. * @returns the created multiview texture
  20134. */
  20135. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20136. /**
  20137. * Binds a multiview framebuffer to be drawn to
  20138. * @param multiviewTexture texture to bind
  20139. */
  20140. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20141. }
  20142. }
  20143. module "babylonjs/Cameras/camera" {
  20144. interface Camera {
  20145. /**
  20146. * @hidden
  20147. * 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)
  20148. */
  20149. _useMultiviewToSingleView: boolean;
  20150. /**
  20151. * @hidden
  20152. * 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)
  20153. */
  20154. _multiviewTexture: Nullable<RenderTargetTexture>;
  20155. /**
  20156. * @hidden
  20157. * ensures the multiview texture of the camera exists and has the specified width/height
  20158. * @param width height to set on the multiview texture
  20159. * @param height width to set on the multiview texture
  20160. */
  20161. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20162. }
  20163. }
  20164. module "babylonjs/scene" {
  20165. interface Scene {
  20166. /** @hidden */
  20167. _transformMatrixR: Matrix;
  20168. /** @hidden */
  20169. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20170. /** @hidden */
  20171. _createMultiviewUbo(): void;
  20172. /** @hidden */
  20173. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20174. /** @hidden */
  20175. _renderMultiviewToSingleView(camera: Camera): void;
  20176. }
  20177. }
  20178. }
  20179. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20180. import { Camera } from "babylonjs/Cameras/camera";
  20181. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20182. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20183. import "babylonjs/Engines/Extensions/engine.multiview";
  20184. /**
  20185. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20186. * This will not be used for webXR as it supports displaying texture arrays directly
  20187. */
  20188. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20189. /**
  20190. * Initializes a VRMultiviewToSingleview
  20191. * @param name name of the post process
  20192. * @param camera camera to be applied to
  20193. * @param scaleFactor scaling factor to the size of the output texture
  20194. */
  20195. constructor(name: string, camera: Camera, scaleFactor: number);
  20196. }
  20197. }
  20198. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20199. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20200. import { Nullable } from "babylonjs/types";
  20201. import { Size } from "babylonjs/Maths/math.size";
  20202. import { Observable } from "babylonjs/Misc/observable";
  20203. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20204. /**
  20205. * Interface used to define additional presentation attributes
  20206. */
  20207. export interface IVRPresentationAttributes {
  20208. /**
  20209. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20210. */
  20211. highRefreshRate: boolean;
  20212. /**
  20213. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20214. */
  20215. foveationLevel: number;
  20216. }
  20217. module "babylonjs/Engines/engine" {
  20218. interface Engine {
  20219. /** @hidden */
  20220. _vrDisplay: any;
  20221. /** @hidden */
  20222. _vrSupported: boolean;
  20223. /** @hidden */
  20224. _oldSize: Size;
  20225. /** @hidden */
  20226. _oldHardwareScaleFactor: number;
  20227. /** @hidden */
  20228. _vrExclusivePointerMode: boolean;
  20229. /** @hidden */
  20230. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20231. /** @hidden */
  20232. _onVRDisplayPointerRestricted: () => void;
  20233. /** @hidden */
  20234. _onVRDisplayPointerUnrestricted: () => void;
  20235. /** @hidden */
  20236. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20237. /** @hidden */
  20238. _onVrDisplayDisconnect: Nullable<() => void>;
  20239. /** @hidden */
  20240. _onVrDisplayPresentChange: Nullable<() => void>;
  20241. /**
  20242. * Observable signaled when VR display mode changes
  20243. */
  20244. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20245. /**
  20246. * Observable signaled when VR request present is complete
  20247. */
  20248. onVRRequestPresentComplete: Observable<boolean>;
  20249. /**
  20250. * Observable signaled when VR request present starts
  20251. */
  20252. onVRRequestPresentStart: Observable<Engine>;
  20253. /**
  20254. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20255. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20256. */
  20257. isInVRExclusivePointerMode: boolean;
  20258. /**
  20259. * Gets a boolean indicating if a webVR device was detected
  20260. * @returns true if a webVR device was detected
  20261. */
  20262. isVRDevicePresent(): boolean;
  20263. /**
  20264. * Gets the current webVR device
  20265. * @returns the current webVR device (or null)
  20266. */
  20267. getVRDevice(): any;
  20268. /**
  20269. * Initializes a webVR display and starts listening to display change events
  20270. * The onVRDisplayChangedObservable will be notified upon these changes
  20271. * @returns A promise containing a VRDisplay and if vr is supported
  20272. */
  20273. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20274. /** @hidden */
  20275. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20276. /**
  20277. * Gets or sets the presentation attributes used to configure VR rendering
  20278. */
  20279. vrPresentationAttributes?: IVRPresentationAttributes;
  20280. /**
  20281. * Call this function to switch to webVR mode
  20282. * Will do nothing if webVR is not supported or if there is no webVR device
  20283. * @param options the webvr options provided to the camera. mainly used for multiview
  20284. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20285. */
  20286. enableVR(options: WebVROptions): void;
  20287. /** @hidden */
  20288. _onVRFullScreenTriggered(): void;
  20289. }
  20290. }
  20291. }
  20292. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20293. import { Nullable } from "babylonjs/types";
  20294. import { Observable } from "babylonjs/Misc/observable";
  20295. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20296. import { Scene } from "babylonjs/scene";
  20297. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20298. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20299. import { Node } from "babylonjs/node";
  20300. import { Ray } from "babylonjs/Culling/ray";
  20301. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20302. import "babylonjs/Engines/Extensions/engine.webVR";
  20303. /**
  20304. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20305. * IMPORTANT!! The data is right-hand data.
  20306. * @export
  20307. * @interface DevicePose
  20308. */
  20309. export interface DevicePose {
  20310. /**
  20311. * The position of the device, values in array are [x,y,z].
  20312. */
  20313. readonly position: Nullable<Float32Array>;
  20314. /**
  20315. * The linearVelocity of the device, values in array are [x,y,z].
  20316. */
  20317. readonly linearVelocity: Nullable<Float32Array>;
  20318. /**
  20319. * The linearAcceleration of the device, values in array are [x,y,z].
  20320. */
  20321. readonly linearAcceleration: Nullable<Float32Array>;
  20322. /**
  20323. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20324. */
  20325. readonly orientation: Nullable<Float32Array>;
  20326. /**
  20327. * The angularVelocity of the device, values in array are [x,y,z].
  20328. */
  20329. readonly angularVelocity: Nullable<Float32Array>;
  20330. /**
  20331. * The angularAcceleration of the device, values in array are [x,y,z].
  20332. */
  20333. readonly angularAcceleration: Nullable<Float32Array>;
  20334. }
  20335. /**
  20336. * Interface representing a pose controlled object in Babylon.
  20337. * A pose controlled object has both regular pose values as well as pose values
  20338. * from an external device such as a VR head mounted display
  20339. */
  20340. export interface PoseControlled {
  20341. /**
  20342. * The position of the object in babylon space.
  20343. */
  20344. position: Vector3;
  20345. /**
  20346. * The rotation quaternion of the object in babylon space.
  20347. */
  20348. rotationQuaternion: Quaternion;
  20349. /**
  20350. * The position of the device in babylon space.
  20351. */
  20352. devicePosition?: Vector3;
  20353. /**
  20354. * The rotation quaternion of the device in babylon space.
  20355. */
  20356. deviceRotationQuaternion: Quaternion;
  20357. /**
  20358. * The raw pose coming from the device.
  20359. */
  20360. rawPose: Nullable<DevicePose>;
  20361. /**
  20362. * The scale of the device to be used when translating from device space to babylon space.
  20363. */
  20364. deviceScaleFactor: number;
  20365. /**
  20366. * Updates the poseControlled values based on the input device pose.
  20367. * @param poseData the pose data to update the object with
  20368. */
  20369. updateFromDevice(poseData: DevicePose): void;
  20370. }
  20371. /**
  20372. * Set of options to customize the webVRCamera
  20373. */
  20374. export interface WebVROptions {
  20375. /**
  20376. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20377. */
  20378. trackPosition?: boolean;
  20379. /**
  20380. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20381. */
  20382. positionScale?: number;
  20383. /**
  20384. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20385. */
  20386. displayName?: string;
  20387. /**
  20388. * Should the native controller meshes be initialized. (default: true)
  20389. */
  20390. controllerMeshes?: boolean;
  20391. /**
  20392. * Creating a default HemiLight only on controllers. (default: true)
  20393. */
  20394. defaultLightingOnControllers?: boolean;
  20395. /**
  20396. * If you don't want to use the default VR button of the helper. (default: false)
  20397. */
  20398. useCustomVRButton?: boolean;
  20399. /**
  20400. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20401. */
  20402. customVRButton?: HTMLButtonElement;
  20403. /**
  20404. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20405. */
  20406. rayLength?: number;
  20407. /**
  20408. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20409. */
  20410. defaultHeight?: number;
  20411. /**
  20412. * If multiview should be used if availible (default: false)
  20413. */
  20414. useMultiview?: boolean;
  20415. }
  20416. /**
  20417. * This represents a WebVR camera.
  20418. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20419. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20420. */
  20421. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20422. private webVROptions;
  20423. /**
  20424. * @hidden
  20425. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20426. */
  20427. _vrDevice: any;
  20428. /**
  20429. * The rawPose of the vrDevice.
  20430. */
  20431. rawPose: Nullable<DevicePose>;
  20432. private _onVREnabled;
  20433. private _specsVersion;
  20434. private _attached;
  20435. private _frameData;
  20436. protected _descendants: Array<Node>;
  20437. private _deviceRoomPosition;
  20438. /** @hidden */
  20439. _deviceRoomRotationQuaternion: Quaternion;
  20440. private _standingMatrix;
  20441. /**
  20442. * Represents device position in babylon space.
  20443. */
  20444. devicePosition: Vector3;
  20445. /**
  20446. * Represents device rotation in babylon space.
  20447. */
  20448. deviceRotationQuaternion: Quaternion;
  20449. /**
  20450. * The scale of the device to be used when translating from device space to babylon space.
  20451. */
  20452. deviceScaleFactor: number;
  20453. private _deviceToWorld;
  20454. private _worldToDevice;
  20455. /**
  20456. * References to the webVR controllers for the vrDevice.
  20457. */
  20458. controllers: Array<WebVRController>;
  20459. /**
  20460. * Emits an event when a controller is attached.
  20461. */
  20462. onControllersAttachedObservable: Observable<WebVRController[]>;
  20463. /**
  20464. * Emits an event when a controller's mesh has been loaded;
  20465. */
  20466. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20467. /**
  20468. * Emits an event when the HMD's pose has been updated.
  20469. */
  20470. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20471. private _poseSet;
  20472. /**
  20473. * If the rig cameras be used as parent instead of this camera.
  20474. */
  20475. rigParenting: boolean;
  20476. private _lightOnControllers;
  20477. private _defaultHeight?;
  20478. /**
  20479. * Instantiates a WebVRFreeCamera.
  20480. * @param name The name of the WebVRFreeCamera
  20481. * @param position The starting anchor position for the camera
  20482. * @param scene The scene the camera belongs to
  20483. * @param webVROptions a set of customizable options for the webVRCamera
  20484. */
  20485. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20486. /**
  20487. * Gets the device distance from the ground in meters.
  20488. * @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.
  20489. */
  20490. deviceDistanceToRoomGround(): number;
  20491. /**
  20492. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20493. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20494. */
  20495. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20496. /**
  20497. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20498. * @returns A promise with a boolean set to if the standing matrix is supported.
  20499. */
  20500. useStandingMatrixAsync(): Promise<boolean>;
  20501. /**
  20502. * Disposes the camera
  20503. */
  20504. dispose(): void;
  20505. /**
  20506. * Gets a vrController by name.
  20507. * @param name The name of the controller to retreive
  20508. * @returns the controller matching the name specified or null if not found
  20509. */
  20510. getControllerByName(name: string): Nullable<WebVRController>;
  20511. private _leftController;
  20512. /**
  20513. * The controller corresponding to the users left hand.
  20514. */
  20515. get leftController(): Nullable<WebVRController>;
  20516. private _rightController;
  20517. /**
  20518. * The controller corresponding to the users right hand.
  20519. */
  20520. get rightController(): Nullable<WebVRController>;
  20521. /**
  20522. * Casts a ray forward from the vrCamera's gaze.
  20523. * @param length Length of the ray (default: 100)
  20524. * @returns the ray corresponding to the gaze
  20525. */
  20526. getForwardRay(length?: number): Ray;
  20527. /**
  20528. * @hidden
  20529. * Updates the camera based on device's frame data
  20530. */
  20531. _checkInputs(): void;
  20532. /**
  20533. * Updates the poseControlled values based on the input device pose.
  20534. * @param poseData Pose coming from the device
  20535. */
  20536. updateFromDevice(poseData: DevicePose): void;
  20537. private _htmlElementAttached;
  20538. private _detachIfAttached;
  20539. /**
  20540. * WebVR's attach control will start broadcasting frames to the device.
  20541. * Note that in certain browsers (chrome for example) this function must be called
  20542. * within a user-interaction callback. Example:
  20543. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20544. *
  20545. * @param element html element to attach the vrDevice to
  20546. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20547. */
  20548. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20549. /**
  20550. * Detaches the camera from the html element and disables VR
  20551. *
  20552. * @param element html element to detach from
  20553. */
  20554. detachControl(element: HTMLElement): void;
  20555. /**
  20556. * @returns the name of this class
  20557. */
  20558. getClassName(): string;
  20559. /**
  20560. * Calls resetPose on the vrDisplay
  20561. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20562. */
  20563. resetToCurrentRotation(): void;
  20564. /**
  20565. * @hidden
  20566. * Updates the rig cameras (left and right eye)
  20567. */
  20568. _updateRigCameras(): void;
  20569. private _workingVector;
  20570. private _oneVector;
  20571. private _workingMatrix;
  20572. private updateCacheCalled;
  20573. private _correctPositionIfNotTrackPosition;
  20574. /**
  20575. * @hidden
  20576. * Updates the cached values of the camera
  20577. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20578. */
  20579. _updateCache(ignoreParentClass?: boolean): void;
  20580. /**
  20581. * @hidden
  20582. * Get current device position in babylon world
  20583. */
  20584. _computeDevicePosition(): void;
  20585. /**
  20586. * Updates the current device position and rotation in the babylon world
  20587. */
  20588. update(): void;
  20589. /**
  20590. * @hidden
  20591. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20592. * @returns an identity matrix
  20593. */
  20594. _getViewMatrix(): Matrix;
  20595. private _tmpMatrix;
  20596. /**
  20597. * This function is called by the two RIG cameras.
  20598. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20599. * @hidden
  20600. */
  20601. _getWebVRViewMatrix(): Matrix;
  20602. /** @hidden */
  20603. _getWebVRProjectionMatrix(): Matrix;
  20604. private _onGamepadConnectedObserver;
  20605. private _onGamepadDisconnectedObserver;
  20606. private _updateCacheWhenTrackingDisabledObserver;
  20607. /**
  20608. * Initializes the controllers and their meshes
  20609. */
  20610. initControllers(): void;
  20611. }
  20612. }
  20613. declare module "babylonjs/Materials/materialHelper" {
  20614. import { Nullable } from "babylonjs/types";
  20615. import { Scene } from "babylonjs/scene";
  20616. import { Engine } from "babylonjs/Engines/engine";
  20617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20618. import { Light } from "babylonjs/Lights/light";
  20619. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20620. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20621. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20622. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20623. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20624. /**
  20625. * "Static Class" containing the most commonly used helper while dealing with material for
  20626. * rendering purpose.
  20627. *
  20628. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20629. *
  20630. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20631. */
  20632. export class MaterialHelper {
  20633. /**
  20634. * Bind the current view position to an effect.
  20635. * @param effect The effect to be bound
  20636. * @param scene The scene the eyes position is used from
  20637. * @param variableName name of the shader variable that will hold the eye position
  20638. */
  20639. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20640. /**
  20641. * Helps preparing the defines values about the UVs in used in the effect.
  20642. * UVs are shared as much as we can accross channels in the shaders.
  20643. * @param texture The texture we are preparing the UVs for
  20644. * @param defines The defines to update
  20645. * @param key The channel key "diffuse", "specular"... used in the shader
  20646. */
  20647. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20648. /**
  20649. * Binds a texture matrix value to its corrsponding uniform
  20650. * @param texture The texture to bind the matrix for
  20651. * @param uniformBuffer The uniform buffer receivin the data
  20652. * @param key The channel key "diffuse", "specular"... used in the shader
  20653. */
  20654. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20655. /**
  20656. * Gets the current status of the fog (should it be enabled?)
  20657. * @param mesh defines the mesh to evaluate for fog support
  20658. * @param scene defines the hosting scene
  20659. * @returns true if fog must be enabled
  20660. */
  20661. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20662. /**
  20663. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20664. * @param mesh defines the current mesh
  20665. * @param scene defines the current scene
  20666. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20667. * @param pointsCloud defines if point cloud rendering has to be turned on
  20668. * @param fogEnabled defines if fog has to be turned on
  20669. * @param alphaTest defines if alpha testing has to be turned on
  20670. * @param defines defines the current list of defines
  20671. */
  20672. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20673. /**
  20674. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20675. * @param scene defines the current scene
  20676. * @param engine defines the current engine
  20677. * @param defines specifies the list of active defines
  20678. * @param useInstances defines if instances have to be turned on
  20679. * @param useClipPlane defines if clip plane have to be turned on
  20680. * @param useInstances defines if instances have to be turned on
  20681. * @param useThinInstances defines if thin instances have to be turned on
  20682. */
  20683. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20684. /**
  20685. * Prepares the defines for bones
  20686. * @param mesh The mesh containing the geometry data we will draw
  20687. * @param defines The defines to update
  20688. */
  20689. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20690. /**
  20691. * Prepares the defines for morph targets
  20692. * @param mesh The mesh containing the geometry data we will draw
  20693. * @param defines The defines to update
  20694. */
  20695. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20696. /**
  20697. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20698. * @param mesh The mesh containing the geometry data we will draw
  20699. * @param defines The defines to update
  20700. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20701. * @param useBones Precise whether bones should be used or not (override mesh info)
  20702. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20703. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20704. * @returns false if defines are considered not dirty and have not been checked
  20705. */
  20706. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20707. /**
  20708. * Prepares the defines related to multiview
  20709. * @param scene The scene we are intending to draw
  20710. * @param defines The defines to update
  20711. */
  20712. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20713. /**
  20714. * Prepares the defines related to the prepass
  20715. * @param scene The scene we are intending to draw
  20716. * @param defines The defines to update
  20717. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20718. */
  20719. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20720. /**
  20721. * Prepares the defines related to the light information passed in parameter
  20722. * @param scene The scene we are intending to draw
  20723. * @param mesh The mesh the effect is compiling for
  20724. * @param light The light the effect is compiling for
  20725. * @param lightIndex The index of the light
  20726. * @param defines The defines to update
  20727. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20728. * @param state Defines the current state regarding what is needed (normals, etc...)
  20729. */
  20730. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20731. needNormals: boolean;
  20732. needRebuild: boolean;
  20733. shadowEnabled: boolean;
  20734. specularEnabled: boolean;
  20735. lightmapMode: boolean;
  20736. }): void;
  20737. /**
  20738. * Prepares the defines related to the light information passed in parameter
  20739. * @param scene The scene we are intending to draw
  20740. * @param mesh The mesh the effect is compiling for
  20741. * @param defines The defines to update
  20742. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20743. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20744. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20745. * @returns true if normals will be required for the rest of the effect
  20746. */
  20747. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20748. /**
  20749. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20750. * @param lightIndex defines the light index
  20751. * @param uniformsList The uniform list
  20752. * @param samplersList The sampler list
  20753. * @param projectedLightTexture defines if projected texture must be used
  20754. * @param uniformBuffersList defines an optional list of uniform buffers
  20755. */
  20756. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20757. /**
  20758. * Prepares the uniforms and samplers list to be used in the effect
  20759. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20760. * @param samplersList The sampler list
  20761. * @param defines The defines helping in the list generation
  20762. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20763. */
  20764. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20765. /**
  20766. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20767. * @param defines The defines to update while falling back
  20768. * @param fallbacks The authorized effect fallbacks
  20769. * @param maxSimultaneousLights The maximum number of lights allowed
  20770. * @param rank the current rank of the Effect
  20771. * @returns The newly affected rank
  20772. */
  20773. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20774. private static _TmpMorphInfluencers;
  20775. /**
  20776. * Prepares the list of attributes required for morph targets according to the effect defines.
  20777. * @param attribs The current list of supported attribs
  20778. * @param mesh The mesh to prepare the morph targets attributes for
  20779. * @param influencers The number of influencers
  20780. */
  20781. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20782. /**
  20783. * Prepares the list of attributes required for morph targets according to the effect defines.
  20784. * @param attribs The current list of supported attribs
  20785. * @param mesh The mesh to prepare the morph targets attributes for
  20786. * @param defines The current Defines of the effect
  20787. */
  20788. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20789. /**
  20790. * Prepares the list of attributes required for bones according to the effect defines.
  20791. * @param attribs The current list of supported attribs
  20792. * @param mesh The mesh to prepare the bones attributes for
  20793. * @param defines The current Defines of the effect
  20794. * @param fallbacks The current efffect fallback strategy
  20795. */
  20796. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20797. /**
  20798. * Check and prepare the list of attributes required for instances according to the effect defines.
  20799. * @param attribs The current list of supported attribs
  20800. * @param defines The current MaterialDefines of the effect
  20801. */
  20802. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20803. /**
  20804. * Add the list of attributes required for instances to the attribs array.
  20805. * @param attribs The current list of supported attribs
  20806. */
  20807. static PushAttributesForInstances(attribs: string[]): void;
  20808. /**
  20809. * Binds the light information to the effect.
  20810. * @param light The light containing the generator
  20811. * @param effect The effect we are binding the data to
  20812. * @param lightIndex The light index in the effect used to render
  20813. */
  20814. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20815. /**
  20816. * Binds the lights information from the scene to the effect for the given mesh.
  20817. * @param light Light to bind
  20818. * @param lightIndex Light index
  20819. * @param scene The scene where the light belongs to
  20820. * @param effect The effect we are binding the data to
  20821. * @param useSpecular Defines if specular is supported
  20822. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20823. */
  20824. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20825. /**
  20826. * Binds the lights information from the scene to the effect for the given mesh.
  20827. * @param scene The scene the lights belongs to
  20828. * @param mesh The mesh we are binding the information to render
  20829. * @param effect The effect we are binding the data to
  20830. * @param defines The generated defines for the effect
  20831. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20832. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20833. */
  20834. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20835. private static _tempFogColor;
  20836. /**
  20837. * Binds the fog information from the scene to the effect for the given mesh.
  20838. * @param scene The scene the lights belongs to
  20839. * @param mesh The mesh we are binding the information to render
  20840. * @param effect The effect we are binding the data to
  20841. * @param linearSpace Defines if the fog effect is applied in linear space
  20842. */
  20843. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20844. /**
  20845. * Binds the bones information from the mesh to the effect.
  20846. * @param mesh The mesh we are binding the information to render
  20847. * @param effect The effect we are binding the data to
  20848. */
  20849. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20850. /**
  20851. * Binds the morph targets information from the mesh to the effect.
  20852. * @param abstractMesh The mesh we are binding the information to render
  20853. * @param effect The effect we are binding the data to
  20854. */
  20855. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20856. /**
  20857. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20858. * @param defines The generated defines used in the effect
  20859. * @param effect The effect we are binding the data to
  20860. * @param scene The scene we are willing to render with logarithmic scale for
  20861. */
  20862. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20863. /**
  20864. * Binds the clip plane information from the scene to the effect.
  20865. * @param scene The scene the clip plane information are extracted from
  20866. * @param effect The effect we are binding the data to
  20867. */
  20868. static BindClipPlane(effect: Effect, scene: Scene): void;
  20869. }
  20870. }
  20871. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20872. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20873. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20874. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20875. import { Nullable } from "babylonjs/types";
  20876. import { Effect } from "babylonjs/Materials/effect";
  20877. import { Matrix } from "babylonjs/Maths/math.vector";
  20878. import { Scene } from "babylonjs/scene";
  20879. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20880. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20881. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20882. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20883. import { Observable } from "babylonjs/Misc/observable";
  20884. /**
  20885. * Block used to expose an input value
  20886. */
  20887. export class InputBlock extends NodeMaterialBlock {
  20888. private _mode;
  20889. private _associatedVariableName;
  20890. private _storedValue;
  20891. private _valueCallback;
  20892. private _type;
  20893. private _animationType;
  20894. /** Gets or set a value used to limit the range of float values */
  20895. min: number;
  20896. /** Gets or set a value used to limit the range of float values */
  20897. max: number;
  20898. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20899. isBoolean: boolean;
  20900. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20901. matrixMode: number;
  20902. /** @hidden */
  20903. _systemValue: Nullable<NodeMaterialSystemValues>;
  20904. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20905. visibleInInspector: boolean;
  20906. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20907. isConstant: boolean;
  20908. /** Gets or sets the group to use to display this block in the Inspector */
  20909. groupInInspector: string;
  20910. /** Gets an observable raised when the value is changed */
  20911. onValueChangedObservable: Observable<InputBlock>;
  20912. /**
  20913. * Gets or sets the connection point type (default is float)
  20914. */
  20915. get type(): NodeMaterialBlockConnectionPointTypes;
  20916. /**
  20917. * Creates a new InputBlock
  20918. * @param name defines the block name
  20919. * @param target defines the target of that block (Vertex by default)
  20920. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20921. */
  20922. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20923. /**
  20924. * Validates if a name is a reserve word.
  20925. * @param newName the new name to be given to the node.
  20926. * @returns false if the name is a reserve word, else true.
  20927. */
  20928. validateBlockName(newName: string): boolean;
  20929. /**
  20930. * Gets the output component
  20931. */
  20932. get output(): NodeMaterialConnectionPoint;
  20933. /**
  20934. * Set the source of this connection point to a vertex attribute
  20935. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20936. * @returns the current connection point
  20937. */
  20938. setAsAttribute(attributeName?: string): InputBlock;
  20939. /**
  20940. * Set the source of this connection point to a system value
  20941. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20942. * @returns the current connection point
  20943. */
  20944. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20945. /**
  20946. * Gets or sets the value of that point.
  20947. * Please note that this value will be ignored if valueCallback is defined
  20948. */
  20949. get value(): any;
  20950. set value(value: any);
  20951. /**
  20952. * Gets or sets a callback used to get the value of that point.
  20953. * Please note that setting this value will force the connection point to ignore the value property
  20954. */
  20955. get valueCallback(): () => any;
  20956. set valueCallback(value: () => any);
  20957. /**
  20958. * Gets or sets the associated variable name in the shader
  20959. */
  20960. get associatedVariableName(): string;
  20961. set associatedVariableName(value: string);
  20962. /** Gets or sets the type of animation applied to the input */
  20963. get animationType(): AnimatedInputBlockTypes;
  20964. set animationType(value: AnimatedInputBlockTypes);
  20965. /**
  20966. * Gets a boolean indicating that this connection point not defined yet
  20967. */
  20968. get isUndefined(): boolean;
  20969. /**
  20970. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20971. * In this case the connection point name must be the name of the uniform to use.
  20972. * Can only be set on inputs
  20973. */
  20974. get isUniform(): boolean;
  20975. set isUniform(value: boolean);
  20976. /**
  20977. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20978. * In this case the connection point name must be the name of the attribute to use
  20979. * Can only be set on inputs
  20980. */
  20981. get isAttribute(): boolean;
  20982. set isAttribute(value: boolean);
  20983. /**
  20984. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20985. * Can only be set on exit points
  20986. */
  20987. get isVarying(): boolean;
  20988. set isVarying(value: boolean);
  20989. /**
  20990. * Gets a boolean indicating that the current connection point is a system value
  20991. */
  20992. get isSystemValue(): boolean;
  20993. /**
  20994. * Gets or sets the current well known value or null if not defined as a system value
  20995. */
  20996. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20997. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20998. /**
  20999. * Gets the current class name
  21000. * @returns the class name
  21001. */
  21002. getClassName(): string;
  21003. /**
  21004. * Animate the input if animationType !== None
  21005. * @param scene defines the rendering scene
  21006. */
  21007. animate(scene: Scene): void;
  21008. private _emitDefine;
  21009. initialize(state: NodeMaterialBuildState): void;
  21010. /**
  21011. * Set the input block to its default value (based on its type)
  21012. */
  21013. setDefaultValue(): void;
  21014. private _emitConstant;
  21015. /** @hidden */
  21016. get _noContextSwitch(): boolean;
  21017. private _emit;
  21018. /** @hidden */
  21019. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21020. /** @hidden */
  21021. _transmit(effect: Effect, scene: Scene): void;
  21022. protected _buildBlock(state: NodeMaterialBuildState): void;
  21023. protected _dumpPropertiesCode(): string;
  21024. dispose(): void;
  21025. serialize(): any;
  21026. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21027. }
  21028. }
  21029. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21030. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21031. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21032. import { Nullable } from "babylonjs/types";
  21033. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21034. import { Observable } from "babylonjs/Misc/observable";
  21035. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21036. /**
  21037. * Enum used to define the compatibility state between two connection points
  21038. */
  21039. export enum NodeMaterialConnectionPointCompatibilityStates {
  21040. /** Points are compatibles */
  21041. Compatible = 0,
  21042. /** Points are incompatible because of their types */
  21043. TypeIncompatible = 1,
  21044. /** Points are incompatible because of their targets (vertex vs fragment) */
  21045. TargetIncompatible = 2
  21046. }
  21047. /**
  21048. * Defines the direction of a connection point
  21049. */
  21050. export enum NodeMaterialConnectionPointDirection {
  21051. /** Input */
  21052. Input = 0,
  21053. /** Output */
  21054. Output = 1
  21055. }
  21056. /**
  21057. * Defines a connection point for a block
  21058. */
  21059. export class NodeMaterialConnectionPoint {
  21060. /** @hidden */
  21061. _ownerBlock: NodeMaterialBlock;
  21062. /** @hidden */
  21063. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21064. private _endpoints;
  21065. private _associatedVariableName;
  21066. private _direction;
  21067. /** @hidden */
  21068. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21069. /** @hidden */
  21070. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21071. private _type;
  21072. /** @hidden */
  21073. _enforceAssociatedVariableName: boolean;
  21074. /** Gets the direction of the point */
  21075. get direction(): NodeMaterialConnectionPointDirection;
  21076. /** Indicates that this connection point needs dual validation before being connected to another point */
  21077. needDualDirectionValidation: boolean;
  21078. /**
  21079. * Gets or sets the additional types supported by this connection point
  21080. */
  21081. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21082. /**
  21083. * Gets or sets the additional types excluded by this connection point
  21084. */
  21085. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21086. /**
  21087. * Observable triggered when this point is connected
  21088. */
  21089. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21090. /**
  21091. * Gets or sets the associated variable name in the shader
  21092. */
  21093. get associatedVariableName(): string;
  21094. set associatedVariableName(value: string);
  21095. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21096. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21097. /**
  21098. * Gets or sets the connection point type (default is float)
  21099. */
  21100. get type(): NodeMaterialBlockConnectionPointTypes;
  21101. set type(value: NodeMaterialBlockConnectionPointTypes);
  21102. /**
  21103. * Gets or sets the connection point name
  21104. */
  21105. name: string;
  21106. /**
  21107. * Gets or sets the connection point name
  21108. */
  21109. displayName: string;
  21110. /**
  21111. * Gets or sets a boolean indicating that this connection point can be omitted
  21112. */
  21113. isOptional: boolean;
  21114. /**
  21115. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21116. */
  21117. isExposedOnFrame: boolean;
  21118. /**
  21119. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21120. */
  21121. define: string;
  21122. /** @hidden */
  21123. _prioritizeVertex: boolean;
  21124. private _target;
  21125. /** Gets or sets the target of that connection point */
  21126. get target(): NodeMaterialBlockTargets;
  21127. set target(value: NodeMaterialBlockTargets);
  21128. /**
  21129. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21130. */
  21131. get isConnected(): boolean;
  21132. /**
  21133. * Gets a boolean indicating that the current point is connected to an input block
  21134. */
  21135. get isConnectedToInputBlock(): boolean;
  21136. /**
  21137. * Gets a the connected input block (if any)
  21138. */
  21139. get connectInputBlock(): Nullable<InputBlock>;
  21140. /** Get the other side of the connection (if any) */
  21141. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21142. /** Get the block that owns this connection point */
  21143. get ownerBlock(): NodeMaterialBlock;
  21144. /** Get the block connected on the other side of this connection (if any) */
  21145. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21146. /** Get the block connected on the endpoints of this connection (if any) */
  21147. get connectedBlocks(): Array<NodeMaterialBlock>;
  21148. /** Gets the list of connected endpoints */
  21149. get endpoints(): NodeMaterialConnectionPoint[];
  21150. /** Gets a boolean indicating if that output point is connected to at least one input */
  21151. get hasEndpoints(): boolean;
  21152. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21153. get isConnectedInVertexShader(): boolean;
  21154. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21155. get isConnectedInFragmentShader(): boolean;
  21156. /**
  21157. * Creates a block suitable to be used as an input for this input point.
  21158. * If null is returned, a block based on the point type will be created.
  21159. * @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
  21160. */
  21161. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21162. /**
  21163. * Creates a new connection point
  21164. * @param name defines the connection point name
  21165. * @param ownerBlock defines the block hosting this connection point
  21166. * @param direction defines the direction of the connection point
  21167. */
  21168. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21169. /**
  21170. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21171. * @returns the class name
  21172. */
  21173. getClassName(): string;
  21174. /**
  21175. * Gets a boolean indicating if the current point can be connected to another point
  21176. * @param connectionPoint defines the other connection point
  21177. * @returns a boolean
  21178. */
  21179. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21180. /**
  21181. * Gets a number indicating if the current point can be connected to another point
  21182. * @param connectionPoint defines the other connection point
  21183. * @returns a number defining the compatibility state
  21184. */
  21185. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21186. /**
  21187. * Connect this point to another connection point
  21188. * @param connectionPoint defines the other connection point
  21189. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21190. * @returns the current connection point
  21191. */
  21192. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21193. /**
  21194. * Disconnect this point from one of his endpoint
  21195. * @param endpoint defines the other connection point
  21196. * @returns the current connection point
  21197. */
  21198. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21199. /**
  21200. * Serializes this point in a JSON representation
  21201. * @param isInput defines if the connection point is an input (default is true)
  21202. * @returns the serialized point object
  21203. */
  21204. serialize(isInput?: boolean): any;
  21205. /**
  21206. * Release resources
  21207. */
  21208. dispose(): void;
  21209. }
  21210. }
  21211. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21212. /**
  21213. * Enum used to define the material modes
  21214. */
  21215. export enum NodeMaterialModes {
  21216. /** Regular material */
  21217. Material = 0,
  21218. /** For post process */
  21219. PostProcess = 1,
  21220. /** For particle system */
  21221. Particle = 2
  21222. }
  21223. }
  21224. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21225. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21226. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21227. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21228. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21230. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21231. import { Effect } from "babylonjs/Materials/effect";
  21232. import { Mesh } from "babylonjs/Meshes/mesh";
  21233. import { Nullable } from "babylonjs/types";
  21234. import { Texture } from "babylonjs/Materials/Textures/texture";
  21235. import { Scene } from "babylonjs/scene";
  21236. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21237. /**
  21238. * Block used to read a texture from a sampler
  21239. */
  21240. export class TextureBlock extends NodeMaterialBlock {
  21241. private _defineName;
  21242. private _linearDefineName;
  21243. private _gammaDefineName;
  21244. private _tempTextureRead;
  21245. private _samplerName;
  21246. private _transformedUVName;
  21247. private _textureTransformName;
  21248. private _textureInfoName;
  21249. private _mainUVName;
  21250. private _mainUVDefineName;
  21251. private _fragmentOnly;
  21252. /**
  21253. * Gets or sets the texture associated with the node
  21254. */
  21255. texture: Nullable<Texture>;
  21256. /**
  21257. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21258. */
  21259. convertToGammaSpace: boolean;
  21260. /**
  21261. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21262. */
  21263. convertToLinearSpace: boolean;
  21264. /**
  21265. * Create a new TextureBlock
  21266. * @param name defines the block name
  21267. */
  21268. constructor(name: string, fragmentOnly?: boolean);
  21269. /**
  21270. * Gets the current class name
  21271. * @returns the class name
  21272. */
  21273. getClassName(): string;
  21274. /**
  21275. * Gets the uv input component
  21276. */
  21277. get uv(): NodeMaterialConnectionPoint;
  21278. /**
  21279. * Gets the rgba output component
  21280. */
  21281. get rgba(): NodeMaterialConnectionPoint;
  21282. /**
  21283. * Gets the rgb output component
  21284. */
  21285. get rgb(): NodeMaterialConnectionPoint;
  21286. /**
  21287. * Gets the r output component
  21288. */
  21289. get r(): NodeMaterialConnectionPoint;
  21290. /**
  21291. * Gets the g output component
  21292. */
  21293. get g(): NodeMaterialConnectionPoint;
  21294. /**
  21295. * Gets the b output component
  21296. */
  21297. get b(): NodeMaterialConnectionPoint;
  21298. /**
  21299. * Gets the a output component
  21300. */
  21301. get a(): NodeMaterialConnectionPoint;
  21302. get target(): NodeMaterialBlockTargets;
  21303. autoConfigure(material: NodeMaterial): void;
  21304. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21305. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21306. isReady(): boolean;
  21307. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21308. private get _isMixed();
  21309. private _injectVertexCode;
  21310. private _writeTextureRead;
  21311. private _writeOutput;
  21312. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21313. protected _dumpPropertiesCode(): string;
  21314. serialize(): any;
  21315. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21316. }
  21317. }
  21318. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21319. /** @hidden */
  21320. export var reflectionFunction: {
  21321. name: string;
  21322. shader: string;
  21323. };
  21324. }
  21325. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21326. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21327. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21329. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21331. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21332. import { Effect } from "babylonjs/Materials/effect";
  21333. import { Mesh } from "babylonjs/Meshes/mesh";
  21334. import { Nullable } from "babylonjs/types";
  21335. import { Scene } from "babylonjs/scene";
  21336. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21337. /**
  21338. * Base block used to read a reflection texture from a sampler
  21339. */
  21340. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21341. /** @hidden */
  21342. _define3DName: string;
  21343. /** @hidden */
  21344. _defineCubicName: string;
  21345. /** @hidden */
  21346. _defineExplicitName: string;
  21347. /** @hidden */
  21348. _defineProjectionName: string;
  21349. /** @hidden */
  21350. _defineLocalCubicName: string;
  21351. /** @hidden */
  21352. _defineSphericalName: string;
  21353. /** @hidden */
  21354. _definePlanarName: string;
  21355. /** @hidden */
  21356. _defineEquirectangularName: string;
  21357. /** @hidden */
  21358. _defineMirroredEquirectangularFixedName: string;
  21359. /** @hidden */
  21360. _defineEquirectangularFixedName: string;
  21361. /** @hidden */
  21362. _defineSkyboxName: string;
  21363. /** @hidden */
  21364. _defineOppositeZ: string;
  21365. /** @hidden */
  21366. _cubeSamplerName: string;
  21367. /** @hidden */
  21368. _2DSamplerName: string;
  21369. protected _positionUVWName: string;
  21370. protected _directionWName: string;
  21371. protected _reflectionVectorName: string;
  21372. /** @hidden */
  21373. _reflectionCoordsName: string;
  21374. /** @hidden */
  21375. _reflectionMatrixName: string;
  21376. protected _reflectionColorName: string;
  21377. /**
  21378. * Gets or sets the texture associated with the node
  21379. */
  21380. texture: Nullable<BaseTexture>;
  21381. /**
  21382. * Create a new ReflectionTextureBaseBlock
  21383. * @param name defines the block name
  21384. */
  21385. constructor(name: string);
  21386. /**
  21387. * Gets the current class name
  21388. * @returns the class name
  21389. */
  21390. getClassName(): string;
  21391. /**
  21392. * Gets the world position input component
  21393. */
  21394. abstract get position(): NodeMaterialConnectionPoint;
  21395. /**
  21396. * Gets the world position input component
  21397. */
  21398. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21399. /**
  21400. * Gets the world normal input component
  21401. */
  21402. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21403. /**
  21404. * Gets the world input component
  21405. */
  21406. abstract get world(): NodeMaterialConnectionPoint;
  21407. /**
  21408. * Gets the camera (or eye) position component
  21409. */
  21410. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21411. /**
  21412. * Gets the view input component
  21413. */
  21414. abstract get view(): NodeMaterialConnectionPoint;
  21415. protected _getTexture(): Nullable<BaseTexture>;
  21416. autoConfigure(material: NodeMaterial): void;
  21417. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21418. isReady(): boolean;
  21419. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21420. /**
  21421. * Gets the code to inject in the vertex shader
  21422. * @param state current state of the node material building
  21423. * @returns the shader code
  21424. */
  21425. handleVertexSide(state: NodeMaterialBuildState): string;
  21426. /**
  21427. * Handles the inits for the fragment code path
  21428. * @param state node material build state
  21429. */
  21430. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21431. /**
  21432. * Generates the reflection coords code for the fragment code path
  21433. * @param worldNormalVarName name of the world normal variable
  21434. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21435. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21436. * @returns the shader code
  21437. */
  21438. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21439. /**
  21440. * Generates the reflection color code for the fragment code path
  21441. * @param lodVarName name of the lod variable
  21442. * @param swizzleLookupTexture swizzle to use for the final color variable
  21443. * @returns the shader code
  21444. */
  21445. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21446. /**
  21447. * Generates the code corresponding to the connected output points
  21448. * @param state node material build state
  21449. * @param varName name of the variable to output
  21450. * @returns the shader code
  21451. */
  21452. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21453. protected _buildBlock(state: NodeMaterialBuildState): this;
  21454. protected _dumpPropertiesCode(): string;
  21455. serialize(): any;
  21456. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21457. }
  21458. }
  21459. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21460. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21461. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21462. import { Nullable } from "babylonjs/types";
  21463. /**
  21464. * Defines a connection point to be used for points with a custom object type
  21465. */
  21466. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21467. private _blockType;
  21468. private _blockName;
  21469. private _nameForCheking?;
  21470. /**
  21471. * Creates a new connection point
  21472. * @param name defines the connection point name
  21473. * @param ownerBlock defines the block hosting this connection point
  21474. * @param direction defines the direction of the connection point
  21475. */
  21476. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21477. /**
  21478. * Gets a number indicating if the current point can be connected to another point
  21479. * @param connectionPoint defines the other connection point
  21480. * @returns a number defining the compatibility state
  21481. */
  21482. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21483. /**
  21484. * Creates a block suitable to be used as an input for this input point.
  21485. * If null is returned, a block based on the point type will be created.
  21486. * @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
  21487. */
  21488. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21489. }
  21490. }
  21491. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21492. /**
  21493. * Enum defining the type of properties that can be edited in the property pages in the NME
  21494. */
  21495. export enum PropertyTypeForEdition {
  21496. /** property is a boolean */
  21497. Boolean = 0,
  21498. /** property is a float */
  21499. Float = 1,
  21500. /** property is a Vector2 */
  21501. Vector2 = 2,
  21502. /** property is a list of values */
  21503. List = 3
  21504. }
  21505. /**
  21506. * Interface that defines an option in a variable of type list
  21507. */
  21508. export interface IEditablePropertyListOption {
  21509. /** label of the option */
  21510. "label": string;
  21511. /** value of the option */
  21512. "value": number;
  21513. }
  21514. /**
  21515. * Interface that defines the options available for an editable property
  21516. */
  21517. export interface IEditablePropertyOption {
  21518. /** min value */
  21519. "min"?: number;
  21520. /** max value */
  21521. "max"?: number;
  21522. /** notifiers: indicates which actions to take when the property is changed */
  21523. "notifiers"?: {
  21524. /** the material should be rebuilt */
  21525. "rebuild"?: boolean;
  21526. /** the preview should be updated */
  21527. "update"?: boolean;
  21528. };
  21529. /** list of the options for a variable of type list */
  21530. "options"?: IEditablePropertyListOption[];
  21531. }
  21532. /**
  21533. * Interface that describes an editable property
  21534. */
  21535. export interface IPropertyDescriptionForEdition {
  21536. /** name of the property */
  21537. "propertyName": string;
  21538. /** display name of the property */
  21539. "displayName": string;
  21540. /** type of the property */
  21541. "type": PropertyTypeForEdition;
  21542. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21543. "groupName": string;
  21544. /** options for the property */
  21545. "options": IEditablePropertyOption;
  21546. }
  21547. /**
  21548. * Decorator that flags a property in a node material block as being editable
  21549. */
  21550. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21551. }
  21552. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21553. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21554. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21555. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21557. import { Nullable } from "babylonjs/types";
  21558. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21559. import { Mesh } from "babylonjs/Meshes/mesh";
  21560. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21561. import { Effect } from "babylonjs/Materials/effect";
  21562. import { Scene } from "babylonjs/scene";
  21563. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21564. /**
  21565. * Block used to implement the refraction part of the sub surface module of the PBR material
  21566. */
  21567. export class RefractionBlock extends NodeMaterialBlock {
  21568. /** @hidden */
  21569. _define3DName: string;
  21570. /** @hidden */
  21571. _refractionMatrixName: string;
  21572. /** @hidden */
  21573. _defineLODRefractionAlpha: string;
  21574. /** @hidden */
  21575. _defineLinearSpecularRefraction: string;
  21576. /** @hidden */
  21577. _defineOppositeZ: string;
  21578. /** @hidden */
  21579. _cubeSamplerName: string;
  21580. /** @hidden */
  21581. _2DSamplerName: string;
  21582. /** @hidden */
  21583. _vRefractionMicrosurfaceInfosName: string;
  21584. /** @hidden */
  21585. _vRefractionInfosName: string;
  21586. private _scene;
  21587. /**
  21588. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21589. * Materials half opaque for instance using refraction could benefit from this control.
  21590. */
  21591. linkRefractionWithTransparency: boolean;
  21592. /**
  21593. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21594. */
  21595. invertRefractionY: boolean;
  21596. /**
  21597. * Gets or sets the texture associated with the node
  21598. */
  21599. texture: Nullable<BaseTexture>;
  21600. /**
  21601. * Create a new RefractionBlock
  21602. * @param name defines the block name
  21603. */
  21604. constructor(name: string);
  21605. /**
  21606. * Gets the current class name
  21607. * @returns the class name
  21608. */
  21609. getClassName(): string;
  21610. /**
  21611. * Gets the intensity input component
  21612. */
  21613. get intensity(): NodeMaterialConnectionPoint;
  21614. /**
  21615. * Gets the index of refraction input component
  21616. */
  21617. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21618. /**
  21619. * Gets the tint at distance input component
  21620. */
  21621. get tintAtDistance(): NodeMaterialConnectionPoint;
  21622. /**
  21623. * Gets the view input component
  21624. */
  21625. get view(): NodeMaterialConnectionPoint;
  21626. /**
  21627. * Gets the refraction object output component
  21628. */
  21629. get refraction(): NodeMaterialConnectionPoint;
  21630. /**
  21631. * Returns true if the block has a texture
  21632. */
  21633. get hasTexture(): boolean;
  21634. protected _getTexture(): Nullable<BaseTexture>;
  21635. autoConfigure(material: NodeMaterial): void;
  21636. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21637. isReady(): boolean;
  21638. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21639. /**
  21640. * Gets the main code of the block (fragment side)
  21641. * @param state current state of the node material building
  21642. * @returns the shader code
  21643. */
  21644. getCode(state: NodeMaterialBuildState): string;
  21645. protected _buildBlock(state: NodeMaterialBuildState): this;
  21646. protected _dumpPropertiesCode(): string;
  21647. serialize(): any;
  21648. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21649. }
  21650. }
  21651. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21652. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21653. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21654. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21655. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21657. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21658. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21659. import { Nullable } from "babylonjs/types";
  21660. import { Scene } from "babylonjs/scene";
  21661. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21662. /**
  21663. * Base block used as input for post process
  21664. */
  21665. export class CurrentScreenBlock extends NodeMaterialBlock {
  21666. private _samplerName;
  21667. private _linearDefineName;
  21668. private _gammaDefineName;
  21669. private _mainUVName;
  21670. private _tempTextureRead;
  21671. /**
  21672. * Gets or sets the texture associated with the node
  21673. */
  21674. texture: Nullable<BaseTexture>;
  21675. /**
  21676. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21677. */
  21678. convertToGammaSpace: boolean;
  21679. /**
  21680. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21681. */
  21682. convertToLinearSpace: boolean;
  21683. /**
  21684. * Create a new CurrentScreenBlock
  21685. * @param name defines the block name
  21686. */
  21687. constructor(name: string);
  21688. /**
  21689. * Gets the current class name
  21690. * @returns the class name
  21691. */
  21692. getClassName(): string;
  21693. /**
  21694. * Gets the uv input component
  21695. */
  21696. get uv(): NodeMaterialConnectionPoint;
  21697. /**
  21698. * Gets the rgba output component
  21699. */
  21700. get rgba(): NodeMaterialConnectionPoint;
  21701. /**
  21702. * Gets the rgb output component
  21703. */
  21704. get rgb(): NodeMaterialConnectionPoint;
  21705. /**
  21706. * Gets the r output component
  21707. */
  21708. get r(): NodeMaterialConnectionPoint;
  21709. /**
  21710. * Gets the g output component
  21711. */
  21712. get g(): NodeMaterialConnectionPoint;
  21713. /**
  21714. * Gets the b output component
  21715. */
  21716. get b(): NodeMaterialConnectionPoint;
  21717. /**
  21718. * Gets the a output component
  21719. */
  21720. get a(): NodeMaterialConnectionPoint;
  21721. /**
  21722. * Initialize the block and prepare the context for build
  21723. * @param state defines the state that will be used for the build
  21724. */
  21725. initialize(state: NodeMaterialBuildState): void;
  21726. get target(): NodeMaterialBlockTargets;
  21727. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21728. isReady(): boolean;
  21729. private _injectVertexCode;
  21730. private _writeTextureRead;
  21731. private _writeOutput;
  21732. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21733. serialize(): any;
  21734. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21735. }
  21736. }
  21737. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21738. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21739. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21740. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21742. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21743. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21744. import { Nullable } from "babylonjs/types";
  21745. import { Scene } from "babylonjs/scene";
  21746. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21747. /**
  21748. * Base block used for the particle texture
  21749. */
  21750. export class ParticleTextureBlock extends NodeMaterialBlock {
  21751. private _samplerName;
  21752. private _linearDefineName;
  21753. private _gammaDefineName;
  21754. private _tempTextureRead;
  21755. /**
  21756. * Gets or sets the texture associated with the node
  21757. */
  21758. texture: Nullable<BaseTexture>;
  21759. /**
  21760. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21761. */
  21762. convertToGammaSpace: boolean;
  21763. /**
  21764. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21765. */
  21766. convertToLinearSpace: boolean;
  21767. /**
  21768. * Create a new ParticleTextureBlock
  21769. * @param name defines the block name
  21770. */
  21771. constructor(name: string);
  21772. /**
  21773. * Gets the current class name
  21774. * @returns the class name
  21775. */
  21776. getClassName(): string;
  21777. /**
  21778. * Gets the uv input component
  21779. */
  21780. get uv(): NodeMaterialConnectionPoint;
  21781. /**
  21782. * Gets the rgba output component
  21783. */
  21784. get rgba(): NodeMaterialConnectionPoint;
  21785. /**
  21786. * Gets the rgb output component
  21787. */
  21788. get rgb(): NodeMaterialConnectionPoint;
  21789. /**
  21790. * Gets the r output component
  21791. */
  21792. get r(): NodeMaterialConnectionPoint;
  21793. /**
  21794. * Gets the g output component
  21795. */
  21796. get g(): NodeMaterialConnectionPoint;
  21797. /**
  21798. * Gets the b output component
  21799. */
  21800. get b(): NodeMaterialConnectionPoint;
  21801. /**
  21802. * Gets the a output component
  21803. */
  21804. get a(): NodeMaterialConnectionPoint;
  21805. /**
  21806. * Initialize the block and prepare the context for build
  21807. * @param state defines the state that will be used for the build
  21808. */
  21809. initialize(state: NodeMaterialBuildState): void;
  21810. autoConfigure(material: NodeMaterial): void;
  21811. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21812. isReady(): boolean;
  21813. private _writeOutput;
  21814. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21815. serialize(): any;
  21816. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21817. }
  21818. }
  21819. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21820. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21821. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21822. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21823. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21824. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21825. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21826. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21827. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21828. import { Scene } from "babylonjs/scene";
  21829. /**
  21830. * Class used to store shared data between 2 NodeMaterialBuildState
  21831. */
  21832. export class NodeMaterialBuildStateSharedData {
  21833. /**
  21834. * Gets the list of emitted varyings
  21835. */
  21836. temps: string[];
  21837. /**
  21838. * Gets the list of emitted varyings
  21839. */
  21840. varyings: string[];
  21841. /**
  21842. * Gets the varying declaration string
  21843. */
  21844. varyingDeclaration: string;
  21845. /**
  21846. * Input blocks
  21847. */
  21848. inputBlocks: InputBlock[];
  21849. /**
  21850. * Input blocks
  21851. */
  21852. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21853. /**
  21854. * Bindable blocks (Blocks that need to set data to the effect)
  21855. */
  21856. bindableBlocks: NodeMaterialBlock[];
  21857. /**
  21858. * List of blocks that can provide a compilation fallback
  21859. */
  21860. blocksWithFallbacks: NodeMaterialBlock[];
  21861. /**
  21862. * List of blocks that can provide a define update
  21863. */
  21864. blocksWithDefines: NodeMaterialBlock[];
  21865. /**
  21866. * List of blocks that can provide a repeatable content
  21867. */
  21868. repeatableContentBlocks: NodeMaterialBlock[];
  21869. /**
  21870. * List of blocks that can provide a dynamic list of uniforms
  21871. */
  21872. dynamicUniformBlocks: NodeMaterialBlock[];
  21873. /**
  21874. * List of blocks that can block the isReady function for the material
  21875. */
  21876. blockingBlocks: NodeMaterialBlock[];
  21877. /**
  21878. * Gets the list of animated inputs
  21879. */
  21880. animatedInputs: InputBlock[];
  21881. /**
  21882. * Build Id used to avoid multiple recompilations
  21883. */
  21884. buildId: number;
  21885. /** List of emitted variables */
  21886. variableNames: {
  21887. [key: string]: number;
  21888. };
  21889. /** List of emitted defines */
  21890. defineNames: {
  21891. [key: string]: number;
  21892. };
  21893. /** Should emit comments? */
  21894. emitComments: boolean;
  21895. /** Emit build activity */
  21896. verbose: boolean;
  21897. /** Gets or sets the hosting scene */
  21898. scene: Scene;
  21899. /**
  21900. * Gets the compilation hints emitted at compilation time
  21901. */
  21902. hints: {
  21903. needWorldViewMatrix: boolean;
  21904. needWorldViewProjectionMatrix: boolean;
  21905. needAlphaBlending: boolean;
  21906. needAlphaTesting: boolean;
  21907. };
  21908. /**
  21909. * List of compilation checks
  21910. */
  21911. checks: {
  21912. emitVertex: boolean;
  21913. emitFragment: boolean;
  21914. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21915. };
  21916. /**
  21917. * Is vertex program allowed to be empty?
  21918. */
  21919. allowEmptyVertexProgram: boolean;
  21920. /** Creates a new shared data */
  21921. constructor();
  21922. /**
  21923. * Emits console errors and exceptions if there is a failing check
  21924. */
  21925. emitErrors(): void;
  21926. }
  21927. }
  21928. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21929. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21930. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21931. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21932. /**
  21933. * Class used to store node based material build state
  21934. */
  21935. export class NodeMaterialBuildState {
  21936. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21937. supportUniformBuffers: boolean;
  21938. /**
  21939. * Gets the list of emitted attributes
  21940. */
  21941. attributes: string[];
  21942. /**
  21943. * Gets the list of emitted uniforms
  21944. */
  21945. uniforms: string[];
  21946. /**
  21947. * Gets the list of emitted constants
  21948. */
  21949. constants: string[];
  21950. /**
  21951. * Gets the list of emitted samplers
  21952. */
  21953. samplers: string[];
  21954. /**
  21955. * Gets the list of emitted functions
  21956. */
  21957. functions: {
  21958. [key: string]: string;
  21959. };
  21960. /**
  21961. * Gets the list of emitted extensions
  21962. */
  21963. extensions: {
  21964. [key: string]: string;
  21965. };
  21966. /**
  21967. * Gets the target of the compilation state
  21968. */
  21969. target: NodeMaterialBlockTargets;
  21970. /**
  21971. * Gets the list of emitted counters
  21972. */
  21973. counters: {
  21974. [key: string]: number;
  21975. };
  21976. /**
  21977. * Shared data between multiple NodeMaterialBuildState instances
  21978. */
  21979. sharedData: NodeMaterialBuildStateSharedData;
  21980. /** @hidden */
  21981. _vertexState: NodeMaterialBuildState;
  21982. /** @hidden */
  21983. _attributeDeclaration: string;
  21984. /** @hidden */
  21985. _uniformDeclaration: string;
  21986. /** @hidden */
  21987. _constantDeclaration: string;
  21988. /** @hidden */
  21989. _samplerDeclaration: string;
  21990. /** @hidden */
  21991. _varyingTransfer: string;
  21992. /** @hidden */
  21993. _injectAtEnd: string;
  21994. private _repeatableContentAnchorIndex;
  21995. /** @hidden */
  21996. _builtCompilationString: string;
  21997. /**
  21998. * Gets the emitted compilation strings
  21999. */
  22000. compilationString: string;
  22001. /**
  22002. * Finalize the compilation strings
  22003. * @param state defines the current compilation state
  22004. */
  22005. finalize(state: NodeMaterialBuildState): void;
  22006. /** @hidden */
  22007. get _repeatableContentAnchor(): string;
  22008. /** @hidden */
  22009. _getFreeVariableName(prefix: string): string;
  22010. /** @hidden */
  22011. _getFreeDefineName(prefix: string): string;
  22012. /** @hidden */
  22013. _excludeVariableName(name: string): void;
  22014. /** @hidden */
  22015. _emit2DSampler(name: string): void;
  22016. /** @hidden */
  22017. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22018. /** @hidden */
  22019. _emitExtension(name: string, extension: string, define?: string): void;
  22020. /** @hidden */
  22021. _emitFunction(name: string, code: string, comments: string): void;
  22022. /** @hidden */
  22023. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22024. replaceStrings?: {
  22025. search: RegExp;
  22026. replace: string;
  22027. }[];
  22028. repeatKey?: string;
  22029. }): string;
  22030. /** @hidden */
  22031. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22032. repeatKey?: string;
  22033. removeAttributes?: boolean;
  22034. removeUniforms?: boolean;
  22035. removeVaryings?: boolean;
  22036. removeIfDef?: boolean;
  22037. replaceStrings?: {
  22038. search: RegExp;
  22039. replace: string;
  22040. }[];
  22041. }, storeKey?: string): void;
  22042. /** @hidden */
  22043. _registerTempVariable(name: string): boolean;
  22044. /** @hidden */
  22045. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22046. /** @hidden */
  22047. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22048. /** @hidden */
  22049. _emitFloat(value: number): string;
  22050. }
  22051. }
  22052. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22053. /**
  22054. * Helper class used to generate session unique ID
  22055. */
  22056. export class UniqueIdGenerator {
  22057. private static _UniqueIdCounter;
  22058. /**
  22059. * Gets an unique (relatively to the current scene) Id
  22060. */
  22061. static get UniqueId(): number;
  22062. }
  22063. }
  22064. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22065. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22066. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22067. import { Nullable } from "babylonjs/types";
  22068. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22069. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22070. import { Effect } from "babylonjs/Materials/effect";
  22071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22072. import { Mesh } from "babylonjs/Meshes/mesh";
  22073. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22074. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22075. import { Scene } from "babylonjs/scene";
  22076. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22077. /**
  22078. * Defines a block that can be used inside a node based material
  22079. */
  22080. export class NodeMaterialBlock {
  22081. private _buildId;
  22082. private _buildTarget;
  22083. private _target;
  22084. private _isFinalMerger;
  22085. private _isInput;
  22086. private _name;
  22087. protected _isUnique: boolean;
  22088. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22089. inputsAreExclusive: boolean;
  22090. /** @hidden */
  22091. _codeVariableName: string;
  22092. /** @hidden */
  22093. _inputs: NodeMaterialConnectionPoint[];
  22094. /** @hidden */
  22095. _outputs: NodeMaterialConnectionPoint[];
  22096. /** @hidden */
  22097. _preparationId: number;
  22098. /**
  22099. * Gets the name of the block
  22100. */
  22101. get name(): string;
  22102. /**
  22103. * Sets the name of the block. Will check if the name is valid.
  22104. */
  22105. set name(newName: string);
  22106. /**
  22107. * Gets or sets the unique id of the node
  22108. */
  22109. uniqueId: number;
  22110. /**
  22111. * Gets or sets the comments associated with this block
  22112. */
  22113. comments: string;
  22114. /**
  22115. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22116. */
  22117. get isUnique(): boolean;
  22118. /**
  22119. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22120. */
  22121. get isFinalMerger(): boolean;
  22122. /**
  22123. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22124. */
  22125. get isInput(): boolean;
  22126. /**
  22127. * Gets or sets the build Id
  22128. */
  22129. get buildId(): number;
  22130. set buildId(value: number);
  22131. /**
  22132. * Gets or sets the target of the block
  22133. */
  22134. get target(): NodeMaterialBlockTargets;
  22135. set target(value: NodeMaterialBlockTargets);
  22136. /**
  22137. * Gets the list of input points
  22138. */
  22139. get inputs(): NodeMaterialConnectionPoint[];
  22140. /** Gets the list of output points */
  22141. get outputs(): NodeMaterialConnectionPoint[];
  22142. /**
  22143. * Find an input by its name
  22144. * @param name defines the name of the input to look for
  22145. * @returns the input or null if not found
  22146. */
  22147. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22148. /**
  22149. * Find an output by its name
  22150. * @param name defines the name of the outputto look for
  22151. * @returns the output or null if not found
  22152. */
  22153. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22154. /**
  22155. * Creates a new NodeMaterialBlock
  22156. * @param name defines the block name
  22157. * @param target defines the target of that block (Vertex by default)
  22158. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22159. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22160. */
  22161. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22162. /**
  22163. * Initialize the block and prepare the context for build
  22164. * @param state defines the state that will be used for the build
  22165. */
  22166. initialize(state: NodeMaterialBuildState): void;
  22167. /**
  22168. * Bind data to effect. Will only be called for blocks with isBindable === true
  22169. * @param effect defines the effect to bind data to
  22170. * @param nodeMaterial defines the hosting NodeMaterial
  22171. * @param mesh defines the mesh that will be rendered
  22172. * @param subMesh defines the submesh that will be rendered
  22173. */
  22174. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22175. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22176. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22177. protected _writeFloat(value: number): string;
  22178. /**
  22179. * Gets the current class name e.g. "NodeMaterialBlock"
  22180. * @returns the class name
  22181. */
  22182. getClassName(): string;
  22183. /**
  22184. * Register a new input. Must be called inside a block constructor
  22185. * @param name defines the connection point name
  22186. * @param type defines the connection point type
  22187. * @param isOptional defines a boolean indicating that this input can be omitted
  22188. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22189. * @param point an already created connection point. If not provided, create a new one
  22190. * @returns the current block
  22191. */
  22192. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22193. /**
  22194. * Register a new output. Must be called inside a block constructor
  22195. * @param name defines the connection point name
  22196. * @param type defines the connection point type
  22197. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22198. * @param point an already created connection point. If not provided, create a new one
  22199. * @returns the current block
  22200. */
  22201. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22202. /**
  22203. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22204. * @param forOutput defines an optional connection point to check compatibility with
  22205. * @returns the first available input or null
  22206. */
  22207. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22208. /**
  22209. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22210. * @param forBlock defines an optional block to check compatibility with
  22211. * @returns the first available input or null
  22212. */
  22213. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22214. /**
  22215. * Gets the sibling of the given output
  22216. * @param current defines the current output
  22217. * @returns the next output in the list or null
  22218. */
  22219. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22220. /**
  22221. * Connect current block with another block
  22222. * @param other defines the block to connect with
  22223. * @param options define the various options to help pick the right connections
  22224. * @returns the current block
  22225. */
  22226. connectTo(other: NodeMaterialBlock, options?: {
  22227. input?: string;
  22228. output?: string;
  22229. outputSwizzle?: string;
  22230. }): this | undefined;
  22231. protected _buildBlock(state: NodeMaterialBuildState): void;
  22232. /**
  22233. * Add uniforms, samplers and uniform buffers at compilation time
  22234. * @param state defines the state to update
  22235. * @param nodeMaterial defines the node material requesting the update
  22236. * @param defines defines the material defines to update
  22237. * @param uniformBuffers defines the list of uniform buffer names
  22238. */
  22239. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22240. /**
  22241. * Add potential fallbacks if shader compilation fails
  22242. * @param mesh defines the mesh to be rendered
  22243. * @param fallbacks defines the current prioritized list of fallbacks
  22244. */
  22245. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22246. /**
  22247. * Initialize defines for shader compilation
  22248. * @param mesh defines the mesh to be rendered
  22249. * @param nodeMaterial defines the node material requesting the update
  22250. * @param defines defines the material defines to update
  22251. * @param useInstances specifies that instances should be used
  22252. */
  22253. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22254. /**
  22255. * Update defines for shader compilation
  22256. * @param mesh defines the mesh to be rendered
  22257. * @param nodeMaterial defines the node material requesting the update
  22258. * @param defines defines the material defines to update
  22259. * @param useInstances specifies that instances should be used
  22260. * @param subMesh defines which submesh to render
  22261. */
  22262. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22263. /**
  22264. * Lets the block try to connect some inputs automatically
  22265. * @param material defines the hosting NodeMaterial
  22266. */
  22267. autoConfigure(material: NodeMaterial): void;
  22268. /**
  22269. * Function called when a block is declared as repeatable content generator
  22270. * @param vertexShaderState defines the current compilation state for the vertex shader
  22271. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22272. * @param mesh defines the mesh to be rendered
  22273. * @param defines defines the material defines to update
  22274. */
  22275. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22276. /**
  22277. * Checks if the block is ready
  22278. * @param mesh defines the mesh to be rendered
  22279. * @param nodeMaterial defines the node material requesting the update
  22280. * @param defines defines the material defines to update
  22281. * @param useInstances specifies that instances should be used
  22282. * @returns true if the block is ready
  22283. */
  22284. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22285. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22286. private _processBuild;
  22287. /**
  22288. * Validates the new name for the block node.
  22289. * @param newName the new name to be given to the node.
  22290. * @returns false if the name is a reserve word, else true.
  22291. */
  22292. validateBlockName(newName: string): boolean;
  22293. /**
  22294. * Compile the current node and generate the shader code
  22295. * @param state defines the current compilation state (uniforms, samplers, current string)
  22296. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22297. * @returns true if already built
  22298. */
  22299. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22300. protected _inputRename(name: string): string;
  22301. protected _outputRename(name: string): string;
  22302. protected _dumpPropertiesCode(): string;
  22303. /** @hidden */
  22304. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22305. /** @hidden */
  22306. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22307. /**
  22308. * Clone the current block to a new identical block
  22309. * @param scene defines the hosting scene
  22310. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22311. * @returns a copy of the current block
  22312. */
  22313. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22314. /**
  22315. * Serializes this block in a JSON representation
  22316. * @returns the serialized block object
  22317. */
  22318. serialize(): any;
  22319. /** @hidden */
  22320. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22321. private _deserializePortDisplayNamesAndExposedOnFrame;
  22322. /**
  22323. * Release resources
  22324. */
  22325. dispose(): void;
  22326. }
  22327. }
  22328. declare module "babylonjs/Materials/pushMaterial" {
  22329. import { Nullable } from "babylonjs/types";
  22330. import { Scene } from "babylonjs/scene";
  22331. import { Matrix } from "babylonjs/Maths/math.vector";
  22332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22333. import { Mesh } from "babylonjs/Meshes/mesh";
  22334. import { Material } from "babylonjs/Materials/material";
  22335. import { Effect } from "babylonjs/Materials/effect";
  22336. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22337. /**
  22338. * Base class of materials working in push mode in babylon JS
  22339. * @hidden
  22340. */
  22341. export class PushMaterial extends Material {
  22342. protected _activeEffect: Effect;
  22343. protected _normalMatrix: Matrix;
  22344. constructor(name: string, scene: Scene);
  22345. getEffect(): Effect;
  22346. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22347. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22348. /**
  22349. * Binds the given world matrix to the active effect
  22350. *
  22351. * @param world the matrix to bind
  22352. */
  22353. bindOnlyWorldMatrix(world: Matrix): void;
  22354. /**
  22355. * Binds the given normal matrix to the active effect
  22356. *
  22357. * @param normalMatrix the matrix to bind
  22358. */
  22359. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22360. bind(world: Matrix, mesh?: Mesh): void;
  22361. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22362. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22363. }
  22364. }
  22365. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22366. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22367. /**
  22368. * Root class for all node material optimizers
  22369. */
  22370. export class NodeMaterialOptimizer {
  22371. /**
  22372. * Function used to optimize a NodeMaterial graph
  22373. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22374. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22375. */
  22376. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22377. }
  22378. }
  22379. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22380. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22381. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22382. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22383. import { Scene } from "babylonjs/scene";
  22384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22385. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22386. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22387. /**
  22388. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22389. */
  22390. export class TransformBlock extends NodeMaterialBlock {
  22391. /**
  22392. * Defines the value to use to complement W value to transform it to a Vector4
  22393. */
  22394. complementW: number;
  22395. /**
  22396. * Defines the value to use to complement z value to transform it to a Vector4
  22397. */
  22398. complementZ: number;
  22399. /**
  22400. * Creates a new TransformBlock
  22401. * @param name defines the block name
  22402. */
  22403. constructor(name: string);
  22404. /**
  22405. * Gets the current class name
  22406. * @returns the class name
  22407. */
  22408. getClassName(): string;
  22409. /**
  22410. * Gets the vector input
  22411. */
  22412. get vector(): NodeMaterialConnectionPoint;
  22413. /**
  22414. * Gets the output component
  22415. */
  22416. get output(): NodeMaterialConnectionPoint;
  22417. /**
  22418. * Gets the xyz output component
  22419. */
  22420. get xyz(): NodeMaterialConnectionPoint;
  22421. /**
  22422. * Gets the matrix transform input
  22423. */
  22424. get transform(): NodeMaterialConnectionPoint;
  22425. protected _buildBlock(state: NodeMaterialBuildState): this;
  22426. /**
  22427. * Update defines for shader compilation
  22428. * @param mesh defines the mesh to be rendered
  22429. * @param nodeMaterial defines the node material requesting the update
  22430. * @param defines defines the material defines to update
  22431. * @param useInstances specifies that instances should be used
  22432. * @param subMesh defines which submesh to render
  22433. */
  22434. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22435. serialize(): any;
  22436. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22437. protected _dumpPropertiesCode(): string;
  22438. }
  22439. }
  22440. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22441. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22442. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22443. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22444. /**
  22445. * Block used to output the vertex position
  22446. */
  22447. export class VertexOutputBlock extends NodeMaterialBlock {
  22448. /**
  22449. * Creates a new VertexOutputBlock
  22450. * @param name defines the block name
  22451. */
  22452. constructor(name: string);
  22453. /**
  22454. * Gets the current class name
  22455. * @returns the class name
  22456. */
  22457. getClassName(): string;
  22458. /**
  22459. * Gets the vector input component
  22460. */
  22461. get vector(): NodeMaterialConnectionPoint;
  22462. protected _buildBlock(state: NodeMaterialBuildState): this;
  22463. }
  22464. }
  22465. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22466. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22467. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22468. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22469. /**
  22470. * Block used to output the final color
  22471. */
  22472. export class FragmentOutputBlock extends NodeMaterialBlock {
  22473. /**
  22474. * Create a new FragmentOutputBlock
  22475. * @param name defines the block name
  22476. */
  22477. constructor(name: string);
  22478. /**
  22479. * Gets the current class name
  22480. * @returns the class name
  22481. */
  22482. getClassName(): string;
  22483. /**
  22484. * Gets the rgba input component
  22485. */
  22486. get rgba(): NodeMaterialConnectionPoint;
  22487. /**
  22488. * Gets the rgb input component
  22489. */
  22490. get rgb(): NodeMaterialConnectionPoint;
  22491. /**
  22492. * Gets the a input component
  22493. */
  22494. get a(): NodeMaterialConnectionPoint;
  22495. protected _buildBlock(state: NodeMaterialBuildState): this;
  22496. }
  22497. }
  22498. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22499. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22500. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22501. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22502. /**
  22503. * Block used for the particle ramp gradient section
  22504. */
  22505. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22506. /**
  22507. * Create a new ParticleRampGradientBlock
  22508. * @param name defines the block name
  22509. */
  22510. constructor(name: string);
  22511. /**
  22512. * Gets the current class name
  22513. * @returns the class name
  22514. */
  22515. getClassName(): string;
  22516. /**
  22517. * Gets the color input component
  22518. */
  22519. get color(): NodeMaterialConnectionPoint;
  22520. /**
  22521. * Gets the rampColor output component
  22522. */
  22523. get rampColor(): NodeMaterialConnectionPoint;
  22524. /**
  22525. * Initialize the block and prepare the context for build
  22526. * @param state defines the state that will be used for the build
  22527. */
  22528. initialize(state: NodeMaterialBuildState): void;
  22529. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22530. }
  22531. }
  22532. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22533. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22534. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22535. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22536. /**
  22537. * Block used for the particle blend multiply section
  22538. */
  22539. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22540. /**
  22541. * Create a new ParticleBlendMultiplyBlock
  22542. * @param name defines the block name
  22543. */
  22544. constructor(name: string);
  22545. /**
  22546. * Gets the current class name
  22547. * @returns the class name
  22548. */
  22549. getClassName(): string;
  22550. /**
  22551. * Gets the color input component
  22552. */
  22553. get color(): NodeMaterialConnectionPoint;
  22554. /**
  22555. * Gets the alphaTexture input component
  22556. */
  22557. get alphaTexture(): NodeMaterialConnectionPoint;
  22558. /**
  22559. * Gets the alphaColor input component
  22560. */
  22561. get alphaColor(): NodeMaterialConnectionPoint;
  22562. /**
  22563. * Gets the blendColor output component
  22564. */
  22565. get blendColor(): NodeMaterialConnectionPoint;
  22566. /**
  22567. * Initialize the block and prepare the context for build
  22568. * @param state defines the state that will be used for the build
  22569. */
  22570. initialize(state: NodeMaterialBuildState): void;
  22571. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22572. }
  22573. }
  22574. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22575. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22576. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22577. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22578. /**
  22579. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22580. */
  22581. export class VectorMergerBlock extends NodeMaterialBlock {
  22582. /**
  22583. * Create a new VectorMergerBlock
  22584. * @param name defines the block name
  22585. */
  22586. constructor(name: string);
  22587. /**
  22588. * Gets the current class name
  22589. * @returns the class name
  22590. */
  22591. getClassName(): string;
  22592. /**
  22593. * Gets the xyz component (input)
  22594. */
  22595. get xyzIn(): NodeMaterialConnectionPoint;
  22596. /**
  22597. * Gets the xy component (input)
  22598. */
  22599. get xyIn(): NodeMaterialConnectionPoint;
  22600. /**
  22601. * Gets the x component (input)
  22602. */
  22603. get x(): NodeMaterialConnectionPoint;
  22604. /**
  22605. * Gets the y component (input)
  22606. */
  22607. get y(): NodeMaterialConnectionPoint;
  22608. /**
  22609. * Gets the z component (input)
  22610. */
  22611. get z(): NodeMaterialConnectionPoint;
  22612. /**
  22613. * Gets the w component (input)
  22614. */
  22615. get w(): NodeMaterialConnectionPoint;
  22616. /**
  22617. * Gets the xyzw component (output)
  22618. */
  22619. get xyzw(): NodeMaterialConnectionPoint;
  22620. /**
  22621. * Gets the xyz component (output)
  22622. */
  22623. get xyzOut(): NodeMaterialConnectionPoint;
  22624. /**
  22625. * Gets the xy component (output)
  22626. */
  22627. get xyOut(): NodeMaterialConnectionPoint;
  22628. /**
  22629. * Gets the xy component (output)
  22630. * @deprecated Please use xyOut instead.
  22631. */
  22632. get xy(): NodeMaterialConnectionPoint;
  22633. /**
  22634. * Gets the xyz component (output)
  22635. * @deprecated Please use xyzOut instead.
  22636. */
  22637. get xyz(): NodeMaterialConnectionPoint;
  22638. protected _buildBlock(state: NodeMaterialBuildState): this;
  22639. }
  22640. }
  22641. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  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 { Vector2 } from "babylonjs/Maths/math.vector";
  22646. import { Scene } from "babylonjs/scene";
  22647. /**
  22648. * Block used to remap a float from a range to a new one
  22649. */
  22650. export class RemapBlock extends NodeMaterialBlock {
  22651. /**
  22652. * Gets or sets the source range
  22653. */
  22654. sourceRange: Vector2;
  22655. /**
  22656. * Gets or sets the target range
  22657. */
  22658. targetRange: Vector2;
  22659. /**
  22660. * Creates a new RemapBlock
  22661. * @param name defines the block name
  22662. */
  22663. constructor(name: string);
  22664. /**
  22665. * Gets the current class name
  22666. * @returns the class name
  22667. */
  22668. getClassName(): string;
  22669. /**
  22670. * Gets the input component
  22671. */
  22672. get input(): NodeMaterialConnectionPoint;
  22673. /**
  22674. * Gets the source min input component
  22675. */
  22676. get sourceMin(): NodeMaterialConnectionPoint;
  22677. /**
  22678. * Gets the source max input component
  22679. */
  22680. get sourceMax(): NodeMaterialConnectionPoint;
  22681. /**
  22682. * Gets the target min input component
  22683. */
  22684. get targetMin(): NodeMaterialConnectionPoint;
  22685. /**
  22686. * Gets the target max input component
  22687. */
  22688. get targetMax(): NodeMaterialConnectionPoint;
  22689. /**
  22690. * Gets the output component
  22691. */
  22692. get output(): NodeMaterialConnectionPoint;
  22693. protected _buildBlock(state: NodeMaterialBuildState): this;
  22694. protected _dumpPropertiesCode(): string;
  22695. serialize(): any;
  22696. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22697. }
  22698. }
  22699. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22700. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22701. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22702. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22703. /**
  22704. * Block used to multiply 2 values
  22705. */
  22706. export class MultiplyBlock extends NodeMaterialBlock {
  22707. /**
  22708. * Creates a new MultiplyBlock
  22709. * @param name defines the block name
  22710. */
  22711. constructor(name: string);
  22712. /**
  22713. * Gets the current class name
  22714. * @returns the class name
  22715. */
  22716. getClassName(): string;
  22717. /**
  22718. * Gets the left operand input component
  22719. */
  22720. get left(): NodeMaterialConnectionPoint;
  22721. /**
  22722. * Gets the right operand input component
  22723. */
  22724. get right(): NodeMaterialConnectionPoint;
  22725. /**
  22726. * Gets the output component
  22727. */
  22728. get output(): NodeMaterialConnectionPoint;
  22729. protected _buildBlock(state: NodeMaterialBuildState): this;
  22730. }
  22731. }
  22732. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22733. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22734. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22735. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22736. /**
  22737. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22738. */
  22739. export class ColorSplitterBlock extends NodeMaterialBlock {
  22740. /**
  22741. * Create a new ColorSplitterBlock
  22742. * @param name defines the block name
  22743. */
  22744. constructor(name: string);
  22745. /**
  22746. * Gets the current class name
  22747. * @returns the class name
  22748. */
  22749. getClassName(): string;
  22750. /**
  22751. * Gets the rgba component (input)
  22752. */
  22753. get rgba(): NodeMaterialConnectionPoint;
  22754. /**
  22755. * Gets the rgb component (input)
  22756. */
  22757. get rgbIn(): NodeMaterialConnectionPoint;
  22758. /**
  22759. * Gets the rgb component (output)
  22760. */
  22761. get rgbOut(): NodeMaterialConnectionPoint;
  22762. /**
  22763. * Gets the r component (output)
  22764. */
  22765. get r(): NodeMaterialConnectionPoint;
  22766. /**
  22767. * Gets the g component (output)
  22768. */
  22769. get g(): NodeMaterialConnectionPoint;
  22770. /**
  22771. * Gets the b component (output)
  22772. */
  22773. get b(): NodeMaterialConnectionPoint;
  22774. /**
  22775. * Gets the a component (output)
  22776. */
  22777. get a(): NodeMaterialConnectionPoint;
  22778. protected _inputRename(name: string): string;
  22779. protected _outputRename(name: string): string;
  22780. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22781. }
  22782. }
  22783. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22784. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22785. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22786. import { Scene } from "babylonjs/scene";
  22787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22788. import { Matrix } from "babylonjs/Maths/math.vector";
  22789. import { Mesh } from "babylonjs/Meshes/mesh";
  22790. import { Engine } from "babylonjs/Engines/engine";
  22791. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22792. import { Observable } from "babylonjs/Misc/observable";
  22793. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22794. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22795. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22796. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22797. import { Nullable } from "babylonjs/types";
  22798. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22799. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22800. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22801. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22802. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22803. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22804. import { Effect } from "babylonjs/Materials/effect";
  22805. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22806. import { Camera } from "babylonjs/Cameras/camera";
  22807. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22808. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22809. /**
  22810. * Interface used to configure the node material editor
  22811. */
  22812. export interface INodeMaterialEditorOptions {
  22813. /** Define the URl to load node editor script */
  22814. editorURL?: string;
  22815. }
  22816. /** @hidden */
  22817. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22818. NORMAL: boolean;
  22819. TANGENT: boolean;
  22820. UV1: boolean;
  22821. /** BONES */
  22822. NUM_BONE_INFLUENCERS: number;
  22823. BonesPerMesh: number;
  22824. BONETEXTURE: boolean;
  22825. /** MORPH TARGETS */
  22826. MORPHTARGETS: boolean;
  22827. MORPHTARGETS_NORMAL: boolean;
  22828. MORPHTARGETS_TANGENT: boolean;
  22829. MORPHTARGETS_UV: boolean;
  22830. NUM_MORPH_INFLUENCERS: number;
  22831. /** IMAGE PROCESSING */
  22832. IMAGEPROCESSING: boolean;
  22833. VIGNETTE: boolean;
  22834. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22835. VIGNETTEBLENDMODEOPAQUE: boolean;
  22836. TONEMAPPING: boolean;
  22837. TONEMAPPING_ACES: boolean;
  22838. CONTRAST: boolean;
  22839. EXPOSURE: boolean;
  22840. COLORCURVES: boolean;
  22841. COLORGRADING: boolean;
  22842. COLORGRADING3D: boolean;
  22843. SAMPLER3DGREENDEPTH: boolean;
  22844. SAMPLER3DBGRMAP: boolean;
  22845. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22846. /** MISC. */
  22847. BUMPDIRECTUV: number;
  22848. constructor();
  22849. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22850. }
  22851. /**
  22852. * Class used to configure NodeMaterial
  22853. */
  22854. export interface INodeMaterialOptions {
  22855. /**
  22856. * Defines if blocks should emit comments
  22857. */
  22858. emitComments: boolean;
  22859. }
  22860. /**
  22861. * Class used to create a node based material built by assembling shader blocks
  22862. */
  22863. export class NodeMaterial extends PushMaterial {
  22864. private static _BuildIdGenerator;
  22865. private _options;
  22866. private _vertexCompilationState;
  22867. private _fragmentCompilationState;
  22868. private _sharedData;
  22869. private _buildId;
  22870. private _buildWasSuccessful;
  22871. private _cachedWorldViewMatrix;
  22872. private _cachedWorldViewProjectionMatrix;
  22873. private _optimizers;
  22874. private _animationFrame;
  22875. /** Define the Url to load node editor script */
  22876. static EditorURL: string;
  22877. /** Define the Url to load snippets */
  22878. static SnippetUrl: string;
  22879. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22880. static IgnoreTexturesAtLoadTime: boolean;
  22881. private BJSNODEMATERIALEDITOR;
  22882. /** Get the inspector from bundle or global */
  22883. private _getGlobalNodeMaterialEditor;
  22884. /**
  22885. * Snippet ID if the material was created from the snippet server
  22886. */
  22887. snippetId: string;
  22888. /**
  22889. * Gets or sets data used by visual editor
  22890. * @see https://nme.babylonjs.com
  22891. */
  22892. editorData: any;
  22893. /**
  22894. * 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)
  22895. */
  22896. ignoreAlpha: boolean;
  22897. /**
  22898. * Defines the maximum number of lights that can be used in the material
  22899. */
  22900. maxSimultaneousLights: number;
  22901. /**
  22902. * Observable raised when the material is built
  22903. */
  22904. onBuildObservable: Observable<NodeMaterial>;
  22905. /**
  22906. * Gets or sets the root nodes of the material vertex shader
  22907. */
  22908. _vertexOutputNodes: NodeMaterialBlock[];
  22909. /**
  22910. * Gets or sets the root nodes of the material fragment (pixel) shader
  22911. */
  22912. _fragmentOutputNodes: NodeMaterialBlock[];
  22913. /** Gets or sets options to control the node material overall behavior */
  22914. get options(): INodeMaterialOptions;
  22915. set options(options: INodeMaterialOptions);
  22916. /**
  22917. * Default configuration related to image processing available in the standard Material.
  22918. */
  22919. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22920. /**
  22921. * Gets the image processing configuration used either in this material.
  22922. */
  22923. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22924. /**
  22925. * Sets the Default image processing configuration used either in the this material.
  22926. *
  22927. * If sets to null, the scene one is in use.
  22928. */
  22929. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22930. /**
  22931. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22932. */
  22933. attachedBlocks: NodeMaterialBlock[];
  22934. /**
  22935. * Specifies the mode of the node material
  22936. * @hidden
  22937. */
  22938. _mode: NodeMaterialModes;
  22939. /**
  22940. * Gets the mode property
  22941. */
  22942. get mode(): NodeMaterialModes;
  22943. /**
  22944. * Create a new node based material
  22945. * @param name defines the material name
  22946. * @param scene defines the hosting scene
  22947. * @param options defines creation option
  22948. */
  22949. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22950. /**
  22951. * Gets the current class name of the material e.g. "NodeMaterial"
  22952. * @returns the class name
  22953. */
  22954. getClassName(): string;
  22955. /**
  22956. * Keep track of the image processing observer to allow dispose and replace.
  22957. */
  22958. private _imageProcessingObserver;
  22959. /**
  22960. * Attaches a new image processing configuration to the Standard Material.
  22961. * @param configuration
  22962. */
  22963. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22964. /**
  22965. * Get a block by its name
  22966. * @param name defines the name of the block to retrieve
  22967. * @returns the required block or null if not found
  22968. */
  22969. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22970. /**
  22971. * Get a block by its name
  22972. * @param predicate defines the predicate used to find the good candidate
  22973. * @returns the required block or null if not found
  22974. */
  22975. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22976. /**
  22977. * Get an input block by its name
  22978. * @param predicate defines the predicate used to find the good candidate
  22979. * @returns the required input block or null if not found
  22980. */
  22981. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22982. /**
  22983. * Gets the list of input blocks attached to this material
  22984. * @returns an array of InputBlocks
  22985. */
  22986. getInputBlocks(): InputBlock[];
  22987. /**
  22988. * Adds a new optimizer to the list of optimizers
  22989. * @param optimizer defines the optimizers to add
  22990. * @returns the current material
  22991. */
  22992. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22993. /**
  22994. * Remove an optimizer from the list of optimizers
  22995. * @param optimizer defines the optimizers to remove
  22996. * @returns the current material
  22997. */
  22998. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22999. /**
  23000. * Add a new block to the list of output nodes
  23001. * @param node defines the node to add
  23002. * @returns the current material
  23003. */
  23004. addOutputNode(node: NodeMaterialBlock): this;
  23005. /**
  23006. * Remove a block from the list of root nodes
  23007. * @param node defines the node to remove
  23008. * @returns the current material
  23009. */
  23010. removeOutputNode(node: NodeMaterialBlock): this;
  23011. private _addVertexOutputNode;
  23012. private _removeVertexOutputNode;
  23013. private _addFragmentOutputNode;
  23014. private _removeFragmentOutputNode;
  23015. /**
  23016. * Specifies if the material will require alpha blending
  23017. * @returns a boolean specifying if alpha blending is needed
  23018. */
  23019. needAlphaBlending(): boolean;
  23020. /**
  23021. * Specifies if this material should be rendered in alpha test mode
  23022. * @returns a boolean specifying if an alpha test is needed.
  23023. */
  23024. needAlphaTesting(): boolean;
  23025. private _initializeBlock;
  23026. private _resetDualBlocks;
  23027. /**
  23028. * Remove a block from the current node material
  23029. * @param block defines the block to remove
  23030. */
  23031. removeBlock(block: NodeMaterialBlock): void;
  23032. /**
  23033. * Build the material and generates the inner effect
  23034. * @param verbose defines if the build should log activity
  23035. */
  23036. build(verbose?: boolean): void;
  23037. /**
  23038. * Runs an otpimization phase to try to improve the shader code
  23039. */
  23040. optimize(): void;
  23041. private _prepareDefinesForAttributes;
  23042. /**
  23043. * Create a post process from the material
  23044. * @param camera The camera to apply the render pass to.
  23045. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23047. * @param engine The engine which the post process will be applied. (default: current engine)
  23048. * @param reusable If the post process can be reused on the same frame. (default: false)
  23049. * @param textureType Type of textures used when performing the post process. (default: 0)
  23050. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23051. * @returns the post process created
  23052. */
  23053. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  23054. /**
  23055. * Create the post process effect from the material
  23056. * @param postProcess The post process to create the effect for
  23057. */
  23058. createEffectForPostProcess(postProcess: PostProcess): void;
  23059. private _createEffectOrPostProcess;
  23060. private _createEffectForParticles;
  23061. /**
  23062. * Create the effect to be used as the custom effect for a particle system
  23063. * @param particleSystem Particle system to create the effect for
  23064. * @param onCompiled defines a function to call when the effect creation is successful
  23065. * @param onError defines a function to call when the effect creation has failed
  23066. */
  23067. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23068. private _processDefines;
  23069. /**
  23070. * Get if the submesh is ready to be used and all its information available.
  23071. * Child classes can use it to update shaders
  23072. * @param mesh defines the mesh to check
  23073. * @param subMesh defines which submesh to check
  23074. * @param useInstances specifies that instances should be used
  23075. * @returns a boolean indicating that the submesh is ready or not
  23076. */
  23077. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23078. /**
  23079. * Get a string representing the shaders built by the current node graph
  23080. */
  23081. get compiledShaders(): string;
  23082. /**
  23083. * Binds the world matrix to the material
  23084. * @param world defines the world transformation matrix
  23085. */
  23086. bindOnlyWorldMatrix(world: Matrix): void;
  23087. /**
  23088. * Binds the submesh to this material by preparing the effect and shader to draw
  23089. * @param world defines the world transformation matrix
  23090. * @param mesh defines the mesh containing the submesh
  23091. * @param subMesh defines the submesh to bind the material to
  23092. */
  23093. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23094. /**
  23095. * Gets the active textures from the material
  23096. * @returns an array of textures
  23097. */
  23098. getActiveTextures(): BaseTexture[];
  23099. /**
  23100. * Gets the list of texture blocks
  23101. * @returns an array of texture blocks
  23102. */
  23103. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23104. /**
  23105. * Specifies if the material uses a texture
  23106. * @param texture defines the texture to check against the material
  23107. * @returns a boolean specifying if the material uses the texture
  23108. */
  23109. hasTexture(texture: BaseTexture): boolean;
  23110. /**
  23111. * Disposes the material
  23112. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23113. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23114. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23115. */
  23116. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23117. /** Creates the node editor window. */
  23118. private _createNodeEditor;
  23119. /**
  23120. * Launch the node material editor
  23121. * @param config Define the configuration of the editor
  23122. * @return a promise fulfilled when the node editor is visible
  23123. */
  23124. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23125. /**
  23126. * Clear the current material
  23127. */
  23128. clear(): void;
  23129. /**
  23130. * Clear the current material and set it to a default state
  23131. */
  23132. setToDefault(): void;
  23133. /**
  23134. * Clear the current material and set it to a default state for post process
  23135. */
  23136. setToDefaultPostProcess(): void;
  23137. /**
  23138. * Clear the current material and set it to a default state for particle
  23139. */
  23140. setToDefaultParticle(): void;
  23141. /**
  23142. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23143. * @param url defines the url to load from
  23144. * @returns a promise that will fullfil when the material is fully loaded
  23145. */
  23146. loadAsync(url: string): Promise<void>;
  23147. private _gatherBlocks;
  23148. /**
  23149. * Generate a string containing the code declaration required to create an equivalent of this material
  23150. * @returns a string
  23151. */
  23152. generateCode(): string;
  23153. /**
  23154. * Serializes this material in a JSON representation
  23155. * @returns the serialized material object
  23156. */
  23157. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23158. private _restoreConnections;
  23159. /**
  23160. * Clear the current graph and load a new one from a serialization object
  23161. * @param source defines the JSON representation of the material
  23162. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23163. * @param merge defines whether or not the source must be merged or replace the current content
  23164. */
  23165. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23166. /**
  23167. * Makes a duplicate of the current material.
  23168. * @param name - name to use for the new material.
  23169. */
  23170. clone(name: string): NodeMaterial;
  23171. /**
  23172. * Creates a node material from parsed material data
  23173. * @param source defines the JSON representation of the material
  23174. * @param scene defines the hosting scene
  23175. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23176. * @returns a new node material
  23177. */
  23178. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23179. /**
  23180. * Creates a node material from a snippet saved in a remote file
  23181. * @param name defines the name of the material to create
  23182. * @param url defines the url to load from
  23183. * @param scene defines the hosting scene
  23184. * @returns a promise that will resolve to the new node material
  23185. */
  23186. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23187. /**
  23188. * Creates a node material from a snippet saved by the node material editor
  23189. * @param snippetId defines the snippet to load
  23190. * @param scene defines the hosting scene
  23191. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23192. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23193. * @returns a promise that will resolve to the new node material
  23194. */
  23195. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23196. /**
  23197. * Creates a new node material set to default basic configuration
  23198. * @param name defines the name of the material
  23199. * @param scene defines the hosting scene
  23200. * @returns a new NodeMaterial
  23201. */
  23202. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23203. }
  23204. }
  23205. declare module "babylonjs/PostProcesses/postProcess" {
  23206. import { Nullable } from "babylonjs/types";
  23207. import { SmartArray } from "babylonjs/Misc/smartArray";
  23208. import { Observable } from "babylonjs/Misc/observable";
  23209. import { Vector2 } from "babylonjs/Maths/math.vector";
  23210. import { Camera } from "babylonjs/Cameras/camera";
  23211. import { Effect } from "babylonjs/Materials/effect";
  23212. import "babylonjs/Shaders/postprocess.vertex";
  23213. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23214. import { Engine } from "babylonjs/Engines/engine";
  23215. import { Color4 } from "babylonjs/Maths/math.color";
  23216. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23217. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23218. import { Scene } from "babylonjs/scene";
  23219. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23220. /**
  23221. * Size options for a post process
  23222. */
  23223. export type PostProcessOptions = {
  23224. width: number;
  23225. height: number;
  23226. };
  23227. /**
  23228. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23229. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23230. */
  23231. export class PostProcess {
  23232. /** Name of the PostProcess. */
  23233. name: string;
  23234. /**
  23235. * Gets or sets the unique id of the post process
  23236. */
  23237. uniqueId: number;
  23238. /**
  23239. * Width of the texture to apply the post process on
  23240. */
  23241. width: number;
  23242. /**
  23243. * Height of the texture to apply the post process on
  23244. */
  23245. height: number;
  23246. /**
  23247. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23248. */
  23249. nodeMaterialSource: Nullable<NodeMaterial>;
  23250. /**
  23251. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23252. * @hidden
  23253. */
  23254. _outputTexture: Nullable<InternalTexture>;
  23255. /**
  23256. * Sampling mode used by the shader
  23257. * See https://doc.babylonjs.com/classes/3.1/texture
  23258. */
  23259. renderTargetSamplingMode: number;
  23260. /**
  23261. * Clear color to use when screen clearing
  23262. */
  23263. clearColor: Color4;
  23264. /**
  23265. * If the buffer needs to be cleared before applying the post process. (default: true)
  23266. * Should be set to false if shader will overwrite all previous pixels.
  23267. */
  23268. autoClear: boolean;
  23269. /**
  23270. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23271. */
  23272. alphaMode: number;
  23273. /**
  23274. * Sets the setAlphaBlendConstants of the babylon engine
  23275. */
  23276. alphaConstants: Color4;
  23277. /**
  23278. * Animations to be used for the post processing
  23279. */
  23280. animations: import("babylonjs/Animations/animation").Animation[];
  23281. /**
  23282. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23283. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23284. */
  23285. enablePixelPerfectMode: boolean;
  23286. /**
  23287. * Force the postprocess to be applied without taking in account viewport
  23288. */
  23289. forceFullscreenViewport: boolean;
  23290. /**
  23291. * List of inspectable custom properties (used by the Inspector)
  23292. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23293. */
  23294. inspectableCustomProperties: IInspectable[];
  23295. /**
  23296. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23297. *
  23298. * | Value | Type | Description |
  23299. * | ----- | ----------------------------------- | ----------- |
  23300. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23301. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23302. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23303. *
  23304. */
  23305. scaleMode: number;
  23306. /**
  23307. * Force textures to be a power of two (default: false)
  23308. */
  23309. alwaysForcePOT: boolean;
  23310. private _samples;
  23311. /**
  23312. * Number of sample textures (default: 1)
  23313. */
  23314. get samples(): number;
  23315. set samples(n: number);
  23316. /**
  23317. * Modify the scale of the post process to be the same as the viewport (default: false)
  23318. */
  23319. adaptScaleToCurrentViewport: boolean;
  23320. private _camera;
  23321. protected _scene: Scene;
  23322. private _engine;
  23323. private _options;
  23324. private _reusable;
  23325. private _textureType;
  23326. private _textureFormat;
  23327. /**
  23328. * Smart array of input and output textures for the post process.
  23329. * @hidden
  23330. */
  23331. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23332. /**
  23333. * The index in _textures that corresponds to the output texture.
  23334. * @hidden
  23335. */
  23336. _currentRenderTextureInd: number;
  23337. private _effect;
  23338. private _samplers;
  23339. private _fragmentUrl;
  23340. private _vertexUrl;
  23341. private _parameters;
  23342. private _scaleRatio;
  23343. protected _indexParameters: any;
  23344. private _shareOutputWithPostProcess;
  23345. private _texelSize;
  23346. private _forcedOutputTexture;
  23347. /**
  23348. * Returns the fragment url or shader name used in the post process.
  23349. * @returns the fragment url or name in the shader store.
  23350. */
  23351. getEffectName(): string;
  23352. /**
  23353. * An event triggered when the postprocess is activated.
  23354. */
  23355. onActivateObservable: Observable<Camera>;
  23356. private _onActivateObserver;
  23357. /**
  23358. * A function that is added to the onActivateObservable
  23359. */
  23360. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23361. /**
  23362. * An event triggered when the postprocess changes its size.
  23363. */
  23364. onSizeChangedObservable: Observable<PostProcess>;
  23365. private _onSizeChangedObserver;
  23366. /**
  23367. * A function that is added to the onSizeChangedObservable
  23368. */
  23369. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23370. /**
  23371. * An event triggered when the postprocess applies its effect.
  23372. */
  23373. onApplyObservable: Observable<Effect>;
  23374. private _onApplyObserver;
  23375. /**
  23376. * A function that is added to the onApplyObservable
  23377. */
  23378. set onApply(callback: (effect: Effect) => void);
  23379. /**
  23380. * An event triggered before rendering the postprocess
  23381. */
  23382. onBeforeRenderObservable: Observable<Effect>;
  23383. private _onBeforeRenderObserver;
  23384. /**
  23385. * A function that is added to the onBeforeRenderObservable
  23386. */
  23387. set onBeforeRender(callback: (effect: Effect) => void);
  23388. /**
  23389. * An event triggered after rendering the postprocess
  23390. */
  23391. onAfterRenderObservable: Observable<Effect>;
  23392. private _onAfterRenderObserver;
  23393. /**
  23394. * A function that is added to the onAfterRenderObservable
  23395. */
  23396. set onAfterRender(callback: (efect: Effect) => void);
  23397. /**
  23398. * 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
  23399. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23400. */
  23401. get inputTexture(): InternalTexture;
  23402. set inputTexture(value: InternalTexture);
  23403. /**
  23404. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23405. * the only way to unset it is to use this function to restore its internal state
  23406. */
  23407. restoreDefaultInputTexture(): void;
  23408. /**
  23409. * Gets the camera which post process is applied to.
  23410. * @returns The camera the post process is applied to.
  23411. */
  23412. getCamera(): Camera;
  23413. /**
  23414. * Gets the texel size of the postprocess.
  23415. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23416. */
  23417. get texelSize(): Vector2;
  23418. /**
  23419. * Creates a new instance PostProcess
  23420. * @param name The name of the PostProcess.
  23421. * @param fragmentUrl The url of the fragment shader to be used.
  23422. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23423. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23424. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23425. * @param camera The camera to apply the render pass to.
  23426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23427. * @param engine The engine which the post process will be applied. (default: current engine)
  23428. * @param reusable If the post process can be reused on the same frame. (default: false)
  23429. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23430. * @param textureType Type of textures used when performing the post process. (default: 0)
  23431. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23432. * @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
  23433. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23434. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23435. */
  23436. constructor(
  23437. /** Name of the PostProcess. */
  23438. 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);
  23439. /**
  23440. * Gets a string idenfifying the name of the class
  23441. * @returns "PostProcess" string
  23442. */
  23443. getClassName(): string;
  23444. /**
  23445. * Gets the engine which this post process belongs to.
  23446. * @returns The engine the post process was enabled with.
  23447. */
  23448. getEngine(): Engine;
  23449. /**
  23450. * The effect that is created when initializing the post process.
  23451. * @returns The created effect corresponding the the postprocess.
  23452. */
  23453. getEffect(): Effect;
  23454. /**
  23455. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23456. * @param postProcess The post process to share the output with.
  23457. * @returns This post process.
  23458. */
  23459. shareOutputWith(postProcess: PostProcess): PostProcess;
  23460. /**
  23461. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23462. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23463. */
  23464. useOwnOutput(): void;
  23465. /**
  23466. * Updates the effect with the current post process compile time values and recompiles the shader.
  23467. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23468. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23469. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23470. * @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
  23471. * @param onCompiled Called when the shader has been compiled.
  23472. * @param onError Called if there is an error when compiling a shader.
  23473. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23474. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23475. */
  23476. 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;
  23477. /**
  23478. * The post process is reusable if it can be used multiple times within one frame.
  23479. * @returns If the post process is reusable
  23480. */
  23481. isReusable(): boolean;
  23482. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23483. markTextureDirty(): void;
  23484. /**
  23485. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23486. * 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.
  23487. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23488. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23489. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23490. * @returns The target texture that was bound to be written to.
  23491. */
  23492. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23493. /**
  23494. * If the post process is supported.
  23495. */
  23496. get isSupported(): boolean;
  23497. /**
  23498. * The aspect ratio of the output texture.
  23499. */
  23500. get aspectRatio(): number;
  23501. /**
  23502. * Get a value indicating if the post-process is ready to be used
  23503. * @returns true if the post-process is ready (shader is compiled)
  23504. */
  23505. isReady(): boolean;
  23506. /**
  23507. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23508. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23509. */
  23510. apply(): Nullable<Effect>;
  23511. private _disposeTextures;
  23512. /**
  23513. * Disposes the post process.
  23514. * @param camera The camera to dispose the post process on.
  23515. */
  23516. dispose(camera?: Camera): void;
  23517. }
  23518. }
  23519. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23520. /** @hidden */
  23521. export var kernelBlurVaryingDeclaration: {
  23522. name: string;
  23523. shader: string;
  23524. };
  23525. }
  23526. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23527. /** @hidden */
  23528. export var kernelBlurFragment: {
  23529. name: string;
  23530. shader: string;
  23531. };
  23532. }
  23533. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23534. /** @hidden */
  23535. export var kernelBlurFragment2: {
  23536. name: string;
  23537. shader: string;
  23538. };
  23539. }
  23540. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23541. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23542. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23543. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23544. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23545. /** @hidden */
  23546. export var kernelBlurPixelShader: {
  23547. name: string;
  23548. shader: string;
  23549. };
  23550. }
  23551. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23552. /** @hidden */
  23553. export var kernelBlurVertex: {
  23554. name: string;
  23555. shader: string;
  23556. };
  23557. }
  23558. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23559. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23560. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23561. /** @hidden */
  23562. export var kernelBlurVertexShader: {
  23563. name: string;
  23564. shader: string;
  23565. };
  23566. }
  23567. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23568. import { Vector2 } from "babylonjs/Maths/math.vector";
  23569. import { Nullable } from "babylonjs/types";
  23570. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23571. import { Camera } from "babylonjs/Cameras/camera";
  23572. import { Effect } from "babylonjs/Materials/effect";
  23573. import { Engine } from "babylonjs/Engines/engine";
  23574. import "babylonjs/Shaders/kernelBlur.fragment";
  23575. import "babylonjs/Shaders/kernelBlur.vertex";
  23576. /**
  23577. * The Blur Post Process which blurs an image based on a kernel and direction.
  23578. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23579. */
  23580. export class BlurPostProcess extends PostProcess {
  23581. /** The direction in which to blur the image. */
  23582. direction: Vector2;
  23583. private blockCompilation;
  23584. protected _kernel: number;
  23585. protected _idealKernel: number;
  23586. protected _packedFloat: boolean;
  23587. private _staticDefines;
  23588. /**
  23589. * Sets the length in pixels of the blur sample region
  23590. */
  23591. set kernel(v: number);
  23592. /**
  23593. * Gets the length in pixels of the blur sample region
  23594. */
  23595. get kernel(): number;
  23596. /**
  23597. * Sets wether or not the blur needs to unpack/repack floats
  23598. */
  23599. set packedFloat(v: boolean);
  23600. /**
  23601. * Gets wether or not the blur is unpacking/repacking floats
  23602. */
  23603. get packedFloat(): boolean;
  23604. /**
  23605. * Creates a new instance BlurPostProcess
  23606. * @param name The name of the effect.
  23607. * @param direction The direction in which to blur the image.
  23608. * @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.
  23609. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23610. * @param camera The camera to apply the render pass to.
  23611. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23612. * @param engine The engine which the post process will be applied. (default: current engine)
  23613. * @param reusable If the post process can be reused on the same frame. (default: false)
  23614. * @param textureType Type of textures used when performing the post process. (default: 0)
  23615. * @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)
  23616. */
  23617. constructor(name: string,
  23618. /** The direction in which to blur the image. */
  23619. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23620. /**
  23621. * Updates the effect with the current post process compile time values and recompiles the shader.
  23622. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23623. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23624. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23625. * @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
  23626. * @param onCompiled Called when the shader has been compiled.
  23627. * @param onError Called if there is an error when compiling a shader.
  23628. */
  23629. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23630. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23631. /**
  23632. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23633. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23634. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23635. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23636. * The gaps between physical kernels are compensated for in the weighting of the samples
  23637. * @param idealKernel Ideal blur kernel.
  23638. * @return Nearest best kernel.
  23639. */
  23640. protected _nearestBestKernel(idealKernel: number): number;
  23641. /**
  23642. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23643. * @param x The point on the Gaussian distribution to sample.
  23644. * @return the value of the Gaussian function at x.
  23645. */
  23646. protected _gaussianWeight(x: number): number;
  23647. /**
  23648. * Generates a string that can be used as a floating point number in GLSL.
  23649. * @param x Value to print.
  23650. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23651. * @return GLSL float string.
  23652. */
  23653. protected _glslFloat(x: number, decimalFigures?: number): string;
  23654. }
  23655. }
  23656. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23657. import { Scene } from "babylonjs/scene";
  23658. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23659. import { Plane } from "babylonjs/Maths/math.plane";
  23660. /**
  23661. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23662. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23663. * You can then easily use it as a reflectionTexture on a flat surface.
  23664. * In case the surface is not a plane, please consider relying on reflection probes.
  23665. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23666. */
  23667. export class MirrorTexture extends RenderTargetTexture {
  23668. private scene;
  23669. /**
  23670. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23671. * 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.
  23672. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23673. */
  23674. mirrorPlane: Plane;
  23675. /**
  23676. * Define the blur ratio used to blur the reflection if needed.
  23677. */
  23678. set blurRatio(value: number);
  23679. get blurRatio(): number;
  23680. /**
  23681. * Define the adaptive blur kernel used to blur the reflection if needed.
  23682. * This will autocompute the closest best match for the `blurKernel`
  23683. */
  23684. set adaptiveBlurKernel(value: number);
  23685. /**
  23686. * Define the blur kernel used to blur the reflection if needed.
  23687. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23688. */
  23689. set blurKernel(value: number);
  23690. /**
  23691. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23692. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23693. */
  23694. set blurKernelX(value: number);
  23695. get blurKernelX(): number;
  23696. /**
  23697. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23698. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23699. */
  23700. set blurKernelY(value: number);
  23701. get blurKernelY(): number;
  23702. private _autoComputeBlurKernel;
  23703. protected _onRatioRescale(): void;
  23704. private _updateGammaSpace;
  23705. private _imageProcessingConfigChangeObserver;
  23706. private _transformMatrix;
  23707. private _mirrorMatrix;
  23708. private _savedViewMatrix;
  23709. private _blurX;
  23710. private _blurY;
  23711. private _adaptiveBlurKernel;
  23712. private _blurKernelX;
  23713. private _blurKernelY;
  23714. private _blurRatio;
  23715. /**
  23716. * Instantiates a Mirror Texture.
  23717. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23718. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23719. * You can then easily use it as a reflectionTexture on a flat surface.
  23720. * In case the surface is not a plane, please consider relying on reflection probes.
  23721. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23722. * @param name
  23723. * @param size
  23724. * @param scene
  23725. * @param generateMipMaps
  23726. * @param type
  23727. * @param samplingMode
  23728. * @param generateDepthBuffer
  23729. */
  23730. constructor(name: string, size: number | {
  23731. width: number;
  23732. height: number;
  23733. } | {
  23734. ratio: number;
  23735. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23736. private _preparePostProcesses;
  23737. /**
  23738. * Clone the mirror texture.
  23739. * @returns the cloned texture
  23740. */
  23741. clone(): MirrorTexture;
  23742. /**
  23743. * Serialize the texture to a JSON representation you could use in Parse later on
  23744. * @returns the serialized JSON representation
  23745. */
  23746. serialize(): any;
  23747. /**
  23748. * Dispose the texture and release its associated resources.
  23749. */
  23750. dispose(): void;
  23751. }
  23752. }
  23753. declare module "babylonjs/Materials/Textures/texture" {
  23754. import { Observable } from "babylonjs/Misc/observable";
  23755. import { Nullable } from "babylonjs/types";
  23756. import { Matrix } from "babylonjs/Maths/math.vector";
  23757. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23758. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23759. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23760. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23761. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23762. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23763. import { Scene } from "babylonjs/scene";
  23764. /**
  23765. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23766. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23767. */
  23768. export class Texture extends BaseTexture {
  23769. /**
  23770. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23771. */
  23772. static SerializeBuffers: boolean;
  23773. /** @hidden */
  23774. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23775. /** @hidden */
  23776. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23777. /** @hidden */
  23778. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23779. /** nearest is mag = nearest and min = nearest and mip = linear */
  23780. static readonly NEAREST_SAMPLINGMODE: number;
  23781. /** nearest is mag = nearest and min = nearest and mip = linear */
  23782. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23783. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23784. static readonly BILINEAR_SAMPLINGMODE: number;
  23785. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23786. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23787. /** Trilinear is mag = linear and min = linear and mip = linear */
  23788. static readonly TRILINEAR_SAMPLINGMODE: number;
  23789. /** Trilinear is mag = linear and min = linear and mip = linear */
  23790. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23791. /** mag = nearest and min = nearest and mip = nearest */
  23792. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23793. /** mag = nearest and min = linear and mip = nearest */
  23794. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23795. /** mag = nearest and min = linear and mip = linear */
  23796. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23797. /** mag = nearest and min = linear and mip = none */
  23798. static readonly NEAREST_LINEAR: number;
  23799. /** mag = nearest and min = nearest and mip = none */
  23800. static readonly NEAREST_NEAREST: number;
  23801. /** mag = linear and min = nearest and mip = nearest */
  23802. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23803. /** mag = linear and min = nearest and mip = linear */
  23804. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23805. /** mag = linear and min = linear and mip = none */
  23806. static readonly LINEAR_LINEAR: number;
  23807. /** mag = linear and min = nearest and mip = none */
  23808. static readonly LINEAR_NEAREST: number;
  23809. /** Explicit coordinates mode */
  23810. static readonly EXPLICIT_MODE: number;
  23811. /** Spherical coordinates mode */
  23812. static readonly SPHERICAL_MODE: number;
  23813. /** Planar coordinates mode */
  23814. static readonly PLANAR_MODE: number;
  23815. /** Cubic coordinates mode */
  23816. static readonly CUBIC_MODE: number;
  23817. /** Projection coordinates mode */
  23818. static readonly PROJECTION_MODE: number;
  23819. /** Inverse Cubic coordinates mode */
  23820. static readonly SKYBOX_MODE: number;
  23821. /** Inverse Cubic coordinates mode */
  23822. static readonly INVCUBIC_MODE: number;
  23823. /** Equirectangular coordinates mode */
  23824. static readonly EQUIRECTANGULAR_MODE: number;
  23825. /** Equirectangular Fixed coordinates mode */
  23826. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23827. /** Equirectangular Fixed Mirrored coordinates mode */
  23828. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23829. /** Texture is not repeating outside of 0..1 UVs */
  23830. static readonly CLAMP_ADDRESSMODE: number;
  23831. /** Texture is repeating outside of 0..1 UVs */
  23832. static readonly WRAP_ADDRESSMODE: number;
  23833. /** Texture is repeating and mirrored */
  23834. static readonly MIRROR_ADDRESSMODE: number;
  23835. /**
  23836. * 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
  23837. */
  23838. static UseSerializedUrlIfAny: boolean;
  23839. /**
  23840. * Define the url of the texture.
  23841. */
  23842. url: Nullable<string>;
  23843. /**
  23844. * Define an offset on the texture to offset the u coordinates of the UVs
  23845. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23846. */
  23847. uOffset: number;
  23848. /**
  23849. * Define an offset on the texture to offset the v coordinates of the UVs
  23850. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23851. */
  23852. vOffset: number;
  23853. /**
  23854. * Define an offset on the texture to scale the u coordinates of the UVs
  23855. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23856. */
  23857. uScale: number;
  23858. /**
  23859. * Define an offset on the texture to scale the v coordinates of the UVs
  23860. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23861. */
  23862. vScale: number;
  23863. /**
  23864. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23865. * @see https://doc.babylonjs.com/how_to/more_materials
  23866. */
  23867. uAng: number;
  23868. /**
  23869. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23870. * @see https://doc.babylonjs.com/how_to/more_materials
  23871. */
  23872. vAng: number;
  23873. /**
  23874. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23875. * @see https://doc.babylonjs.com/how_to/more_materials
  23876. */
  23877. wAng: number;
  23878. /**
  23879. * Defines the center of rotation (U)
  23880. */
  23881. uRotationCenter: number;
  23882. /**
  23883. * Defines the center of rotation (V)
  23884. */
  23885. vRotationCenter: number;
  23886. /**
  23887. * Defines the center of rotation (W)
  23888. */
  23889. wRotationCenter: number;
  23890. /**
  23891. * Are mip maps generated for this texture or not.
  23892. */
  23893. get noMipmap(): boolean;
  23894. /**
  23895. * List of inspectable custom properties (used by the Inspector)
  23896. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23897. */
  23898. inspectableCustomProperties: Nullable<IInspectable[]>;
  23899. private _noMipmap;
  23900. /** @hidden */
  23901. _invertY: boolean;
  23902. private _rowGenerationMatrix;
  23903. private _cachedTextureMatrix;
  23904. private _projectionModeMatrix;
  23905. private _t0;
  23906. private _t1;
  23907. private _t2;
  23908. private _cachedUOffset;
  23909. private _cachedVOffset;
  23910. private _cachedUScale;
  23911. private _cachedVScale;
  23912. private _cachedUAng;
  23913. private _cachedVAng;
  23914. private _cachedWAng;
  23915. private _cachedProjectionMatrixId;
  23916. private _cachedCoordinatesMode;
  23917. /** @hidden */
  23918. protected _initialSamplingMode: number;
  23919. /** @hidden */
  23920. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23921. private _deleteBuffer;
  23922. protected _format: Nullable<number>;
  23923. private _delayedOnLoad;
  23924. private _delayedOnError;
  23925. private _mimeType?;
  23926. /**
  23927. * Observable triggered once the texture has been loaded.
  23928. */
  23929. onLoadObservable: Observable<Texture>;
  23930. protected _isBlocking: boolean;
  23931. /**
  23932. * Is the texture preventing material to render while loading.
  23933. * If false, a default texture will be used instead of the loading one during the preparation step.
  23934. */
  23935. set isBlocking(value: boolean);
  23936. get isBlocking(): boolean;
  23937. /**
  23938. * Get the current sampling mode associated with the texture.
  23939. */
  23940. get samplingMode(): number;
  23941. /**
  23942. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23943. */
  23944. get invertY(): boolean;
  23945. /**
  23946. * Instantiates a new texture.
  23947. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23948. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23949. * @param url defines the url of the picture to load as a texture
  23950. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23951. * @param noMipmap defines if the texture will require mip maps or not
  23952. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23953. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23954. * @param onLoad defines a callback triggered when the texture has been loaded
  23955. * @param onError defines a callback triggered when an error occurred during the loading session
  23956. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23957. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23958. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23959. * @param mimeType defines an optional mime type information
  23960. */
  23961. 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);
  23962. /**
  23963. * Update the url (and optional buffer) of this texture if url was null during construction.
  23964. * @param url the url of the texture
  23965. * @param buffer the buffer of the texture (defaults to null)
  23966. * @param onLoad callback called when the texture is loaded (defaults to null)
  23967. */
  23968. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23969. /**
  23970. * Finish the loading sequence of a texture flagged as delayed load.
  23971. * @hidden
  23972. */
  23973. delayLoad(): void;
  23974. private _prepareRowForTextureGeneration;
  23975. /**
  23976. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23977. * @returns the transform matrix of the texture.
  23978. */
  23979. getTextureMatrix(uBase?: number): Matrix;
  23980. /**
  23981. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23982. * @returns The reflection texture transform
  23983. */
  23984. getReflectionTextureMatrix(): Matrix;
  23985. /**
  23986. * Clones the texture.
  23987. * @returns the cloned texture
  23988. */
  23989. clone(): Texture;
  23990. /**
  23991. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23992. * @returns The JSON representation of the texture
  23993. */
  23994. serialize(): any;
  23995. /**
  23996. * Get the current class name of the texture useful for serialization or dynamic coding.
  23997. * @returns "Texture"
  23998. */
  23999. getClassName(): string;
  24000. /**
  24001. * Dispose the texture and release its associated resources.
  24002. */
  24003. dispose(): void;
  24004. /**
  24005. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24006. * @param parsedTexture Define the JSON representation of the texture
  24007. * @param scene Define the scene the parsed texture should be instantiated in
  24008. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24009. * @returns The parsed texture if successful
  24010. */
  24011. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24012. /**
  24013. * Creates a texture from its base 64 representation.
  24014. * @param data Define the base64 payload without the data: prefix
  24015. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24016. * @param scene Define the scene the texture should belong to
  24017. * @param noMipmap Forces the texture to not create mip map information if true
  24018. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24019. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24020. * @param onLoad define a callback triggered when the texture has been loaded
  24021. * @param onError define a callback triggered when an error occurred during the loading session
  24022. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24023. * @returns the created texture
  24024. */
  24025. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24026. /**
  24027. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24028. * @param data Define the base64 payload without the data: prefix
  24029. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24030. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24031. * @param scene Define the scene the texture should belong to
  24032. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24033. * @param noMipmap Forces the texture to not create mip map information if true
  24034. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24035. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24036. * @param onLoad define a callback triggered when the texture has been loaded
  24037. * @param onError define a callback triggered when an error occurred during the loading session
  24038. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24039. * @returns the created texture
  24040. */
  24041. 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;
  24042. }
  24043. }
  24044. declare module "babylonjs/PostProcesses/postProcessManager" {
  24045. import { Nullable } from "babylonjs/types";
  24046. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24047. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24048. import { Scene } from "babylonjs/scene";
  24049. /**
  24050. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24051. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24052. */
  24053. export class PostProcessManager {
  24054. private _scene;
  24055. private _indexBuffer;
  24056. private _vertexBuffers;
  24057. /**
  24058. * Creates a new instance PostProcess
  24059. * @param scene The scene that the post process is associated with.
  24060. */
  24061. constructor(scene: Scene);
  24062. private _prepareBuffers;
  24063. private _buildIndexBuffer;
  24064. /**
  24065. * Rebuilds the vertex buffers of the manager.
  24066. * @hidden
  24067. */
  24068. _rebuild(): void;
  24069. /**
  24070. * Prepares a frame to be run through a post process.
  24071. * @param sourceTexture The input texture to the post procesess. (default: null)
  24072. * @param postProcesses An array of post processes to be run. (default: null)
  24073. * @returns True if the post processes were able to be run.
  24074. * @hidden
  24075. */
  24076. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24077. /**
  24078. * Manually render a set of post processes to a texture.
  24079. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24080. * @param postProcesses An array of post processes to be run.
  24081. * @param targetTexture The target texture to render to.
  24082. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24083. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24084. * @param lodLevel defines which lod of the texture to render to
  24085. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24086. */
  24087. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24088. /**
  24089. * Finalize the result of the output of the postprocesses.
  24090. * @param doNotPresent If true the result will not be displayed to the screen.
  24091. * @param targetTexture The target texture to render to.
  24092. * @param faceIndex The index of the face to bind the target texture to.
  24093. * @param postProcesses The array of post processes to render.
  24094. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24095. * @hidden
  24096. */
  24097. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24098. /**
  24099. * Disposes of the post process manager.
  24100. */
  24101. dispose(): void;
  24102. }
  24103. }
  24104. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24105. import { Observable } from "babylonjs/Misc/observable";
  24106. import { SmartArray } from "babylonjs/Misc/smartArray";
  24107. import { Nullable, Immutable } from "babylonjs/types";
  24108. import { Camera } from "babylonjs/Cameras/camera";
  24109. import { Scene } from "babylonjs/scene";
  24110. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24111. import { Color4 } from "babylonjs/Maths/math.color";
  24112. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24114. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24115. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24116. import { Texture } from "babylonjs/Materials/Textures/texture";
  24117. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24118. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24119. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24120. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24121. import { Engine } from "babylonjs/Engines/engine";
  24122. /**
  24123. * This Helps creating a texture that will be created from a camera in your scene.
  24124. * It is basically a dynamic texture that could be used to create special effects for instance.
  24125. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24126. */
  24127. export class RenderTargetTexture extends Texture {
  24128. isCube: boolean;
  24129. /**
  24130. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24131. */
  24132. static readonly REFRESHRATE_RENDER_ONCE: number;
  24133. /**
  24134. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24135. */
  24136. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24137. /**
  24138. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24139. * the central point of your effect and can save a lot of performances.
  24140. */
  24141. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24142. /**
  24143. * Use this predicate to dynamically define the list of mesh you want to render.
  24144. * If set, the renderList property will be overwritten.
  24145. */
  24146. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24147. private _renderList;
  24148. /**
  24149. * Use this list to define the list of mesh you want to render.
  24150. */
  24151. get renderList(): Nullable<Array<AbstractMesh>>;
  24152. set renderList(value: Nullable<Array<AbstractMesh>>);
  24153. /**
  24154. * Use this function to overload the renderList array at rendering time.
  24155. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24156. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24157. * the cube (if the RTT is a cube, else layerOrFace=0).
  24158. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24159. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24160. * hold dummy elements!
  24161. */
  24162. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24163. private _hookArray;
  24164. /**
  24165. * Define if particles should be rendered in your texture.
  24166. */
  24167. renderParticles: boolean;
  24168. /**
  24169. * Define if sprites should be rendered in your texture.
  24170. */
  24171. renderSprites: boolean;
  24172. /**
  24173. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24174. */
  24175. coordinatesMode: number;
  24176. /**
  24177. * Define the camera used to render the texture.
  24178. */
  24179. activeCamera: Nullable<Camera>;
  24180. /**
  24181. * Override the mesh isReady function with your own one.
  24182. */
  24183. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24184. /**
  24185. * Override the render function of the texture with your own one.
  24186. */
  24187. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24188. /**
  24189. * Define if camera post processes should be use while rendering the texture.
  24190. */
  24191. useCameraPostProcesses: boolean;
  24192. /**
  24193. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24194. */
  24195. ignoreCameraViewport: boolean;
  24196. private _postProcessManager;
  24197. private _postProcesses;
  24198. private _resizeObserver;
  24199. /**
  24200. * An event triggered when the texture is unbind.
  24201. */
  24202. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24203. /**
  24204. * An event triggered when the texture is unbind.
  24205. */
  24206. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24207. private _onAfterUnbindObserver;
  24208. /**
  24209. * Set a after unbind callback in the texture.
  24210. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24211. */
  24212. set onAfterUnbind(callback: () => void);
  24213. /**
  24214. * An event triggered before rendering the texture
  24215. */
  24216. onBeforeRenderObservable: Observable<number>;
  24217. private _onBeforeRenderObserver;
  24218. /**
  24219. * Set a before render callback in the texture.
  24220. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24221. */
  24222. set onBeforeRender(callback: (faceIndex: number) => void);
  24223. /**
  24224. * An event triggered after rendering the texture
  24225. */
  24226. onAfterRenderObservable: Observable<number>;
  24227. private _onAfterRenderObserver;
  24228. /**
  24229. * Set a after render callback in the texture.
  24230. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24231. */
  24232. set onAfterRender(callback: (faceIndex: number) => void);
  24233. /**
  24234. * An event triggered after the texture clear
  24235. */
  24236. onClearObservable: Observable<Engine>;
  24237. private _onClearObserver;
  24238. /**
  24239. * Set a clear callback in the texture.
  24240. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24241. */
  24242. set onClear(callback: (Engine: Engine) => void);
  24243. /**
  24244. * An event triggered when the texture is resized.
  24245. */
  24246. onResizeObservable: Observable<RenderTargetTexture>;
  24247. /**
  24248. * Define the clear color of the Render Target if it should be different from the scene.
  24249. */
  24250. clearColor: Color4;
  24251. protected _size: number | {
  24252. width: number;
  24253. height: number;
  24254. layers?: number;
  24255. };
  24256. protected _initialSizeParameter: number | {
  24257. width: number;
  24258. height: number;
  24259. } | {
  24260. ratio: number;
  24261. };
  24262. protected _sizeRatio: Nullable<number>;
  24263. /** @hidden */
  24264. _generateMipMaps: boolean;
  24265. protected _renderingManager: RenderingManager;
  24266. /** @hidden */
  24267. _waitingRenderList: string[];
  24268. protected _doNotChangeAspectRatio: boolean;
  24269. protected _currentRefreshId: number;
  24270. protected _refreshRate: number;
  24271. protected _textureMatrix: Matrix;
  24272. protected _samples: number;
  24273. protected _renderTargetOptions: RenderTargetCreationOptions;
  24274. /**
  24275. * Gets render target creation options that were used.
  24276. */
  24277. get renderTargetOptions(): RenderTargetCreationOptions;
  24278. protected _onRatioRescale(): void;
  24279. /**
  24280. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24281. * It must define where the camera used to render the texture is set
  24282. */
  24283. boundingBoxPosition: Vector3;
  24284. private _boundingBoxSize;
  24285. /**
  24286. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24287. * When defined, the cubemap will switch to local mode
  24288. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24289. * @example https://www.babylonjs-playground.com/#RNASML
  24290. */
  24291. set boundingBoxSize(value: Vector3);
  24292. get boundingBoxSize(): Vector3;
  24293. /**
  24294. * In case the RTT has been created with a depth texture, get the associated
  24295. * depth texture.
  24296. * Otherwise, return null.
  24297. */
  24298. get depthStencilTexture(): Nullable<InternalTexture>;
  24299. /**
  24300. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24301. * or used a shadow, depth texture...
  24302. * @param name The friendly name of the texture
  24303. * @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)
  24304. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24305. * @param generateMipMaps True if mip maps need to be generated after render.
  24306. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24307. * @param type The type of the buffer in the RTT (int, half float, float...)
  24308. * @param isCube True if a cube texture needs to be created
  24309. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24310. * @param generateDepthBuffer True to generate a depth buffer
  24311. * @param generateStencilBuffer True to generate a stencil buffer
  24312. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24313. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24314. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24315. */
  24316. constructor(name: string, size: number | {
  24317. width: number;
  24318. height: number;
  24319. layers?: number;
  24320. } | {
  24321. ratio: number;
  24322. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24323. /**
  24324. * Creates a depth stencil texture.
  24325. * This is only available in WebGL 2 or with the depth texture extension available.
  24326. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24327. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24328. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24329. */
  24330. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24331. private _processSizeParameter;
  24332. /**
  24333. * Define the number of samples to use in case of MSAA.
  24334. * It defaults to one meaning no MSAA has been enabled.
  24335. */
  24336. get samples(): number;
  24337. set samples(value: number);
  24338. /**
  24339. * Resets the refresh counter of the texture and start bak from scratch.
  24340. * Could be useful to regenerate the texture if it is setup to render only once.
  24341. */
  24342. resetRefreshCounter(): void;
  24343. /**
  24344. * Define the refresh rate of the texture or the rendering frequency.
  24345. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24346. */
  24347. get refreshRate(): number;
  24348. set refreshRate(value: number);
  24349. /**
  24350. * Adds a post process to the render target rendering passes.
  24351. * @param postProcess define the post process to add
  24352. */
  24353. addPostProcess(postProcess: PostProcess): void;
  24354. /**
  24355. * Clear all the post processes attached to the render target
  24356. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24357. */
  24358. clearPostProcesses(dispose?: boolean): void;
  24359. /**
  24360. * Remove one of the post process from the list of attached post processes to the texture
  24361. * @param postProcess define the post process to remove from the list
  24362. */
  24363. removePostProcess(postProcess: PostProcess): void;
  24364. /** @hidden */
  24365. _shouldRender(): boolean;
  24366. /**
  24367. * Gets the actual render size of the texture.
  24368. * @returns the width of the render size
  24369. */
  24370. getRenderSize(): number;
  24371. /**
  24372. * Gets the actual render width of the texture.
  24373. * @returns the width of the render size
  24374. */
  24375. getRenderWidth(): number;
  24376. /**
  24377. * Gets the actual render height of the texture.
  24378. * @returns the height of the render size
  24379. */
  24380. getRenderHeight(): number;
  24381. /**
  24382. * Gets the actual number of layers of the texture.
  24383. * @returns the number of layers
  24384. */
  24385. getRenderLayers(): number;
  24386. /**
  24387. * Get if the texture can be rescaled or not.
  24388. */
  24389. get canRescale(): boolean;
  24390. /**
  24391. * Resize the texture using a ratio.
  24392. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24393. */
  24394. scale(ratio: number): void;
  24395. /**
  24396. * Get the texture reflection matrix used to rotate/transform the reflection.
  24397. * @returns the reflection matrix
  24398. */
  24399. getReflectionTextureMatrix(): Matrix;
  24400. /**
  24401. * Resize the texture to a new desired size.
  24402. * Be carrefull as it will recreate all the data in the new texture.
  24403. * @param size Define the new size. It can be:
  24404. * - a number for squared texture,
  24405. * - an object containing { width: number, height: number }
  24406. * - or an object containing a ratio { ratio: number }
  24407. */
  24408. resize(size: number | {
  24409. width: number;
  24410. height: number;
  24411. } | {
  24412. ratio: number;
  24413. }): void;
  24414. private _defaultRenderListPrepared;
  24415. /**
  24416. * Renders all the objects from the render list into the texture.
  24417. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24418. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24419. */
  24420. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24421. private _bestReflectionRenderTargetDimension;
  24422. private _prepareRenderingManager;
  24423. /**
  24424. * @hidden
  24425. * @param faceIndex face index to bind to if this is a cubetexture
  24426. * @param layer defines the index of the texture to bind in the array
  24427. */
  24428. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24429. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24430. private renderToTarget;
  24431. /**
  24432. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24433. * This allowed control for front to back rendering or reversly depending of the special needs.
  24434. *
  24435. * @param renderingGroupId The rendering group id corresponding to its index
  24436. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24437. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24438. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24439. */
  24440. 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;
  24441. /**
  24442. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24443. *
  24444. * @param renderingGroupId The rendering group id corresponding to its index
  24445. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24446. */
  24447. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24448. /**
  24449. * Clones the texture.
  24450. * @returns the cloned texture
  24451. */
  24452. clone(): RenderTargetTexture;
  24453. /**
  24454. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24455. * @returns The JSON representation of the texture
  24456. */
  24457. serialize(): any;
  24458. /**
  24459. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24460. */
  24461. disposeFramebufferObjects(): void;
  24462. /**
  24463. * Dispose the texture and release its associated resources.
  24464. */
  24465. dispose(): void;
  24466. /** @hidden */
  24467. _rebuild(): void;
  24468. /**
  24469. * Clear the info related to rendering groups preventing retention point in material dispose.
  24470. */
  24471. freeRenderingGroups(): void;
  24472. /**
  24473. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24474. * @returns the view count
  24475. */
  24476. getViewCount(): number;
  24477. }
  24478. }
  24479. declare module "babylonjs/Misc/guid" {
  24480. /**
  24481. * Class used to manipulate GUIDs
  24482. */
  24483. export class GUID {
  24484. /**
  24485. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24486. * Be aware Math.random() could cause collisions, but:
  24487. * "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"
  24488. * @returns a pseudo random id
  24489. */
  24490. static RandomId(): string;
  24491. }
  24492. }
  24493. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24494. import { Nullable } from "babylonjs/types";
  24495. import { Scene } from "babylonjs/scene";
  24496. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24497. import { Material } from "babylonjs/Materials/material";
  24498. import { Effect } from "babylonjs/Materials/effect";
  24499. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24500. /**
  24501. * Options to be used when creating a shadow depth material
  24502. */
  24503. export interface IIOptionShadowDepthMaterial {
  24504. /** Variables in the vertex shader code that need to have their names remapped.
  24505. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24506. * "var_name" should be either: worldPos or vNormalW
  24507. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24508. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24509. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24510. */
  24511. remappedVariables?: string[];
  24512. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24513. standalone?: boolean;
  24514. }
  24515. /**
  24516. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24517. */
  24518. export class ShadowDepthWrapper {
  24519. private _scene;
  24520. private _options?;
  24521. private _baseMaterial;
  24522. private _onEffectCreatedObserver;
  24523. private _subMeshToEffect;
  24524. private _subMeshToDepthEffect;
  24525. private _meshes;
  24526. /** @hidden */
  24527. _matriceNames: any;
  24528. /** Gets the standalone status of the wrapper */
  24529. get standalone(): boolean;
  24530. /** Gets the base material the wrapper is built upon */
  24531. get baseMaterial(): Material;
  24532. /**
  24533. * Instantiate a new shadow depth wrapper.
  24534. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24535. * generate the shadow depth map. For more information, please refer to the documentation:
  24536. * https://doc.babylonjs.com/babylon101/shadows
  24537. * @param baseMaterial Material to wrap
  24538. * @param scene Define the scene the material belongs to
  24539. * @param options Options used to create the wrapper
  24540. */
  24541. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24542. /**
  24543. * Gets the effect to use to generate the depth map
  24544. * @param subMesh subMesh to get the effect for
  24545. * @param shadowGenerator shadow generator to get the effect for
  24546. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24547. */
  24548. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24549. /**
  24550. * Specifies that the submesh is ready to be used for depth rendering
  24551. * @param subMesh submesh to check
  24552. * @param defines the list of defines to take into account when checking the effect
  24553. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24554. * @param useInstances specifies that instances should be used
  24555. * @returns a boolean indicating that the submesh is ready or not
  24556. */
  24557. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24558. /**
  24559. * Disposes the resources
  24560. */
  24561. dispose(): void;
  24562. private _makeEffect;
  24563. }
  24564. }
  24565. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24566. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24567. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24568. import { Nullable } from "babylonjs/types";
  24569. module "babylonjs/Engines/thinEngine" {
  24570. interface ThinEngine {
  24571. /**
  24572. * Unbind a list of render target textures from the webGL context
  24573. * This is used only when drawBuffer extension or webGL2 are active
  24574. * @param textures defines the render target textures to unbind
  24575. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24576. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24577. */
  24578. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24579. /**
  24580. * Create a multi render target texture
  24581. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24582. * @param size defines the size of the texture
  24583. * @param options defines the creation options
  24584. * @returns the cube texture as an InternalTexture
  24585. */
  24586. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24587. /**
  24588. * Update the sample count for a given multiple render target texture
  24589. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24590. * @param textures defines the textures to update
  24591. * @param samples defines the sample count to set
  24592. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24593. */
  24594. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24595. /**
  24596. * Select a subsets of attachments to draw to.
  24597. * @param attachments gl attachments
  24598. */
  24599. bindAttachments(attachments: number[]): void;
  24600. }
  24601. }
  24602. }
  24603. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24604. import { Scene } from "babylonjs/scene";
  24605. import { Engine } from "babylonjs/Engines/engine";
  24606. import { Texture } from "babylonjs/Materials/Textures/texture";
  24607. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24608. import "babylonjs/Engines/Extensions/engine.multiRender";
  24609. /**
  24610. * Creation options of the multi render target texture.
  24611. */
  24612. export interface IMultiRenderTargetOptions {
  24613. /**
  24614. * Define if the texture needs to create mip maps after render.
  24615. */
  24616. generateMipMaps?: boolean;
  24617. /**
  24618. * Define the types of all the draw buffers we want to create
  24619. */
  24620. types?: number[];
  24621. /**
  24622. * Define the sampling modes of all the draw buffers we want to create
  24623. */
  24624. samplingModes?: number[];
  24625. /**
  24626. * Define if a depth buffer is required
  24627. */
  24628. generateDepthBuffer?: boolean;
  24629. /**
  24630. * Define if a stencil buffer is required
  24631. */
  24632. generateStencilBuffer?: boolean;
  24633. /**
  24634. * Define if a depth texture is required instead of a depth buffer
  24635. */
  24636. generateDepthTexture?: boolean;
  24637. /**
  24638. * Define the number of desired draw buffers
  24639. */
  24640. textureCount?: number;
  24641. /**
  24642. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24643. */
  24644. doNotChangeAspectRatio?: boolean;
  24645. /**
  24646. * Define the default type of the buffers we are creating
  24647. */
  24648. defaultType?: number;
  24649. }
  24650. /**
  24651. * A multi render target, like a render target provides the ability to render to a texture.
  24652. * Unlike the render target, it can render to several draw buffers in one draw.
  24653. * This is specially interesting in deferred rendering or for any effects requiring more than
  24654. * just one color from a single pass.
  24655. */
  24656. export class MultiRenderTarget extends RenderTargetTexture {
  24657. private _internalTextures;
  24658. private _textures;
  24659. private _multiRenderTargetOptions;
  24660. private _count;
  24661. /**
  24662. * Get if draw buffers are currently supported by the used hardware and browser.
  24663. */
  24664. get isSupported(): boolean;
  24665. /**
  24666. * Get the list of textures generated by the multi render target.
  24667. */
  24668. get textures(): Texture[];
  24669. /**
  24670. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24671. */
  24672. get count(): number;
  24673. /**
  24674. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24675. */
  24676. get depthTexture(): Texture;
  24677. /**
  24678. * Set the wrapping mode on U of all the textures we are rendering to.
  24679. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24680. */
  24681. set wrapU(wrap: number);
  24682. /**
  24683. * Set the wrapping mode on V of all the textures we are rendering to.
  24684. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24685. */
  24686. set wrapV(wrap: number);
  24687. /**
  24688. * Instantiate a new multi render target texture.
  24689. * A multi render target, like a render target provides the ability to render to a texture.
  24690. * Unlike the render target, it can render to several draw buffers in one draw.
  24691. * This is specially interesting in deferred rendering or for any effects requiring more than
  24692. * just one color from a single pass.
  24693. * @param name Define the name of the texture
  24694. * @param size Define the size of the buffers to render to
  24695. * @param count Define the number of target we are rendering into
  24696. * @param scene Define the scene the texture belongs to
  24697. * @param options Define the options used to create the multi render target
  24698. */
  24699. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24700. /** @hidden */
  24701. _rebuild(): void;
  24702. private _createInternalTextures;
  24703. private _createTextures;
  24704. /**
  24705. * Define the number of samples used if MSAA is enabled.
  24706. */
  24707. get samples(): number;
  24708. set samples(value: number);
  24709. /**
  24710. * Resize all the textures in the multi render target.
  24711. * Be carrefull as it will recreate all the data in the new texture.
  24712. * @param size Define the new size
  24713. */
  24714. resize(size: any): void;
  24715. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24716. /**
  24717. * Dispose the render targets and their associated resources
  24718. */
  24719. dispose(): void;
  24720. /**
  24721. * Release all the underlying texture used as draw buffers.
  24722. */
  24723. releaseInternalTextures(): void;
  24724. }
  24725. }
  24726. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  24727. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24728. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24729. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24730. /** @hidden */
  24731. export var imageProcessingPixelShader: {
  24732. name: string;
  24733. shader: string;
  24734. };
  24735. }
  24736. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  24737. import { Nullable } from "babylonjs/types";
  24738. import { Color4 } from "babylonjs/Maths/math.color";
  24739. import { Camera } from "babylonjs/Cameras/camera";
  24740. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24741. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24742. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  24743. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24744. import { Engine } from "babylonjs/Engines/engine";
  24745. import "babylonjs/Shaders/imageProcessing.fragment";
  24746. import "babylonjs/Shaders/postprocess.vertex";
  24747. /**
  24748. * ImageProcessingPostProcess
  24749. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24750. */
  24751. export class ImageProcessingPostProcess extends PostProcess {
  24752. /**
  24753. * Default configuration related to image processing available in the PBR Material.
  24754. */
  24755. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24756. /**
  24757. * Gets the image processing configuration used either in this material.
  24758. */
  24759. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24760. /**
  24761. * Sets the Default image processing configuration used either in the this material.
  24762. *
  24763. * If sets to null, the scene one is in use.
  24764. */
  24765. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24766. /**
  24767. * Keep track of the image processing observer to allow dispose and replace.
  24768. */
  24769. private _imageProcessingObserver;
  24770. /**
  24771. * Attaches a new image processing configuration to the PBR Material.
  24772. * @param configuration
  24773. */
  24774. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24775. /**
  24776. * If the post process is supported.
  24777. */
  24778. get isSupported(): boolean;
  24779. /**
  24780. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24781. */
  24782. get colorCurves(): Nullable<ColorCurves>;
  24783. /**
  24784. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24785. */
  24786. set colorCurves(value: Nullable<ColorCurves>);
  24787. /**
  24788. * Gets wether the color curves effect is enabled.
  24789. */
  24790. get colorCurvesEnabled(): boolean;
  24791. /**
  24792. * Sets wether the color curves effect is enabled.
  24793. */
  24794. set colorCurvesEnabled(value: boolean);
  24795. /**
  24796. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24797. */
  24798. get colorGradingTexture(): Nullable<BaseTexture>;
  24799. /**
  24800. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24801. */
  24802. set colorGradingTexture(value: Nullable<BaseTexture>);
  24803. /**
  24804. * Gets wether the color grading effect is enabled.
  24805. */
  24806. get colorGradingEnabled(): boolean;
  24807. /**
  24808. * Gets wether the color grading effect is enabled.
  24809. */
  24810. set colorGradingEnabled(value: boolean);
  24811. /**
  24812. * Gets exposure used in the effect.
  24813. */
  24814. get exposure(): number;
  24815. /**
  24816. * Sets exposure used in the effect.
  24817. */
  24818. set exposure(value: number);
  24819. /**
  24820. * Gets wether tonemapping is enabled or not.
  24821. */
  24822. get toneMappingEnabled(): boolean;
  24823. /**
  24824. * Sets wether tonemapping is enabled or not
  24825. */
  24826. set toneMappingEnabled(value: boolean);
  24827. /**
  24828. * Gets the type of tone mapping effect.
  24829. */
  24830. get toneMappingType(): number;
  24831. /**
  24832. * Sets the type of tone mapping effect.
  24833. */
  24834. set toneMappingType(value: number);
  24835. /**
  24836. * Gets contrast used in the effect.
  24837. */
  24838. get contrast(): number;
  24839. /**
  24840. * Sets contrast used in the effect.
  24841. */
  24842. set contrast(value: number);
  24843. /**
  24844. * Gets Vignette stretch size.
  24845. */
  24846. get vignetteStretch(): number;
  24847. /**
  24848. * Sets Vignette stretch size.
  24849. */
  24850. set vignetteStretch(value: number);
  24851. /**
  24852. * Gets Vignette centre X Offset.
  24853. */
  24854. get vignetteCentreX(): number;
  24855. /**
  24856. * Sets Vignette centre X Offset.
  24857. */
  24858. set vignetteCentreX(value: number);
  24859. /**
  24860. * Gets Vignette centre Y Offset.
  24861. */
  24862. get vignetteCentreY(): number;
  24863. /**
  24864. * Sets Vignette centre Y Offset.
  24865. */
  24866. set vignetteCentreY(value: number);
  24867. /**
  24868. * Gets Vignette weight or intensity of the vignette effect.
  24869. */
  24870. get vignetteWeight(): number;
  24871. /**
  24872. * Sets Vignette weight or intensity of the vignette effect.
  24873. */
  24874. set vignetteWeight(value: number);
  24875. /**
  24876. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24877. * if vignetteEnabled is set to true.
  24878. */
  24879. get vignetteColor(): Color4;
  24880. /**
  24881. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24882. * if vignetteEnabled is set to true.
  24883. */
  24884. set vignetteColor(value: Color4);
  24885. /**
  24886. * Gets Camera field of view used by the Vignette effect.
  24887. */
  24888. get vignetteCameraFov(): number;
  24889. /**
  24890. * Sets Camera field of view used by the Vignette effect.
  24891. */
  24892. set vignetteCameraFov(value: number);
  24893. /**
  24894. * Gets the vignette blend mode allowing different kind of effect.
  24895. */
  24896. get vignetteBlendMode(): number;
  24897. /**
  24898. * Sets the vignette blend mode allowing different kind of effect.
  24899. */
  24900. set vignetteBlendMode(value: number);
  24901. /**
  24902. * Gets wether the vignette effect is enabled.
  24903. */
  24904. get vignetteEnabled(): boolean;
  24905. /**
  24906. * Sets wether the vignette effect is enabled.
  24907. */
  24908. set vignetteEnabled(value: boolean);
  24909. private _fromLinearSpace;
  24910. /**
  24911. * Gets wether the input of the processing is in Gamma or Linear Space.
  24912. */
  24913. get fromLinearSpace(): boolean;
  24914. /**
  24915. * Sets wether the input of the processing is in Gamma or Linear Space.
  24916. */
  24917. set fromLinearSpace(value: boolean);
  24918. /**
  24919. * Defines cache preventing GC.
  24920. */
  24921. private _defines;
  24922. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24923. /**
  24924. * "ImageProcessingPostProcess"
  24925. * @returns "ImageProcessingPostProcess"
  24926. */
  24927. getClassName(): string;
  24928. /**
  24929. * @hidden
  24930. */
  24931. _updateParameters(): void;
  24932. dispose(camera?: Camera): void;
  24933. }
  24934. }
  24935. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  24936. /** @hidden */
  24937. export var fibonacci: {
  24938. name: string;
  24939. shader: string;
  24940. };
  24941. }
  24942. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  24943. /** @hidden */
  24944. export var subSurfaceScatteringFunctions: {
  24945. name: string;
  24946. shader: string;
  24947. };
  24948. }
  24949. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  24950. /** @hidden */
  24951. export var diffusionProfile: {
  24952. name: string;
  24953. shader: string;
  24954. };
  24955. }
  24956. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  24957. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  24958. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24959. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  24960. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  24961. /** @hidden */
  24962. export var subSurfaceScatteringPixelShader: {
  24963. name: string;
  24964. shader: string;
  24965. };
  24966. }
  24967. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  24968. import { Nullable } from "babylonjs/types";
  24969. import { Camera } from "babylonjs/Cameras/camera";
  24970. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24971. import { Engine } from "babylonjs/Engines/engine";
  24972. import { Scene } from "babylonjs/scene";
  24973. import "babylonjs/Shaders/imageProcessing.fragment";
  24974. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  24975. import "babylonjs/Shaders/postprocess.vertex";
  24976. /**
  24977. * Sub surface scattering post process
  24978. */
  24979. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24980. /** @hidden */
  24981. texelWidth: number;
  24982. /** @hidden */
  24983. texelHeight: number;
  24984. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24985. }
  24986. }
  24987. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24988. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24989. /**
  24990. * Interface for defining prepass effects in the prepass post-process pipeline
  24991. */
  24992. export interface PrePassEffectConfiguration {
  24993. /**
  24994. * Post process to attach for this effect
  24995. */
  24996. postProcess: PostProcess;
  24997. /**
  24998. * Is the effect enabled
  24999. */
  25000. enabled: boolean;
  25001. /**
  25002. * Disposes the effect configuration
  25003. */
  25004. dispose(): void;
  25005. /**
  25006. * Disposes the effect configuration
  25007. */
  25008. createPostProcess: () => PostProcess;
  25009. }
  25010. }
  25011. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  25012. import { Scene } from "babylonjs/scene";
  25013. import { Color3 } from "babylonjs/Maths/math.color";
  25014. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  25015. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25016. /**
  25017. * Contains all parameters needed for the prepass to perform
  25018. * screen space subsurface scattering
  25019. */
  25020. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  25021. private _ssDiffusionS;
  25022. private _ssFilterRadii;
  25023. private _ssDiffusionD;
  25024. /**
  25025. * Post process to attach for screen space subsurface scattering
  25026. */
  25027. postProcess: SubSurfaceScatteringPostProcess;
  25028. /**
  25029. * Diffusion profile color for subsurface scattering
  25030. */
  25031. get ssDiffusionS(): number[];
  25032. /**
  25033. * Diffusion profile max color channel value for subsurface scattering
  25034. */
  25035. get ssDiffusionD(): number[];
  25036. /**
  25037. * Diffusion profile filter radius for subsurface scattering
  25038. */
  25039. get ssFilterRadii(): number[];
  25040. /**
  25041. * Is subsurface enabled
  25042. */
  25043. enabled: boolean;
  25044. /**
  25045. * Diffusion profile colors for subsurface scattering
  25046. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  25047. * See ...
  25048. * Note that you can only store up to 5 of them
  25049. */
  25050. ssDiffusionProfileColors: Color3[];
  25051. /**
  25052. * Defines the ratio real world => scene units.
  25053. * Used for subsurface scattering
  25054. */
  25055. metersPerUnit: number;
  25056. private _scene;
  25057. /**
  25058. * Builds a subsurface configuration object
  25059. * @param scene The scene
  25060. */
  25061. constructor(scene: Scene);
  25062. /**
  25063. * Adds a new diffusion profile.
  25064. * Useful for more realistic subsurface scattering on diverse materials.
  25065. * @param color The color of the diffusion profile. Should be the average color of the material.
  25066. * @return The index of the diffusion profile for the material subsurface configuration
  25067. */
  25068. addDiffusionProfile(color: Color3): number;
  25069. /**
  25070. * Creates the sss post process
  25071. * @return The created post process
  25072. */
  25073. createPostProcess(): SubSurfaceScatteringPostProcess;
  25074. /**
  25075. * Deletes all diffusion profiles.
  25076. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  25077. */
  25078. clearAllDiffusionProfiles(): void;
  25079. /**
  25080. * Disposes this object
  25081. */
  25082. dispose(): void;
  25083. /**
  25084. * @hidden
  25085. * https://zero-radiance.github.io/post/sampling-diffusion/
  25086. *
  25087. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  25088. * ------------------------------------------------------------------------------------
  25089. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  25090. * PDF[r, phi, s] = r * R[r, phi, s]
  25091. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  25092. * ------------------------------------------------------------------------------------
  25093. * We importance sample the color channel with the widest scattering distance.
  25094. */
  25095. getDiffusionProfileParameters(color: Color3): number;
  25096. /**
  25097. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  25098. * 'u' is the random number (the value of the CDF): [0, 1).
  25099. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  25100. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  25101. */
  25102. private _sampleBurleyDiffusionProfile;
  25103. }
  25104. }
  25105. declare module "babylonjs/Rendering/prePassRenderer" {
  25106. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25107. import { Scene } from "babylonjs/scene";
  25108. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25109. import { Effect } from "babylonjs/Materials/effect";
  25110. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  25111. /**
  25112. * Renders a pre pass of the scene
  25113. * This means every mesh in the scene will be rendered to a render target texture
  25114. * And then this texture will be composited to the rendering canvas with post processes
  25115. * It is necessary for effects like subsurface scattering or deferred shading
  25116. */
  25117. export class PrePassRenderer {
  25118. /** @hidden */
  25119. static _SceneComponentInitialization: (scene: Scene) => void;
  25120. private _scene;
  25121. private _engine;
  25122. private _isDirty;
  25123. /**
  25124. * Number of textures in the multi render target texture where the scene is directly rendered
  25125. */
  25126. readonly mrtCount: number;
  25127. /**
  25128. * The render target where the scene is directly rendered
  25129. */
  25130. prePassRT: MultiRenderTarget;
  25131. private _mrtTypes;
  25132. private _multiRenderAttachments;
  25133. private _defaultAttachments;
  25134. private _clearAttachments;
  25135. private _postProcesses;
  25136. private readonly _clearColor;
  25137. /**
  25138. * Image processing post process for composition
  25139. */
  25140. imageProcessingPostProcess: ImageProcessingPostProcess;
  25141. /**
  25142. * Configuration for sub surface scattering post process
  25143. */
  25144. subSurfaceConfiguration: SubSurfaceConfiguration;
  25145. /**
  25146. * Should materials render their geometry on the MRT
  25147. */
  25148. materialsShouldRenderGeometry: boolean;
  25149. /**
  25150. * Should materials render the irradiance information on the MRT
  25151. */
  25152. materialsShouldRenderIrradiance: boolean;
  25153. private _enabled;
  25154. /**
  25155. * Indicates if the prepass is enabled
  25156. */
  25157. get enabled(): boolean;
  25158. /**
  25159. * How many samples are used for MSAA of the scene render target
  25160. */
  25161. get samples(): number;
  25162. set samples(n: number);
  25163. /**
  25164. * Instanciates a prepass renderer
  25165. * @param scene The scene
  25166. */
  25167. constructor(scene: Scene);
  25168. private _initializeAttachments;
  25169. private _createCompositionEffect;
  25170. /**
  25171. * Indicates if rendering a prepass is supported
  25172. */
  25173. get isSupported(): boolean;
  25174. /**
  25175. * Sets the proper output textures to draw in the engine.
  25176. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25177. */
  25178. bindAttachmentsForEffect(effect: Effect): void;
  25179. /**
  25180. * @hidden
  25181. */
  25182. _beforeCameraDraw(): void;
  25183. /**
  25184. * @hidden
  25185. */
  25186. _afterCameraDraw(): void;
  25187. private _checkRTSize;
  25188. private _bindFrameBuffer;
  25189. /**
  25190. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25191. */
  25192. clear(): void;
  25193. private _setState;
  25194. private _enable;
  25195. private _disable;
  25196. private _resetPostProcessChain;
  25197. private _bindPostProcessChain;
  25198. /**
  25199. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25200. */
  25201. markAsDirty(): void;
  25202. private _update;
  25203. /**
  25204. * Disposes the prepass renderer.
  25205. */
  25206. dispose(): void;
  25207. }
  25208. }
  25209. declare module "babylonjs/Materials/material" {
  25210. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25211. import { SmartArray } from "babylonjs/Misc/smartArray";
  25212. import { Observable } from "babylonjs/Misc/observable";
  25213. import { Nullable } from "babylonjs/types";
  25214. import { Scene } from "babylonjs/scene";
  25215. import { Matrix } from "babylonjs/Maths/math.vector";
  25216. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25218. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25219. import { Effect } from "babylonjs/Materials/effect";
  25220. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25221. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25222. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25223. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25224. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25225. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25226. import { Mesh } from "babylonjs/Meshes/mesh";
  25227. import { Animation } from "babylonjs/Animations/animation";
  25228. /**
  25229. * Options for compiling materials.
  25230. */
  25231. export interface IMaterialCompilationOptions {
  25232. /**
  25233. * Defines whether clip planes are enabled.
  25234. */
  25235. clipPlane: boolean;
  25236. /**
  25237. * Defines whether instances are enabled.
  25238. */
  25239. useInstances: boolean;
  25240. }
  25241. /**
  25242. * Options passed when calling customShaderNameResolve
  25243. */
  25244. export interface ICustomShaderNameResolveOptions {
  25245. /**
  25246. * 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
  25247. */
  25248. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25249. }
  25250. /**
  25251. * Base class for the main features of a material in Babylon.js
  25252. */
  25253. export class Material implements IAnimatable {
  25254. /**
  25255. * Returns the triangle fill mode
  25256. */
  25257. static readonly TriangleFillMode: number;
  25258. /**
  25259. * Returns the wireframe mode
  25260. */
  25261. static readonly WireFrameFillMode: number;
  25262. /**
  25263. * Returns the point fill mode
  25264. */
  25265. static readonly PointFillMode: number;
  25266. /**
  25267. * Returns the point list draw mode
  25268. */
  25269. static readonly PointListDrawMode: number;
  25270. /**
  25271. * Returns the line list draw mode
  25272. */
  25273. static readonly LineListDrawMode: number;
  25274. /**
  25275. * Returns the line loop draw mode
  25276. */
  25277. static readonly LineLoopDrawMode: number;
  25278. /**
  25279. * Returns the line strip draw mode
  25280. */
  25281. static readonly LineStripDrawMode: number;
  25282. /**
  25283. * Returns the triangle strip draw mode
  25284. */
  25285. static readonly TriangleStripDrawMode: number;
  25286. /**
  25287. * Returns the triangle fan draw mode
  25288. */
  25289. static readonly TriangleFanDrawMode: number;
  25290. /**
  25291. * Stores the clock-wise side orientation
  25292. */
  25293. static readonly ClockWiseSideOrientation: number;
  25294. /**
  25295. * Stores the counter clock-wise side orientation
  25296. */
  25297. static readonly CounterClockWiseSideOrientation: number;
  25298. /**
  25299. * The dirty texture flag value
  25300. */
  25301. static readonly TextureDirtyFlag: number;
  25302. /**
  25303. * The dirty light flag value
  25304. */
  25305. static readonly LightDirtyFlag: number;
  25306. /**
  25307. * The dirty fresnel flag value
  25308. */
  25309. static readonly FresnelDirtyFlag: number;
  25310. /**
  25311. * The dirty attribute flag value
  25312. */
  25313. static readonly AttributesDirtyFlag: number;
  25314. /**
  25315. * The dirty misc flag value
  25316. */
  25317. static readonly MiscDirtyFlag: number;
  25318. /**
  25319. * The all dirty flag value
  25320. */
  25321. static readonly AllDirtyFlag: number;
  25322. /**
  25323. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25324. */
  25325. static readonly MATERIAL_OPAQUE: number;
  25326. /**
  25327. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25328. */
  25329. static readonly MATERIAL_ALPHATEST: number;
  25330. /**
  25331. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25332. */
  25333. static readonly MATERIAL_ALPHABLEND: number;
  25334. /**
  25335. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25336. * They are also discarded below the alpha cutoff threshold to improve performances.
  25337. */
  25338. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25339. /**
  25340. * The Whiteout method is used to blend normals.
  25341. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25342. */
  25343. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25344. /**
  25345. * The Reoriented Normal Mapping method is used to blend normals.
  25346. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25347. */
  25348. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25349. /**
  25350. * Custom callback helping to override the default shader used in the material.
  25351. */
  25352. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25353. /**
  25354. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25355. */
  25356. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25357. /**
  25358. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25359. * This means that the material can keep using a previous shader while a new one is being compiled.
  25360. * This is mostly used when shader parallel compilation is supported (true by default)
  25361. */
  25362. allowShaderHotSwapping: boolean;
  25363. /**
  25364. * The ID of the material
  25365. */
  25366. id: string;
  25367. /**
  25368. * Gets or sets the unique id of the material
  25369. */
  25370. uniqueId: number;
  25371. /**
  25372. * The name of the material
  25373. */
  25374. name: string;
  25375. /**
  25376. * Gets or sets user defined metadata
  25377. */
  25378. metadata: any;
  25379. /**
  25380. * For internal use only. Please do not use.
  25381. */
  25382. reservedDataStore: any;
  25383. /**
  25384. * Specifies if the ready state should be checked on each call
  25385. */
  25386. checkReadyOnEveryCall: boolean;
  25387. /**
  25388. * Specifies if the ready state should be checked once
  25389. */
  25390. checkReadyOnlyOnce: boolean;
  25391. /**
  25392. * The state of the material
  25393. */
  25394. state: string;
  25395. /**
  25396. * If the material can be rendered to several textures with MRT extension
  25397. */
  25398. get canRenderToMRT(): boolean;
  25399. /**
  25400. * The alpha value of the material
  25401. */
  25402. protected _alpha: number;
  25403. /**
  25404. * List of inspectable custom properties (used by the Inspector)
  25405. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25406. */
  25407. inspectableCustomProperties: IInspectable[];
  25408. /**
  25409. * Sets the alpha value of the material
  25410. */
  25411. set alpha(value: number);
  25412. /**
  25413. * Gets the alpha value of the material
  25414. */
  25415. get alpha(): number;
  25416. /**
  25417. * Specifies if back face culling is enabled
  25418. */
  25419. protected _backFaceCulling: boolean;
  25420. /**
  25421. * Sets the back-face culling state
  25422. */
  25423. set backFaceCulling(value: boolean);
  25424. /**
  25425. * Gets the back-face culling state
  25426. */
  25427. get backFaceCulling(): boolean;
  25428. /**
  25429. * Stores the value for side orientation
  25430. */
  25431. sideOrientation: number;
  25432. /**
  25433. * Callback triggered when the material is compiled
  25434. */
  25435. onCompiled: Nullable<(effect: Effect) => void>;
  25436. /**
  25437. * Callback triggered when an error occurs
  25438. */
  25439. onError: Nullable<(effect: Effect, errors: string) => void>;
  25440. /**
  25441. * Callback triggered to get the render target textures
  25442. */
  25443. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25444. /**
  25445. * Gets a boolean indicating that current material needs to register RTT
  25446. */
  25447. get hasRenderTargetTextures(): boolean;
  25448. /**
  25449. * Specifies if the material should be serialized
  25450. */
  25451. doNotSerialize: boolean;
  25452. /**
  25453. * @hidden
  25454. */
  25455. _storeEffectOnSubMeshes: boolean;
  25456. /**
  25457. * Stores the animations for the material
  25458. */
  25459. animations: Nullable<Array<Animation>>;
  25460. /**
  25461. * An event triggered when the material is disposed
  25462. */
  25463. onDisposeObservable: Observable<Material>;
  25464. /**
  25465. * An observer which watches for dispose events
  25466. */
  25467. private _onDisposeObserver;
  25468. private _onUnBindObservable;
  25469. /**
  25470. * Called during a dispose event
  25471. */
  25472. set onDispose(callback: () => void);
  25473. private _onBindObservable;
  25474. /**
  25475. * An event triggered when the material is bound
  25476. */
  25477. get onBindObservable(): Observable<AbstractMesh>;
  25478. /**
  25479. * An observer which watches for bind events
  25480. */
  25481. private _onBindObserver;
  25482. /**
  25483. * Called during a bind event
  25484. */
  25485. set onBind(callback: (Mesh: AbstractMesh) => void);
  25486. /**
  25487. * An event triggered when the material is unbound
  25488. */
  25489. get onUnBindObservable(): Observable<Material>;
  25490. protected _onEffectCreatedObservable: Nullable<Observable<{
  25491. effect: Effect;
  25492. subMesh: Nullable<SubMesh>;
  25493. }>>;
  25494. /**
  25495. * An event triggered when the effect is (re)created
  25496. */
  25497. get onEffectCreatedObservable(): Observable<{
  25498. effect: Effect;
  25499. subMesh: Nullable<SubMesh>;
  25500. }>;
  25501. /**
  25502. * Stores the value of the alpha mode
  25503. */
  25504. private _alphaMode;
  25505. /**
  25506. * Sets the value of the alpha mode.
  25507. *
  25508. * | Value | Type | Description |
  25509. * | --- | --- | --- |
  25510. * | 0 | ALPHA_DISABLE | |
  25511. * | 1 | ALPHA_ADD | |
  25512. * | 2 | ALPHA_COMBINE | |
  25513. * | 3 | ALPHA_SUBTRACT | |
  25514. * | 4 | ALPHA_MULTIPLY | |
  25515. * | 5 | ALPHA_MAXIMIZED | |
  25516. * | 6 | ALPHA_ONEONE | |
  25517. * | 7 | ALPHA_PREMULTIPLIED | |
  25518. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25519. * | 9 | ALPHA_INTERPOLATE | |
  25520. * | 10 | ALPHA_SCREENMODE | |
  25521. *
  25522. */
  25523. set alphaMode(value: number);
  25524. /**
  25525. * Gets the value of the alpha mode
  25526. */
  25527. get alphaMode(): number;
  25528. /**
  25529. * Stores the state of the need depth pre-pass value
  25530. */
  25531. private _needDepthPrePass;
  25532. /**
  25533. * Sets the need depth pre-pass value
  25534. */
  25535. set needDepthPrePass(value: boolean);
  25536. /**
  25537. * Gets the depth pre-pass value
  25538. */
  25539. get needDepthPrePass(): boolean;
  25540. /**
  25541. * Specifies if depth writing should be disabled
  25542. */
  25543. disableDepthWrite: boolean;
  25544. /**
  25545. * Specifies if color writing should be disabled
  25546. */
  25547. disableColorWrite: boolean;
  25548. /**
  25549. * Specifies if depth writing should be forced
  25550. */
  25551. forceDepthWrite: boolean;
  25552. /**
  25553. * Specifies the depth function that should be used. 0 means the default engine function
  25554. */
  25555. depthFunction: number;
  25556. /**
  25557. * Specifies if there should be a separate pass for culling
  25558. */
  25559. separateCullingPass: boolean;
  25560. /**
  25561. * Stores the state specifing if fog should be enabled
  25562. */
  25563. private _fogEnabled;
  25564. /**
  25565. * Sets the state for enabling fog
  25566. */
  25567. set fogEnabled(value: boolean);
  25568. /**
  25569. * Gets the value of the fog enabled state
  25570. */
  25571. get fogEnabled(): boolean;
  25572. /**
  25573. * Stores the size of points
  25574. */
  25575. pointSize: number;
  25576. /**
  25577. * Stores the z offset value
  25578. */
  25579. zOffset: number;
  25580. get wireframe(): boolean;
  25581. /**
  25582. * Sets the state of wireframe mode
  25583. */
  25584. set wireframe(value: boolean);
  25585. /**
  25586. * Gets the value specifying if point clouds are enabled
  25587. */
  25588. get pointsCloud(): boolean;
  25589. /**
  25590. * Sets the state of point cloud mode
  25591. */
  25592. set pointsCloud(value: boolean);
  25593. /**
  25594. * Gets the material fill mode
  25595. */
  25596. get fillMode(): number;
  25597. /**
  25598. * Sets the material fill mode
  25599. */
  25600. set fillMode(value: number);
  25601. /**
  25602. * @hidden
  25603. * Stores the effects for the material
  25604. */
  25605. _effect: Nullable<Effect>;
  25606. /**
  25607. * Specifies if uniform buffers should be used
  25608. */
  25609. private _useUBO;
  25610. /**
  25611. * Stores a reference to the scene
  25612. */
  25613. private _scene;
  25614. /**
  25615. * Stores the fill mode state
  25616. */
  25617. private _fillMode;
  25618. /**
  25619. * Specifies if the depth write state should be cached
  25620. */
  25621. private _cachedDepthWriteState;
  25622. /**
  25623. * Specifies if the color write state should be cached
  25624. */
  25625. private _cachedColorWriteState;
  25626. /**
  25627. * Specifies if the depth function state should be cached
  25628. */
  25629. private _cachedDepthFunctionState;
  25630. /**
  25631. * Stores the uniform buffer
  25632. */
  25633. protected _uniformBuffer: UniformBuffer;
  25634. /** @hidden */
  25635. _indexInSceneMaterialArray: number;
  25636. /** @hidden */
  25637. meshMap: Nullable<{
  25638. [id: string]: AbstractMesh | undefined;
  25639. }>;
  25640. /**
  25641. * Creates a material instance
  25642. * @param name defines the name of the material
  25643. * @param scene defines the scene to reference
  25644. * @param doNotAdd specifies if the material should be added to the scene
  25645. */
  25646. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25647. /**
  25648. * Returns a string representation of the current material
  25649. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25650. * @returns a string with material information
  25651. */
  25652. toString(fullDetails?: boolean): string;
  25653. /**
  25654. * Gets the class name of the material
  25655. * @returns a string with the class name of the material
  25656. */
  25657. getClassName(): string;
  25658. /**
  25659. * Specifies if updates for the material been locked
  25660. */
  25661. get isFrozen(): boolean;
  25662. /**
  25663. * Locks updates for the material
  25664. */
  25665. freeze(): void;
  25666. /**
  25667. * Unlocks updates for the material
  25668. */
  25669. unfreeze(): void;
  25670. /**
  25671. * Specifies if the material is ready to be used
  25672. * @param mesh defines the mesh to check
  25673. * @param useInstances specifies if instances should be used
  25674. * @returns a boolean indicating if the material is ready to be used
  25675. */
  25676. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25677. /**
  25678. * Specifies that the submesh is ready to be used
  25679. * @param mesh defines the mesh to check
  25680. * @param subMesh defines which submesh to check
  25681. * @param useInstances specifies that instances should be used
  25682. * @returns a boolean indicating that the submesh is ready or not
  25683. */
  25684. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25685. /**
  25686. * Returns the material effect
  25687. * @returns the effect associated with the material
  25688. */
  25689. getEffect(): Nullable<Effect>;
  25690. /**
  25691. * Returns the current scene
  25692. * @returns a Scene
  25693. */
  25694. getScene(): Scene;
  25695. /**
  25696. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25697. */
  25698. protected _forceAlphaTest: boolean;
  25699. /**
  25700. * The transparency mode of the material.
  25701. */
  25702. protected _transparencyMode: Nullable<number>;
  25703. /**
  25704. * Gets the current transparency mode.
  25705. */
  25706. get transparencyMode(): Nullable<number>;
  25707. /**
  25708. * Sets the transparency mode of the material.
  25709. *
  25710. * | Value | Type | Description |
  25711. * | ----- | ----------------------------------- | ----------- |
  25712. * | 0 | OPAQUE | |
  25713. * | 1 | ALPHATEST | |
  25714. * | 2 | ALPHABLEND | |
  25715. * | 3 | ALPHATESTANDBLEND | |
  25716. *
  25717. */
  25718. set transparencyMode(value: Nullable<number>);
  25719. /**
  25720. * Returns true if alpha blending should be disabled.
  25721. */
  25722. protected get _disableAlphaBlending(): boolean;
  25723. /**
  25724. * Specifies whether or not this material should be rendered in alpha blend mode.
  25725. * @returns a boolean specifying if alpha blending is needed
  25726. */
  25727. needAlphaBlending(): boolean;
  25728. /**
  25729. * Specifies if the mesh will require alpha blending
  25730. * @param mesh defines the mesh to check
  25731. * @returns a boolean specifying if alpha blending is needed for the mesh
  25732. */
  25733. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25734. /**
  25735. * Specifies whether or not this material should be rendered in alpha test mode.
  25736. * @returns a boolean specifying if an alpha test is needed.
  25737. */
  25738. needAlphaTesting(): boolean;
  25739. /**
  25740. * Specifies if material alpha testing should be turned on for the mesh
  25741. * @param mesh defines the mesh to check
  25742. */
  25743. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25744. /**
  25745. * Gets the texture used for the alpha test
  25746. * @returns the texture to use for alpha testing
  25747. */
  25748. getAlphaTestTexture(): Nullable<BaseTexture>;
  25749. /**
  25750. * Marks the material to indicate that it needs to be re-calculated
  25751. */
  25752. markDirty(): void;
  25753. /** @hidden */
  25754. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25755. /**
  25756. * Binds the material to the mesh
  25757. * @param world defines the world transformation matrix
  25758. * @param mesh defines the mesh to bind the material to
  25759. */
  25760. bind(world: Matrix, mesh?: Mesh): void;
  25761. /**
  25762. * Binds the submesh to the material
  25763. * @param world defines the world transformation matrix
  25764. * @param mesh defines the mesh containing the submesh
  25765. * @param subMesh defines the submesh to bind the material to
  25766. */
  25767. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25768. /**
  25769. * Binds the world matrix to the material
  25770. * @param world defines the world transformation matrix
  25771. */
  25772. bindOnlyWorldMatrix(world: Matrix): void;
  25773. /**
  25774. * Binds the scene's uniform buffer to the effect.
  25775. * @param effect defines the effect to bind to the scene uniform buffer
  25776. * @param sceneUbo defines the uniform buffer storing scene data
  25777. */
  25778. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25779. /**
  25780. * Binds the view matrix to the effect
  25781. * @param effect defines the effect to bind the view matrix to
  25782. */
  25783. bindView(effect: Effect): void;
  25784. /**
  25785. * Binds the view projection matrix to the effect
  25786. * @param effect defines the effect to bind the view projection matrix to
  25787. */
  25788. bindViewProjection(effect: Effect): void;
  25789. /**
  25790. * Processes to execute after binding the material to a mesh
  25791. * @param mesh defines the rendered mesh
  25792. */
  25793. protected _afterBind(mesh?: Mesh): void;
  25794. /**
  25795. * Unbinds the material from the mesh
  25796. */
  25797. unbind(): void;
  25798. /**
  25799. * Gets the active textures from the material
  25800. * @returns an array of textures
  25801. */
  25802. getActiveTextures(): BaseTexture[];
  25803. /**
  25804. * Specifies if the material uses a texture
  25805. * @param texture defines the texture to check against the material
  25806. * @returns a boolean specifying if the material uses the texture
  25807. */
  25808. hasTexture(texture: BaseTexture): boolean;
  25809. /**
  25810. * Makes a duplicate of the material, and gives it a new name
  25811. * @param name defines the new name for the duplicated material
  25812. * @returns the cloned material
  25813. */
  25814. clone(name: string): Nullable<Material>;
  25815. /**
  25816. * Gets the meshes bound to the material
  25817. * @returns an array of meshes bound to the material
  25818. */
  25819. getBindedMeshes(): AbstractMesh[];
  25820. /**
  25821. * Force shader compilation
  25822. * @param mesh defines the mesh associated with this material
  25823. * @param onCompiled defines a function to execute once the material is compiled
  25824. * @param options defines the options to configure the compilation
  25825. * @param onError defines a function to execute if the material fails compiling
  25826. */
  25827. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25828. /**
  25829. * Force shader compilation
  25830. * @param mesh defines the mesh that will use this material
  25831. * @param options defines additional options for compiling the shaders
  25832. * @returns a promise that resolves when the compilation completes
  25833. */
  25834. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25835. private static readonly _AllDirtyCallBack;
  25836. private static readonly _ImageProcessingDirtyCallBack;
  25837. private static readonly _TextureDirtyCallBack;
  25838. private static readonly _FresnelDirtyCallBack;
  25839. private static readonly _MiscDirtyCallBack;
  25840. private static readonly _LightsDirtyCallBack;
  25841. private static readonly _AttributeDirtyCallBack;
  25842. private static _FresnelAndMiscDirtyCallBack;
  25843. private static _TextureAndMiscDirtyCallBack;
  25844. private static readonly _DirtyCallbackArray;
  25845. private static readonly _RunDirtyCallBacks;
  25846. /**
  25847. * Marks a define in the material to indicate that it needs to be re-computed
  25848. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25849. */
  25850. markAsDirty(flag: number): void;
  25851. /**
  25852. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25853. * @param func defines a function which checks material defines against the submeshes
  25854. */
  25855. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25856. /**
  25857. * Indicates that the scene should check if the rendering now needs a prepass
  25858. */
  25859. protected _markScenePrePassDirty(): void;
  25860. /**
  25861. * Indicates that we need to re-calculated for all submeshes
  25862. */
  25863. protected _markAllSubMeshesAsAllDirty(): void;
  25864. /**
  25865. * Indicates that image processing needs to be re-calculated for all submeshes
  25866. */
  25867. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25868. /**
  25869. * Indicates that textures need to be re-calculated for all submeshes
  25870. */
  25871. protected _markAllSubMeshesAsTexturesDirty(): void;
  25872. /**
  25873. * Indicates that fresnel needs to be re-calculated for all submeshes
  25874. */
  25875. protected _markAllSubMeshesAsFresnelDirty(): void;
  25876. /**
  25877. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25878. */
  25879. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25880. /**
  25881. * Indicates that lights need to be re-calculated for all submeshes
  25882. */
  25883. protected _markAllSubMeshesAsLightsDirty(): void;
  25884. /**
  25885. * Indicates that attributes need to be re-calculated for all submeshes
  25886. */
  25887. protected _markAllSubMeshesAsAttributesDirty(): void;
  25888. /**
  25889. * Indicates that misc needs to be re-calculated for all submeshes
  25890. */
  25891. protected _markAllSubMeshesAsMiscDirty(): void;
  25892. /**
  25893. * Indicates that textures and misc need to be re-calculated for all submeshes
  25894. */
  25895. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25896. /**
  25897. * Sets the required values to the prepass renderer.
  25898. * @param prePassRenderer defines the prepass renderer to setup.
  25899. * @returns true if the pre pass is needed.
  25900. */
  25901. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25902. /**
  25903. * Disposes the material
  25904. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25905. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25906. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25907. */
  25908. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25909. /** @hidden */
  25910. private releaseVertexArrayObject;
  25911. /**
  25912. * Serializes this material
  25913. * @returns the serialized material object
  25914. */
  25915. serialize(): any;
  25916. /**
  25917. * Creates a material from parsed material data
  25918. * @param parsedMaterial defines parsed material data
  25919. * @param scene defines the hosting scene
  25920. * @param rootUrl defines the root URL to use to load textures
  25921. * @returns a new material
  25922. */
  25923. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25924. }
  25925. }
  25926. declare module "babylonjs/Materials/multiMaterial" {
  25927. import { Nullable } from "babylonjs/types";
  25928. import { Scene } from "babylonjs/scene";
  25929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25930. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25931. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25932. import { Material } from "babylonjs/Materials/material";
  25933. /**
  25934. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25935. * separate meshes. This can be use to improve performances.
  25936. * @see https://doc.babylonjs.com/how_to/multi_materials
  25937. */
  25938. export class MultiMaterial extends Material {
  25939. private _subMaterials;
  25940. /**
  25941. * Gets or Sets the list of Materials used within the multi material.
  25942. * They need to be ordered according to the submeshes order in the associated mesh
  25943. */
  25944. get subMaterials(): Nullable<Material>[];
  25945. set subMaterials(value: Nullable<Material>[]);
  25946. /**
  25947. * Function used to align with Node.getChildren()
  25948. * @returns the list of Materials used within the multi material
  25949. */
  25950. getChildren(): Nullable<Material>[];
  25951. /**
  25952. * Instantiates a new Multi Material
  25953. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25954. * separate meshes. This can be use to improve performances.
  25955. * @see https://doc.babylonjs.com/how_to/multi_materials
  25956. * @param name Define the name in the scene
  25957. * @param scene Define the scene the material belongs to
  25958. */
  25959. constructor(name: string, scene: Scene);
  25960. private _hookArray;
  25961. /**
  25962. * Get one of the submaterial by its index in the submaterials array
  25963. * @param index The index to look the sub material at
  25964. * @returns The Material if the index has been defined
  25965. */
  25966. getSubMaterial(index: number): Nullable<Material>;
  25967. /**
  25968. * Get the list of active textures for the whole sub materials list.
  25969. * @returns All the textures that will be used during the rendering
  25970. */
  25971. getActiveTextures(): BaseTexture[];
  25972. /**
  25973. * Gets the current class name of the material e.g. "MultiMaterial"
  25974. * Mainly use in serialization.
  25975. * @returns the class name
  25976. */
  25977. getClassName(): string;
  25978. /**
  25979. * Checks if the material is ready to render the requested sub mesh
  25980. * @param mesh Define the mesh the submesh belongs to
  25981. * @param subMesh Define the sub mesh to look readyness for
  25982. * @param useInstances Define whether or not the material is used with instances
  25983. * @returns true if ready, otherwise false
  25984. */
  25985. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25986. /**
  25987. * Clones the current material and its related sub materials
  25988. * @param name Define the name of the newly cloned material
  25989. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25990. * @returns the cloned material
  25991. */
  25992. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25993. /**
  25994. * Serializes the materials into a JSON representation.
  25995. * @returns the JSON representation
  25996. */
  25997. serialize(): any;
  25998. /**
  25999. * Dispose the material and release its associated resources
  26000. * @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)
  26001. * @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)
  26002. * @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)
  26003. */
  26004. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26005. /**
  26006. * Creates a MultiMaterial from parsed MultiMaterial data.
  26007. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26008. * @param scene defines the hosting scene
  26009. * @returns a new MultiMaterial
  26010. */
  26011. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26012. }
  26013. }
  26014. declare module "babylonjs/Meshes/subMesh" {
  26015. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26016. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26017. import { Engine } from "babylonjs/Engines/engine";
  26018. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26019. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26020. import { Effect } from "babylonjs/Materials/effect";
  26021. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26022. import { Plane } from "babylonjs/Maths/math.plane";
  26023. import { Collider } from "babylonjs/Collisions/collider";
  26024. import { Material } from "babylonjs/Materials/material";
  26025. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26027. import { Mesh } from "babylonjs/Meshes/mesh";
  26028. import { Ray } from "babylonjs/Culling/ray";
  26029. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26030. /**
  26031. * Defines a subdivision inside a mesh
  26032. */
  26033. export class SubMesh implements ICullable {
  26034. /** the material index to use */
  26035. materialIndex: number;
  26036. /** vertex index start */
  26037. verticesStart: number;
  26038. /** vertices count */
  26039. verticesCount: number;
  26040. /** index start */
  26041. indexStart: number;
  26042. /** indices count */
  26043. indexCount: number;
  26044. /** @hidden */
  26045. _materialDefines: Nullable<MaterialDefines>;
  26046. /** @hidden */
  26047. _materialEffect: Nullable<Effect>;
  26048. /** @hidden */
  26049. _effectOverride: Nullable<Effect>;
  26050. /**
  26051. * Gets material defines used by the effect associated to the sub mesh
  26052. */
  26053. get materialDefines(): Nullable<MaterialDefines>;
  26054. /**
  26055. * Sets material defines used by the effect associated to the sub mesh
  26056. */
  26057. set materialDefines(defines: Nullable<MaterialDefines>);
  26058. /**
  26059. * Gets associated effect
  26060. */
  26061. get effect(): Nullable<Effect>;
  26062. /**
  26063. * Sets associated effect (effect used to render this submesh)
  26064. * @param effect defines the effect to associate with
  26065. * @param defines defines the set of defines used to compile this effect
  26066. */
  26067. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26068. /** @hidden */
  26069. _linesIndexCount: number;
  26070. private _mesh;
  26071. private _renderingMesh;
  26072. private _boundingInfo;
  26073. private _linesIndexBuffer;
  26074. /** @hidden */
  26075. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26076. /** @hidden */
  26077. _trianglePlanes: Plane[];
  26078. /** @hidden */
  26079. _lastColliderTransformMatrix: Nullable<Matrix>;
  26080. /** @hidden */
  26081. _renderId: number;
  26082. /** @hidden */
  26083. _alphaIndex: number;
  26084. /** @hidden */
  26085. _distanceToCamera: number;
  26086. /** @hidden */
  26087. _id: number;
  26088. private _currentMaterial;
  26089. /**
  26090. * Add a new submesh to a mesh
  26091. * @param materialIndex defines the material index to use
  26092. * @param verticesStart defines vertex index start
  26093. * @param verticesCount defines vertices count
  26094. * @param indexStart defines index start
  26095. * @param indexCount defines indices count
  26096. * @param mesh defines the parent mesh
  26097. * @param renderingMesh defines an optional rendering mesh
  26098. * @param createBoundingBox defines if bounding box should be created for this submesh
  26099. * @returns the new submesh
  26100. */
  26101. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26102. /**
  26103. * Creates a new submesh
  26104. * @param materialIndex defines the material index to use
  26105. * @param verticesStart defines vertex index start
  26106. * @param verticesCount defines vertices count
  26107. * @param indexStart defines index start
  26108. * @param indexCount defines indices count
  26109. * @param mesh defines the parent mesh
  26110. * @param renderingMesh defines an optional rendering mesh
  26111. * @param createBoundingBox defines if bounding box should be created for this submesh
  26112. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26113. */
  26114. constructor(
  26115. /** the material index to use */
  26116. materialIndex: number,
  26117. /** vertex index start */
  26118. verticesStart: number,
  26119. /** vertices count */
  26120. verticesCount: number,
  26121. /** index start */
  26122. indexStart: number,
  26123. /** indices count */
  26124. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26125. /**
  26126. * Returns true if this submesh covers the entire parent mesh
  26127. * @ignorenaming
  26128. */
  26129. get IsGlobal(): boolean;
  26130. /**
  26131. * Returns the submesh BoudingInfo object
  26132. * @returns current bounding info (or mesh's one if the submesh is global)
  26133. */
  26134. getBoundingInfo(): BoundingInfo;
  26135. /**
  26136. * Sets the submesh BoundingInfo
  26137. * @param boundingInfo defines the new bounding info to use
  26138. * @returns the SubMesh
  26139. */
  26140. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26141. /**
  26142. * Returns the mesh of the current submesh
  26143. * @return the parent mesh
  26144. */
  26145. getMesh(): AbstractMesh;
  26146. /**
  26147. * Returns the rendering mesh of the submesh
  26148. * @returns the rendering mesh (could be different from parent mesh)
  26149. */
  26150. getRenderingMesh(): Mesh;
  26151. /**
  26152. * Returns the replacement mesh of the submesh
  26153. * @returns the replacement mesh (could be different from parent mesh)
  26154. */
  26155. getReplacementMesh(): Nullable<AbstractMesh>;
  26156. /**
  26157. * Returns the effective mesh of the submesh
  26158. * @returns the effective mesh (could be different from parent mesh)
  26159. */
  26160. getEffectiveMesh(): AbstractMesh;
  26161. /**
  26162. * Returns the submesh material
  26163. * @returns null or the current material
  26164. */
  26165. getMaterial(): Nullable<Material>;
  26166. private _IsMultiMaterial;
  26167. /**
  26168. * Sets a new updated BoundingInfo object to the submesh
  26169. * @param data defines an optional position array to use to determine the bounding info
  26170. * @returns the SubMesh
  26171. */
  26172. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26173. /** @hidden */
  26174. _checkCollision(collider: Collider): boolean;
  26175. /**
  26176. * Updates the submesh BoundingInfo
  26177. * @param world defines the world matrix to use to update the bounding info
  26178. * @returns the submesh
  26179. */
  26180. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26181. /**
  26182. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26183. * @param frustumPlanes defines the frustum planes
  26184. * @returns true if the submesh is intersecting with the frustum
  26185. */
  26186. isInFrustum(frustumPlanes: Plane[]): boolean;
  26187. /**
  26188. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26189. * @param frustumPlanes defines the frustum planes
  26190. * @returns true if the submesh is inside the frustum
  26191. */
  26192. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26193. /**
  26194. * Renders the submesh
  26195. * @param enableAlphaMode defines if alpha needs to be used
  26196. * @returns the submesh
  26197. */
  26198. render(enableAlphaMode: boolean): SubMesh;
  26199. /**
  26200. * @hidden
  26201. */
  26202. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26203. /**
  26204. * Checks if the submesh intersects with a ray
  26205. * @param ray defines the ray to test
  26206. * @returns true is the passed ray intersects the submesh bounding box
  26207. */
  26208. canIntersects(ray: Ray): boolean;
  26209. /**
  26210. * Intersects current submesh with a ray
  26211. * @param ray defines the ray to test
  26212. * @param positions defines mesh's positions array
  26213. * @param indices defines mesh's indices array
  26214. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26215. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26216. * @returns intersection info or null if no intersection
  26217. */
  26218. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26219. /** @hidden */
  26220. private _intersectLines;
  26221. /** @hidden */
  26222. private _intersectUnIndexedLines;
  26223. /** @hidden */
  26224. private _intersectTriangles;
  26225. /** @hidden */
  26226. private _intersectUnIndexedTriangles;
  26227. /** @hidden */
  26228. _rebuild(): void;
  26229. /**
  26230. * Creates a new submesh from the passed mesh
  26231. * @param newMesh defines the new hosting mesh
  26232. * @param newRenderingMesh defines an optional rendering mesh
  26233. * @returns the new submesh
  26234. */
  26235. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26236. /**
  26237. * Release associated resources
  26238. */
  26239. dispose(): void;
  26240. /**
  26241. * Gets the class name
  26242. * @returns the string "SubMesh".
  26243. */
  26244. getClassName(): string;
  26245. /**
  26246. * Creates a new submesh from indices data
  26247. * @param materialIndex the index of the main mesh material
  26248. * @param startIndex the index where to start the copy in the mesh indices array
  26249. * @param indexCount the number of indices to copy then from the startIndex
  26250. * @param mesh the main mesh to create the submesh from
  26251. * @param renderingMesh the optional rendering mesh
  26252. * @returns a new submesh
  26253. */
  26254. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26255. }
  26256. }
  26257. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26258. /**
  26259. * Class used to represent data loading progression
  26260. */
  26261. export class SceneLoaderFlags {
  26262. private static _ForceFullSceneLoadingForIncremental;
  26263. private static _ShowLoadingScreen;
  26264. private static _CleanBoneMatrixWeights;
  26265. private static _loggingLevel;
  26266. /**
  26267. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26268. */
  26269. static get ForceFullSceneLoadingForIncremental(): boolean;
  26270. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26271. /**
  26272. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26273. */
  26274. static get ShowLoadingScreen(): boolean;
  26275. static set ShowLoadingScreen(value: boolean);
  26276. /**
  26277. * Defines the current logging level (while loading the scene)
  26278. * @ignorenaming
  26279. */
  26280. static get loggingLevel(): number;
  26281. static set loggingLevel(value: number);
  26282. /**
  26283. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26284. */
  26285. static get CleanBoneMatrixWeights(): boolean;
  26286. static set CleanBoneMatrixWeights(value: boolean);
  26287. }
  26288. }
  26289. declare module "babylonjs/Meshes/geometry" {
  26290. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26291. import { Scene } from "babylonjs/scene";
  26292. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26293. import { Engine } from "babylonjs/Engines/engine";
  26294. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26295. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26296. import { Effect } from "babylonjs/Materials/effect";
  26297. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26298. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26299. import { Mesh } from "babylonjs/Meshes/mesh";
  26300. /**
  26301. * Class used to store geometry data (vertex buffers + index buffer)
  26302. */
  26303. export class Geometry implements IGetSetVerticesData {
  26304. /**
  26305. * Gets or sets the ID of the geometry
  26306. */
  26307. id: string;
  26308. /**
  26309. * Gets or sets the unique ID of the geometry
  26310. */
  26311. uniqueId: number;
  26312. /**
  26313. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26314. */
  26315. delayLoadState: number;
  26316. /**
  26317. * Gets the file containing the data to load when running in delay load state
  26318. */
  26319. delayLoadingFile: Nullable<string>;
  26320. /**
  26321. * Callback called when the geometry is updated
  26322. */
  26323. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26324. private _scene;
  26325. private _engine;
  26326. private _meshes;
  26327. private _totalVertices;
  26328. /** @hidden */
  26329. _indices: IndicesArray;
  26330. /** @hidden */
  26331. _vertexBuffers: {
  26332. [key: string]: VertexBuffer;
  26333. };
  26334. private _isDisposed;
  26335. private _extend;
  26336. private _boundingBias;
  26337. /** @hidden */
  26338. _delayInfo: Array<string>;
  26339. private _indexBuffer;
  26340. private _indexBufferIsUpdatable;
  26341. /** @hidden */
  26342. _boundingInfo: Nullable<BoundingInfo>;
  26343. /** @hidden */
  26344. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26345. /** @hidden */
  26346. _softwareSkinningFrameId: number;
  26347. private _vertexArrayObjects;
  26348. private _updatable;
  26349. /** @hidden */
  26350. _positions: Nullable<Vector3[]>;
  26351. /**
  26352. * 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
  26353. */
  26354. get boundingBias(): Vector2;
  26355. /**
  26356. * 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
  26357. */
  26358. set boundingBias(value: Vector2);
  26359. /**
  26360. * Static function used to attach a new empty geometry to a mesh
  26361. * @param mesh defines the mesh to attach the geometry to
  26362. * @returns the new Geometry
  26363. */
  26364. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26365. /** Get the list of meshes using this geometry */
  26366. get meshes(): Mesh[];
  26367. /**
  26368. * 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
  26369. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26370. */
  26371. useBoundingInfoFromGeometry: boolean;
  26372. /**
  26373. * Creates a new geometry
  26374. * @param id defines the unique ID
  26375. * @param scene defines the hosting scene
  26376. * @param vertexData defines the VertexData used to get geometry data
  26377. * @param updatable defines if geometry must be updatable (false by default)
  26378. * @param mesh defines the mesh that will be associated with the geometry
  26379. */
  26380. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26381. /**
  26382. * Gets the current extend of the geometry
  26383. */
  26384. get extend(): {
  26385. minimum: Vector3;
  26386. maximum: Vector3;
  26387. };
  26388. /**
  26389. * Gets the hosting scene
  26390. * @returns the hosting Scene
  26391. */
  26392. getScene(): Scene;
  26393. /**
  26394. * Gets the hosting engine
  26395. * @returns the hosting Engine
  26396. */
  26397. getEngine(): Engine;
  26398. /**
  26399. * Defines if the geometry is ready to use
  26400. * @returns true if the geometry is ready to be used
  26401. */
  26402. isReady(): boolean;
  26403. /**
  26404. * Gets a value indicating that the geometry should not be serialized
  26405. */
  26406. get doNotSerialize(): boolean;
  26407. /** @hidden */
  26408. _rebuild(): void;
  26409. /**
  26410. * Affects all geometry data in one call
  26411. * @param vertexData defines the geometry data
  26412. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26413. */
  26414. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26415. /**
  26416. * Set specific vertex data
  26417. * @param kind defines the data kind (Position, normal, etc...)
  26418. * @param data defines the vertex data to use
  26419. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26420. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26421. */
  26422. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26423. /**
  26424. * Removes a specific vertex data
  26425. * @param kind defines the data kind (Position, normal, etc...)
  26426. */
  26427. removeVerticesData(kind: string): void;
  26428. /**
  26429. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26430. * @param buffer defines the vertex buffer to use
  26431. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26432. */
  26433. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26434. /**
  26435. * Update a specific vertex buffer
  26436. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26437. * It will do nothing if the buffer is not updatable
  26438. * @param kind defines the data kind (Position, normal, etc...)
  26439. * @param data defines the data to use
  26440. * @param offset defines the offset in the target buffer where to store the data
  26441. * @param useBytes set to true if the offset is in bytes
  26442. */
  26443. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26444. /**
  26445. * Update a specific vertex buffer
  26446. * This function will create a new buffer if the current one is not updatable
  26447. * @param kind defines the data kind (Position, normal, etc...)
  26448. * @param data defines the data to use
  26449. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26450. */
  26451. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26452. private _updateBoundingInfo;
  26453. /** @hidden */
  26454. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26455. /**
  26456. * Gets total number of vertices
  26457. * @returns the total number of vertices
  26458. */
  26459. getTotalVertices(): number;
  26460. /**
  26461. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26462. * @param kind defines the data kind (Position, normal, etc...)
  26463. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26464. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26465. * @returns a float array containing vertex data
  26466. */
  26467. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26468. /**
  26469. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26470. * @param kind defines the data kind (Position, normal, etc...)
  26471. * @returns true if the vertex buffer with the specified kind is updatable
  26472. */
  26473. isVertexBufferUpdatable(kind: string): boolean;
  26474. /**
  26475. * Gets a specific vertex buffer
  26476. * @param kind defines the data kind (Position, normal, etc...)
  26477. * @returns a VertexBuffer
  26478. */
  26479. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26480. /**
  26481. * Returns all vertex buffers
  26482. * @return an object holding all vertex buffers indexed by kind
  26483. */
  26484. getVertexBuffers(): Nullable<{
  26485. [key: string]: VertexBuffer;
  26486. }>;
  26487. /**
  26488. * Gets a boolean indicating if specific vertex buffer is present
  26489. * @param kind defines the data kind (Position, normal, etc...)
  26490. * @returns true if data is present
  26491. */
  26492. isVerticesDataPresent(kind: string): boolean;
  26493. /**
  26494. * Gets a list of all attached data kinds (Position, normal, etc...)
  26495. * @returns a list of string containing all kinds
  26496. */
  26497. getVerticesDataKinds(): string[];
  26498. /**
  26499. * Update index buffer
  26500. * @param indices defines the indices to store in the index buffer
  26501. * @param offset defines the offset in the target buffer where to store the data
  26502. * @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)
  26503. */
  26504. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26505. /**
  26506. * Creates a new index buffer
  26507. * @param indices defines the indices to store in the index buffer
  26508. * @param totalVertices defines the total number of vertices (could be null)
  26509. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26510. */
  26511. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26512. /**
  26513. * Return the total number of indices
  26514. * @returns the total number of indices
  26515. */
  26516. getTotalIndices(): number;
  26517. /**
  26518. * Gets the index buffer array
  26519. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26520. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26521. * @returns the index buffer array
  26522. */
  26523. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26524. /**
  26525. * Gets the index buffer
  26526. * @return the index buffer
  26527. */
  26528. getIndexBuffer(): Nullable<DataBuffer>;
  26529. /** @hidden */
  26530. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26531. /**
  26532. * Release the associated resources for a specific mesh
  26533. * @param mesh defines the source mesh
  26534. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26535. */
  26536. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26537. /**
  26538. * Apply current geometry to a given mesh
  26539. * @param mesh defines the mesh to apply geometry to
  26540. */
  26541. applyToMesh(mesh: Mesh): void;
  26542. private _updateExtend;
  26543. private _applyToMesh;
  26544. private notifyUpdate;
  26545. /**
  26546. * Load the geometry if it was flagged as delay loaded
  26547. * @param scene defines the hosting scene
  26548. * @param onLoaded defines a callback called when the geometry is loaded
  26549. */
  26550. load(scene: Scene, onLoaded?: () => void): void;
  26551. private _queueLoad;
  26552. /**
  26553. * Invert the geometry to move from a right handed system to a left handed one.
  26554. */
  26555. toLeftHanded(): void;
  26556. /** @hidden */
  26557. _resetPointsArrayCache(): void;
  26558. /** @hidden */
  26559. _generatePointsArray(): boolean;
  26560. /**
  26561. * Gets a value indicating if the geometry is disposed
  26562. * @returns true if the geometry was disposed
  26563. */
  26564. isDisposed(): boolean;
  26565. private _disposeVertexArrayObjects;
  26566. /**
  26567. * Free all associated resources
  26568. */
  26569. dispose(): void;
  26570. /**
  26571. * Clone the current geometry into a new geometry
  26572. * @param id defines the unique ID of the new geometry
  26573. * @returns a new geometry object
  26574. */
  26575. copy(id: string): Geometry;
  26576. /**
  26577. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26578. * @return a JSON representation of the current geometry data (without the vertices data)
  26579. */
  26580. serialize(): any;
  26581. private toNumberArray;
  26582. /**
  26583. * Serialize all vertices data into a JSON oject
  26584. * @returns a JSON representation of the current geometry data
  26585. */
  26586. serializeVerticeData(): any;
  26587. /**
  26588. * Extracts a clone of a mesh geometry
  26589. * @param mesh defines the source mesh
  26590. * @param id defines the unique ID of the new geometry object
  26591. * @returns the new geometry object
  26592. */
  26593. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26594. /**
  26595. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26596. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26597. * Be aware Math.random() could cause collisions, but:
  26598. * "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"
  26599. * @returns a string containing a new GUID
  26600. */
  26601. static RandomId(): string;
  26602. /** @hidden */
  26603. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26604. private static _CleanMatricesWeights;
  26605. /**
  26606. * Create a new geometry from persisted data (Using .babylon file format)
  26607. * @param parsedVertexData defines the persisted data
  26608. * @param scene defines the hosting scene
  26609. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26610. * @returns the new geometry object
  26611. */
  26612. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26613. }
  26614. }
  26615. declare module "babylonjs/Meshes/mesh.vertexData" {
  26616. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26617. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26618. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26619. import { Geometry } from "babylonjs/Meshes/geometry";
  26620. import { Mesh } from "babylonjs/Meshes/mesh";
  26621. /**
  26622. * Define an interface for all classes that will get and set the data on vertices
  26623. */
  26624. export interface IGetSetVerticesData {
  26625. /**
  26626. * Gets a boolean indicating if specific vertex data is present
  26627. * @param kind defines the vertex data kind to use
  26628. * @returns true is data kind is present
  26629. */
  26630. isVerticesDataPresent(kind: string): boolean;
  26631. /**
  26632. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26633. * @param kind defines the data kind (Position, normal, etc...)
  26634. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26635. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26636. * @returns a float array containing vertex data
  26637. */
  26638. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26639. /**
  26640. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26641. * @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.
  26642. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26643. * @returns the indices array or an empty array if the mesh has no geometry
  26644. */
  26645. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26646. /**
  26647. * Set specific vertex data
  26648. * @param kind defines the data kind (Position, normal, etc...)
  26649. * @param data defines the vertex data to use
  26650. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26651. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26652. */
  26653. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26654. /**
  26655. * Update a specific associated vertex buffer
  26656. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26657. * - VertexBuffer.PositionKind
  26658. * - VertexBuffer.UVKind
  26659. * - VertexBuffer.UV2Kind
  26660. * - VertexBuffer.UV3Kind
  26661. * - VertexBuffer.UV4Kind
  26662. * - VertexBuffer.UV5Kind
  26663. * - VertexBuffer.UV6Kind
  26664. * - VertexBuffer.ColorKind
  26665. * - VertexBuffer.MatricesIndicesKind
  26666. * - VertexBuffer.MatricesIndicesExtraKind
  26667. * - VertexBuffer.MatricesWeightsKind
  26668. * - VertexBuffer.MatricesWeightsExtraKind
  26669. * @param data defines the data source
  26670. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26671. * @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)
  26672. */
  26673. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26674. /**
  26675. * Creates a new index buffer
  26676. * @param indices defines the indices to store in the index buffer
  26677. * @param totalVertices defines the total number of vertices (could be null)
  26678. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26679. */
  26680. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26681. }
  26682. /**
  26683. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26684. */
  26685. export class VertexData {
  26686. /**
  26687. * Mesh side orientation : usually the external or front surface
  26688. */
  26689. static readonly FRONTSIDE: number;
  26690. /**
  26691. * Mesh side orientation : usually the internal or back surface
  26692. */
  26693. static readonly BACKSIDE: number;
  26694. /**
  26695. * Mesh side orientation : both internal and external or front and back surfaces
  26696. */
  26697. static readonly DOUBLESIDE: number;
  26698. /**
  26699. * Mesh side orientation : by default, `FRONTSIDE`
  26700. */
  26701. static readonly DEFAULTSIDE: number;
  26702. /**
  26703. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26704. */
  26705. positions: Nullable<FloatArray>;
  26706. /**
  26707. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26708. */
  26709. normals: Nullable<FloatArray>;
  26710. /**
  26711. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26712. */
  26713. tangents: Nullable<FloatArray>;
  26714. /**
  26715. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26716. */
  26717. uvs: Nullable<FloatArray>;
  26718. /**
  26719. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26720. */
  26721. uvs2: Nullable<FloatArray>;
  26722. /**
  26723. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26724. */
  26725. uvs3: Nullable<FloatArray>;
  26726. /**
  26727. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26728. */
  26729. uvs4: Nullable<FloatArray>;
  26730. /**
  26731. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26732. */
  26733. uvs5: Nullable<FloatArray>;
  26734. /**
  26735. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26736. */
  26737. uvs6: Nullable<FloatArray>;
  26738. /**
  26739. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26740. */
  26741. colors: Nullable<FloatArray>;
  26742. /**
  26743. * 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).
  26744. */
  26745. matricesIndices: Nullable<FloatArray>;
  26746. /**
  26747. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26748. */
  26749. matricesWeights: Nullable<FloatArray>;
  26750. /**
  26751. * An array extending the number of possible indices
  26752. */
  26753. matricesIndicesExtra: Nullable<FloatArray>;
  26754. /**
  26755. * An array extending the number of possible weights when the number of indices is extended
  26756. */
  26757. matricesWeightsExtra: Nullable<FloatArray>;
  26758. /**
  26759. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26760. */
  26761. indices: Nullable<IndicesArray>;
  26762. /**
  26763. * Uses the passed data array to set the set the values for the specified kind of data
  26764. * @param data a linear array of floating numbers
  26765. * @param kind the type of data that is being set, eg positions, colors etc
  26766. */
  26767. set(data: FloatArray, kind: string): void;
  26768. /**
  26769. * Associates the vertexData to the passed Mesh.
  26770. * Sets it as updatable or not (default `false`)
  26771. * @param mesh the mesh the vertexData is applied to
  26772. * @param updatable when used and having the value true allows new data to update the vertexData
  26773. * @returns the VertexData
  26774. */
  26775. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26776. /**
  26777. * Associates the vertexData to the passed Geometry.
  26778. * Sets it as updatable or not (default `false`)
  26779. * @param geometry the geometry the vertexData is applied to
  26780. * @param updatable when used and having the value true allows new data to update the vertexData
  26781. * @returns VertexData
  26782. */
  26783. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26784. /**
  26785. * Updates the associated mesh
  26786. * @param mesh the mesh to be updated
  26787. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26788. * @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
  26789. * @returns VertexData
  26790. */
  26791. updateMesh(mesh: Mesh): VertexData;
  26792. /**
  26793. * Updates the associated geometry
  26794. * @param geometry the geometry to be updated
  26795. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26796. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  26797. * @returns VertexData.
  26798. */
  26799. updateGeometry(geometry: Geometry): VertexData;
  26800. private _applyTo;
  26801. private _update;
  26802. /**
  26803. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26804. * @param matrix the transforming matrix
  26805. * @returns the VertexData
  26806. */
  26807. transform(matrix: Matrix): VertexData;
  26808. /**
  26809. * Merges the passed VertexData into the current one
  26810. * @param other the VertexData to be merged into the current one
  26811. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26812. * @returns the modified VertexData
  26813. */
  26814. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26815. private _mergeElement;
  26816. private _validate;
  26817. /**
  26818. * Serializes the VertexData
  26819. * @returns a serialized object
  26820. */
  26821. serialize(): any;
  26822. /**
  26823. * Extracts the vertexData from a mesh
  26824. * @param mesh the mesh from which to extract the VertexData
  26825. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26826. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26827. * @returns the object VertexData associated to the passed mesh
  26828. */
  26829. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26830. /**
  26831. * Extracts the vertexData from the geometry
  26832. * @param geometry the geometry from which to extract the VertexData
  26833. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26834. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26835. * @returns the object VertexData associated to the passed mesh
  26836. */
  26837. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26838. private static _ExtractFrom;
  26839. /**
  26840. * Creates the VertexData for a Ribbon
  26841. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26842. * * pathArray array of paths, each of which an array of successive Vector3
  26843. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26844. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26845. * * 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
  26846. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26847. * * 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)
  26848. * * 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)
  26849. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26850. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26851. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26852. * @returns the VertexData of the ribbon
  26853. */
  26854. static CreateRibbon(options: {
  26855. pathArray: Vector3[][];
  26856. closeArray?: boolean;
  26857. closePath?: boolean;
  26858. offset?: number;
  26859. sideOrientation?: number;
  26860. frontUVs?: Vector4;
  26861. backUVs?: Vector4;
  26862. invertUV?: boolean;
  26863. uvs?: Vector2[];
  26864. colors?: Color4[];
  26865. }): VertexData;
  26866. /**
  26867. * Creates the VertexData for a box
  26868. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26869. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26870. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26871. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26872. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26873. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26874. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26875. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26876. * * 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)
  26877. * * 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)
  26878. * @returns the VertexData of the box
  26879. */
  26880. static CreateBox(options: {
  26881. size?: number;
  26882. width?: number;
  26883. height?: number;
  26884. depth?: number;
  26885. faceUV?: Vector4[];
  26886. faceColors?: Color4[];
  26887. sideOrientation?: number;
  26888. frontUVs?: Vector4;
  26889. backUVs?: Vector4;
  26890. }): VertexData;
  26891. /**
  26892. * Creates the VertexData for a tiled box
  26893. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26894. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26895. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26896. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26897. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26898. * @returns the VertexData of the box
  26899. */
  26900. static CreateTiledBox(options: {
  26901. pattern?: number;
  26902. width?: number;
  26903. height?: number;
  26904. depth?: number;
  26905. tileSize?: number;
  26906. tileWidth?: number;
  26907. tileHeight?: number;
  26908. alignHorizontal?: number;
  26909. alignVertical?: number;
  26910. faceUV?: Vector4[];
  26911. faceColors?: Color4[];
  26912. sideOrientation?: number;
  26913. }): VertexData;
  26914. /**
  26915. * Creates the VertexData for a tiled plane
  26916. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26917. * * pattern a limited pattern arrangement depending on the number
  26918. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26919. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26920. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26921. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26922. * * 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)
  26923. * * 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)
  26924. * @returns the VertexData of the tiled plane
  26925. */
  26926. static CreateTiledPlane(options: {
  26927. pattern?: number;
  26928. tileSize?: number;
  26929. tileWidth?: number;
  26930. tileHeight?: number;
  26931. size?: number;
  26932. width?: number;
  26933. height?: number;
  26934. alignHorizontal?: number;
  26935. alignVertical?: number;
  26936. sideOrientation?: number;
  26937. frontUVs?: Vector4;
  26938. backUVs?: Vector4;
  26939. }): VertexData;
  26940. /**
  26941. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26942. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26943. * * segments sets the number of horizontal strips optional, default 32
  26944. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26945. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26946. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26947. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26948. * * 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
  26949. * * 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
  26950. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26951. * * 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)
  26952. * * 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)
  26953. * @returns the VertexData of the ellipsoid
  26954. */
  26955. static CreateSphere(options: {
  26956. segments?: number;
  26957. diameter?: number;
  26958. diameterX?: number;
  26959. diameterY?: number;
  26960. diameterZ?: number;
  26961. arc?: number;
  26962. slice?: number;
  26963. sideOrientation?: number;
  26964. frontUVs?: Vector4;
  26965. backUVs?: Vector4;
  26966. }): VertexData;
  26967. /**
  26968. * Creates the VertexData for a cylinder, cone or prism
  26969. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26970. * * height sets the height (y direction) of the cylinder, optional, default 2
  26971. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26972. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26973. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26974. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26975. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26976. * * 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
  26977. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26978. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26979. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26980. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26981. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26982. * * 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)
  26983. * * 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)
  26984. * @returns the VertexData of the cylinder, cone or prism
  26985. */
  26986. static CreateCylinder(options: {
  26987. height?: number;
  26988. diameterTop?: number;
  26989. diameterBottom?: number;
  26990. diameter?: number;
  26991. tessellation?: number;
  26992. subdivisions?: number;
  26993. arc?: number;
  26994. faceColors?: Color4[];
  26995. faceUV?: Vector4[];
  26996. hasRings?: boolean;
  26997. enclose?: boolean;
  26998. sideOrientation?: number;
  26999. frontUVs?: Vector4;
  27000. backUVs?: Vector4;
  27001. }): VertexData;
  27002. /**
  27003. * Creates the VertexData for a torus
  27004. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27005. * * diameter the diameter of the torus, optional default 1
  27006. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27007. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27008. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27009. * * 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)
  27010. * * 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)
  27011. * @returns the VertexData of the torus
  27012. */
  27013. static CreateTorus(options: {
  27014. diameter?: number;
  27015. thickness?: number;
  27016. tessellation?: number;
  27017. sideOrientation?: number;
  27018. frontUVs?: Vector4;
  27019. backUVs?: Vector4;
  27020. }): VertexData;
  27021. /**
  27022. * Creates the VertexData of the LineSystem
  27023. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27024. * - lines an array of lines, each line being an array of successive Vector3
  27025. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27026. * @returns the VertexData of the LineSystem
  27027. */
  27028. static CreateLineSystem(options: {
  27029. lines: Vector3[][];
  27030. colors?: Nullable<Color4[][]>;
  27031. }): VertexData;
  27032. /**
  27033. * Create the VertexData for a DashedLines
  27034. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27035. * - points an array successive Vector3
  27036. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27037. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27038. * - dashNb the intended total number of dashes, optional, default 200
  27039. * @returns the VertexData for the DashedLines
  27040. */
  27041. static CreateDashedLines(options: {
  27042. points: Vector3[];
  27043. dashSize?: number;
  27044. gapSize?: number;
  27045. dashNb?: number;
  27046. }): VertexData;
  27047. /**
  27048. * Creates the VertexData for a Ground
  27049. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27050. * - width the width (x direction) of the ground, optional, default 1
  27051. * - height the height (z direction) of the ground, optional, default 1
  27052. * - subdivisions the number of subdivisions per side, optional, default 1
  27053. * @returns the VertexData of the Ground
  27054. */
  27055. static CreateGround(options: {
  27056. width?: number;
  27057. height?: number;
  27058. subdivisions?: number;
  27059. subdivisionsX?: number;
  27060. subdivisionsY?: number;
  27061. }): VertexData;
  27062. /**
  27063. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27064. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27065. * * xmin the ground minimum X coordinate, optional, default -1
  27066. * * zmin the ground minimum Z coordinate, optional, default -1
  27067. * * xmax the ground maximum X coordinate, optional, default 1
  27068. * * zmax the ground maximum Z coordinate, optional, default 1
  27069. * * 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}
  27070. * * 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}
  27071. * @returns the VertexData of the TiledGround
  27072. */
  27073. static CreateTiledGround(options: {
  27074. xmin: number;
  27075. zmin: number;
  27076. xmax: number;
  27077. zmax: number;
  27078. subdivisions?: {
  27079. w: number;
  27080. h: number;
  27081. };
  27082. precision?: {
  27083. w: number;
  27084. h: number;
  27085. };
  27086. }): VertexData;
  27087. /**
  27088. * Creates the VertexData of the Ground designed from a heightmap
  27089. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27090. * * width the width (x direction) of the ground
  27091. * * height the height (z direction) of the ground
  27092. * * subdivisions the number of subdivisions per side
  27093. * * minHeight the minimum altitude on the ground, optional, default 0
  27094. * * maxHeight the maximum altitude on the ground, optional default 1
  27095. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27096. * * buffer the array holding the image color data
  27097. * * bufferWidth the width of image
  27098. * * bufferHeight the height of image
  27099. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27100. * @returns the VertexData of the Ground designed from a heightmap
  27101. */
  27102. static CreateGroundFromHeightMap(options: {
  27103. width: number;
  27104. height: number;
  27105. subdivisions: number;
  27106. minHeight: number;
  27107. maxHeight: number;
  27108. colorFilter: Color3;
  27109. buffer: Uint8Array;
  27110. bufferWidth: number;
  27111. bufferHeight: number;
  27112. alphaFilter: number;
  27113. }): VertexData;
  27114. /**
  27115. * Creates the VertexData for a Plane
  27116. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27117. * * size sets the width and height of the plane to the value of size, optional default 1
  27118. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27119. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27120. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27121. * * 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)
  27122. * * 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)
  27123. * @returns the VertexData of the box
  27124. */
  27125. static CreatePlane(options: {
  27126. size?: number;
  27127. width?: number;
  27128. height?: number;
  27129. sideOrientation?: number;
  27130. frontUVs?: Vector4;
  27131. backUVs?: Vector4;
  27132. }): VertexData;
  27133. /**
  27134. * Creates the VertexData of the Disc or regular Polygon
  27135. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27136. * * radius the radius of the disc, optional default 0.5
  27137. * * tessellation the number of polygon sides, optional, default 64
  27138. * * 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
  27139. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27140. * * 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)
  27141. * * 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)
  27142. * @returns the VertexData of the box
  27143. */
  27144. static CreateDisc(options: {
  27145. radius?: number;
  27146. tessellation?: number;
  27147. arc?: number;
  27148. sideOrientation?: number;
  27149. frontUVs?: Vector4;
  27150. backUVs?: Vector4;
  27151. }): VertexData;
  27152. /**
  27153. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27154. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27155. * @param polygon a mesh built from polygonTriangulation.build()
  27156. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27157. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27158. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27159. * @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)
  27160. * @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)
  27161. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27162. * @returns the VertexData of the Polygon
  27163. */
  27164. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27165. /**
  27166. * Creates the VertexData of the IcoSphere
  27167. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27168. * * radius the radius of the IcoSphere, optional default 1
  27169. * * radiusX allows stretching in the x direction, optional, default radius
  27170. * * radiusY allows stretching in the y direction, optional, default radius
  27171. * * radiusZ allows stretching in the z direction, optional, default radius
  27172. * * flat when true creates a flat shaded mesh, optional, default true
  27173. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27174. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27175. * * 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)
  27176. * * 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)
  27177. * @returns the VertexData of the IcoSphere
  27178. */
  27179. static CreateIcoSphere(options: {
  27180. radius?: number;
  27181. radiusX?: number;
  27182. radiusY?: number;
  27183. radiusZ?: number;
  27184. flat?: boolean;
  27185. subdivisions?: number;
  27186. sideOrientation?: number;
  27187. frontUVs?: Vector4;
  27188. backUVs?: Vector4;
  27189. }): VertexData;
  27190. /**
  27191. * Creates the VertexData for a Polyhedron
  27192. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27193. * * type provided types are:
  27194. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27195. * * 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)
  27196. * * size the size of the IcoSphere, optional default 1
  27197. * * sizeX allows stretching in the x direction, optional, default size
  27198. * * sizeY allows stretching in the y direction, optional, default size
  27199. * * sizeZ allows stretching in the z direction, optional, default size
  27200. * * 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
  27201. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27202. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27203. * * flat when true creates a flat shaded mesh, optional, default true
  27204. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27205. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27206. * * 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)
  27207. * * 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)
  27208. * @returns the VertexData of the Polyhedron
  27209. */
  27210. static CreatePolyhedron(options: {
  27211. type?: number;
  27212. size?: number;
  27213. sizeX?: number;
  27214. sizeY?: number;
  27215. sizeZ?: number;
  27216. custom?: any;
  27217. faceUV?: Vector4[];
  27218. faceColors?: Color4[];
  27219. flat?: boolean;
  27220. sideOrientation?: number;
  27221. frontUVs?: Vector4;
  27222. backUVs?: Vector4;
  27223. }): VertexData;
  27224. /**
  27225. * Creates the VertexData for a TorusKnot
  27226. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27227. * * radius the radius of the torus knot, optional, default 2
  27228. * * tube the thickness of the tube, optional, default 0.5
  27229. * * radialSegments the number of sides on each tube segments, optional, default 32
  27230. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27231. * * p the number of windings around the z axis, optional, default 2
  27232. * * q the number of windings around the x axis, optional, default 3
  27233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27234. * * 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)
  27235. * * 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)
  27236. * @returns the VertexData of the Torus Knot
  27237. */
  27238. static CreateTorusKnot(options: {
  27239. radius?: number;
  27240. tube?: number;
  27241. radialSegments?: number;
  27242. tubularSegments?: number;
  27243. p?: number;
  27244. q?: number;
  27245. sideOrientation?: number;
  27246. frontUVs?: Vector4;
  27247. backUVs?: Vector4;
  27248. }): VertexData;
  27249. /**
  27250. * Compute normals for given positions and indices
  27251. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27252. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27253. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27254. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27255. * * facetNormals : optional array of facet normals (vector3)
  27256. * * facetPositions : optional array of facet positions (vector3)
  27257. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27258. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27259. * * bInfo : optional bounding info, required for facetPartitioning computation
  27260. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27261. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27262. * * useRightHandedSystem: optional boolean to for right handed system computation
  27263. * * depthSort : optional boolean to enable the facet depth sort computation
  27264. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27265. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27266. */
  27267. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27268. facetNormals?: any;
  27269. facetPositions?: any;
  27270. facetPartitioning?: any;
  27271. ratio?: number;
  27272. bInfo?: any;
  27273. bbSize?: Vector3;
  27274. subDiv?: any;
  27275. useRightHandedSystem?: boolean;
  27276. depthSort?: boolean;
  27277. distanceTo?: Vector3;
  27278. depthSortedFacets?: any;
  27279. }): void;
  27280. /** @hidden */
  27281. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27282. /**
  27283. * Applies VertexData created from the imported parameters to the geometry
  27284. * @param parsedVertexData the parsed data from an imported file
  27285. * @param geometry the geometry to apply the VertexData to
  27286. */
  27287. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27288. }
  27289. }
  27290. declare module "babylonjs/Morph/morphTarget" {
  27291. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27292. import { Observable } from "babylonjs/Misc/observable";
  27293. import { Nullable, FloatArray } from "babylonjs/types";
  27294. import { Scene } from "babylonjs/scene";
  27295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27296. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27297. /**
  27298. * Defines a target to use with MorphTargetManager
  27299. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27300. */
  27301. export class MorphTarget implements IAnimatable {
  27302. /** defines the name of the target */
  27303. name: string;
  27304. /**
  27305. * Gets or sets the list of animations
  27306. */
  27307. animations: import("babylonjs/Animations/animation").Animation[];
  27308. private _scene;
  27309. private _positions;
  27310. private _normals;
  27311. private _tangents;
  27312. private _uvs;
  27313. private _influence;
  27314. private _uniqueId;
  27315. /**
  27316. * Observable raised when the influence changes
  27317. */
  27318. onInfluenceChanged: Observable<boolean>;
  27319. /** @hidden */
  27320. _onDataLayoutChanged: Observable<void>;
  27321. /**
  27322. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27323. */
  27324. get influence(): number;
  27325. set influence(influence: number);
  27326. /**
  27327. * Gets or sets the id of the morph Target
  27328. */
  27329. id: string;
  27330. private _animationPropertiesOverride;
  27331. /**
  27332. * Gets or sets the animation properties override
  27333. */
  27334. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27335. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27336. /**
  27337. * Creates a new MorphTarget
  27338. * @param name defines the name of the target
  27339. * @param influence defines the influence to use
  27340. * @param scene defines the scene the morphtarget belongs to
  27341. */
  27342. constructor(
  27343. /** defines the name of the target */
  27344. name: string, influence?: number, scene?: Nullable<Scene>);
  27345. /**
  27346. * Gets the unique ID of this manager
  27347. */
  27348. get uniqueId(): number;
  27349. /**
  27350. * Gets a boolean defining if the target contains position data
  27351. */
  27352. get hasPositions(): boolean;
  27353. /**
  27354. * Gets a boolean defining if the target contains normal data
  27355. */
  27356. get hasNormals(): boolean;
  27357. /**
  27358. * Gets a boolean defining if the target contains tangent data
  27359. */
  27360. get hasTangents(): boolean;
  27361. /**
  27362. * Gets a boolean defining if the target contains texture coordinates data
  27363. */
  27364. get hasUVs(): boolean;
  27365. /**
  27366. * Affects position data to this target
  27367. * @param data defines the position data to use
  27368. */
  27369. setPositions(data: Nullable<FloatArray>): void;
  27370. /**
  27371. * Gets the position data stored in this target
  27372. * @returns a FloatArray containing the position data (or null if not present)
  27373. */
  27374. getPositions(): Nullable<FloatArray>;
  27375. /**
  27376. * Affects normal data to this target
  27377. * @param data defines the normal data to use
  27378. */
  27379. setNormals(data: Nullable<FloatArray>): void;
  27380. /**
  27381. * Gets the normal data stored in this target
  27382. * @returns a FloatArray containing the normal data (or null if not present)
  27383. */
  27384. getNormals(): Nullable<FloatArray>;
  27385. /**
  27386. * Affects tangent data to this target
  27387. * @param data defines the tangent data to use
  27388. */
  27389. setTangents(data: Nullable<FloatArray>): void;
  27390. /**
  27391. * Gets the tangent data stored in this target
  27392. * @returns a FloatArray containing the tangent data (or null if not present)
  27393. */
  27394. getTangents(): Nullable<FloatArray>;
  27395. /**
  27396. * Affects texture coordinates data to this target
  27397. * @param data defines the texture coordinates data to use
  27398. */
  27399. setUVs(data: Nullable<FloatArray>): void;
  27400. /**
  27401. * Gets the texture coordinates data stored in this target
  27402. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27403. */
  27404. getUVs(): Nullable<FloatArray>;
  27405. /**
  27406. * Clone the current target
  27407. * @returns a new MorphTarget
  27408. */
  27409. clone(): MorphTarget;
  27410. /**
  27411. * Serializes the current target into a Serialization object
  27412. * @returns the serialized object
  27413. */
  27414. serialize(): any;
  27415. /**
  27416. * Returns the string "MorphTarget"
  27417. * @returns "MorphTarget"
  27418. */
  27419. getClassName(): string;
  27420. /**
  27421. * Creates a new target from serialized data
  27422. * @param serializationObject defines the serialized data to use
  27423. * @returns a new MorphTarget
  27424. */
  27425. static Parse(serializationObject: any): MorphTarget;
  27426. /**
  27427. * Creates a MorphTarget from mesh data
  27428. * @param mesh defines the source mesh
  27429. * @param name defines the name to use for the new target
  27430. * @param influence defines the influence to attach to the target
  27431. * @returns a new MorphTarget
  27432. */
  27433. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27434. }
  27435. }
  27436. declare module "babylonjs/Morph/morphTargetManager" {
  27437. import { Nullable } from "babylonjs/types";
  27438. import { Scene } from "babylonjs/scene";
  27439. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27440. /**
  27441. * This class is used to deform meshes using morphing between different targets
  27442. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27443. */
  27444. export class MorphTargetManager {
  27445. private _targets;
  27446. private _targetInfluenceChangedObservers;
  27447. private _targetDataLayoutChangedObservers;
  27448. private _activeTargets;
  27449. private _scene;
  27450. private _influences;
  27451. private _supportsNormals;
  27452. private _supportsTangents;
  27453. private _supportsUVs;
  27454. private _vertexCount;
  27455. private _uniqueId;
  27456. private _tempInfluences;
  27457. /**
  27458. * Gets or sets a boolean indicating if normals must be morphed
  27459. */
  27460. enableNormalMorphing: boolean;
  27461. /**
  27462. * Gets or sets a boolean indicating if tangents must be morphed
  27463. */
  27464. enableTangentMorphing: boolean;
  27465. /**
  27466. * Gets or sets a boolean indicating if UV must be morphed
  27467. */
  27468. enableUVMorphing: boolean;
  27469. /**
  27470. * Creates a new MorphTargetManager
  27471. * @param scene defines the current scene
  27472. */
  27473. constructor(scene?: Nullable<Scene>);
  27474. /**
  27475. * Gets the unique ID of this manager
  27476. */
  27477. get uniqueId(): number;
  27478. /**
  27479. * Gets the number of vertices handled by this manager
  27480. */
  27481. get vertexCount(): number;
  27482. /**
  27483. * Gets a boolean indicating if this manager supports morphing of normals
  27484. */
  27485. get supportsNormals(): boolean;
  27486. /**
  27487. * Gets a boolean indicating if this manager supports morphing of tangents
  27488. */
  27489. get supportsTangents(): boolean;
  27490. /**
  27491. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27492. */
  27493. get supportsUVs(): boolean;
  27494. /**
  27495. * Gets the number of targets stored in this manager
  27496. */
  27497. get numTargets(): number;
  27498. /**
  27499. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27500. */
  27501. get numInfluencers(): number;
  27502. /**
  27503. * Gets the list of influences (one per target)
  27504. */
  27505. get influences(): Float32Array;
  27506. /**
  27507. * Gets the active target at specified index. An active target is a target with an influence > 0
  27508. * @param index defines the index to check
  27509. * @returns the requested target
  27510. */
  27511. getActiveTarget(index: number): MorphTarget;
  27512. /**
  27513. * Gets the target at specified index
  27514. * @param index defines the index to check
  27515. * @returns the requested target
  27516. */
  27517. getTarget(index: number): MorphTarget;
  27518. /**
  27519. * Add a new target to this manager
  27520. * @param target defines the target to add
  27521. */
  27522. addTarget(target: MorphTarget): void;
  27523. /**
  27524. * Removes a target from the manager
  27525. * @param target defines the target to remove
  27526. */
  27527. removeTarget(target: MorphTarget): void;
  27528. /**
  27529. * Clone the current manager
  27530. * @returns a new MorphTargetManager
  27531. */
  27532. clone(): MorphTargetManager;
  27533. /**
  27534. * Serializes the current manager into a Serialization object
  27535. * @returns the serialized object
  27536. */
  27537. serialize(): any;
  27538. private _syncActiveTargets;
  27539. /**
  27540. * Syncrhonize the targets with all the meshes using this morph target manager
  27541. */
  27542. synchronize(): void;
  27543. /**
  27544. * Creates a new MorphTargetManager from serialized data
  27545. * @param serializationObject defines the serialized data
  27546. * @param scene defines the hosting scene
  27547. * @returns the new MorphTargetManager
  27548. */
  27549. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27550. }
  27551. }
  27552. declare module "babylonjs/Meshes/meshLODLevel" {
  27553. import { Mesh } from "babylonjs/Meshes/mesh";
  27554. import { Nullable } from "babylonjs/types";
  27555. /**
  27556. * Class used to represent a specific level of detail of a mesh
  27557. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27558. */
  27559. export class MeshLODLevel {
  27560. /** Defines the distance where this level should start being displayed */
  27561. distance: number;
  27562. /** Defines the mesh to use to render this level */
  27563. mesh: Nullable<Mesh>;
  27564. /**
  27565. * Creates a new LOD level
  27566. * @param distance defines the distance where this level should star being displayed
  27567. * @param mesh defines the mesh to use to render this level
  27568. */
  27569. constructor(
  27570. /** Defines the distance where this level should start being displayed */
  27571. distance: number,
  27572. /** Defines the mesh to use to render this level */
  27573. mesh: Nullable<Mesh>);
  27574. }
  27575. }
  27576. declare module "babylonjs/Misc/canvasGenerator" {
  27577. /**
  27578. * Helper class used to generate a canvas to manipulate images
  27579. */
  27580. export class CanvasGenerator {
  27581. /**
  27582. * Create a new canvas (or offscreen canvas depending on the context)
  27583. * @param width defines the expected width
  27584. * @param height defines the expected height
  27585. * @return a new canvas or offscreen canvas
  27586. */
  27587. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27588. }
  27589. }
  27590. declare module "babylonjs/Meshes/groundMesh" {
  27591. import { Scene } from "babylonjs/scene";
  27592. import { Vector3 } from "babylonjs/Maths/math.vector";
  27593. import { Mesh } from "babylonjs/Meshes/mesh";
  27594. /**
  27595. * Mesh representing the gorund
  27596. */
  27597. export class GroundMesh extends Mesh {
  27598. /** If octree should be generated */
  27599. generateOctree: boolean;
  27600. private _heightQuads;
  27601. /** @hidden */
  27602. _subdivisionsX: number;
  27603. /** @hidden */
  27604. _subdivisionsY: number;
  27605. /** @hidden */
  27606. _width: number;
  27607. /** @hidden */
  27608. _height: number;
  27609. /** @hidden */
  27610. _minX: number;
  27611. /** @hidden */
  27612. _maxX: number;
  27613. /** @hidden */
  27614. _minZ: number;
  27615. /** @hidden */
  27616. _maxZ: number;
  27617. constructor(name: string, scene: Scene);
  27618. /**
  27619. * "GroundMesh"
  27620. * @returns "GroundMesh"
  27621. */
  27622. getClassName(): string;
  27623. /**
  27624. * The minimum of x and y subdivisions
  27625. */
  27626. get subdivisions(): number;
  27627. /**
  27628. * X subdivisions
  27629. */
  27630. get subdivisionsX(): number;
  27631. /**
  27632. * Y subdivisions
  27633. */
  27634. get subdivisionsY(): number;
  27635. /**
  27636. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27637. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27638. * @param chunksCount the number of subdivisions for x and y
  27639. * @param octreeBlocksSize (Default: 32)
  27640. */
  27641. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27642. /**
  27643. * Returns a height (y) value in the Worl system :
  27644. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27645. * @param x x coordinate
  27646. * @param z z coordinate
  27647. * @returns the ground y position if (x, z) are outside the ground surface.
  27648. */
  27649. getHeightAtCoordinates(x: number, z: number): number;
  27650. /**
  27651. * Returns a normalized vector (Vector3) orthogonal to the ground
  27652. * at the ground coordinates (x, z) expressed in the World system.
  27653. * @param x x coordinate
  27654. * @param z z coordinate
  27655. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27656. */
  27657. getNormalAtCoordinates(x: number, z: number): Vector3;
  27658. /**
  27659. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27660. * at the ground coordinates (x, z) expressed in the World system.
  27661. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27662. * @param x x coordinate
  27663. * @param z z coordinate
  27664. * @param ref vector to store the result
  27665. * @returns the GroundMesh.
  27666. */
  27667. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27668. /**
  27669. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27670. * if the ground has been updated.
  27671. * This can be used in the render loop.
  27672. * @returns the GroundMesh.
  27673. */
  27674. updateCoordinateHeights(): GroundMesh;
  27675. private _getFacetAt;
  27676. private _initHeightQuads;
  27677. private _computeHeightQuads;
  27678. /**
  27679. * Serializes this ground mesh
  27680. * @param serializationObject object to write serialization to
  27681. */
  27682. serialize(serializationObject: any): void;
  27683. /**
  27684. * Parses a serialized ground mesh
  27685. * @param parsedMesh the serialized mesh
  27686. * @param scene the scene to create the ground mesh in
  27687. * @returns the created ground mesh
  27688. */
  27689. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27690. }
  27691. }
  27692. declare module "babylonjs/Physics/physicsJoint" {
  27693. import { Vector3 } from "babylonjs/Maths/math.vector";
  27694. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27695. /**
  27696. * Interface for Physics-Joint data
  27697. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27698. */
  27699. export interface PhysicsJointData {
  27700. /**
  27701. * The main pivot of the joint
  27702. */
  27703. mainPivot?: Vector3;
  27704. /**
  27705. * The connected pivot of the joint
  27706. */
  27707. connectedPivot?: Vector3;
  27708. /**
  27709. * The main axis of the joint
  27710. */
  27711. mainAxis?: Vector3;
  27712. /**
  27713. * The connected axis of the joint
  27714. */
  27715. connectedAxis?: Vector3;
  27716. /**
  27717. * The collision of the joint
  27718. */
  27719. collision?: boolean;
  27720. /**
  27721. * Native Oimo/Cannon/Energy data
  27722. */
  27723. nativeParams?: any;
  27724. }
  27725. /**
  27726. * This is a holder class for the physics joint created by the physics plugin
  27727. * It holds a set of functions to control the underlying joint
  27728. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27729. */
  27730. export class PhysicsJoint {
  27731. /**
  27732. * The type of the physics joint
  27733. */
  27734. type: number;
  27735. /**
  27736. * The data for the physics joint
  27737. */
  27738. jointData: PhysicsJointData;
  27739. private _physicsJoint;
  27740. protected _physicsPlugin: IPhysicsEnginePlugin;
  27741. /**
  27742. * Initializes the physics joint
  27743. * @param type The type of the physics joint
  27744. * @param jointData The data for the physics joint
  27745. */
  27746. constructor(
  27747. /**
  27748. * The type of the physics joint
  27749. */
  27750. type: number,
  27751. /**
  27752. * The data for the physics joint
  27753. */
  27754. jointData: PhysicsJointData);
  27755. /**
  27756. * Gets the physics joint
  27757. */
  27758. get physicsJoint(): any;
  27759. /**
  27760. * Sets the physics joint
  27761. */
  27762. set physicsJoint(newJoint: any);
  27763. /**
  27764. * Sets the physics plugin
  27765. */
  27766. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27767. /**
  27768. * Execute a function that is physics-plugin specific.
  27769. * @param {Function} func the function that will be executed.
  27770. * It accepts two parameters: the physics world and the physics joint
  27771. */
  27772. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27773. /**
  27774. * Distance-Joint type
  27775. */
  27776. static DistanceJoint: number;
  27777. /**
  27778. * Hinge-Joint type
  27779. */
  27780. static HingeJoint: number;
  27781. /**
  27782. * Ball-and-Socket joint type
  27783. */
  27784. static BallAndSocketJoint: number;
  27785. /**
  27786. * Wheel-Joint type
  27787. */
  27788. static WheelJoint: number;
  27789. /**
  27790. * Slider-Joint type
  27791. */
  27792. static SliderJoint: number;
  27793. /**
  27794. * Prismatic-Joint type
  27795. */
  27796. static PrismaticJoint: number;
  27797. /**
  27798. * Universal-Joint type
  27799. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27800. */
  27801. static UniversalJoint: number;
  27802. /**
  27803. * Hinge-Joint 2 type
  27804. */
  27805. static Hinge2Joint: number;
  27806. /**
  27807. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27808. */
  27809. static PointToPointJoint: number;
  27810. /**
  27811. * Spring-Joint type
  27812. */
  27813. static SpringJoint: number;
  27814. /**
  27815. * Lock-Joint type
  27816. */
  27817. static LockJoint: number;
  27818. }
  27819. /**
  27820. * A class representing a physics distance joint
  27821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27822. */
  27823. export class DistanceJoint extends PhysicsJoint {
  27824. /**
  27825. *
  27826. * @param jointData The data for the Distance-Joint
  27827. */
  27828. constructor(jointData: DistanceJointData);
  27829. /**
  27830. * Update the predefined distance.
  27831. * @param maxDistance The maximum preferred distance
  27832. * @param minDistance The minimum preferred distance
  27833. */
  27834. updateDistance(maxDistance: number, minDistance?: number): void;
  27835. }
  27836. /**
  27837. * Represents a Motor-Enabled Joint
  27838. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27839. */
  27840. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27841. /**
  27842. * Initializes the Motor-Enabled Joint
  27843. * @param type The type of the joint
  27844. * @param jointData The physica joint data for the joint
  27845. */
  27846. constructor(type: number, jointData: PhysicsJointData);
  27847. /**
  27848. * Set the motor values.
  27849. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27850. * @param force the force to apply
  27851. * @param maxForce max force for this motor.
  27852. */
  27853. setMotor(force?: number, maxForce?: number): void;
  27854. /**
  27855. * Set the motor's limits.
  27856. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27857. * @param upperLimit The upper limit of the motor
  27858. * @param lowerLimit The lower limit of the motor
  27859. */
  27860. setLimit(upperLimit: number, lowerLimit?: number): void;
  27861. }
  27862. /**
  27863. * This class represents a single physics Hinge-Joint
  27864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27865. */
  27866. export class HingeJoint extends MotorEnabledJoint {
  27867. /**
  27868. * Initializes the Hinge-Joint
  27869. * @param jointData The joint data for the Hinge-Joint
  27870. */
  27871. constructor(jointData: PhysicsJointData);
  27872. /**
  27873. * Set the motor values.
  27874. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27875. * @param {number} force the force to apply
  27876. * @param {number} maxForce max force for this motor.
  27877. */
  27878. setMotor(force?: number, maxForce?: number): void;
  27879. /**
  27880. * Set the motor's limits.
  27881. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27882. * @param upperLimit The upper limit of the motor
  27883. * @param lowerLimit The lower limit of the motor
  27884. */
  27885. setLimit(upperLimit: number, lowerLimit?: number): void;
  27886. }
  27887. /**
  27888. * This class represents a dual hinge physics joint (same as wheel joint)
  27889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27890. */
  27891. export class Hinge2Joint extends MotorEnabledJoint {
  27892. /**
  27893. * Initializes the Hinge2-Joint
  27894. * @param jointData The joint data for the Hinge2-Joint
  27895. */
  27896. constructor(jointData: PhysicsJointData);
  27897. /**
  27898. * Set the motor values.
  27899. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27900. * @param {number} targetSpeed the speed the motor is to reach
  27901. * @param {number} maxForce max force for this motor.
  27902. * @param {motorIndex} the motor's index, 0 or 1.
  27903. */
  27904. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27905. /**
  27906. * Set the motor limits.
  27907. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27908. * @param {number} upperLimit the upper limit
  27909. * @param {number} lowerLimit lower limit
  27910. * @param {motorIndex} the motor's index, 0 or 1.
  27911. */
  27912. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27913. }
  27914. /**
  27915. * Interface for a motor enabled joint
  27916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27917. */
  27918. export interface IMotorEnabledJoint {
  27919. /**
  27920. * Physics joint
  27921. */
  27922. physicsJoint: any;
  27923. /**
  27924. * Sets the motor of the motor-enabled joint
  27925. * @param force The force of the motor
  27926. * @param maxForce The maximum force of the motor
  27927. * @param motorIndex The index of the motor
  27928. */
  27929. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27930. /**
  27931. * Sets the limit of the motor
  27932. * @param upperLimit The upper limit of the motor
  27933. * @param lowerLimit The lower limit of the motor
  27934. * @param motorIndex The index of the motor
  27935. */
  27936. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27937. }
  27938. /**
  27939. * Joint data for a Distance-Joint
  27940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27941. */
  27942. export interface DistanceJointData extends PhysicsJointData {
  27943. /**
  27944. * Max distance the 2 joint objects can be apart
  27945. */
  27946. maxDistance: number;
  27947. }
  27948. /**
  27949. * Joint data from a spring joint
  27950. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27951. */
  27952. export interface SpringJointData extends PhysicsJointData {
  27953. /**
  27954. * Length of the spring
  27955. */
  27956. length: number;
  27957. /**
  27958. * Stiffness of the spring
  27959. */
  27960. stiffness: number;
  27961. /**
  27962. * Damping of the spring
  27963. */
  27964. damping: number;
  27965. /** this callback will be called when applying the force to the impostors. */
  27966. forceApplicationCallback: () => void;
  27967. }
  27968. }
  27969. declare module "babylonjs/Physics/physicsRaycastResult" {
  27970. import { Vector3 } from "babylonjs/Maths/math.vector";
  27971. /**
  27972. * Holds the data for the raycast result
  27973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27974. */
  27975. export class PhysicsRaycastResult {
  27976. private _hasHit;
  27977. private _hitDistance;
  27978. private _hitNormalWorld;
  27979. private _hitPointWorld;
  27980. private _rayFromWorld;
  27981. private _rayToWorld;
  27982. /**
  27983. * Gets if there was a hit
  27984. */
  27985. get hasHit(): boolean;
  27986. /**
  27987. * Gets the distance from the hit
  27988. */
  27989. get hitDistance(): number;
  27990. /**
  27991. * Gets the hit normal/direction in the world
  27992. */
  27993. get hitNormalWorld(): Vector3;
  27994. /**
  27995. * Gets the hit point in the world
  27996. */
  27997. get hitPointWorld(): Vector3;
  27998. /**
  27999. * Gets the ray "start point" of the ray in the world
  28000. */
  28001. get rayFromWorld(): Vector3;
  28002. /**
  28003. * Gets the ray "end point" of the ray in the world
  28004. */
  28005. get rayToWorld(): Vector3;
  28006. /**
  28007. * Sets the hit data (normal & point in world space)
  28008. * @param hitNormalWorld defines the normal in world space
  28009. * @param hitPointWorld defines the point in world space
  28010. */
  28011. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28012. /**
  28013. * Sets the distance from the start point to the hit point
  28014. * @param distance
  28015. */
  28016. setHitDistance(distance: number): void;
  28017. /**
  28018. * Calculates the distance manually
  28019. */
  28020. calculateHitDistance(): void;
  28021. /**
  28022. * Resets all the values to default
  28023. * @param from The from point on world space
  28024. * @param to The to point on world space
  28025. */
  28026. reset(from?: Vector3, to?: Vector3): void;
  28027. }
  28028. /**
  28029. * Interface for the size containing width and height
  28030. */
  28031. interface IXYZ {
  28032. /**
  28033. * X
  28034. */
  28035. x: number;
  28036. /**
  28037. * Y
  28038. */
  28039. y: number;
  28040. /**
  28041. * Z
  28042. */
  28043. z: number;
  28044. }
  28045. }
  28046. declare module "babylonjs/Physics/IPhysicsEngine" {
  28047. import { Nullable } from "babylonjs/types";
  28048. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28050. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28051. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28052. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28053. /**
  28054. * Interface used to describe a physics joint
  28055. */
  28056. export interface PhysicsImpostorJoint {
  28057. /** Defines the main impostor to which the joint is linked */
  28058. mainImpostor: PhysicsImpostor;
  28059. /** Defines the impostor that is connected to the main impostor using this joint */
  28060. connectedImpostor: PhysicsImpostor;
  28061. /** Defines the joint itself */
  28062. joint: PhysicsJoint;
  28063. }
  28064. /** @hidden */
  28065. export interface IPhysicsEnginePlugin {
  28066. world: any;
  28067. name: string;
  28068. setGravity(gravity: Vector3): void;
  28069. setTimeStep(timeStep: number): void;
  28070. getTimeStep(): number;
  28071. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28072. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28073. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28074. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28075. removePhysicsBody(impostor: PhysicsImpostor): void;
  28076. generateJoint(joint: PhysicsImpostorJoint): void;
  28077. removeJoint(joint: PhysicsImpostorJoint): void;
  28078. isSupported(): boolean;
  28079. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28080. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28081. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28082. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28083. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28084. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28085. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28086. getBodyMass(impostor: PhysicsImpostor): number;
  28087. getBodyFriction(impostor: PhysicsImpostor): number;
  28088. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28089. getBodyRestitution(impostor: PhysicsImpostor): number;
  28090. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28091. getBodyPressure?(impostor: PhysicsImpostor): number;
  28092. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28093. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28094. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28095. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28096. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28097. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28098. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28099. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28100. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28101. sleepBody(impostor: PhysicsImpostor): void;
  28102. wakeUpBody(impostor: PhysicsImpostor): void;
  28103. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28104. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28105. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28106. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28107. getRadius(impostor: PhysicsImpostor): number;
  28108. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28109. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28110. dispose(): void;
  28111. }
  28112. /**
  28113. * Interface used to define a physics engine
  28114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28115. */
  28116. export interface IPhysicsEngine {
  28117. /**
  28118. * Gets the gravity vector used by the simulation
  28119. */
  28120. gravity: Vector3;
  28121. /**
  28122. * Sets the gravity vector used by the simulation
  28123. * @param gravity defines the gravity vector to use
  28124. */
  28125. setGravity(gravity: Vector3): void;
  28126. /**
  28127. * Set the time step of the physics engine.
  28128. * Default is 1/60.
  28129. * To slow it down, enter 1/600 for example.
  28130. * To speed it up, 1/30
  28131. * @param newTimeStep the new timestep to apply to this world.
  28132. */
  28133. setTimeStep(newTimeStep: number): void;
  28134. /**
  28135. * Get the time step of the physics engine.
  28136. * @returns the current time step
  28137. */
  28138. getTimeStep(): number;
  28139. /**
  28140. * Set the sub time step of the physics engine.
  28141. * Default is 0 meaning there is no sub steps
  28142. * To increase physics resolution precision, set a small value (like 1 ms)
  28143. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28144. */
  28145. setSubTimeStep(subTimeStep: number): void;
  28146. /**
  28147. * Get the sub time step of the physics engine.
  28148. * @returns the current sub time step
  28149. */
  28150. getSubTimeStep(): number;
  28151. /**
  28152. * Release all resources
  28153. */
  28154. dispose(): void;
  28155. /**
  28156. * Gets the name of the current physics plugin
  28157. * @returns the name of the plugin
  28158. */
  28159. getPhysicsPluginName(): string;
  28160. /**
  28161. * Adding a new impostor for the impostor tracking.
  28162. * This will be done by the impostor itself.
  28163. * @param impostor the impostor to add
  28164. */
  28165. addImpostor(impostor: PhysicsImpostor): void;
  28166. /**
  28167. * Remove an impostor from the engine.
  28168. * This impostor and its mesh will not longer be updated by the physics engine.
  28169. * @param impostor the impostor to remove
  28170. */
  28171. removeImpostor(impostor: PhysicsImpostor): void;
  28172. /**
  28173. * Add a joint to the physics engine
  28174. * @param mainImpostor defines the main impostor to which the joint is added.
  28175. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28176. * @param joint defines the joint that will connect both impostors.
  28177. */
  28178. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28179. /**
  28180. * Removes a joint from the simulation
  28181. * @param mainImpostor defines the impostor used with the joint
  28182. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28183. * @param joint defines the joint to remove
  28184. */
  28185. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28186. /**
  28187. * Gets the current plugin used to run the simulation
  28188. * @returns current plugin
  28189. */
  28190. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28191. /**
  28192. * Gets the list of physic impostors
  28193. * @returns an array of PhysicsImpostor
  28194. */
  28195. getImpostors(): Array<PhysicsImpostor>;
  28196. /**
  28197. * Gets the impostor for a physics enabled object
  28198. * @param object defines the object impersonated by the impostor
  28199. * @returns the PhysicsImpostor or null if not found
  28200. */
  28201. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28202. /**
  28203. * Gets the impostor for a physics body object
  28204. * @param body defines physics body used by the impostor
  28205. * @returns the PhysicsImpostor or null if not found
  28206. */
  28207. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28208. /**
  28209. * Does a raycast in the physics world
  28210. * @param from when should the ray start?
  28211. * @param to when should the ray end?
  28212. * @returns PhysicsRaycastResult
  28213. */
  28214. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28215. /**
  28216. * Called by the scene. No need to call it.
  28217. * @param delta defines the timespam between frames
  28218. */
  28219. _step(delta: number): void;
  28220. }
  28221. }
  28222. declare module "babylonjs/Physics/physicsImpostor" {
  28223. import { Nullable, IndicesArray } from "babylonjs/types";
  28224. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28225. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28227. import { Scene } from "babylonjs/scene";
  28228. import { Bone } from "babylonjs/Bones/bone";
  28229. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28230. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28231. import { Space } from "babylonjs/Maths/math.axis";
  28232. /**
  28233. * The interface for the physics imposter parameters
  28234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28235. */
  28236. export interface PhysicsImpostorParameters {
  28237. /**
  28238. * The mass of the physics imposter
  28239. */
  28240. mass: number;
  28241. /**
  28242. * The friction of the physics imposter
  28243. */
  28244. friction?: number;
  28245. /**
  28246. * The coefficient of restitution of the physics imposter
  28247. */
  28248. restitution?: number;
  28249. /**
  28250. * The native options of the physics imposter
  28251. */
  28252. nativeOptions?: any;
  28253. /**
  28254. * Specifies if the parent should be ignored
  28255. */
  28256. ignoreParent?: boolean;
  28257. /**
  28258. * Specifies if bi-directional transformations should be disabled
  28259. */
  28260. disableBidirectionalTransformation?: boolean;
  28261. /**
  28262. * The pressure inside the physics imposter, soft object only
  28263. */
  28264. pressure?: number;
  28265. /**
  28266. * The stiffness the physics imposter, soft object only
  28267. */
  28268. stiffness?: number;
  28269. /**
  28270. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28271. */
  28272. velocityIterations?: number;
  28273. /**
  28274. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28275. */
  28276. positionIterations?: number;
  28277. /**
  28278. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28279. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28280. * Add to fix multiple points
  28281. */
  28282. fixedPoints?: number;
  28283. /**
  28284. * The collision margin around a soft object
  28285. */
  28286. margin?: number;
  28287. /**
  28288. * The collision margin around a soft object
  28289. */
  28290. damping?: number;
  28291. /**
  28292. * The path for a rope based on an extrusion
  28293. */
  28294. path?: any;
  28295. /**
  28296. * The shape of an extrusion used for a rope based on an extrusion
  28297. */
  28298. shape?: any;
  28299. }
  28300. /**
  28301. * Interface for a physics-enabled object
  28302. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28303. */
  28304. export interface IPhysicsEnabledObject {
  28305. /**
  28306. * The position of the physics-enabled object
  28307. */
  28308. position: Vector3;
  28309. /**
  28310. * The rotation of the physics-enabled object
  28311. */
  28312. rotationQuaternion: Nullable<Quaternion>;
  28313. /**
  28314. * The scale of the physics-enabled object
  28315. */
  28316. scaling: Vector3;
  28317. /**
  28318. * The rotation of the physics-enabled object
  28319. */
  28320. rotation?: Vector3;
  28321. /**
  28322. * The parent of the physics-enabled object
  28323. */
  28324. parent?: any;
  28325. /**
  28326. * The bounding info of the physics-enabled object
  28327. * @returns The bounding info of the physics-enabled object
  28328. */
  28329. getBoundingInfo(): BoundingInfo;
  28330. /**
  28331. * Computes the world matrix
  28332. * @param force Specifies if the world matrix should be computed by force
  28333. * @returns A world matrix
  28334. */
  28335. computeWorldMatrix(force: boolean): Matrix;
  28336. /**
  28337. * Gets the world matrix
  28338. * @returns A world matrix
  28339. */
  28340. getWorldMatrix?(): Matrix;
  28341. /**
  28342. * Gets the child meshes
  28343. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28344. * @returns An array of abstract meshes
  28345. */
  28346. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28347. /**
  28348. * Gets the vertex data
  28349. * @param kind The type of vertex data
  28350. * @returns A nullable array of numbers, or a float32 array
  28351. */
  28352. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28353. /**
  28354. * Gets the indices from the mesh
  28355. * @returns A nullable array of index arrays
  28356. */
  28357. getIndices?(): Nullable<IndicesArray>;
  28358. /**
  28359. * Gets the scene from the mesh
  28360. * @returns the indices array or null
  28361. */
  28362. getScene?(): Scene;
  28363. /**
  28364. * Gets the absolute position from the mesh
  28365. * @returns the absolute position
  28366. */
  28367. getAbsolutePosition(): Vector3;
  28368. /**
  28369. * Gets the absolute pivot point from the mesh
  28370. * @returns the absolute pivot point
  28371. */
  28372. getAbsolutePivotPoint(): Vector3;
  28373. /**
  28374. * Rotates the mesh
  28375. * @param axis The axis of rotation
  28376. * @param amount The amount of rotation
  28377. * @param space The space of the rotation
  28378. * @returns The rotation transform node
  28379. */
  28380. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28381. /**
  28382. * Translates the mesh
  28383. * @param axis The axis of translation
  28384. * @param distance The distance of translation
  28385. * @param space The space of the translation
  28386. * @returns The transform node
  28387. */
  28388. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28389. /**
  28390. * Sets the absolute position of the mesh
  28391. * @param absolutePosition The absolute position of the mesh
  28392. * @returns The transform node
  28393. */
  28394. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28395. /**
  28396. * Gets the class name of the mesh
  28397. * @returns The class name
  28398. */
  28399. getClassName(): string;
  28400. }
  28401. /**
  28402. * Represents a physics imposter
  28403. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28404. */
  28405. export class PhysicsImpostor {
  28406. /**
  28407. * The physics-enabled object used as the physics imposter
  28408. */
  28409. object: IPhysicsEnabledObject;
  28410. /**
  28411. * The type of the physics imposter
  28412. */
  28413. type: number;
  28414. private _options;
  28415. private _scene?;
  28416. /**
  28417. * The default object size of the imposter
  28418. */
  28419. static DEFAULT_OBJECT_SIZE: Vector3;
  28420. /**
  28421. * The identity quaternion of the imposter
  28422. */
  28423. static IDENTITY_QUATERNION: Quaternion;
  28424. /** @hidden */
  28425. _pluginData: any;
  28426. private _physicsEngine;
  28427. private _physicsBody;
  28428. private _bodyUpdateRequired;
  28429. private _onBeforePhysicsStepCallbacks;
  28430. private _onAfterPhysicsStepCallbacks;
  28431. /** @hidden */
  28432. _onPhysicsCollideCallbacks: Array<{
  28433. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28434. otherImpostors: Array<PhysicsImpostor>;
  28435. }>;
  28436. private _deltaPosition;
  28437. private _deltaRotation;
  28438. private _deltaRotationConjugated;
  28439. /** @hidden */
  28440. _isFromLine: boolean;
  28441. private _parent;
  28442. private _isDisposed;
  28443. private static _tmpVecs;
  28444. private static _tmpQuat;
  28445. /**
  28446. * Specifies if the physics imposter is disposed
  28447. */
  28448. get isDisposed(): boolean;
  28449. /**
  28450. * Gets the mass of the physics imposter
  28451. */
  28452. get mass(): number;
  28453. set mass(value: number);
  28454. /**
  28455. * Gets the coefficient of friction
  28456. */
  28457. get friction(): number;
  28458. /**
  28459. * Sets the coefficient of friction
  28460. */
  28461. set friction(value: number);
  28462. /**
  28463. * Gets the coefficient of restitution
  28464. */
  28465. get restitution(): number;
  28466. /**
  28467. * Sets the coefficient of restitution
  28468. */
  28469. set restitution(value: number);
  28470. /**
  28471. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28472. */
  28473. get pressure(): number;
  28474. /**
  28475. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28476. */
  28477. set pressure(value: number);
  28478. /**
  28479. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28480. */
  28481. get stiffness(): number;
  28482. /**
  28483. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28484. */
  28485. set stiffness(value: number);
  28486. /**
  28487. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28488. */
  28489. get velocityIterations(): number;
  28490. /**
  28491. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28492. */
  28493. set velocityIterations(value: number);
  28494. /**
  28495. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28496. */
  28497. get positionIterations(): number;
  28498. /**
  28499. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28500. */
  28501. set positionIterations(value: number);
  28502. /**
  28503. * The unique id of the physics imposter
  28504. * set by the physics engine when adding this impostor to the array
  28505. */
  28506. uniqueId: number;
  28507. /**
  28508. * @hidden
  28509. */
  28510. soft: boolean;
  28511. /**
  28512. * @hidden
  28513. */
  28514. segments: number;
  28515. private _joints;
  28516. /**
  28517. * Initializes the physics imposter
  28518. * @param object The physics-enabled object used as the physics imposter
  28519. * @param type The type of the physics imposter
  28520. * @param _options The options for the physics imposter
  28521. * @param _scene The Babylon scene
  28522. */
  28523. constructor(
  28524. /**
  28525. * The physics-enabled object used as the physics imposter
  28526. */
  28527. object: IPhysicsEnabledObject,
  28528. /**
  28529. * The type of the physics imposter
  28530. */
  28531. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28532. /**
  28533. * This function will completly initialize this impostor.
  28534. * It will create a new body - but only if this mesh has no parent.
  28535. * If it has, this impostor will not be used other than to define the impostor
  28536. * of the child mesh.
  28537. * @hidden
  28538. */
  28539. _init(): void;
  28540. private _getPhysicsParent;
  28541. /**
  28542. * Should a new body be generated.
  28543. * @returns boolean specifying if body initialization is required
  28544. */
  28545. isBodyInitRequired(): boolean;
  28546. /**
  28547. * Sets the updated scaling
  28548. * @param updated Specifies if the scaling is updated
  28549. */
  28550. setScalingUpdated(): void;
  28551. /**
  28552. * Force a regeneration of this or the parent's impostor's body.
  28553. * Use under cautious - This will remove all joints already implemented.
  28554. */
  28555. forceUpdate(): void;
  28556. /**
  28557. * Gets the body that holds this impostor. Either its own, or its parent.
  28558. */
  28559. get physicsBody(): any;
  28560. /**
  28561. * Get the parent of the physics imposter
  28562. * @returns Physics imposter or null
  28563. */
  28564. get parent(): Nullable<PhysicsImpostor>;
  28565. /**
  28566. * Sets the parent of the physics imposter
  28567. */
  28568. set parent(value: Nullable<PhysicsImpostor>);
  28569. /**
  28570. * Set the physics body. Used mainly by the physics engine/plugin
  28571. */
  28572. set physicsBody(physicsBody: any);
  28573. /**
  28574. * Resets the update flags
  28575. */
  28576. resetUpdateFlags(): void;
  28577. /**
  28578. * Gets the object extend size
  28579. * @returns the object extend size
  28580. */
  28581. getObjectExtendSize(): Vector3;
  28582. /**
  28583. * Gets the object center
  28584. * @returns The object center
  28585. */
  28586. getObjectCenter(): Vector3;
  28587. /**
  28588. * Get a specific parameter from the options parameters
  28589. * @param paramName The object parameter name
  28590. * @returns The object parameter
  28591. */
  28592. getParam(paramName: string): any;
  28593. /**
  28594. * Sets a specific parameter in the options given to the physics plugin
  28595. * @param paramName The parameter name
  28596. * @param value The value of the parameter
  28597. */
  28598. setParam(paramName: string, value: number): void;
  28599. /**
  28600. * Specifically change the body's mass option. Won't recreate the physics body object
  28601. * @param mass The mass of the physics imposter
  28602. */
  28603. setMass(mass: number): void;
  28604. /**
  28605. * Gets the linear velocity
  28606. * @returns linear velocity or null
  28607. */
  28608. getLinearVelocity(): Nullable<Vector3>;
  28609. /**
  28610. * Sets the linear velocity
  28611. * @param velocity linear velocity or null
  28612. */
  28613. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28614. /**
  28615. * Gets the angular velocity
  28616. * @returns angular velocity or null
  28617. */
  28618. getAngularVelocity(): Nullable<Vector3>;
  28619. /**
  28620. * Sets the angular velocity
  28621. * @param velocity The velocity or null
  28622. */
  28623. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28624. /**
  28625. * Execute a function with the physics plugin native code
  28626. * Provide a function the will have two variables - the world object and the physics body object
  28627. * @param func The function to execute with the physics plugin native code
  28628. */
  28629. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28630. /**
  28631. * Register a function that will be executed before the physics world is stepping forward
  28632. * @param func The function to execute before the physics world is stepped forward
  28633. */
  28634. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28635. /**
  28636. * Unregister a function that will be executed before the physics world is stepping forward
  28637. * @param func The function to execute before the physics world is stepped forward
  28638. */
  28639. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28640. /**
  28641. * Register a function that will be executed after the physics step
  28642. * @param func The function to execute after physics step
  28643. */
  28644. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28645. /**
  28646. * Unregisters a function that will be executed after the physics step
  28647. * @param func The function to execute after physics step
  28648. */
  28649. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28650. /**
  28651. * register a function that will be executed when this impostor collides against a different body
  28652. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28653. * @param func Callback that is executed on collision
  28654. */
  28655. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28656. /**
  28657. * Unregisters the physics imposter on contact
  28658. * @param collideAgainst The physics object to collide against
  28659. * @param func Callback to execute on collision
  28660. */
  28661. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28662. private _tmpQuat;
  28663. private _tmpQuat2;
  28664. /**
  28665. * Get the parent rotation
  28666. * @returns The parent rotation
  28667. */
  28668. getParentsRotation(): Quaternion;
  28669. /**
  28670. * this function is executed by the physics engine.
  28671. */
  28672. beforeStep: () => void;
  28673. /**
  28674. * this function is executed by the physics engine
  28675. */
  28676. afterStep: () => void;
  28677. /**
  28678. * Legacy collision detection event support
  28679. */
  28680. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28681. /**
  28682. * event and body object due to cannon's event-based architecture.
  28683. */
  28684. onCollide: (e: {
  28685. body: any;
  28686. }) => void;
  28687. /**
  28688. * Apply a force
  28689. * @param force The force to apply
  28690. * @param contactPoint The contact point for the force
  28691. * @returns The physics imposter
  28692. */
  28693. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28694. /**
  28695. * Apply an impulse
  28696. * @param force The impulse force
  28697. * @param contactPoint The contact point for the impulse force
  28698. * @returns The physics imposter
  28699. */
  28700. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28701. /**
  28702. * A help function to create a joint
  28703. * @param otherImpostor A physics imposter used to create a joint
  28704. * @param jointType The type of joint
  28705. * @param jointData The data for the joint
  28706. * @returns The physics imposter
  28707. */
  28708. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28709. /**
  28710. * Add a joint to this impostor with a different impostor
  28711. * @param otherImpostor A physics imposter used to add a joint
  28712. * @param joint The joint to add
  28713. * @returns The physics imposter
  28714. */
  28715. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28716. /**
  28717. * Add an anchor to a cloth impostor
  28718. * @param otherImpostor rigid impostor to anchor to
  28719. * @param width ratio across width from 0 to 1
  28720. * @param height ratio up height from 0 to 1
  28721. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28722. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28723. * @returns impostor the soft imposter
  28724. */
  28725. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28726. /**
  28727. * Add a hook to a rope impostor
  28728. * @param otherImpostor rigid impostor to anchor to
  28729. * @param length ratio across rope from 0 to 1
  28730. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28731. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28732. * @returns impostor the rope imposter
  28733. */
  28734. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28735. /**
  28736. * Will keep this body still, in a sleep mode.
  28737. * @returns the physics imposter
  28738. */
  28739. sleep(): PhysicsImpostor;
  28740. /**
  28741. * Wake the body up.
  28742. * @returns The physics imposter
  28743. */
  28744. wakeUp(): PhysicsImpostor;
  28745. /**
  28746. * Clones the physics imposter
  28747. * @param newObject The physics imposter clones to this physics-enabled object
  28748. * @returns A nullable physics imposter
  28749. */
  28750. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28751. /**
  28752. * Disposes the physics imposter
  28753. */
  28754. dispose(): void;
  28755. /**
  28756. * Sets the delta position
  28757. * @param position The delta position amount
  28758. */
  28759. setDeltaPosition(position: Vector3): void;
  28760. /**
  28761. * Sets the delta rotation
  28762. * @param rotation The delta rotation amount
  28763. */
  28764. setDeltaRotation(rotation: Quaternion): void;
  28765. /**
  28766. * Gets the box size of the physics imposter and stores the result in the input parameter
  28767. * @param result Stores the box size
  28768. * @returns The physics imposter
  28769. */
  28770. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28771. /**
  28772. * Gets the radius of the physics imposter
  28773. * @returns Radius of the physics imposter
  28774. */
  28775. getRadius(): number;
  28776. /**
  28777. * Sync a bone with this impostor
  28778. * @param bone The bone to sync to the impostor.
  28779. * @param boneMesh The mesh that the bone is influencing.
  28780. * @param jointPivot The pivot of the joint / bone in local space.
  28781. * @param distToJoint Optional distance from the impostor to the joint.
  28782. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28783. */
  28784. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28785. /**
  28786. * Sync impostor to a bone
  28787. * @param bone The bone that the impostor will be synced to.
  28788. * @param boneMesh The mesh that the bone is influencing.
  28789. * @param jointPivot The pivot of the joint / bone in local space.
  28790. * @param distToJoint Optional distance from the impostor to the joint.
  28791. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28792. * @param boneAxis Optional vector3 axis the bone is aligned with
  28793. */
  28794. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28795. /**
  28796. * No-Imposter type
  28797. */
  28798. static NoImpostor: number;
  28799. /**
  28800. * Sphere-Imposter type
  28801. */
  28802. static SphereImpostor: number;
  28803. /**
  28804. * Box-Imposter type
  28805. */
  28806. static BoxImpostor: number;
  28807. /**
  28808. * Plane-Imposter type
  28809. */
  28810. static PlaneImpostor: number;
  28811. /**
  28812. * Mesh-imposter type
  28813. */
  28814. static MeshImpostor: number;
  28815. /**
  28816. * Capsule-Impostor type (Ammo.js plugin only)
  28817. */
  28818. static CapsuleImpostor: number;
  28819. /**
  28820. * Cylinder-Imposter type
  28821. */
  28822. static CylinderImpostor: number;
  28823. /**
  28824. * Particle-Imposter type
  28825. */
  28826. static ParticleImpostor: number;
  28827. /**
  28828. * Heightmap-Imposter type
  28829. */
  28830. static HeightmapImpostor: number;
  28831. /**
  28832. * ConvexHull-Impostor type (Ammo.js plugin only)
  28833. */
  28834. static ConvexHullImpostor: number;
  28835. /**
  28836. * Custom-Imposter type (Ammo.js plugin only)
  28837. */
  28838. static CustomImpostor: number;
  28839. /**
  28840. * Rope-Imposter type
  28841. */
  28842. static RopeImpostor: number;
  28843. /**
  28844. * Cloth-Imposter type
  28845. */
  28846. static ClothImpostor: number;
  28847. /**
  28848. * Softbody-Imposter type
  28849. */
  28850. static SoftbodyImpostor: number;
  28851. }
  28852. }
  28853. declare module "babylonjs/Meshes/mesh" {
  28854. import { Observable } from "babylonjs/Misc/observable";
  28855. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28856. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28857. import { Camera } from "babylonjs/Cameras/camera";
  28858. import { Scene } from "babylonjs/scene";
  28859. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28860. import { Color4 } from "babylonjs/Maths/math.color";
  28861. import { Engine } from "babylonjs/Engines/engine";
  28862. import { Node } from "babylonjs/node";
  28863. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28864. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28865. import { Buffer } from "babylonjs/Meshes/buffer";
  28866. import { Geometry } from "babylonjs/Meshes/geometry";
  28867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28868. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28869. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28870. import { Effect } from "babylonjs/Materials/effect";
  28871. import { Material } from "babylonjs/Materials/material";
  28872. import { Skeleton } from "babylonjs/Bones/skeleton";
  28873. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28874. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28875. import { Path3D } from "babylonjs/Maths/math.path";
  28876. import { Plane } from "babylonjs/Maths/math.plane";
  28877. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28878. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28879. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28880. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28881. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28882. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28883. /**
  28884. * @hidden
  28885. **/
  28886. export class _CreationDataStorage {
  28887. closePath?: boolean;
  28888. closeArray?: boolean;
  28889. idx: number[];
  28890. dashSize: number;
  28891. gapSize: number;
  28892. path3D: Path3D;
  28893. pathArray: Vector3[][];
  28894. arc: number;
  28895. radius: number;
  28896. cap: number;
  28897. tessellation: number;
  28898. }
  28899. /**
  28900. * @hidden
  28901. **/
  28902. class _InstanceDataStorage {
  28903. visibleInstances: any;
  28904. batchCache: _InstancesBatch;
  28905. instancesBufferSize: number;
  28906. instancesBuffer: Nullable<Buffer>;
  28907. instancesData: Float32Array;
  28908. overridenInstanceCount: number;
  28909. isFrozen: boolean;
  28910. previousBatch: Nullable<_InstancesBatch>;
  28911. hardwareInstancedRendering: boolean;
  28912. sideOrientation: number;
  28913. manualUpdate: boolean;
  28914. }
  28915. /**
  28916. * @hidden
  28917. **/
  28918. export class _InstancesBatch {
  28919. mustReturn: boolean;
  28920. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28921. renderSelf: boolean[];
  28922. hardwareInstancedRendering: boolean[];
  28923. }
  28924. /**
  28925. * @hidden
  28926. **/
  28927. class _ThinInstanceDataStorage {
  28928. instancesCount: number;
  28929. matrixBuffer: Nullable<Buffer>;
  28930. matrixBufferSize: number;
  28931. matrixData: Nullable<Float32Array>;
  28932. boundingVectors: Array<Vector3>;
  28933. }
  28934. /**
  28935. * Class used to represent renderable models
  28936. */
  28937. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28938. /**
  28939. * Mesh side orientation : usually the external or front surface
  28940. */
  28941. static readonly FRONTSIDE: number;
  28942. /**
  28943. * Mesh side orientation : usually the internal or back surface
  28944. */
  28945. static readonly BACKSIDE: number;
  28946. /**
  28947. * Mesh side orientation : both internal and external or front and back surfaces
  28948. */
  28949. static readonly DOUBLESIDE: number;
  28950. /**
  28951. * Mesh side orientation : by default, `FRONTSIDE`
  28952. */
  28953. static readonly DEFAULTSIDE: number;
  28954. /**
  28955. * Mesh cap setting : no cap
  28956. */
  28957. static readonly NO_CAP: number;
  28958. /**
  28959. * Mesh cap setting : one cap at the beginning of the mesh
  28960. */
  28961. static readonly CAP_START: number;
  28962. /**
  28963. * Mesh cap setting : one cap at the end of the mesh
  28964. */
  28965. static readonly CAP_END: number;
  28966. /**
  28967. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28968. */
  28969. static readonly CAP_ALL: number;
  28970. /**
  28971. * Mesh pattern setting : no flip or rotate
  28972. */
  28973. static readonly NO_FLIP: number;
  28974. /**
  28975. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28976. */
  28977. static readonly FLIP_TILE: number;
  28978. /**
  28979. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28980. */
  28981. static readonly ROTATE_TILE: number;
  28982. /**
  28983. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28984. */
  28985. static readonly FLIP_ROW: number;
  28986. /**
  28987. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28988. */
  28989. static readonly ROTATE_ROW: number;
  28990. /**
  28991. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28992. */
  28993. static readonly FLIP_N_ROTATE_TILE: number;
  28994. /**
  28995. * Mesh pattern setting : rotate pattern and rotate
  28996. */
  28997. static readonly FLIP_N_ROTATE_ROW: number;
  28998. /**
  28999. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29000. */
  29001. static readonly CENTER: number;
  29002. /**
  29003. * Mesh tile positioning : part tiles on left
  29004. */
  29005. static readonly LEFT: number;
  29006. /**
  29007. * Mesh tile positioning : part tiles on right
  29008. */
  29009. static readonly RIGHT: number;
  29010. /**
  29011. * Mesh tile positioning : part tiles on top
  29012. */
  29013. static readonly TOP: number;
  29014. /**
  29015. * Mesh tile positioning : part tiles on bottom
  29016. */
  29017. static readonly BOTTOM: number;
  29018. /**
  29019. * Gets the default side orientation.
  29020. * @param orientation the orientation to value to attempt to get
  29021. * @returns the default orientation
  29022. * @hidden
  29023. */
  29024. static _GetDefaultSideOrientation(orientation?: number): number;
  29025. private _internalMeshDataInfo;
  29026. get computeBonesUsingShaders(): boolean;
  29027. set computeBonesUsingShaders(value: boolean);
  29028. /**
  29029. * An event triggered before rendering the mesh
  29030. */
  29031. get onBeforeRenderObservable(): Observable<Mesh>;
  29032. /**
  29033. * An event triggered before binding the mesh
  29034. */
  29035. get onBeforeBindObservable(): Observable<Mesh>;
  29036. /**
  29037. * An event triggered after rendering the mesh
  29038. */
  29039. get onAfterRenderObservable(): Observable<Mesh>;
  29040. /**
  29041. * An event triggered before drawing the mesh
  29042. */
  29043. get onBeforeDrawObservable(): Observable<Mesh>;
  29044. private _onBeforeDrawObserver;
  29045. /**
  29046. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29047. */
  29048. set onBeforeDraw(callback: () => void);
  29049. get hasInstances(): boolean;
  29050. get hasThinInstances(): boolean;
  29051. /**
  29052. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29053. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29054. */
  29055. delayLoadState: number;
  29056. /**
  29057. * Gets the list of instances created from this mesh
  29058. * it is not supposed to be modified manually.
  29059. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29060. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29061. */
  29062. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29063. /**
  29064. * Gets the file containing delay loading data for this mesh
  29065. */
  29066. delayLoadingFile: string;
  29067. /** @hidden */
  29068. _binaryInfo: any;
  29069. /**
  29070. * User defined function used to change how LOD level selection is done
  29071. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29072. */
  29073. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29074. /**
  29075. * Gets or sets the morph target manager
  29076. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29077. */
  29078. get morphTargetManager(): Nullable<MorphTargetManager>;
  29079. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29080. /** @hidden */
  29081. _creationDataStorage: Nullable<_CreationDataStorage>;
  29082. /** @hidden */
  29083. _geometry: Nullable<Geometry>;
  29084. /** @hidden */
  29085. _delayInfo: Array<string>;
  29086. /** @hidden */
  29087. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29088. /** @hidden */
  29089. _instanceDataStorage: _InstanceDataStorage;
  29090. /** @hidden */
  29091. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29092. private _effectiveMaterial;
  29093. /** @hidden */
  29094. _shouldGenerateFlatShading: boolean;
  29095. /** @hidden */
  29096. _originalBuilderSideOrientation: number;
  29097. /**
  29098. * Use this property to change the original side orientation defined at construction time
  29099. */
  29100. overrideMaterialSideOrientation: Nullable<number>;
  29101. /**
  29102. * Gets the source mesh (the one used to clone this one from)
  29103. */
  29104. get source(): Nullable<Mesh>;
  29105. /**
  29106. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29107. */
  29108. get isUnIndexed(): boolean;
  29109. set isUnIndexed(value: boolean);
  29110. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29111. get worldMatrixInstancedBuffer(): Float32Array;
  29112. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29113. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29114. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29115. /**
  29116. * @constructor
  29117. * @param name The value used by scene.getMeshByName() to do a lookup.
  29118. * @param scene The scene to add this mesh to.
  29119. * @param parent The parent of this mesh, if it has one
  29120. * @param source An optional Mesh from which geometry is shared, cloned.
  29121. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29122. * When false, achieved by calling a clone(), also passing False.
  29123. * This will make creation of children, recursive.
  29124. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29125. */
  29126. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29127. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29128. doNotInstantiate: boolean;
  29129. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29130. /**
  29131. * Gets the class name
  29132. * @returns the string "Mesh".
  29133. */
  29134. getClassName(): string;
  29135. /** @hidden */
  29136. get _isMesh(): boolean;
  29137. /**
  29138. * Returns a description of this mesh
  29139. * @param fullDetails define if full details about this mesh must be used
  29140. * @returns a descriptive string representing this mesh
  29141. */
  29142. toString(fullDetails?: boolean): string;
  29143. /** @hidden */
  29144. _unBindEffect(): void;
  29145. /**
  29146. * Gets a boolean indicating if this mesh has LOD
  29147. */
  29148. get hasLODLevels(): boolean;
  29149. /**
  29150. * Gets the list of MeshLODLevel associated with the current mesh
  29151. * @returns an array of MeshLODLevel
  29152. */
  29153. getLODLevels(): MeshLODLevel[];
  29154. private _sortLODLevels;
  29155. /**
  29156. * Add a mesh as LOD level triggered at the given distance.
  29157. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29158. * @param distance The distance from the center of the object to show this level
  29159. * @param mesh The mesh to be added as LOD level (can be null)
  29160. * @return This mesh (for chaining)
  29161. */
  29162. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29163. /**
  29164. * Returns the LOD level mesh at the passed distance or null if not found.
  29165. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29166. * @param distance The distance from the center of the object to show this level
  29167. * @returns a Mesh or `null`
  29168. */
  29169. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29170. /**
  29171. * Remove a mesh from the LOD array
  29172. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29173. * @param mesh defines the mesh to be removed
  29174. * @return This mesh (for chaining)
  29175. */
  29176. removeLODLevel(mesh: Mesh): Mesh;
  29177. /**
  29178. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29179. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29180. * @param camera defines the camera to use to compute distance
  29181. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29182. * @return This mesh (for chaining)
  29183. */
  29184. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29185. /**
  29186. * Gets the mesh internal Geometry object
  29187. */
  29188. get geometry(): Nullable<Geometry>;
  29189. /**
  29190. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29191. * @returns the total number of vertices
  29192. */
  29193. getTotalVertices(): number;
  29194. /**
  29195. * Returns the content of an associated vertex buffer
  29196. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29197. * - VertexBuffer.PositionKind
  29198. * - VertexBuffer.UVKind
  29199. * - VertexBuffer.UV2Kind
  29200. * - VertexBuffer.UV3Kind
  29201. * - VertexBuffer.UV4Kind
  29202. * - VertexBuffer.UV5Kind
  29203. * - VertexBuffer.UV6Kind
  29204. * - VertexBuffer.ColorKind
  29205. * - VertexBuffer.MatricesIndicesKind
  29206. * - VertexBuffer.MatricesIndicesExtraKind
  29207. * - VertexBuffer.MatricesWeightsKind
  29208. * - VertexBuffer.MatricesWeightsExtraKind
  29209. * @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
  29210. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29211. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29212. */
  29213. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29214. /**
  29215. * Returns the mesh VertexBuffer object from the requested `kind`
  29216. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29217. * - VertexBuffer.PositionKind
  29218. * - VertexBuffer.NormalKind
  29219. * - VertexBuffer.UVKind
  29220. * - VertexBuffer.UV2Kind
  29221. * - VertexBuffer.UV3Kind
  29222. * - VertexBuffer.UV4Kind
  29223. * - VertexBuffer.UV5Kind
  29224. * - VertexBuffer.UV6Kind
  29225. * - VertexBuffer.ColorKind
  29226. * - VertexBuffer.MatricesIndicesKind
  29227. * - VertexBuffer.MatricesIndicesExtraKind
  29228. * - VertexBuffer.MatricesWeightsKind
  29229. * - VertexBuffer.MatricesWeightsExtraKind
  29230. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29231. */
  29232. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29233. /**
  29234. * Tests if a specific vertex buffer is associated with this mesh
  29235. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29236. * - VertexBuffer.PositionKind
  29237. * - VertexBuffer.NormalKind
  29238. * - VertexBuffer.UVKind
  29239. * - VertexBuffer.UV2Kind
  29240. * - VertexBuffer.UV3Kind
  29241. * - VertexBuffer.UV4Kind
  29242. * - VertexBuffer.UV5Kind
  29243. * - VertexBuffer.UV6Kind
  29244. * - VertexBuffer.ColorKind
  29245. * - VertexBuffer.MatricesIndicesKind
  29246. * - VertexBuffer.MatricesIndicesExtraKind
  29247. * - VertexBuffer.MatricesWeightsKind
  29248. * - VertexBuffer.MatricesWeightsExtraKind
  29249. * @returns a boolean
  29250. */
  29251. isVerticesDataPresent(kind: string): boolean;
  29252. /**
  29253. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29254. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29255. * - VertexBuffer.PositionKind
  29256. * - VertexBuffer.UVKind
  29257. * - VertexBuffer.UV2Kind
  29258. * - VertexBuffer.UV3Kind
  29259. * - VertexBuffer.UV4Kind
  29260. * - VertexBuffer.UV5Kind
  29261. * - VertexBuffer.UV6Kind
  29262. * - VertexBuffer.ColorKind
  29263. * - VertexBuffer.MatricesIndicesKind
  29264. * - VertexBuffer.MatricesIndicesExtraKind
  29265. * - VertexBuffer.MatricesWeightsKind
  29266. * - VertexBuffer.MatricesWeightsExtraKind
  29267. * @returns a boolean
  29268. */
  29269. isVertexBufferUpdatable(kind: string): boolean;
  29270. /**
  29271. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29272. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29273. * - VertexBuffer.PositionKind
  29274. * - VertexBuffer.NormalKind
  29275. * - VertexBuffer.UVKind
  29276. * - VertexBuffer.UV2Kind
  29277. * - VertexBuffer.UV3Kind
  29278. * - VertexBuffer.UV4Kind
  29279. * - VertexBuffer.UV5Kind
  29280. * - VertexBuffer.UV6Kind
  29281. * - VertexBuffer.ColorKind
  29282. * - VertexBuffer.MatricesIndicesKind
  29283. * - VertexBuffer.MatricesIndicesExtraKind
  29284. * - VertexBuffer.MatricesWeightsKind
  29285. * - VertexBuffer.MatricesWeightsExtraKind
  29286. * @returns an array of strings
  29287. */
  29288. getVerticesDataKinds(): string[];
  29289. /**
  29290. * Returns a positive integer : the total number of indices in this mesh geometry.
  29291. * @returns the numner of indices or zero if the mesh has no geometry.
  29292. */
  29293. getTotalIndices(): number;
  29294. /**
  29295. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29296. * @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.
  29297. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29298. * @returns the indices array or an empty array if the mesh has no geometry
  29299. */
  29300. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29301. get isBlocked(): boolean;
  29302. /**
  29303. * Determine if the current mesh is ready to be rendered
  29304. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29305. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29306. * @returns true if all associated assets are ready (material, textures, shaders)
  29307. */
  29308. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29309. /**
  29310. * 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.
  29311. */
  29312. get areNormalsFrozen(): boolean;
  29313. /**
  29314. * 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.
  29315. * @returns the current mesh
  29316. */
  29317. freezeNormals(): Mesh;
  29318. /**
  29319. * 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
  29320. * @returns the current mesh
  29321. */
  29322. unfreezeNormals(): Mesh;
  29323. /**
  29324. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29325. */
  29326. set overridenInstanceCount(count: number);
  29327. /** @hidden */
  29328. _preActivate(): Mesh;
  29329. /** @hidden */
  29330. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29331. /** @hidden */
  29332. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29333. protected _afterComputeWorldMatrix(): void;
  29334. /** @hidden */
  29335. _postActivate(): void;
  29336. /**
  29337. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29338. * This means the mesh underlying bounding box and sphere are recomputed.
  29339. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29340. * @returns the current mesh
  29341. */
  29342. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29343. /** @hidden */
  29344. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29345. /**
  29346. * This function will subdivide the mesh into multiple submeshes
  29347. * @param count defines the expected number of submeshes
  29348. */
  29349. subdivide(count: number): void;
  29350. /**
  29351. * Copy a FloatArray into a specific associated vertex buffer
  29352. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29353. * - VertexBuffer.PositionKind
  29354. * - VertexBuffer.UVKind
  29355. * - VertexBuffer.UV2Kind
  29356. * - VertexBuffer.UV3Kind
  29357. * - VertexBuffer.UV4Kind
  29358. * - VertexBuffer.UV5Kind
  29359. * - VertexBuffer.UV6Kind
  29360. * - VertexBuffer.ColorKind
  29361. * - VertexBuffer.MatricesIndicesKind
  29362. * - VertexBuffer.MatricesIndicesExtraKind
  29363. * - VertexBuffer.MatricesWeightsKind
  29364. * - VertexBuffer.MatricesWeightsExtraKind
  29365. * @param data defines the data source
  29366. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29367. * @param stride defines the data stride size (can be null)
  29368. * @returns the current mesh
  29369. */
  29370. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29371. /**
  29372. * Delete a vertex buffer associated with this mesh
  29373. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29374. * - VertexBuffer.PositionKind
  29375. * - VertexBuffer.UVKind
  29376. * - VertexBuffer.UV2Kind
  29377. * - VertexBuffer.UV3Kind
  29378. * - VertexBuffer.UV4Kind
  29379. * - VertexBuffer.UV5Kind
  29380. * - VertexBuffer.UV6Kind
  29381. * - VertexBuffer.ColorKind
  29382. * - VertexBuffer.MatricesIndicesKind
  29383. * - VertexBuffer.MatricesIndicesExtraKind
  29384. * - VertexBuffer.MatricesWeightsKind
  29385. * - VertexBuffer.MatricesWeightsExtraKind
  29386. */
  29387. removeVerticesData(kind: string): void;
  29388. /**
  29389. * Flags an associated vertex buffer as updatable
  29390. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29391. * - VertexBuffer.PositionKind
  29392. * - VertexBuffer.UVKind
  29393. * - VertexBuffer.UV2Kind
  29394. * - VertexBuffer.UV3Kind
  29395. * - VertexBuffer.UV4Kind
  29396. * - VertexBuffer.UV5Kind
  29397. * - VertexBuffer.UV6Kind
  29398. * - VertexBuffer.ColorKind
  29399. * - VertexBuffer.MatricesIndicesKind
  29400. * - VertexBuffer.MatricesIndicesExtraKind
  29401. * - VertexBuffer.MatricesWeightsKind
  29402. * - VertexBuffer.MatricesWeightsExtraKind
  29403. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29404. */
  29405. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29406. /**
  29407. * Sets the mesh global Vertex Buffer
  29408. * @param buffer defines the buffer to use
  29409. * @returns the current mesh
  29410. */
  29411. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29412. /**
  29413. * Update a specific associated vertex buffer
  29414. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29415. * - VertexBuffer.PositionKind
  29416. * - VertexBuffer.UVKind
  29417. * - VertexBuffer.UV2Kind
  29418. * - VertexBuffer.UV3Kind
  29419. * - VertexBuffer.UV4Kind
  29420. * - VertexBuffer.UV5Kind
  29421. * - VertexBuffer.UV6Kind
  29422. * - VertexBuffer.ColorKind
  29423. * - VertexBuffer.MatricesIndicesKind
  29424. * - VertexBuffer.MatricesIndicesExtraKind
  29425. * - VertexBuffer.MatricesWeightsKind
  29426. * - VertexBuffer.MatricesWeightsExtraKind
  29427. * @param data defines the data source
  29428. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29429. * @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)
  29430. * @returns the current mesh
  29431. */
  29432. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29433. /**
  29434. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29435. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29436. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29437. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29438. * @returns the current mesh
  29439. */
  29440. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29441. /**
  29442. * Creates a un-shared specific occurence of the geometry for the mesh.
  29443. * @returns the current mesh
  29444. */
  29445. makeGeometryUnique(): Mesh;
  29446. /**
  29447. * Set the index buffer of this mesh
  29448. * @param indices defines the source data
  29449. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29450. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29451. * @returns the current mesh
  29452. */
  29453. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29454. /**
  29455. * Update the current index buffer
  29456. * @param indices defines the source data
  29457. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29458. * @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)
  29459. * @returns the current mesh
  29460. */
  29461. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29462. /**
  29463. * Invert the geometry to move from a right handed system to a left handed one.
  29464. * @returns the current mesh
  29465. */
  29466. toLeftHanded(): Mesh;
  29467. /** @hidden */
  29468. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29469. /** @hidden */
  29470. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29471. /**
  29472. * Registers for this mesh a javascript function called just before the rendering process
  29473. * @param func defines the function to call before rendering this mesh
  29474. * @returns the current mesh
  29475. */
  29476. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29477. /**
  29478. * Disposes a previously registered javascript function called before the rendering
  29479. * @param func defines the function to remove
  29480. * @returns the current mesh
  29481. */
  29482. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29483. /**
  29484. * Registers for this mesh a javascript function called just after the rendering is complete
  29485. * @param func defines the function to call after rendering this mesh
  29486. * @returns the current mesh
  29487. */
  29488. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29489. /**
  29490. * Disposes a previously registered javascript function called after the rendering.
  29491. * @param func defines the function to remove
  29492. * @returns the current mesh
  29493. */
  29494. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29495. /** @hidden */
  29496. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29497. /** @hidden */
  29498. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29499. /** @hidden */
  29500. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29501. /** @hidden */
  29502. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29503. /** @hidden */
  29504. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29505. /** @hidden */
  29506. _rebuild(): void;
  29507. /** @hidden */
  29508. _freeze(): void;
  29509. /** @hidden */
  29510. _unFreeze(): void;
  29511. /**
  29512. * 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
  29513. * @param subMesh defines the subMesh to render
  29514. * @param enableAlphaMode defines if alpha mode can be changed
  29515. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29516. * @returns the current mesh
  29517. */
  29518. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29519. private _onBeforeDraw;
  29520. /**
  29521. * Renormalize the mesh and patch it up if there are no weights
  29522. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29523. * However in the case of zero weights then we set just a single influence to 1.
  29524. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29525. */
  29526. cleanMatrixWeights(): void;
  29527. private normalizeSkinFourWeights;
  29528. private normalizeSkinWeightsAndExtra;
  29529. /**
  29530. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29531. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29532. * the user know there was an issue with importing the mesh
  29533. * @returns a validation object with skinned, valid and report string
  29534. */
  29535. validateSkinning(): {
  29536. skinned: boolean;
  29537. valid: boolean;
  29538. report: string;
  29539. };
  29540. /** @hidden */
  29541. _checkDelayState(): Mesh;
  29542. private _queueLoad;
  29543. /**
  29544. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29545. * A mesh is in the frustum if its bounding box intersects the frustum
  29546. * @param frustumPlanes defines the frustum to test
  29547. * @returns true if the mesh is in the frustum planes
  29548. */
  29549. isInFrustum(frustumPlanes: Plane[]): boolean;
  29550. /**
  29551. * Sets the mesh material by the material or multiMaterial `id` property
  29552. * @param id is a string identifying the material or the multiMaterial
  29553. * @returns the current mesh
  29554. */
  29555. setMaterialByID(id: string): Mesh;
  29556. /**
  29557. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29558. * @returns an array of IAnimatable
  29559. */
  29560. getAnimatables(): IAnimatable[];
  29561. /**
  29562. * Modifies the mesh geometry according to the passed transformation matrix.
  29563. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29564. * The mesh normals are modified using the same transformation.
  29565. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29566. * @param transform defines the transform matrix to use
  29567. * @see https://doc.babylonjs.com/resources/baking_transformations
  29568. * @returns the current mesh
  29569. */
  29570. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29571. /**
  29572. * Modifies the mesh geometry according to its own current World Matrix.
  29573. * The mesh World Matrix is then reset.
  29574. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29575. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29576. * @see https://doc.babylonjs.com/resources/baking_transformations
  29577. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29578. * @returns the current mesh
  29579. */
  29580. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29581. /** @hidden */
  29582. get _positions(): Nullable<Vector3[]>;
  29583. /** @hidden */
  29584. _resetPointsArrayCache(): Mesh;
  29585. /** @hidden */
  29586. _generatePointsArray(): boolean;
  29587. /**
  29588. * Returns a new Mesh object generated from the current mesh properties.
  29589. * This method must not get confused with createInstance()
  29590. * @param name is a string, the name given to the new mesh
  29591. * @param newParent can be any Node object (default `null`)
  29592. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29593. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29594. * @returns a new mesh
  29595. */
  29596. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29597. /**
  29598. * Releases resources associated with this mesh.
  29599. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29600. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29601. */
  29602. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29603. /** @hidden */
  29604. _disposeInstanceSpecificData(): void;
  29605. /** @hidden */
  29606. _disposeThinInstanceSpecificData(): void;
  29607. /**
  29608. * Modifies the mesh geometry according to a displacement map.
  29609. * 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.
  29610. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29611. * @param url is a string, the URL from the image file is to be downloaded.
  29612. * @param minHeight is the lower limit of the displacement.
  29613. * @param maxHeight is the upper limit of the displacement.
  29614. * @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.
  29615. * @param uvOffset is an optional vector2 used to offset UV.
  29616. * @param uvScale is an optional vector2 used to scale UV.
  29617. * @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.
  29618. * @returns the Mesh.
  29619. */
  29620. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29621. /**
  29622. * Modifies the mesh geometry according to a displacementMap buffer.
  29623. * 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.
  29624. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29625. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29626. * @param heightMapWidth is the width of the buffer image.
  29627. * @param heightMapHeight is the height of the buffer image.
  29628. * @param minHeight is the lower limit of the displacement.
  29629. * @param maxHeight is the upper limit of the displacement.
  29630. * @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.
  29631. * @param uvOffset is an optional vector2 used to offset UV.
  29632. * @param uvScale is an optional vector2 used to scale UV.
  29633. * @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.
  29634. * @returns the Mesh.
  29635. */
  29636. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29637. /**
  29638. * Modify the mesh to get a flat shading rendering.
  29639. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29640. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29641. * @returns current mesh
  29642. */
  29643. convertToFlatShadedMesh(): Mesh;
  29644. /**
  29645. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29646. * In other words, more vertices, no more indices and a single bigger VBO.
  29647. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29648. * @returns current mesh
  29649. */
  29650. convertToUnIndexedMesh(): Mesh;
  29651. /**
  29652. * Inverses facet orientations.
  29653. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29654. * @param flipNormals will also inverts the normals
  29655. * @returns current mesh
  29656. */
  29657. flipFaces(flipNormals?: boolean): Mesh;
  29658. /**
  29659. * Increase the number of facets and hence vertices in a mesh
  29660. * Vertex normals are interpolated from existing vertex normals
  29661. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29662. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29663. */
  29664. increaseVertices(numberPerEdge: number): void;
  29665. /**
  29666. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29667. * This will undo any application of covertToFlatShadedMesh
  29668. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29669. */
  29670. forceSharedVertices(): void;
  29671. /** @hidden */
  29672. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29673. /** @hidden */
  29674. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29675. /**
  29676. * Creates a new InstancedMesh object from the mesh model.
  29677. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29678. * @param name defines the name of the new instance
  29679. * @returns a new InstancedMesh
  29680. */
  29681. createInstance(name: string): InstancedMesh;
  29682. /**
  29683. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29684. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29685. * @returns the current mesh
  29686. */
  29687. synchronizeInstances(): Mesh;
  29688. /**
  29689. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29690. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29691. * This should be used together with the simplification to avoid disappearing triangles.
  29692. * @param successCallback an optional success callback to be called after the optimization finished.
  29693. * @returns the current mesh
  29694. */
  29695. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29696. /**
  29697. * Serialize current mesh
  29698. * @param serializationObject defines the object which will receive the serialization data
  29699. */
  29700. serialize(serializationObject: any): void;
  29701. /** @hidden */
  29702. _syncGeometryWithMorphTargetManager(): void;
  29703. /** @hidden */
  29704. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29705. /**
  29706. * Returns a new Mesh object parsed from the source provided.
  29707. * @param parsedMesh is the source
  29708. * @param scene defines the hosting scene
  29709. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29710. * @returns a new Mesh
  29711. */
  29712. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29713. /**
  29714. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29715. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29716. * @param name defines the name of the mesh to create
  29717. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29718. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29719. * @param closePath creates a seam between the first and the last points of each path of the path array
  29720. * @param offset is taken in account only if the `pathArray` is containing a single path
  29721. * @param scene defines the hosting scene
  29722. * @param updatable defines if the mesh must be flagged as updatable
  29723. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29724. * @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)
  29725. * @returns a new Mesh
  29726. */
  29727. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29728. /**
  29729. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  29730. * @param name defines the name of the mesh to create
  29731. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29732. * @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
  29733. * @param scene defines the hosting scene
  29734. * @param updatable defines if the mesh must be flagged as updatable
  29735. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29736. * @returns a new Mesh
  29737. */
  29738. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29739. /**
  29740. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29741. * @param name defines the name of the mesh to create
  29742. * @param size sets the size (float) of each box side (default 1)
  29743. * @param scene defines the hosting scene
  29744. * @param updatable defines if the mesh must be flagged as updatable
  29745. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29746. * @returns a new Mesh
  29747. */
  29748. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29749. /**
  29750. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29751. * @param name defines the name of the mesh to create
  29752. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29753. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29754. * @param scene defines the hosting scene
  29755. * @param updatable defines if the mesh must be flagged as updatable
  29756. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29757. * @returns a new Mesh
  29758. */
  29759. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29760. /**
  29761. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29762. * @param name defines the name of the mesh to create
  29763. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29764. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29765. * @param scene defines the hosting scene
  29766. * @returns a new Mesh
  29767. */
  29768. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29769. /**
  29770. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29771. * @param name defines the name of the mesh to create
  29772. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29773. * @param diameterTop set the top cap diameter (floats, default 1)
  29774. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29775. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29776. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29777. * @param scene defines the hosting scene
  29778. * @param updatable defines if the mesh must be flagged as updatable
  29779. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29780. * @returns a new Mesh
  29781. */
  29782. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29783. /**
  29784. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29785. * @param name defines the name of the mesh to create
  29786. * @param diameter sets the diameter size (float) of the torus (default 1)
  29787. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29788. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29789. * @param scene defines the hosting scene
  29790. * @param updatable defines if the mesh must be flagged as updatable
  29791. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29792. * @returns a new Mesh
  29793. */
  29794. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29795. /**
  29796. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29797. * @param name defines the name of the mesh to create
  29798. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29799. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29800. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29801. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29802. * @param p the number of windings on X axis (positive integers, default 2)
  29803. * @param q the number of windings on Y axis (positive integers, default 3)
  29804. * @param scene defines the hosting scene
  29805. * @param updatable defines if the mesh must be flagged as updatable
  29806. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29807. * @returns a new Mesh
  29808. */
  29809. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29810. /**
  29811. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29812. * @param name defines the name of the mesh to create
  29813. * @param points is an array successive Vector3
  29814. * @param scene defines the hosting scene
  29815. * @param updatable defines if the mesh must be flagged as updatable
  29816. * @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).
  29817. * @returns a new Mesh
  29818. */
  29819. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29820. /**
  29821. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29822. * @param name defines the name of the mesh to create
  29823. * @param points is an array successive Vector3
  29824. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29825. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29826. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29827. * @param scene defines the hosting scene
  29828. * @param updatable defines if the mesh must be flagged as updatable
  29829. * @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)
  29830. * @returns a new Mesh
  29831. */
  29832. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29833. /**
  29834. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29835. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29836. * 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.
  29837. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29838. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29839. * Remember you can only change the shape positions, not their number when updating a polygon.
  29840. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29841. * @param name defines the name of the mesh to create
  29842. * @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
  29843. * @param scene defines the hosting scene
  29844. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29845. * @param updatable defines if the mesh must be flagged as updatable
  29846. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29847. * @param earcutInjection can be used to inject your own earcut reference
  29848. * @returns a new Mesh
  29849. */
  29850. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29851. /**
  29852. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29853. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29854. * @param name defines the name of the mesh to create
  29855. * @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
  29856. * @param depth defines the height of extrusion
  29857. * @param scene defines the hosting scene
  29858. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29859. * @param updatable defines if the mesh must be flagged as updatable
  29860. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29861. * @param earcutInjection can be used to inject your own earcut reference
  29862. * @returns a new Mesh
  29863. */
  29864. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29865. /**
  29866. * Creates an extruded shape mesh.
  29867. * 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
  29868. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29869. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29870. * @param name defines the name of the mesh to create
  29871. * @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
  29872. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29873. * @param scale is the value to scale the shape
  29874. * @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
  29875. * @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
  29876. * @param scene defines the hosting scene
  29877. * @param updatable defines if the mesh must be flagged as updatable
  29878. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29879. * @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)
  29880. * @returns a new Mesh
  29881. */
  29882. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29883. /**
  29884. * Creates an custom extruded shape mesh.
  29885. * The custom extrusion is a parametric shape.
  29886. * It has no predefined shape. Its final shape will depend on the input parameters.
  29887. * Please consider using the same method from the MeshBuilder class instead
  29888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29889. * @param name defines the name of the mesh to create
  29890. * @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
  29891. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29892. * @param scaleFunction is a custom Javascript function called on each path point
  29893. * @param rotationFunction is a custom Javascript function called on each path point
  29894. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29895. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29896. * @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
  29897. * @param scene defines the hosting scene
  29898. * @param updatable defines if the mesh must be flagged as updatable
  29899. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29900. * @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)
  29901. * @returns a new Mesh
  29902. */
  29903. 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;
  29904. /**
  29905. * Creates lathe mesh.
  29906. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29907. * Please consider using the same method from the MeshBuilder class instead
  29908. * @param name defines the name of the mesh to create
  29909. * @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
  29910. * @param radius is the radius value of the lathe
  29911. * @param tessellation is the side number of the lathe.
  29912. * @param scene defines the hosting scene
  29913. * @param updatable defines if the mesh must be flagged as updatable
  29914. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29915. * @returns a new Mesh
  29916. */
  29917. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29918. /**
  29919. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29920. * @param name defines the name of the mesh to create
  29921. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29922. * @param scene defines the hosting scene
  29923. * @param updatable defines if the mesh must be flagged as updatable
  29924. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29925. * @returns a new Mesh
  29926. */
  29927. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29928. /**
  29929. * Creates a ground mesh.
  29930. * Please consider using the same method from the MeshBuilder class instead
  29931. * @param name defines the name of the mesh to create
  29932. * @param width set the width of the ground
  29933. * @param height set the height of the ground
  29934. * @param subdivisions sets the number of subdivisions per side
  29935. * @param scene defines the hosting scene
  29936. * @param updatable defines if the mesh must be flagged as updatable
  29937. * @returns a new Mesh
  29938. */
  29939. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29940. /**
  29941. * Creates a tiled ground mesh.
  29942. * Please consider using the same method from the MeshBuilder class instead
  29943. * @param name defines the name of the mesh to create
  29944. * @param xmin set the ground minimum X coordinate
  29945. * @param zmin set the ground minimum Y coordinate
  29946. * @param xmax set the ground maximum X coordinate
  29947. * @param zmax set the ground maximum Z coordinate
  29948. * @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
  29949. * @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
  29950. * @param scene defines the hosting scene
  29951. * @param updatable defines if the mesh must be flagged as updatable
  29952. * @returns a new Mesh
  29953. */
  29954. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29955. w: number;
  29956. h: number;
  29957. }, precision: {
  29958. w: number;
  29959. h: number;
  29960. }, scene: Scene, updatable?: boolean): Mesh;
  29961. /**
  29962. * Creates a ground mesh from a height map.
  29963. * Please consider using the same method from the MeshBuilder class instead
  29964. * @see https://doc.babylonjs.com/babylon101/height_map
  29965. * @param name defines the name of the mesh to create
  29966. * @param url sets the URL of the height map image resource
  29967. * @param width set the ground width size
  29968. * @param height set the ground height size
  29969. * @param subdivisions sets the number of subdivision per side
  29970. * @param minHeight is the minimum altitude on the ground
  29971. * @param maxHeight is the maximum altitude on the ground
  29972. * @param scene defines the hosting scene
  29973. * @param updatable defines if the mesh must be flagged as updatable
  29974. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29975. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29976. * @returns a new Mesh
  29977. */
  29978. 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;
  29979. /**
  29980. * Creates a tube mesh.
  29981. * The tube is a parametric shape.
  29982. * It has no predefined shape. Its final shape will depend on the input parameters.
  29983. * Please consider using the same method from the MeshBuilder class instead
  29984. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29985. * @param name defines the name of the mesh to create
  29986. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29987. * @param radius sets the tube radius size
  29988. * @param tessellation is the number of sides on the tubular surface
  29989. * @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
  29990. * @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
  29991. * @param scene defines the hosting scene
  29992. * @param updatable defines if the mesh must be flagged as updatable
  29993. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29994. * @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)
  29995. * @returns a new Mesh
  29996. */
  29997. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29998. (i: number, distance: number): number;
  29999. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30000. /**
  30001. * Creates a polyhedron mesh.
  30002. * Please consider using the same method from the MeshBuilder class instead.
  30003. * * 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
  30004. * * The parameter `size` (positive float, default 1) sets the polygon size
  30005. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30006. * * 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`
  30007. * * 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
  30008. * * 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)`)
  30009. * * 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
  30010. * * 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
  30011. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30014. * @param name defines the name of the mesh to create
  30015. * @param options defines the options used to create the mesh
  30016. * @param scene defines the hosting scene
  30017. * @returns a new Mesh
  30018. */
  30019. static CreatePolyhedron(name: string, options: {
  30020. type?: number;
  30021. size?: number;
  30022. sizeX?: number;
  30023. sizeY?: number;
  30024. sizeZ?: number;
  30025. custom?: any;
  30026. faceUV?: Vector4[];
  30027. faceColors?: Color4[];
  30028. updatable?: boolean;
  30029. sideOrientation?: number;
  30030. }, scene: Scene): Mesh;
  30031. /**
  30032. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30033. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30034. * * 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`)
  30035. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30036. * * 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
  30037. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30038. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30040. * @param name defines the name of the mesh
  30041. * @param options defines the options used to create the mesh
  30042. * @param scene defines the hosting scene
  30043. * @returns a new Mesh
  30044. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30045. */
  30046. static CreateIcoSphere(name: string, options: {
  30047. radius?: number;
  30048. flat?: boolean;
  30049. subdivisions?: number;
  30050. sideOrientation?: number;
  30051. updatable?: boolean;
  30052. }, scene: Scene): Mesh;
  30053. /**
  30054. * Creates a decal mesh.
  30055. * Please consider using the same method from the MeshBuilder class instead.
  30056. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30057. * @param name defines the name of the mesh
  30058. * @param sourceMesh defines the mesh receiving the decal
  30059. * @param position sets the position of the decal in world coordinates
  30060. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30061. * @param size sets the decal scaling
  30062. * @param angle sets the angle to rotate the decal
  30063. * @returns a new Mesh
  30064. */
  30065. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30066. /**
  30067. * Prepare internal position array for software CPU skinning
  30068. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30069. */
  30070. setPositionsForCPUSkinning(): Float32Array;
  30071. /**
  30072. * Prepare internal normal array for software CPU skinning
  30073. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30074. */
  30075. setNormalsForCPUSkinning(): Float32Array;
  30076. /**
  30077. * Updates the vertex buffer by applying transformation from the bones
  30078. * @param skeleton defines the skeleton to apply to current mesh
  30079. * @returns the current mesh
  30080. */
  30081. applySkeleton(skeleton: Skeleton): Mesh;
  30082. /**
  30083. * 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
  30084. * @param meshes defines the list of meshes to scan
  30085. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30086. */
  30087. static MinMax(meshes: AbstractMesh[]): {
  30088. min: Vector3;
  30089. max: Vector3;
  30090. };
  30091. /**
  30092. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30093. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30094. * @returns a vector3
  30095. */
  30096. static Center(meshesOrMinMaxVector: {
  30097. min: Vector3;
  30098. max: Vector3;
  30099. } | AbstractMesh[]): Vector3;
  30100. /**
  30101. * Merge the array of meshes into a single mesh for performance reasons.
  30102. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30103. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30104. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30105. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30106. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30107. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30108. * @returns a new mesh
  30109. */
  30110. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30111. /** @hidden */
  30112. addInstance(instance: InstancedMesh): void;
  30113. /** @hidden */
  30114. removeInstance(instance: InstancedMesh): void;
  30115. }
  30116. }
  30117. declare module "babylonjs/Cameras/camera" {
  30118. import { SmartArray } from "babylonjs/Misc/smartArray";
  30119. import { Observable } from "babylonjs/Misc/observable";
  30120. import { Nullable } from "babylonjs/types";
  30121. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30122. import { Scene } from "babylonjs/scene";
  30123. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30124. import { Node } from "babylonjs/node";
  30125. import { Mesh } from "babylonjs/Meshes/mesh";
  30126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30127. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30128. import { Viewport } from "babylonjs/Maths/math.viewport";
  30129. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30130. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30131. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30132. import { Ray } from "babylonjs/Culling/ray";
  30133. /**
  30134. * This is the base class of all the camera used in the application.
  30135. * @see https://doc.babylonjs.com/features/cameras
  30136. */
  30137. export class Camera extends Node {
  30138. /** @hidden */
  30139. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30140. /**
  30141. * This is the default projection mode used by the cameras.
  30142. * It helps recreating a feeling of perspective and better appreciate depth.
  30143. * This is the best way to simulate real life cameras.
  30144. */
  30145. static readonly PERSPECTIVE_CAMERA: number;
  30146. /**
  30147. * This helps creating camera with an orthographic mode.
  30148. * 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.
  30149. */
  30150. static readonly ORTHOGRAPHIC_CAMERA: number;
  30151. /**
  30152. * This is the default FOV mode for perspective cameras.
  30153. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30154. */
  30155. static readonly FOVMODE_VERTICAL_FIXED: number;
  30156. /**
  30157. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30158. */
  30159. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30160. /**
  30161. * This specifies ther is no need for a camera rig.
  30162. * Basically only one eye is rendered corresponding to the camera.
  30163. */
  30164. static readonly RIG_MODE_NONE: number;
  30165. /**
  30166. * Simulates a camera Rig with one blue eye and one red eye.
  30167. * This can be use with 3d blue and red glasses.
  30168. */
  30169. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30170. /**
  30171. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30172. */
  30173. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30174. /**
  30175. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30176. */
  30177. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30178. /**
  30179. * Defines that both eyes of the camera will be rendered over under each other.
  30180. */
  30181. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30182. /**
  30183. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30184. */
  30185. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30186. /**
  30187. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30188. */
  30189. static readonly RIG_MODE_VR: number;
  30190. /**
  30191. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30192. */
  30193. static readonly RIG_MODE_WEBVR: number;
  30194. /**
  30195. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30196. */
  30197. static readonly RIG_MODE_CUSTOM: number;
  30198. /**
  30199. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30200. */
  30201. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30202. /**
  30203. * Define the input manager associated with the camera.
  30204. */
  30205. inputs: CameraInputsManager<Camera>;
  30206. /** @hidden */
  30207. _position: Vector3;
  30208. /**
  30209. * Define the current local position of the camera in the scene
  30210. */
  30211. get position(): Vector3;
  30212. set position(newPosition: Vector3);
  30213. /**
  30214. * The vector the camera should consider as up.
  30215. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30216. */
  30217. upVector: Vector3;
  30218. /**
  30219. * Define the current limit on the left side for an orthographic camera
  30220. * In scene unit
  30221. */
  30222. orthoLeft: Nullable<number>;
  30223. /**
  30224. * Define the current limit on the right side for an orthographic camera
  30225. * In scene unit
  30226. */
  30227. orthoRight: Nullable<number>;
  30228. /**
  30229. * Define the current limit on the bottom side for an orthographic camera
  30230. * In scene unit
  30231. */
  30232. orthoBottom: Nullable<number>;
  30233. /**
  30234. * Define the current limit on the top side for an orthographic camera
  30235. * In scene unit
  30236. */
  30237. orthoTop: Nullable<number>;
  30238. /**
  30239. * Field Of View is set in Radians. (default is 0.8)
  30240. */
  30241. fov: number;
  30242. /**
  30243. * Define the minimum distance the camera can see from.
  30244. * This is important to note that the depth buffer are not infinite and the closer it starts
  30245. * the more your scene might encounter depth fighting issue.
  30246. */
  30247. minZ: number;
  30248. /**
  30249. * Define the maximum distance the camera can see to.
  30250. * This is important to note that the depth buffer are not infinite and the further it end
  30251. * the more your scene might encounter depth fighting issue.
  30252. */
  30253. maxZ: number;
  30254. /**
  30255. * Define the default inertia of the camera.
  30256. * This helps giving a smooth feeling to the camera movement.
  30257. */
  30258. inertia: number;
  30259. /**
  30260. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30261. */
  30262. mode: number;
  30263. /**
  30264. * Define whether the camera is intermediate.
  30265. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30266. */
  30267. isIntermediate: boolean;
  30268. /**
  30269. * Define the viewport of the camera.
  30270. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30271. */
  30272. viewport: Viewport;
  30273. /**
  30274. * Restricts the camera to viewing objects with the same layerMask.
  30275. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30276. */
  30277. layerMask: number;
  30278. /**
  30279. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30280. */
  30281. fovMode: number;
  30282. /**
  30283. * Rig mode of the camera.
  30284. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30285. * This is normally controlled byt the camera themselves as internal use.
  30286. */
  30287. cameraRigMode: number;
  30288. /**
  30289. * Defines the distance between both "eyes" in case of a RIG
  30290. */
  30291. interaxialDistance: number;
  30292. /**
  30293. * Defines if stereoscopic rendering is done side by side or over under.
  30294. */
  30295. isStereoscopicSideBySide: boolean;
  30296. /**
  30297. * 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
  30298. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30299. * else in the scene. (Eg. security camera)
  30300. *
  30301. * 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)
  30302. */
  30303. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30304. /**
  30305. * When set, the camera will render to this render target instead of the default canvas
  30306. *
  30307. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30308. */
  30309. outputRenderTarget: Nullable<RenderTargetTexture>;
  30310. /**
  30311. * Observable triggered when the camera view matrix has changed.
  30312. */
  30313. onViewMatrixChangedObservable: Observable<Camera>;
  30314. /**
  30315. * Observable triggered when the camera Projection matrix has changed.
  30316. */
  30317. onProjectionMatrixChangedObservable: Observable<Camera>;
  30318. /**
  30319. * Observable triggered when the inputs have been processed.
  30320. */
  30321. onAfterCheckInputsObservable: Observable<Camera>;
  30322. /**
  30323. * Observable triggered when reset has been called and applied to the camera.
  30324. */
  30325. onRestoreStateObservable: Observable<Camera>;
  30326. /**
  30327. * Is this camera a part of a rig system?
  30328. */
  30329. isRigCamera: boolean;
  30330. /**
  30331. * If isRigCamera set to true this will be set with the parent camera.
  30332. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30333. */
  30334. rigParent?: Camera;
  30335. /** @hidden */
  30336. _cameraRigParams: any;
  30337. /** @hidden */
  30338. _rigCameras: Camera[];
  30339. /** @hidden */
  30340. _rigPostProcess: Nullable<PostProcess>;
  30341. protected _webvrViewMatrix: Matrix;
  30342. /** @hidden */
  30343. _skipRendering: boolean;
  30344. /** @hidden */
  30345. _projectionMatrix: Matrix;
  30346. /** @hidden */
  30347. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30348. /** @hidden */
  30349. _activeMeshes: SmartArray<AbstractMesh>;
  30350. protected _globalPosition: Vector3;
  30351. /** @hidden */
  30352. _computedViewMatrix: Matrix;
  30353. private _doNotComputeProjectionMatrix;
  30354. private _transformMatrix;
  30355. private _frustumPlanes;
  30356. private _refreshFrustumPlanes;
  30357. private _storedFov;
  30358. private _stateStored;
  30359. /**
  30360. * Instantiates a new camera object.
  30361. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30362. * @see https://doc.babylonjs.com/features/cameras
  30363. * @param name Defines the name of the camera in the scene
  30364. * @param position Defines the position of the camera
  30365. * @param scene Defines the scene the camera belongs too
  30366. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30367. */
  30368. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30369. /**
  30370. * Store current camera state (fov, position, etc..)
  30371. * @returns the camera
  30372. */
  30373. storeState(): Camera;
  30374. /**
  30375. * Restores the camera state values if it has been stored. You must call storeState() first
  30376. */
  30377. protected _restoreStateValues(): boolean;
  30378. /**
  30379. * Restored camera state. You must call storeState() first.
  30380. * @returns true if restored and false otherwise
  30381. */
  30382. restoreState(): boolean;
  30383. /**
  30384. * Gets the class name of the camera.
  30385. * @returns the class name
  30386. */
  30387. getClassName(): string;
  30388. /** @hidden */
  30389. readonly _isCamera: boolean;
  30390. /**
  30391. * Gets a string representation of the camera useful for debug purpose.
  30392. * @param fullDetails Defines that a more verboe level of logging is required
  30393. * @returns the string representation
  30394. */
  30395. toString(fullDetails?: boolean): string;
  30396. /**
  30397. * Gets the current world space position of the camera.
  30398. */
  30399. get globalPosition(): Vector3;
  30400. /**
  30401. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30402. * @returns the active meshe list
  30403. */
  30404. getActiveMeshes(): SmartArray<AbstractMesh>;
  30405. /**
  30406. * Check whether a mesh is part of the current active mesh list of the camera
  30407. * @param mesh Defines the mesh to check
  30408. * @returns true if active, false otherwise
  30409. */
  30410. isActiveMesh(mesh: Mesh): boolean;
  30411. /**
  30412. * Is this camera ready to be used/rendered
  30413. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30414. * @return true if the camera is ready
  30415. */
  30416. isReady(completeCheck?: boolean): boolean;
  30417. /** @hidden */
  30418. _initCache(): void;
  30419. /** @hidden */
  30420. _updateCache(ignoreParentClass?: boolean): void;
  30421. /** @hidden */
  30422. _isSynchronized(): boolean;
  30423. /** @hidden */
  30424. _isSynchronizedViewMatrix(): boolean;
  30425. /** @hidden */
  30426. _isSynchronizedProjectionMatrix(): boolean;
  30427. /**
  30428. * Attach the input controls to a specific dom element to get the input from.
  30429. * @param element Defines the element the controls should be listened from
  30430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30431. */
  30432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30433. /**
  30434. * Detach the current controls from the specified dom element.
  30435. * @param element Defines the element to stop listening the inputs from
  30436. */
  30437. detachControl(element: HTMLElement): void;
  30438. /**
  30439. * Update the camera state according to the different inputs gathered during the frame.
  30440. */
  30441. update(): void;
  30442. /** @hidden */
  30443. _checkInputs(): void;
  30444. /** @hidden */
  30445. get rigCameras(): Camera[];
  30446. /**
  30447. * Gets the post process used by the rig cameras
  30448. */
  30449. get rigPostProcess(): Nullable<PostProcess>;
  30450. /**
  30451. * Internal, gets the first post proces.
  30452. * @returns the first post process to be run on this camera.
  30453. */
  30454. _getFirstPostProcess(): Nullable<PostProcess>;
  30455. private _cascadePostProcessesToRigCams;
  30456. /**
  30457. * Attach a post process to the camera.
  30458. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30459. * @param postProcess The post process to attach to the camera
  30460. * @param insertAt The position of the post process in case several of them are in use in the scene
  30461. * @returns the position the post process has been inserted at
  30462. */
  30463. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30464. /**
  30465. * Detach a post process to the camera.
  30466. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30467. * @param postProcess The post process to detach from the camera
  30468. */
  30469. detachPostProcess(postProcess: PostProcess): void;
  30470. /**
  30471. * Gets the current world matrix of the camera
  30472. */
  30473. getWorldMatrix(): Matrix;
  30474. /** @hidden */
  30475. _getViewMatrix(): Matrix;
  30476. /**
  30477. * Gets the current view matrix of the camera.
  30478. * @param force forces the camera to recompute the matrix without looking at the cached state
  30479. * @returns the view matrix
  30480. */
  30481. getViewMatrix(force?: boolean): Matrix;
  30482. /**
  30483. * Freeze the projection matrix.
  30484. * It will prevent the cache check of the camera projection compute and can speed up perf
  30485. * if no parameter of the camera are meant to change
  30486. * @param projection Defines manually a projection if necessary
  30487. */
  30488. freezeProjectionMatrix(projection?: Matrix): void;
  30489. /**
  30490. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30491. */
  30492. unfreezeProjectionMatrix(): void;
  30493. /**
  30494. * Gets the current projection matrix of the camera.
  30495. * @param force forces the camera to recompute the matrix without looking at the cached state
  30496. * @returns the projection matrix
  30497. */
  30498. getProjectionMatrix(force?: boolean): Matrix;
  30499. /**
  30500. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30501. * @returns a Matrix
  30502. */
  30503. getTransformationMatrix(): Matrix;
  30504. private _updateFrustumPlanes;
  30505. /**
  30506. * Checks if a cullable object (mesh...) is in the camera frustum
  30507. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30508. * @param target The object to check
  30509. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30510. * @returns true if the object is in frustum otherwise false
  30511. */
  30512. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30513. /**
  30514. * Checks if a cullable object (mesh...) is in the camera frustum
  30515. * Unlike isInFrustum this cheks the full bounding box
  30516. * @param target The object to check
  30517. * @returns true if the object is in frustum otherwise false
  30518. */
  30519. isCompletelyInFrustum(target: ICullable): boolean;
  30520. /**
  30521. * Gets a ray in the forward direction from the camera.
  30522. * @param length Defines the length of the ray to create
  30523. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30524. * @param origin Defines the start point of the ray which defaults to the camera position
  30525. * @returns the forward ray
  30526. */
  30527. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30528. /**
  30529. * Gets a ray in the forward direction from the camera.
  30530. * @param refRay the ray to (re)use when setting the values
  30531. * @param length Defines the length of the ray to create
  30532. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30533. * @param origin Defines the start point of the ray which defaults to the camera position
  30534. * @returns the forward ray
  30535. */
  30536. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30537. /**
  30538. * Releases resources associated with this node.
  30539. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30540. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30541. */
  30542. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30543. /** @hidden */
  30544. _isLeftCamera: boolean;
  30545. /**
  30546. * Gets the left camera of a rig setup in case of Rigged Camera
  30547. */
  30548. get isLeftCamera(): boolean;
  30549. /** @hidden */
  30550. _isRightCamera: boolean;
  30551. /**
  30552. * Gets the right camera of a rig setup in case of Rigged Camera
  30553. */
  30554. get isRightCamera(): boolean;
  30555. /**
  30556. * Gets the left camera of a rig setup in case of Rigged Camera
  30557. */
  30558. get leftCamera(): Nullable<FreeCamera>;
  30559. /**
  30560. * Gets the right camera of a rig setup in case of Rigged Camera
  30561. */
  30562. get rightCamera(): Nullable<FreeCamera>;
  30563. /**
  30564. * Gets the left camera target of a rig setup in case of Rigged Camera
  30565. * @returns the target position
  30566. */
  30567. getLeftTarget(): Nullable<Vector3>;
  30568. /**
  30569. * Gets the right camera target of a rig setup in case of Rigged Camera
  30570. * @returns the target position
  30571. */
  30572. getRightTarget(): Nullable<Vector3>;
  30573. /**
  30574. * @hidden
  30575. */
  30576. setCameraRigMode(mode: number, rigParams: any): void;
  30577. /** @hidden */
  30578. static _setStereoscopicRigMode(camera: Camera): void;
  30579. /** @hidden */
  30580. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30581. /** @hidden */
  30582. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30583. /** @hidden */
  30584. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30585. /** @hidden */
  30586. _getVRProjectionMatrix(): Matrix;
  30587. protected _updateCameraRotationMatrix(): void;
  30588. protected _updateWebVRCameraRotationMatrix(): void;
  30589. /**
  30590. * This function MUST be overwritten by the different WebVR cameras available.
  30591. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30592. * @hidden
  30593. */
  30594. _getWebVRProjectionMatrix(): Matrix;
  30595. /**
  30596. * This function MUST be overwritten by the different WebVR cameras available.
  30597. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30598. * @hidden
  30599. */
  30600. _getWebVRViewMatrix(): Matrix;
  30601. /** @hidden */
  30602. setCameraRigParameter(name: string, value: any): void;
  30603. /**
  30604. * needs to be overridden by children so sub has required properties to be copied
  30605. * @hidden
  30606. */
  30607. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30608. /**
  30609. * May need to be overridden by children
  30610. * @hidden
  30611. */
  30612. _updateRigCameras(): void;
  30613. /** @hidden */
  30614. _setupInputs(): void;
  30615. /**
  30616. * Serialiaze the camera setup to a json represention
  30617. * @returns the JSON representation
  30618. */
  30619. serialize(): any;
  30620. /**
  30621. * Clones the current camera.
  30622. * @param name The cloned camera name
  30623. * @returns the cloned camera
  30624. */
  30625. clone(name: string): Camera;
  30626. /**
  30627. * Gets the direction of the camera relative to a given local axis.
  30628. * @param localAxis Defines the reference axis to provide a relative direction.
  30629. * @return the direction
  30630. */
  30631. getDirection(localAxis: Vector3): Vector3;
  30632. /**
  30633. * Returns the current camera absolute rotation
  30634. */
  30635. get absoluteRotation(): Quaternion;
  30636. /**
  30637. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30638. * @param localAxis Defines the reference axis to provide a relative direction.
  30639. * @param result Defines the vector to store the result in
  30640. */
  30641. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30642. /**
  30643. * Gets a camera constructor for a given camera type
  30644. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30645. * @param name The name of the camera the result will be able to instantiate
  30646. * @param scene The scene the result will construct the camera in
  30647. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30648. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30649. * @returns a factory method to construc the camera
  30650. */
  30651. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30652. /**
  30653. * Compute the world matrix of the camera.
  30654. * @returns the camera world matrix
  30655. */
  30656. computeWorldMatrix(): Matrix;
  30657. /**
  30658. * Parse a JSON and creates the camera from the parsed information
  30659. * @param parsedCamera The JSON to parse
  30660. * @param scene The scene to instantiate the camera in
  30661. * @returns the newly constructed camera
  30662. */
  30663. static Parse(parsedCamera: any, scene: Scene): Camera;
  30664. }
  30665. }
  30666. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30667. import { Nullable } from "babylonjs/types";
  30668. import { Scene } from "babylonjs/scene";
  30669. import { Vector4 } from "babylonjs/Maths/math.vector";
  30670. import { Mesh } from "babylonjs/Meshes/mesh";
  30671. /**
  30672. * Class containing static functions to help procedurally build meshes
  30673. */
  30674. export class DiscBuilder {
  30675. /**
  30676. * Creates a plane polygonal mesh. By default, this is a disc
  30677. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30678. * * 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
  30679. * * 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
  30680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30683. * @param name defines the name of the mesh
  30684. * @param options defines the options used to create the mesh
  30685. * @param scene defines the hosting scene
  30686. * @returns the plane polygonal mesh
  30687. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30688. */
  30689. static CreateDisc(name: string, options: {
  30690. radius?: number;
  30691. tessellation?: number;
  30692. arc?: number;
  30693. updatable?: boolean;
  30694. sideOrientation?: number;
  30695. frontUVs?: Vector4;
  30696. backUVs?: Vector4;
  30697. }, scene?: Nullable<Scene>): Mesh;
  30698. }
  30699. }
  30700. declare module "babylonjs/Materials/fresnelParameters" {
  30701. import { DeepImmutable } from "babylonjs/types";
  30702. import { Color3 } from "babylonjs/Maths/math.color";
  30703. /**
  30704. * Options to be used when creating a FresnelParameters.
  30705. */
  30706. export type IFresnelParametersCreationOptions = {
  30707. /**
  30708. * Define the color used on edges (grazing angle)
  30709. */
  30710. leftColor?: Color3;
  30711. /**
  30712. * Define the color used on center
  30713. */
  30714. rightColor?: Color3;
  30715. /**
  30716. * Define bias applied to computed fresnel term
  30717. */
  30718. bias?: number;
  30719. /**
  30720. * Defined the power exponent applied to fresnel term
  30721. */
  30722. power?: number;
  30723. /**
  30724. * Define if the fresnel effect is enable or not.
  30725. */
  30726. isEnabled?: boolean;
  30727. };
  30728. /**
  30729. * Serialized format for FresnelParameters.
  30730. */
  30731. export type IFresnelParametersSerialized = {
  30732. /**
  30733. * Define the color used on edges (grazing angle) [as an array]
  30734. */
  30735. leftColor: number[];
  30736. /**
  30737. * Define the color used on center [as an array]
  30738. */
  30739. rightColor: number[];
  30740. /**
  30741. * Define bias applied to computed fresnel term
  30742. */
  30743. bias: number;
  30744. /**
  30745. * Defined the power exponent applied to fresnel term
  30746. */
  30747. power?: number;
  30748. /**
  30749. * Define if the fresnel effect is enable or not.
  30750. */
  30751. isEnabled: boolean;
  30752. };
  30753. /**
  30754. * This represents all the required information to add a fresnel effect on a material:
  30755. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30756. */
  30757. export class FresnelParameters {
  30758. private _isEnabled;
  30759. /**
  30760. * Define if the fresnel effect is enable or not.
  30761. */
  30762. get isEnabled(): boolean;
  30763. set isEnabled(value: boolean);
  30764. /**
  30765. * Define the color used on edges (grazing angle)
  30766. */
  30767. leftColor: Color3;
  30768. /**
  30769. * Define the color used on center
  30770. */
  30771. rightColor: Color3;
  30772. /**
  30773. * Define bias applied to computed fresnel term
  30774. */
  30775. bias: number;
  30776. /**
  30777. * Defined the power exponent applied to fresnel term
  30778. */
  30779. power: number;
  30780. /**
  30781. * Creates a new FresnelParameters object.
  30782. *
  30783. * @param options provide your own settings to optionally to override defaults
  30784. */
  30785. constructor(options?: IFresnelParametersCreationOptions);
  30786. /**
  30787. * Clones the current fresnel and its valuues
  30788. * @returns a clone fresnel configuration
  30789. */
  30790. clone(): FresnelParameters;
  30791. /**
  30792. * Determines equality between FresnelParameters objects
  30793. * @param otherFresnelParameters defines the second operand
  30794. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30795. */
  30796. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30797. /**
  30798. * Serializes the current fresnel parameters to a JSON representation.
  30799. * @return the JSON serialization
  30800. */
  30801. serialize(): IFresnelParametersSerialized;
  30802. /**
  30803. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30804. * @param parsedFresnelParameters Define the JSON representation
  30805. * @returns the parsed parameters
  30806. */
  30807. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30808. }
  30809. }
  30810. declare module "babylonjs/Materials/materialFlags" {
  30811. /**
  30812. * This groups all the flags used to control the materials channel.
  30813. */
  30814. export class MaterialFlags {
  30815. private static _DiffuseTextureEnabled;
  30816. /**
  30817. * Are diffuse textures enabled in the application.
  30818. */
  30819. static get DiffuseTextureEnabled(): boolean;
  30820. static set DiffuseTextureEnabled(value: boolean);
  30821. private static _DetailTextureEnabled;
  30822. /**
  30823. * Are detail textures enabled in the application.
  30824. */
  30825. static get DetailTextureEnabled(): boolean;
  30826. static set DetailTextureEnabled(value: boolean);
  30827. private static _AmbientTextureEnabled;
  30828. /**
  30829. * Are ambient textures enabled in the application.
  30830. */
  30831. static get AmbientTextureEnabled(): boolean;
  30832. static set AmbientTextureEnabled(value: boolean);
  30833. private static _OpacityTextureEnabled;
  30834. /**
  30835. * Are opacity textures enabled in the application.
  30836. */
  30837. static get OpacityTextureEnabled(): boolean;
  30838. static set OpacityTextureEnabled(value: boolean);
  30839. private static _ReflectionTextureEnabled;
  30840. /**
  30841. * Are reflection textures enabled in the application.
  30842. */
  30843. static get ReflectionTextureEnabled(): boolean;
  30844. static set ReflectionTextureEnabled(value: boolean);
  30845. private static _EmissiveTextureEnabled;
  30846. /**
  30847. * Are emissive textures enabled in the application.
  30848. */
  30849. static get EmissiveTextureEnabled(): boolean;
  30850. static set EmissiveTextureEnabled(value: boolean);
  30851. private static _SpecularTextureEnabled;
  30852. /**
  30853. * Are specular textures enabled in the application.
  30854. */
  30855. static get SpecularTextureEnabled(): boolean;
  30856. static set SpecularTextureEnabled(value: boolean);
  30857. private static _BumpTextureEnabled;
  30858. /**
  30859. * Are bump textures enabled in the application.
  30860. */
  30861. static get BumpTextureEnabled(): boolean;
  30862. static set BumpTextureEnabled(value: boolean);
  30863. private static _LightmapTextureEnabled;
  30864. /**
  30865. * Are lightmap textures enabled in the application.
  30866. */
  30867. static get LightmapTextureEnabled(): boolean;
  30868. static set LightmapTextureEnabled(value: boolean);
  30869. private static _RefractionTextureEnabled;
  30870. /**
  30871. * Are refraction textures enabled in the application.
  30872. */
  30873. static get RefractionTextureEnabled(): boolean;
  30874. static set RefractionTextureEnabled(value: boolean);
  30875. private static _ColorGradingTextureEnabled;
  30876. /**
  30877. * Are color grading textures enabled in the application.
  30878. */
  30879. static get ColorGradingTextureEnabled(): boolean;
  30880. static set ColorGradingTextureEnabled(value: boolean);
  30881. private static _FresnelEnabled;
  30882. /**
  30883. * Are fresnels enabled in the application.
  30884. */
  30885. static get FresnelEnabled(): boolean;
  30886. static set FresnelEnabled(value: boolean);
  30887. private static _ClearCoatTextureEnabled;
  30888. /**
  30889. * Are clear coat textures enabled in the application.
  30890. */
  30891. static get ClearCoatTextureEnabled(): boolean;
  30892. static set ClearCoatTextureEnabled(value: boolean);
  30893. private static _ClearCoatBumpTextureEnabled;
  30894. /**
  30895. * Are clear coat bump textures enabled in the application.
  30896. */
  30897. static get ClearCoatBumpTextureEnabled(): boolean;
  30898. static set ClearCoatBumpTextureEnabled(value: boolean);
  30899. private static _ClearCoatTintTextureEnabled;
  30900. /**
  30901. * Are clear coat tint textures enabled in the application.
  30902. */
  30903. static get ClearCoatTintTextureEnabled(): boolean;
  30904. static set ClearCoatTintTextureEnabled(value: boolean);
  30905. private static _SheenTextureEnabled;
  30906. /**
  30907. * Are sheen textures enabled in the application.
  30908. */
  30909. static get SheenTextureEnabled(): boolean;
  30910. static set SheenTextureEnabled(value: boolean);
  30911. private static _AnisotropicTextureEnabled;
  30912. /**
  30913. * Are anisotropic textures enabled in the application.
  30914. */
  30915. static get AnisotropicTextureEnabled(): boolean;
  30916. static set AnisotropicTextureEnabled(value: boolean);
  30917. private static _ThicknessTextureEnabled;
  30918. /**
  30919. * Are thickness textures enabled in the application.
  30920. */
  30921. static get ThicknessTextureEnabled(): boolean;
  30922. static set ThicknessTextureEnabled(value: boolean);
  30923. }
  30924. }
  30925. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30926. /** @hidden */
  30927. export var defaultFragmentDeclaration: {
  30928. name: string;
  30929. shader: string;
  30930. };
  30931. }
  30932. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30933. /** @hidden */
  30934. export var defaultUboDeclaration: {
  30935. name: string;
  30936. shader: string;
  30937. };
  30938. }
  30939. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  30940. /** @hidden */
  30941. export var prePassDeclaration: {
  30942. name: string;
  30943. shader: string;
  30944. };
  30945. }
  30946. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30947. /** @hidden */
  30948. export var lightFragmentDeclaration: {
  30949. name: string;
  30950. shader: string;
  30951. };
  30952. }
  30953. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30954. /** @hidden */
  30955. export var lightUboDeclaration: {
  30956. name: string;
  30957. shader: string;
  30958. };
  30959. }
  30960. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30961. /** @hidden */
  30962. export var lightsFragmentFunctions: {
  30963. name: string;
  30964. shader: string;
  30965. };
  30966. }
  30967. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30968. /** @hidden */
  30969. export var shadowsFragmentFunctions: {
  30970. name: string;
  30971. shader: string;
  30972. };
  30973. }
  30974. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30975. /** @hidden */
  30976. export var fresnelFunction: {
  30977. name: string;
  30978. shader: string;
  30979. };
  30980. }
  30981. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30982. /** @hidden */
  30983. export var bumpFragmentMainFunctions: {
  30984. name: string;
  30985. shader: string;
  30986. };
  30987. }
  30988. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30989. /** @hidden */
  30990. export var bumpFragmentFunctions: {
  30991. name: string;
  30992. shader: string;
  30993. };
  30994. }
  30995. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30996. /** @hidden */
  30997. export var logDepthDeclaration: {
  30998. name: string;
  30999. shader: string;
  31000. };
  31001. }
  31002. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31003. /** @hidden */
  31004. export var bumpFragment: {
  31005. name: string;
  31006. shader: string;
  31007. };
  31008. }
  31009. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31010. /** @hidden */
  31011. export var depthPrePass: {
  31012. name: string;
  31013. shader: string;
  31014. };
  31015. }
  31016. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31017. /** @hidden */
  31018. export var lightFragment: {
  31019. name: string;
  31020. shader: string;
  31021. };
  31022. }
  31023. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31024. /** @hidden */
  31025. export var logDepthFragment: {
  31026. name: string;
  31027. shader: string;
  31028. };
  31029. }
  31030. declare module "babylonjs/Shaders/default.fragment" {
  31031. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31032. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31033. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31034. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31035. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31036. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31037. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31038. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31039. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31040. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31041. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31042. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31043. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31044. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31045. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31046. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31047. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31048. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31049. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31050. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31051. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31052. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31053. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31054. /** @hidden */
  31055. export var defaultPixelShader: {
  31056. name: string;
  31057. shader: string;
  31058. };
  31059. }
  31060. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31061. /** @hidden */
  31062. export var defaultVertexDeclaration: {
  31063. name: string;
  31064. shader: string;
  31065. };
  31066. }
  31067. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31068. /** @hidden */
  31069. export var bumpVertexDeclaration: {
  31070. name: string;
  31071. shader: string;
  31072. };
  31073. }
  31074. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31075. /** @hidden */
  31076. export var bumpVertex: {
  31077. name: string;
  31078. shader: string;
  31079. };
  31080. }
  31081. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31082. /** @hidden */
  31083. export var fogVertex: {
  31084. name: string;
  31085. shader: string;
  31086. };
  31087. }
  31088. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31089. /** @hidden */
  31090. export var shadowsVertex: {
  31091. name: string;
  31092. shader: string;
  31093. };
  31094. }
  31095. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31096. /** @hidden */
  31097. export var pointCloudVertex: {
  31098. name: string;
  31099. shader: string;
  31100. };
  31101. }
  31102. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31103. /** @hidden */
  31104. export var logDepthVertex: {
  31105. name: string;
  31106. shader: string;
  31107. };
  31108. }
  31109. declare module "babylonjs/Shaders/default.vertex" {
  31110. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31111. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31112. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31113. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31114. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31115. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31116. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31117. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31118. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31119. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31120. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31121. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31122. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31123. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31124. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31125. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31126. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31127. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31128. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31129. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31130. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31131. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31132. /** @hidden */
  31133. export var defaultVertexShader: {
  31134. name: string;
  31135. shader: string;
  31136. };
  31137. }
  31138. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31139. import { Nullable } from "babylonjs/types";
  31140. import { Scene } from "babylonjs/scene";
  31141. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31142. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31143. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31144. /**
  31145. * @hidden
  31146. */
  31147. export interface IMaterialDetailMapDefines {
  31148. DETAIL: boolean;
  31149. DETAILDIRECTUV: number;
  31150. DETAIL_NORMALBLENDMETHOD: number;
  31151. /** @hidden */
  31152. _areTexturesDirty: boolean;
  31153. }
  31154. /**
  31155. * Define the code related to the detail map parameters of a material
  31156. *
  31157. * Inspired from:
  31158. * 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
  31159. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31160. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31161. */
  31162. export class DetailMapConfiguration {
  31163. private _texture;
  31164. /**
  31165. * The detail texture of the material.
  31166. */
  31167. texture: Nullable<BaseTexture>;
  31168. /**
  31169. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31170. * Bigger values mean stronger blending
  31171. */
  31172. diffuseBlendLevel: number;
  31173. /**
  31174. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31175. * Bigger values mean stronger blending. Only used with PBR materials
  31176. */
  31177. roughnessBlendLevel: number;
  31178. /**
  31179. * Defines how strong the bump effect from the detail map is
  31180. * Bigger values mean stronger effect
  31181. */
  31182. bumpLevel: number;
  31183. private _normalBlendMethod;
  31184. /**
  31185. * The method used to blend the bump and detail normals together
  31186. */
  31187. normalBlendMethod: number;
  31188. private _isEnabled;
  31189. /**
  31190. * Enable or disable the detail map on this material
  31191. */
  31192. isEnabled: boolean;
  31193. /** @hidden */
  31194. private _internalMarkAllSubMeshesAsTexturesDirty;
  31195. /** @hidden */
  31196. _markAllSubMeshesAsTexturesDirty(): void;
  31197. /**
  31198. * Instantiate a new detail map
  31199. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31200. */
  31201. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31202. /**
  31203. * Gets whether the submesh is ready to be used or not.
  31204. * @param defines the list of "defines" to update.
  31205. * @param scene defines the scene the material belongs to.
  31206. * @returns - boolean indicating that the submesh is ready or not.
  31207. */
  31208. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31209. /**
  31210. * Update the defines for detail map usage
  31211. * @param defines the list of "defines" to update.
  31212. * @param scene defines the scene the material belongs to.
  31213. */
  31214. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31215. /**
  31216. * Binds the material data.
  31217. * @param uniformBuffer defines the Uniform buffer to fill in.
  31218. * @param scene defines the scene the material belongs to.
  31219. * @param isFrozen defines whether the material is frozen or not.
  31220. */
  31221. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31222. /**
  31223. * Checks to see if a texture is used in the material.
  31224. * @param texture - Base texture to use.
  31225. * @returns - Boolean specifying if a texture is used in the material.
  31226. */
  31227. hasTexture(texture: BaseTexture): boolean;
  31228. /**
  31229. * Returns an array of the actively used textures.
  31230. * @param activeTextures Array of BaseTextures
  31231. */
  31232. getActiveTextures(activeTextures: BaseTexture[]): void;
  31233. /**
  31234. * Returns the animatable textures.
  31235. * @param animatables Array of animatable textures.
  31236. */
  31237. getAnimatables(animatables: IAnimatable[]): void;
  31238. /**
  31239. * Disposes the resources of the material.
  31240. * @param forceDisposeTextures - Forces the disposal of all textures.
  31241. */
  31242. dispose(forceDisposeTextures?: boolean): void;
  31243. /**
  31244. * Get the current class name useful for serialization or dynamic coding.
  31245. * @returns "DetailMap"
  31246. */
  31247. getClassName(): string;
  31248. /**
  31249. * Add the required uniforms to the current list.
  31250. * @param uniforms defines the current uniform list.
  31251. */
  31252. static AddUniforms(uniforms: string[]): void;
  31253. /**
  31254. * Add the required samplers to the current list.
  31255. * @param samplers defines the current sampler list.
  31256. */
  31257. static AddSamplers(samplers: string[]): void;
  31258. /**
  31259. * Add the required uniforms to the current buffer.
  31260. * @param uniformBuffer defines the current uniform buffer.
  31261. */
  31262. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31263. /**
  31264. * Makes a duplicate of the current instance into another one.
  31265. * @param detailMap define the instance where to copy the info
  31266. */
  31267. copyTo(detailMap: DetailMapConfiguration): void;
  31268. /**
  31269. * Serializes this detail map instance
  31270. * @returns - An object with the serialized instance.
  31271. */
  31272. serialize(): any;
  31273. /**
  31274. * Parses a detail map setting from a serialized object.
  31275. * @param source - Serialized object.
  31276. * @param scene Defines the scene we are parsing for
  31277. * @param rootUrl Defines the rootUrl to load from
  31278. */
  31279. parse(source: any, scene: Scene, rootUrl: string): void;
  31280. }
  31281. }
  31282. declare module "babylonjs/Materials/standardMaterial" {
  31283. import { SmartArray } from "babylonjs/Misc/smartArray";
  31284. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31285. import { Nullable } from "babylonjs/types";
  31286. import { Scene } from "babylonjs/scene";
  31287. import { Matrix } from "babylonjs/Maths/math.vector";
  31288. import { Color3 } from "babylonjs/Maths/math.color";
  31289. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31291. import { Mesh } from "babylonjs/Meshes/mesh";
  31292. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31293. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31294. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31295. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31296. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31297. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31298. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31299. import "babylonjs/Shaders/default.fragment";
  31300. import "babylonjs/Shaders/default.vertex";
  31301. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31302. /** @hidden */
  31303. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31304. MAINUV1: boolean;
  31305. MAINUV2: boolean;
  31306. DIFFUSE: boolean;
  31307. DIFFUSEDIRECTUV: number;
  31308. DETAIL: boolean;
  31309. DETAILDIRECTUV: number;
  31310. DETAIL_NORMALBLENDMETHOD: number;
  31311. AMBIENT: boolean;
  31312. AMBIENTDIRECTUV: number;
  31313. OPACITY: boolean;
  31314. OPACITYDIRECTUV: number;
  31315. OPACITYRGB: boolean;
  31316. REFLECTION: boolean;
  31317. EMISSIVE: boolean;
  31318. EMISSIVEDIRECTUV: number;
  31319. SPECULAR: boolean;
  31320. SPECULARDIRECTUV: number;
  31321. BUMP: boolean;
  31322. BUMPDIRECTUV: number;
  31323. PARALLAX: boolean;
  31324. PARALLAXOCCLUSION: boolean;
  31325. SPECULAROVERALPHA: boolean;
  31326. CLIPPLANE: boolean;
  31327. CLIPPLANE2: boolean;
  31328. CLIPPLANE3: boolean;
  31329. CLIPPLANE4: boolean;
  31330. CLIPPLANE5: boolean;
  31331. CLIPPLANE6: boolean;
  31332. ALPHATEST: boolean;
  31333. DEPTHPREPASS: boolean;
  31334. ALPHAFROMDIFFUSE: boolean;
  31335. POINTSIZE: boolean;
  31336. FOG: boolean;
  31337. SPECULARTERM: boolean;
  31338. DIFFUSEFRESNEL: boolean;
  31339. OPACITYFRESNEL: boolean;
  31340. REFLECTIONFRESNEL: boolean;
  31341. REFRACTIONFRESNEL: boolean;
  31342. EMISSIVEFRESNEL: boolean;
  31343. FRESNEL: boolean;
  31344. NORMAL: boolean;
  31345. UV1: boolean;
  31346. UV2: boolean;
  31347. VERTEXCOLOR: boolean;
  31348. VERTEXALPHA: boolean;
  31349. NUM_BONE_INFLUENCERS: number;
  31350. BonesPerMesh: number;
  31351. BONETEXTURE: boolean;
  31352. INSTANCES: boolean;
  31353. THIN_INSTANCES: boolean;
  31354. GLOSSINESS: boolean;
  31355. ROUGHNESS: boolean;
  31356. EMISSIVEASILLUMINATION: boolean;
  31357. LINKEMISSIVEWITHDIFFUSE: boolean;
  31358. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31359. LIGHTMAP: boolean;
  31360. LIGHTMAPDIRECTUV: number;
  31361. OBJECTSPACE_NORMALMAP: boolean;
  31362. USELIGHTMAPASSHADOWMAP: boolean;
  31363. REFLECTIONMAP_3D: boolean;
  31364. REFLECTIONMAP_SPHERICAL: boolean;
  31365. REFLECTIONMAP_PLANAR: boolean;
  31366. REFLECTIONMAP_CUBIC: boolean;
  31367. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31368. REFLECTIONMAP_PROJECTION: boolean;
  31369. REFLECTIONMAP_SKYBOX: boolean;
  31370. REFLECTIONMAP_EXPLICIT: boolean;
  31371. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31372. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31373. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31374. INVERTCUBICMAP: boolean;
  31375. LOGARITHMICDEPTH: boolean;
  31376. REFRACTION: boolean;
  31377. REFRACTIONMAP_3D: boolean;
  31378. REFLECTIONOVERALPHA: boolean;
  31379. TWOSIDEDLIGHTING: boolean;
  31380. SHADOWFLOAT: boolean;
  31381. MORPHTARGETS: boolean;
  31382. MORPHTARGETS_NORMAL: boolean;
  31383. MORPHTARGETS_TANGENT: boolean;
  31384. MORPHTARGETS_UV: boolean;
  31385. NUM_MORPH_INFLUENCERS: number;
  31386. NONUNIFORMSCALING: boolean;
  31387. PREMULTIPLYALPHA: boolean;
  31388. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31389. ALPHABLEND: boolean;
  31390. PREPASS: boolean;
  31391. SCENE_MRT_COUNT: number;
  31392. RGBDLIGHTMAP: boolean;
  31393. RGBDREFLECTION: boolean;
  31394. RGBDREFRACTION: boolean;
  31395. IMAGEPROCESSING: boolean;
  31396. VIGNETTE: boolean;
  31397. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31398. VIGNETTEBLENDMODEOPAQUE: boolean;
  31399. TONEMAPPING: boolean;
  31400. TONEMAPPING_ACES: boolean;
  31401. CONTRAST: boolean;
  31402. COLORCURVES: boolean;
  31403. COLORGRADING: boolean;
  31404. COLORGRADING3D: boolean;
  31405. SAMPLER3DGREENDEPTH: boolean;
  31406. SAMPLER3DBGRMAP: boolean;
  31407. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31408. MULTIVIEW: boolean;
  31409. /**
  31410. * If the reflection texture on this material is in linear color space
  31411. * @hidden
  31412. */
  31413. IS_REFLECTION_LINEAR: boolean;
  31414. /**
  31415. * If the refraction texture on this material is in linear color space
  31416. * @hidden
  31417. */
  31418. IS_REFRACTION_LINEAR: boolean;
  31419. EXPOSURE: boolean;
  31420. constructor();
  31421. setReflectionMode(modeToEnable: string): void;
  31422. }
  31423. /**
  31424. * This is the default material used in Babylon. It is the best trade off between quality
  31425. * and performances.
  31426. * @see https://doc.babylonjs.com/babylon101/materials
  31427. */
  31428. export class StandardMaterial extends PushMaterial {
  31429. private _diffuseTexture;
  31430. /**
  31431. * The basic texture of the material as viewed under a light.
  31432. */
  31433. diffuseTexture: Nullable<BaseTexture>;
  31434. private _ambientTexture;
  31435. /**
  31436. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31437. */
  31438. ambientTexture: Nullable<BaseTexture>;
  31439. private _opacityTexture;
  31440. /**
  31441. * Define the transparency of the material from a texture.
  31442. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31443. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31444. */
  31445. opacityTexture: Nullable<BaseTexture>;
  31446. private _reflectionTexture;
  31447. /**
  31448. * Define the texture used to display the reflection.
  31449. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31450. */
  31451. reflectionTexture: Nullable<BaseTexture>;
  31452. private _emissiveTexture;
  31453. /**
  31454. * Define texture of the material as if self lit.
  31455. * This will be mixed in the final result even in the absence of light.
  31456. */
  31457. emissiveTexture: Nullable<BaseTexture>;
  31458. private _specularTexture;
  31459. /**
  31460. * Define how the color and intensity of the highlight given by the light in the material.
  31461. */
  31462. specularTexture: Nullable<BaseTexture>;
  31463. private _bumpTexture;
  31464. /**
  31465. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31466. * 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.
  31467. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31468. */
  31469. bumpTexture: Nullable<BaseTexture>;
  31470. private _lightmapTexture;
  31471. /**
  31472. * Complex lighting can be computationally expensive to compute at runtime.
  31473. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31474. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31475. */
  31476. lightmapTexture: Nullable<BaseTexture>;
  31477. private _refractionTexture;
  31478. /**
  31479. * Define the texture used to display the refraction.
  31480. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31481. */
  31482. refractionTexture: Nullable<BaseTexture>;
  31483. /**
  31484. * The color of the material lit by the environmental background lighting.
  31485. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31486. */
  31487. ambientColor: Color3;
  31488. /**
  31489. * The basic color of the material as viewed under a light.
  31490. */
  31491. diffuseColor: Color3;
  31492. /**
  31493. * Define how the color and intensity of the highlight given by the light in the material.
  31494. */
  31495. specularColor: Color3;
  31496. /**
  31497. * Define the color of the material as if self lit.
  31498. * This will be mixed in the final result even in the absence of light.
  31499. */
  31500. emissiveColor: Color3;
  31501. /**
  31502. * Defines how sharp are the highlights in the material.
  31503. * The bigger the value the sharper giving a more glossy feeling to the result.
  31504. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31505. */
  31506. specularPower: number;
  31507. private _useAlphaFromDiffuseTexture;
  31508. /**
  31509. * Does the transparency come from the diffuse texture alpha channel.
  31510. */
  31511. useAlphaFromDiffuseTexture: boolean;
  31512. private _useEmissiveAsIllumination;
  31513. /**
  31514. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31515. */
  31516. useEmissiveAsIllumination: boolean;
  31517. private _linkEmissiveWithDiffuse;
  31518. /**
  31519. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31520. * the emissive level when the final color is close to one.
  31521. */
  31522. linkEmissiveWithDiffuse: boolean;
  31523. private _useSpecularOverAlpha;
  31524. /**
  31525. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31526. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31527. */
  31528. useSpecularOverAlpha: boolean;
  31529. private _useReflectionOverAlpha;
  31530. /**
  31531. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31532. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31533. */
  31534. useReflectionOverAlpha: boolean;
  31535. private _disableLighting;
  31536. /**
  31537. * Does lights from the scene impacts this material.
  31538. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31539. */
  31540. disableLighting: boolean;
  31541. private _useObjectSpaceNormalMap;
  31542. /**
  31543. * Allows using an object space normal map (instead of tangent space).
  31544. */
  31545. useObjectSpaceNormalMap: boolean;
  31546. private _useParallax;
  31547. /**
  31548. * Is parallax enabled or not.
  31549. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31550. */
  31551. useParallax: boolean;
  31552. private _useParallaxOcclusion;
  31553. /**
  31554. * Is parallax occlusion enabled or not.
  31555. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31556. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31557. */
  31558. useParallaxOcclusion: boolean;
  31559. /**
  31560. * 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.
  31561. */
  31562. parallaxScaleBias: number;
  31563. private _roughness;
  31564. /**
  31565. * Helps to define how blurry the reflections should appears in the material.
  31566. */
  31567. roughness: number;
  31568. /**
  31569. * In case of refraction, define the value of the index of refraction.
  31570. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31571. */
  31572. indexOfRefraction: number;
  31573. /**
  31574. * Invert the refraction texture alongside the y axis.
  31575. * It can be useful with procedural textures or probe for instance.
  31576. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31577. */
  31578. invertRefractionY: boolean;
  31579. /**
  31580. * Defines the alpha limits in alpha test mode.
  31581. */
  31582. alphaCutOff: number;
  31583. private _useLightmapAsShadowmap;
  31584. /**
  31585. * In case of light mapping, define whether the map contains light or shadow informations.
  31586. */
  31587. useLightmapAsShadowmap: boolean;
  31588. private _diffuseFresnelParameters;
  31589. /**
  31590. * Define the diffuse fresnel parameters of the material.
  31591. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31592. */
  31593. diffuseFresnelParameters: FresnelParameters;
  31594. private _opacityFresnelParameters;
  31595. /**
  31596. * Define the opacity fresnel parameters of the material.
  31597. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31598. */
  31599. opacityFresnelParameters: FresnelParameters;
  31600. private _reflectionFresnelParameters;
  31601. /**
  31602. * Define the reflection fresnel parameters of the material.
  31603. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31604. */
  31605. reflectionFresnelParameters: FresnelParameters;
  31606. private _refractionFresnelParameters;
  31607. /**
  31608. * Define the refraction fresnel parameters of the material.
  31609. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31610. */
  31611. refractionFresnelParameters: FresnelParameters;
  31612. private _emissiveFresnelParameters;
  31613. /**
  31614. * Define the emissive fresnel parameters of the material.
  31615. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31616. */
  31617. emissiveFresnelParameters: FresnelParameters;
  31618. private _useReflectionFresnelFromSpecular;
  31619. /**
  31620. * If true automatically deducts the fresnels values from the material specularity.
  31621. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31622. */
  31623. useReflectionFresnelFromSpecular: boolean;
  31624. private _useGlossinessFromSpecularMapAlpha;
  31625. /**
  31626. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31627. */
  31628. useGlossinessFromSpecularMapAlpha: boolean;
  31629. private _maxSimultaneousLights;
  31630. /**
  31631. * Defines the maximum number of lights that can be used in the material
  31632. */
  31633. maxSimultaneousLights: number;
  31634. private _invertNormalMapX;
  31635. /**
  31636. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31637. */
  31638. invertNormalMapX: boolean;
  31639. private _invertNormalMapY;
  31640. /**
  31641. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31642. */
  31643. invertNormalMapY: boolean;
  31644. private _twoSidedLighting;
  31645. /**
  31646. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31647. */
  31648. twoSidedLighting: boolean;
  31649. /**
  31650. * Default configuration related to image processing available in the standard Material.
  31651. */
  31652. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31653. /**
  31654. * Gets the image processing configuration used either in this material.
  31655. */
  31656. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31657. /**
  31658. * Sets the Default image processing configuration used either in the this material.
  31659. *
  31660. * If sets to null, the scene one is in use.
  31661. */
  31662. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31663. /**
  31664. * Keep track of the image processing observer to allow dispose and replace.
  31665. */
  31666. private _imageProcessingObserver;
  31667. /**
  31668. * Attaches a new image processing configuration to the Standard Material.
  31669. * @param configuration
  31670. */
  31671. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31672. /**
  31673. * Gets wether the color curves effect is enabled.
  31674. */
  31675. get cameraColorCurvesEnabled(): boolean;
  31676. /**
  31677. * Sets wether the color curves effect is enabled.
  31678. */
  31679. set cameraColorCurvesEnabled(value: boolean);
  31680. /**
  31681. * Gets wether the color grading effect is enabled.
  31682. */
  31683. get cameraColorGradingEnabled(): boolean;
  31684. /**
  31685. * Gets wether the color grading effect is enabled.
  31686. */
  31687. set cameraColorGradingEnabled(value: boolean);
  31688. /**
  31689. * Gets wether tonemapping is enabled or not.
  31690. */
  31691. get cameraToneMappingEnabled(): boolean;
  31692. /**
  31693. * Sets wether tonemapping is enabled or not
  31694. */
  31695. set cameraToneMappingEnabled(value: boolean);
  31696. /**
  31697. * The camera exposure used on this material.
  31698. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31699. * This corresponds to a photographic exposure.
  31700. */
  31701. get cameraExposure(): number;
  31702. /**
  31703. * The camera exposure used on this material.
  31704. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31705. * This corresponds to a photographic exposure.
  31706. */
  31707. set cameraExposure(value: number);
  31708. /**
  31709. * Gets The camera contrast used on this material.
  31710. */
  31711. get cameraContrast(): number;
  31712. /**
  31713. * Sets The camera contrast used on this material.
  31714. */
  31715. set cameraContrast(value: number);
  31716. /**
  31717. * Gets the Color Grading 2D Lookup Texture.
  31718. */
  31719. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  31720. /**
  31721. * Sets the Color Grading 2D Lookup Texture.
  31722. */
  31723. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  31724. /**
  31725. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31726. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31727. * 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;
  31728. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31729. */
  31730. get cameraColorCurves(): Nullable<ColorCurves>;
  31731. /**
  31732. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31733. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31734. * 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;
  31735. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31736. */
  31737. set cameraColorCurves(value: Nullable<ColorCurves>);
  31738. /**
  31739. * Can this material render to several textures at once
  31740. */
  31741. get canRenderToMRT(): boolean;
  31742. /**
  31743. * Defines the detail map parameters for the material.
  31744. */
  31745. readonly detailMap: DetailMapConfiguration;
  31746. protected _renderTargets: SmartArray<RenderTargetTexture>;
  31747. protected _worldViewProjectionMatrix: Matrix;
  31748. protected _globalAmbientColor: Color3;
  31749. protected _useLogarithmicDepth: boolean;
  31750. protected _rebuildInParallel: boolean;
  31751. /**
  31752. * Instantiates a new standard material.
  31753. * This is the default material used in Babylon. It is the best trade off between quality
  31754. * and performances.
  31755. * @see https://doc.babylonjs.com/babylon101/materials
  31756. * @param name Define the name of the material in the scene
  31757. * @param scene Define the scene the material belong to
  31758. */
  31759. constructor(name: string, scene: Scene);
  31760. /**
  31761. * Gets a boolean indicating that current material needs to register RTT
  31762. */
  31763. get hasRenderTargetTextures(): boolean;
  31764. /**
  31765. * Gets the current class name of the material e.g. "StandardMaterial"
  31766. * Mainly use in serialization.
  31767. * @returns the class name
  31768. */
  31769. getClassName(): string;
  31770. /**
  31771. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31772. * You can try switching to logarithmic depth.
  31773. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31774. */
  31775. get useLogarithmicDepth(): boolean;
  31776. set useLogarithmicDepth(value: boolean);
  31777. /**
  31778. * Specifies if the material will require alpha blending
  31779. * @returns a boolean specifying if alpha blending is needed
  31780. */
  31781. needAlphaBlending(): boolean;
  31782. /**
  31783. * Specifies if this material should be rendered in alpha test mode
  31784. * @returns a boolean specifying if an alpha test is needed.
  31785. */
  31786. needAlphaTesting(): boolean;
  31787. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31788. /**
  31789. * Get the texture used for alpha test purpose.
  31790. * @returns the diffuse texture in case of the standard material.
  31791. */
  31792. getAlphaTestTexture(): Nullable<BaseTexture>;
  31793. /**
  31794. * Get if the submesh is ready to be used and all its information available.
  31795. * Child classes can use it to update shaders
  31796. * @param mesh defines the mesh to check
  31797. * @param subMesh defines which submesh to check
  31798. * @param useInstances specifies that instances should be used
  31799. * @returns a boolean indicating that the submesh is ready or not
  31800. */
  31801. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31802. /**
  31803. * Builds the material UBO layouts.
  31804. * Used internally during the effect preparation.
  31805. */
  31806. buildUniformLayout(): void;
  31807. /**
  31808. * Unbinds the material from the mesh
  31809. */
  31810. unbind(): void;
  31811. /**
  31812. * Binds the submesh to this material by preparing the effect and shader to draw
  31813. * @param world defines the world transformation matrix
  31814. * @param mesh defines the mesh containing the submesh
  31815. * @param subMesh defines the submesh to bind the material to
  31816. */
  31817. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31818. /**
  31819. * Get the list of animatables in the material.
  31820. * @returns the list of animatables object used in the material
  31821. */
  31822. getAnimatables(): IAnimatable[];
  31823. /**
  31824. * Gets the active textures from the material
  31825. * @returns an array of textures
  31826. */
  31827. getActiveTextures(): BaseTexture[];
  31828. /**
  31829. * Specifies if the material uses a texture
  31830. * @param texture defines the texture to check against the material
  31831. * @returns a boolean specifying if the material uses the texture
  31832. */
  31833. hasTexture(texture: BaseTexture): boolean;
  31834. /**
  31835. * Disposes the material
  31836. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31837. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31838. */
  31839. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31840. /**
  31841. * Makes a duplicate of the material, and gives it a new name
  31842. * @param name defines the new name for the duplicated material
  31843. * @returns the cloned material
  31844. */
  31845. clone(name: string): StandardMaterial;
  31846. /**
  31847. * Serializes this material in a JSON representation
  31848. * @returns the serialized material object
  31849. */
  31850. serialize(): any;
  31851. /**
  31852. * Creates a standard material from parsed material data
  31853. * @param source defines the JSON representation of the material
  31854. * @param scene defines the hosting scene
  31855. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31856. * @returns a new standard material
  31857. */
  31858. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31859. /**
  31860. * Are diffuse textures enabled in the application.
  31861. */
  31862. static get DiffuseTextureEnabled(): boolean;
  31863. static set DiffuseTextureEnabled(value: boolean);
  31864. /**
  31865. * Are detail textures enabled in the application.
  31866. */
  31867. static get DetailTextureEnabled(): boolean;
  31868. static set DetailTextureEnabled(value: boolean);
  31869. /**
  31870. * Are ambient textures enabled in the application.
  31871. */
  31872. static get AmbientTextureEnabled(): boolean;
  31873. static set AmbientTextureEnabled(value: boolean);
  31874. /**
  31875. * Are opacity textures enabled in the application.
  31876. */
  31877. static get OpacityTextureEnabled(): boolean;
  31878. static set OpacityTextureEnabled(value: boolean);
  31879. /**
  31880. * Are reflection textures enabled in the application.
  31881. */
  31882. static get ReflectionTextureEnabled(): boolean;
  31883. static set ReflectionTextureEnabled(value: boolean);
  31884. /**
  31885. * Are emissive textures enabled in the application.
  31886. */
  31887. static get EmissiveTextureEnabled(): boolean;
  31888. static set EmissiveTextureEnabled(value: boolean);
  31889. /**
  31890. * Are specular textures enabled in the application.
  31891. */
  31892. static get SpecularTextureEnabled(): boolean;
  31893. static set SpecularTextureEnabled(value: boolean);
  31894. /**
  31895. * Are bump textures enabled in the application.
  31896. */
  31897. static get BumpTextureEnabled(): boolean;
  31898. static set BumpTextureEnabled(value: boolean);
  31899. /**
  31900. * Are lightmap textures enabled in the application.
  31901. */
  31902. static get LightmapTextureEnabled(): boolean;
  31903. static set LightmapTextureEnabled(value: boolean);
  31904. /**
  31905. * Are refraction textures enabled in the application.
  31906. */
  31907. static get RefractionTextureEnabled(): boolean;
  31908. static set RefractionTextureEnabled(value: boolean);
  31909. /**
  31910. * Are color grading textures enabled in the application.
  31911. */
  31912. static get ColorGradingTextureEnabled(): boolean;
  31913. static set ColorGradingTextureEnabled(value: boolean);
  31914. /**
  31915. * Are fresnels enabled in the application.
  31916. */
  31917. static get FresnelEnabled(): boolean;
  31918. static set FresnelEnabled(value: boolean);
  31919. }
  31920. }
  31921. declare module "babylonjs/Particles/solidParticleSystem" {
  31922. import { Nullable } from "babylonjs/types";
  31923. import { Mesh } from "babylonjs/Meshes/mesh";
  31924. import { Scene, IDisposable } from "babylonjs/scene";
  31925. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  31926. import { Material } from "babylonjs/Materials/material";
  31927. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31928. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31929. /**
  31930. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31931. *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.
  31932. * The SPS is also a particle system. It provides some methods to manage the particles.
  31933. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31934. *
  31935. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31936. */
  31937. export class SolidParticleSystem implements IDisposable {
  31938. /**
  31939. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31940. * Example : var p = SPS.particles[i];
  31941. */
  31942. particles: SolidParticle[];
  31943. /**
  31944. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31945. */
  31946. nbParticles: number;
  31947. /**
  31948. * If the particles must ever face the camera (default false). Useful for planar particles.
  31949. */
  31950. billboard: boolean;
  31951. /**
  31952. * Recompute normals when adding a shape
  31953. */
  31954. recomputeNormals: boolean;
  31955. /**
  31956. * This a counter ofr your own usage. It's not set by any SPS functions.
  31957. */
  31958. counter: number;
  31959. /**
  31960. * The SPS name. This name is also given to the underlying mesh.
  31961. */
  31962. name: string;
  31963. /**
  31964. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31965. */
  31966. mesh: Mesh;
  31967. /**
  31968. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31969. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31970. */
  31971. vars: any;
  31972. /**
  31973. * This array is populated when the SPS is set as 'pickable'.
  31974. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31975. * Each element of this array is an object `{idx: int, faceId: int}`.
  31976. * `idx` is the picked particle index in the `SPS.particles` array
  31977. * `faceId` is the picked face index counted within this particle.
  31978. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31979. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31980. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31981. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31982. */
  31983. pickedParticles: {
  31984. idx: number;
  31985. faceId: number;
  31986. }[];
  31987. /**
  31988. * This array is populated when the SPS is set as 'pickable'
  31989. * Each key of this array is a submesh index.
  31990. * Each element of this array is a second array defined like this :
  31991. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31992. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31993. * `idx` is the picked particle index in the `SPS.particles` array
  31994. * `faceId` is the picked face index counted within this particle.
  31995. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31996. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31997. */
  31998. pickedBySubMesh: {
  31999. idx: number;
  32000. faceId: number;
  32001. }[][];
  32002. /**
  32003. * This array is populated when `enableDepthSort` is set to true.
  32004. * Each element of this array is an instance of the class DepthSortedParticle.
  32005. */
  32006. depthSortedParticles: DepthSortedParticle[];
  32007. /**
  32008. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32009. * @hidden
  32010. */
  32011. _bSphereOnly: boolean;
  32012. /**
  32013. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32014. * @hidden
  32015. */
  32016. _bSphereRadiusFactor: number;
  32017. private _scene;
  32018. private _positions;
  32019. private _indices;
  32020. private _normals;
  32021. private _colors;
  32022. private _uvs;
  32023. private _indices32;
  32024. private _positions32;
  32025. private _normals32;
  32026. private _fixedNormal32;
  32027. private _colors32;
  32028. private _uvs32;
  32029. private _index;
  32030. private _updatable;
  32031. private _pickable;
  32032. private _isVisibilityBoxLocked;
  32033. private _alwaysVisible;
  32034. private _depthSort;
  32035. private _expandable;
  32036. private _shapeCounter;
  32037. private _copy;
  32038. private _color;
  32039. private _computeParticleColor;
  32040. private _computeParticleTexture;
  32041. private _computeParticleRotation;
  32042. private _computeParticleVertex;
  32043. private _computeBoundingBox;
  32044. private _depthSortParticles;
  32045. private _camera;
  32046. private _mustUnrotateFixedNormals;
  32047. private _particlesIntersect;
  32048. private _needs32Bits;
  32049. private _isNotBuilt;
  32050. private _lastParticleId;
  32051. private _idxOfId;
  32052. private _multimaterialEnabled;
  32053. private _useModelMaterial;
  32054. private _indicesByMaterial;
  32055. private _materialIndexes;
  32056. private _depthSortFunction;
  32057. private _materialSortFunction;
  32058. private _materials;
  32059. private _multimaterial;
  32060. private _materialIndexesById;
  32061. private _defaultMaterial;
  32062. private _autoUpdateSubMeshes;
  32063. private _tmpVertex;
  32064. /**
  32065. * Creates a SPS (Solid Particle System) object.
  32066. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32067. * @param scene (Scene) is the scene in which the SPS is added.
  32068. * @param options defines the options of the sps e.g.
  32069. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32070. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32071. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32072. * * 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.
  32073. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32074. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32075. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32076. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32077. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32078. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32079. */
  32080. constructor(name: string, scene: Scene, options?: {
  32081. updatable?: boolean;
  32082. isPickable?: boolean;
  32083. enableDepthSort?: boolean;
  32084. particleIntersection?: boolean;
  32085. boundingSphereOnly?: boolean;
  32086. bSphereRadiusFactor?: number;
  32087. expandable?: boolean;
  32088. useModelMaterial?: boolean;
  32089. enableMultiMaterial?: boolean;
  32090. });
  32091. /**
  32092. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32093. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32094. * @returns the created mesh
  32095. */
  32096. buildMesh(): Mesh;
  32097. /**
  32098. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32099. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32100. * Thus the particles generated from `digest()` have their property `position` set yet.
  32101. * @param mesh ( Mesh ) is the mesh to be digested
  32102. * @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
  32103. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32104. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32105. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32106. * @returns the current SPS
  32107. */
  32108. digest(mesh: Mesh, options?: {
  32109. facetNb?: number;
  32110. number?: number;
  32111. delta?: number;
  32112. storage?: [];
  32113. }): SolidParticleSystem;
  32114. /**
  32115. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32116. * @hidden
  32117. */
  32118. private _unrotateFixedNormals;
  32119. /**
  32120. * Resets the temporary working copy particle
  32121. * @hidden
  32122. */
  32123. private _resetCopy;
  32124. /**
  32125. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32126. * @param p the current index in the positions array to be updated
  32127. * @param ind the current index in the indices array
  32128. * @param shape a Vector3 array, the shape geometry
  32129. * @param positions the positions array to be updated
  32130. * @param meshInd the shape indices array
  32131. * @param indices the indices array to be updated
  32132. * @param meshUV the shape uv array
  32133. * @param uvs the uv array to be updated
  32134. * @param meshCol the shape color array
  32135. * @param colors the color array to be updated
  32136. * @param meshNor the shape normals array
  32137. * @param normals the normals array to be updated
  32138. * @param idx the particle index
  32139. * @param idxInShape the particle index in its shape
  32140. * @param options the addShape() method passed options
  32141. * @model the particle model
  32142. * @hidden
  32143. */
  32144. private _meshBuilder;
  32145. /**
  32146. * Returns a shape Vector3 array from positions float array
  32147. * @param positions float array
  32148. * @returns a vector3 array
  32149. * @hidden
  32150. */
  32151. private _posToShape;
  32152. /**
  32153. * Returns a shapeUV array from a float uvs (array deep copy)
  32154. * @param uvs as a float array
  32155. * @returns a shapeUV array
  32156. * @hidden
  32157. */
  32158. private _uvsToShapeUV;
  32159. /**
  32160. * Adds a new particle object in the particles array
  32161. * @param idx particle index in particles array
  32162. * @param id particle id
  32163. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32164. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32165. * @param model particle ModelShape object
  32166. * @param shapeId model shape identifier
  32167. * @param idxInShape index of the particle in the current model
  32168. * @param bInfo model bounding info object
  32169. * @param storage target storage array, if any
  32170. * @hidden
  32171. */
  32172. private _addParticle;
  32173. /**
  32174. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32175. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32176. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32177. * @param nb (positive integer) the number of particles to be created from this model
  32178. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32179. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32180. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32181. * @returns the number of shapes in the system
  32182. */
  32183. addShape(mesh: Mesh, nb: number, options?: {
  32184. positionFunction?: any;
  32185. vertexFunction?: any;
  32186. storage?: [];
  32187. }): number;
  32188. /**
  32189. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32190. * @hidden
  32191. */
  32192. private _rebuildParticle;
  32193. /**
  32194. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32195. * @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.
  32196. * @returns the SPS.
  32197. */
  32198. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32199. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32200. * Returns an array with the removed particles.
  32201. * 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.
  32202. * The SPS can't be empty so at least one particle needs to remain in place.
  32203. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32204. * @param start index of the first particle to remove
  32205. * @param end index of the last particle to remove (included)
  32206. * @returns an array populated with the removed particles
  32207. */
  32208. removeParticles(start: number, end: number): SolidParticle[];
  32209. /**
  32210. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32211. * @param solidParticleArray an array populated with Solid Particles objects
  32212. * @returns the SPS
  32213. */
  32214. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32215. /**
  32216. * Creates a new particle and modifies the SPS mesh geometry :
  32217. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32218. * - calls _addParticle() to populate the particle array
  32219. * factorized code from addShape() and insertParticlesFromArray()
  32220. * @param idx particle index in the particles array
  32221. * @param i particle index in its shape
  32222. * @param modelShape particle ModelShape object
  32223. * @param shape shape vertex array
  32224. * @param meshInd shape indices array
  32225. * @param meshUV shape uv array
  32226. * @param meshCol shape color array
  32227. * @param meshNor shape normals array
  32228. * @param bbInfo shape bounding info
  32229. * @param storage target particle storage
  32230. * @options addShape() passed options
  32231. * @hidden
  32232. */
  32233. private _insertNewParticle;
  32234. /**
  32235. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32236. * This method calls `updateParticle()` for each particle of the SPS.
  32237. * For an animated SPS, it is usually called within the render loop.
  32238. * 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.
  32239. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32240. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32241. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32242. * @returns the SPS.
  32243. */
  32244. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32245. /**
  32246. * Disposes the SPS.
  32247. */
  32248. dispose(): void;
  32249. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32250. * idx is the particle index in the SPS
  32251. * faceId is the picked face index counted within this particle.
  32252. * Returns null if the pickInfo can't identify a picked particle.
  32253. * @param pickingInfo (PickingInfo object)
  32254. * @returns {idx: number, faceId: number} or null
  32255. */
  32256. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32257. idx: number;
  32258. faceId: number;
  32259. }>;
  32260. /**
  32261. * Returns a SolidParticle object from its identifier : particle.id
  32262. * @param id (integer) the particle Id
  32263. * @returns the searched particle or null if not found in the SPS.
  32264. */
  32265. getParticleById(id: number): Nullable<SolidParticle>;
  32266. /**
  32267. * Returns a new array populated with the particles having the passed shapeId.
  32268. * @param shapeId (integer) the shape identifier
  32269. * @returns a new solid particle array
  32270. */
  32271. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32272. /**
  32273. * Populates the passed array "ref" with the particles having the passed shapeId.
  32274. * @param shapeId the shape identifier
  32275. * @returns the SPS
  32276. * @param ref
  32277. */
  32278. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32279. /**
  32280. * Computes the required SubMeshes according the materials assigned to the particles.
  32281. * @returns the solid particle system.
  32282. * Does nothing if called before the SPS mesh is built.
  32283. */
  32284. computeSubMeshes(): SolidParticleSystem;
  32285. /**
  32286. * Sorts the solid particles by material when MultiMaterial is enabled.
  32287. * Updates the indices32 array.
  32288. * Updates the indicesByMaterial array.
  32289. * Updates the mesh indices array.
  32290. * @returns the SPS
  32291. * @hidden
  32292. */
  32293. private _sortParticlesByMaterial;
  32294. /**
  32295. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32296. * @hidden
  32297. */
  32298. private _setMaterialIndexesById;
  32299. /**
  32300. * Returns an array with unique values of Materials from the passed array
  32301. * @param array the material array to be checked and filtered
  32302. * @hidden
  32303. */
  32304. private _filterUniqueMaterialId;
  32305. /**
  32306. * Sets a new Standard Material as _defaultMaterial if not already set.
  32307. * @hidden
  32308. */
  32309. private _setDefaultMaterial;
  32310. /**
  32311. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32312. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32313. * @returns the SPS.
  32314. */
  32315. refreshVisibleSize(): SolidParticleSystem;
  32316. /**
  32317. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32318. * @param size the size (float) of the visibility box
  32319. * note : this doesn't lock the SPS mesh bounding box.
  32320. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32321. */
  32322. setVisibilityBox(size: number): void;
  32323. /**
  32324. * Gets whether the SPS as always visible or not
  32325. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32326. */
  32327. get isAlwaysVisible(): boolean;
  32328. /**
  32329. * Sets the SPS as always visible or not
  32330. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32331. */
  32332. set isAlwaysVisible(val: boolean);
  32333. /**
  32334. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32335. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32336. */
  32337. set isVisibilityBoxLocked(val: boolean);
  32338. /**
  32339. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32340. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32341. */
  32342. get isVisibilityBoxLocked(): boolean;
  32343. /**
  32344. * Tells to `setParticles()` to compute the particle rotations or not.
  32345. * Default value : true. The SPS is faster when it's set to false.
  32346. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32347. */
  32348. set computeParticleRotation(val: boolean);
  32349. /**
  32350. * Tells to `setParticles()` to compute the particle colors or not.
  32351. * Default value : true. The SPS is faster when it's set to false.
  32352. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32353. */
  32354. set computeParticleColor(val: boolean);
  32355. set computeParticleTexture(val: boolean);
  32356. /**
  32357. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32358. * Default value : false. The SPS is faster when it's set to false.
  32359. * Note : the particle custom vertex positions aren't stored values.
  32360. */
  32361. set computeParticleVertex(val: boolean);
  32362. /**
  32363. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32364. */
  32365. set computeBoundingBox(val: boolean);
  32366. /**
  32367. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32368. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32369. * Default : `true`
  32370. */
  32371. set depthSortParticles(val: boolean);
  32372. /**
  32373. * Gets if `setParticles()` computes the particle rotations or not.
  32374. * Default value : true. The SPS is faster when it's set to false.
  32375. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32376. */
  32377. get computeParticleRotation(): boolean;
  32378. /**
  32379. * Gets if `setParticles()` computes the particle colors or not.
  32380. * Default value : true. The SPS is faster when it's set to false.
  32381. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32382. */
  32383. get computeParticleColor(): boolean;
  32384. /**
  32385. * Gets if `setParticles()` computes the particle textures or not.
  32386. * Default value : true. The SPS is faster when it's set to false.
  32387. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32388. */
  32389. get computeParticleTexture(): boolean;
  32390. /**
  32391. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32392. * Default value : false. The SPS is faster when it's set to false.
  32393. * Note : the particle custom vertex positions aren't stored values.
  32394. */
  32395. get computeParticleVertex(): boolean;
  32396. /**
  32397. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32398. */
  32399. get computeBoundingBox(): boolean;
  32400. /**
  32401. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32402. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32403. * Default : `true`
  32404. */
  32405. get depthSortParticles(): boolean;
  32406. /**
  32407. * Gets if the SPS is created as expandable at construction time.
  32408. * Default : `false`
  32409. */
  32410. get expandable(): boolean;
  32411. /**
  32412. * Gets if the SPS supports the Multi Materials
  32413. */
  32414. get multimaterialEnabled(): boolean;
  32415. /**
  32416. * Gets if the SPS uses the model materials for its own multimaterial.
  32417. */
  32418. get useModelMaterial(): boolean;
  32419. /**
  32420. * The SPS used material array.
  32421. */
  32422. get materials(): Material[];
  32423. /**
  32424. * Sets the SPS MultiMaterial from the passed materials.
  32425. * Note : the passed array is internally copied and not used then by reference.
  32426. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32427. */
  32428. setMultiMaterial(materials: Material[]): void;
  32429. /**
  32430. * The SPS computed multimaterial object
  32431. */
  32432. get multimaterial(): MultiMaterial;
  32433. set multimaterial(mm: MultiMaterial);
  32434. /**
  32435. * If the subMeshes must be updated on the next call to setParticles()
  32436. */
  32437. get autoUpdateSubMeshes(): boolean;
  32438. set autoUpdateSubMeshes(val: boolean);
  32439. /**
  32440. * This function does nothing. It may be overwritten to set all the particle first values.
  32441. * The SPS doesn't call this function, you may have to call it by your own.
  32442. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32443. */
  32444. initParticles(): void;
  32445. /**
  32446. * This function does nothing. It may be overwritten to recycle a particle.
  32447. * The SPS doesn't call this function, you may have to call it by your own.
  32448. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32449. * @param particle The particle to recycle
  32450. * @returns the recycled particle
  32451. */
  32452. recycleParticle(particle: SolidParticle): SolidParticle;
  32453. /**
  32454. * Updates a particle : this function should be overwritten by the user.
  32455. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32456. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32457. * @example : just set a particle position or velocity and recycle conditions
  32458. * @param particle The particle to update
  32459. * @returns the updated particle
  32460. */
  32461. updateParticle(particle: SolidParticle): SolidParticle;
  32462. /**
  32463. * Updates a vertex of a particle : it can be overwritten by the user.
  32464. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32465. * @param particle the current particle
  32466. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32467. * @param pt the index of the current vertex in the particle shape
  32468. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32469. * @example : just set a vertex particle position or color
  32470. * @returns the sps
  32471. */
  32472. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32473. /**
  32474. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32475. * This does nothing and may be overwritten by the user.
  32476. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32477. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32478. * @param update the boolean update value actually passed to setParticles()
  32479. */
  32480. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32481. /**
  32482. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32483. * This will be passed three parameters.
  32484. * This does nothing and may be overwritten by the user.
  32485. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32486. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32487. * @param update the boolean update value actually passed to setParticles()
  32488. */
  32489. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32490. }
  32491. }
  32492. declare module "babylonjs/Particles/solidParticle" {
  32493. import { Nullable } from "babylonjs/types";
  32494. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32495. import { Color4 } from "babylonjs/Maths/math.color";
  32496. import { Mesh } from "babylonjs/Meshes/mesh";
  32497. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32498. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32499. import { Plane } from "babylonjs/Maths/math.plane";
  32500. import { Material } from "babylonjs/Materials/material";
  32501. /**
  32502. * Represents one particle of a solid particle system.
  32503. */
  32504. export class SolidParticle {
  32505. /**
  32506. * particle global index
  32507. */
  32508. idx: number;
  32509. /**
  32510. * particle identifier
  32511. */
  32512. id: number;
  32513. /**
  32514. * The color of the particle
  32515. */
  32516. color: Nullable<Color4>;
  32517. /**
  32518. * The world space position of the particle.
  32519. */
  32520. position: Vector3;
  32521. /**
  32522. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32523. */
  32524. rotation: Vector3;
  32525. /**
  32526. * The world space rotation quaternion of the particle.
  32527. */
  32528. rotationQuaternion: Nullable<Quaternion>;
  32529. /**
  32530. * The scaling of the particle.
  32531. */
  32532. scaling: Vector3;
  32533. /**
  32534. * The uvs of the particle.
  32535. */
  32536. uvs: Vector4;
  32537. /**
  32538. * The current speed of the particle.
  32539. */
  32540. velocity: Vector3;
  32541. /**
  32542. * The pivot point in the particle local space.
  32543. */
  32544. pivot: Vector3;
  32545. /**
  32546. * Must the particle be translated from its pivot point in its local space ?
  32547. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32548. * Default : false
  32549. */
  32550. translateFromPivot: boolean;
  32551. /**
  32552. * Is the particle active or not ?
  32553. */
  32554. alive: boolean;
  32555. /**
  32556. * Is the particle visible or not ?
  32557. */
  32558. isVisible: boolean;
  32559. /**
  32560. * Index of this particle in the global "positions" array (Internal use)
  32561. * @hidden
  32562. */
  32563. _pos: number;
  32564. /**
  32565. * @hidden Index of this particle in the global "indices" array (Internal use)
  32566. */
  32567. _ind: number;
  32568. /**
  32569. * @hidden ModelShape of this particle (Internal use)
  32570. */
  32571. _model: ModelShape;
  32572. /**
  32573. * ModelShape id of this particle
  32574. */
  32575. shapeId: number;
  32576. /**
  32577. * Index of the particle in its shape id
  32578. */
  32579. idxInShape: number;
  32580. /**
  32581. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32582. */
  32583. _modelBoundingInfo: BoundingInfo;
  32584. /**
  32585. * @hidden Particle BoundingInfo object (Internal use)
  32586. */
  32587. _boundingInfo: BoundingInfo;
  32588. /**
  32589. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32590. */
  32591. _sps: SolidParticleSystem;
  32592. /**
  32593. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32594. */
  32595. _stillInvisible: boolean;
  32596. /**
  32597. * @hidden Last computed particle rotation matrix
  32598. */
  32599. _rotationMatrix: number[];
  32600. /**
  32601. * Parent particle Id, if any.
  32602. * Default null.
  32603. */
  32604. parentId: Nullable<number>;
  32605. /**
  32606. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32607. */
  32608. materialIndex: Nullable<number>;
  32609. /**
  32610. * Custom object or properties.
  32611. */
  32612. props: Nullable<any>;
  32613. /**
  32614. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32615. * The possible values are :
  32616. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32617. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32618. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32619. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32620. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32621. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32622. * */
  32623. cullingStrategy: number;
  32624. /**
  32625. * @hidden Internal global position in the SPS.
  32626. */
  32627. _globalPosition: Vector3;
  32628. /**
  32629. * Creates a Solid Particle object.
  32630. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32631. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32632. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32633. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32634. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32635. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32636. * @param shapeId (integer) is the model shape identifier in the SPS.
  32637. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32638. * @param sps defines the sps it is associated to
  32639. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32640. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32641. */
  32642. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32643. /**
  32644. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32645. * @param target the particle target
  32646. * @returns the current particle
  32647. */
  32648. copyToRef(target: SolidParticle): SolidParticle;
  32649. /**
  32650. * Legacy support, changed scale to scaling
  32651. */
  32652. get scale(): Vector3;
  32653. /**
  32654. * Legacy support, changed scale to scaling
  32655. */
  32656. set scale(scale: Vector3);
  32657. /**
  32658. * Legacy support, changed quaternion to rotationQuaternion
  32659. */
  32660. get quaternion(): Nullable<Quaternion>;
  32661. /**
  32662. * Legacy support, changed quaternion to rotationQuaternion
  32663. */
  32664. set quaternion(q: Nullable<Quaternion>);
  32665. /**
  32666. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32667. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32668. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32669. * @returns true if it intersects
  32670. */
  32671. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32672. /**
  32673. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32674. * A particle is in the frustum if its bounding box intersects the frustum
  32675. * @param frustumPlanes defines the frustum to test
  32676. * @returns true if the particle is in the frustum planes
  32677. */
  32678. isInFrustum(frustumPlanes: Plane[]): boolean;
  32679. /**
  32680. * get the rotation matrix of the particle
  32681. * @hidden
  32682. */
  32683. getRotationMatrix(m: Matrix): void;
  32684. }
  32685. /**
  32686. * Represents the shape of the model used by one particle of a solid particle system.
  32687. * SPS internal tool, don't use it manually.
  32688. */
  32689. export class ModelShape {
  32690. /**
  32691. * The shape id
  32692. * @hidden
  32693. */
  32694. shapeID: number;
  32695. /**
  32696. * flat array of model positions (internal use)
  32697. * @hidden
  32698. */
  32699. _shape: Vector3[];
  32700. /**
  32701. * flat array of model UVs (internal use)
  32702. * @hidden
  32703. */
  32704. _shapeUV: number[];
  32705. /**
  32706. * color array of the model
  32707. * @hidden
  32708. */
  32709. _shapeColors: number[];
  32710. /**
  32711. * indices array of the model
  32712. * @hidden
  32713. */
  32714. _indices: number[];
  32715. /**
  32716. * normals array of the model
  32717. * @hidden
  32718. */
  32719. _normals: number[];
  32720. /**
  32721. * length of the shape in the model indices array (internal use)
  32722. * @hidden
  32723. */
  32724. _indicesLength: number;
  32725. /**
  32726. * Custom position function (internal use)
  32727. * @hidden
  32728. */
  32729. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32730. /**
  32731. * Custom vertex function (internal use)
  32732. * @hidden
  32733. */
  32734. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32735. /**
  32736. * Model material (internal use)
  32737. * @hidden
  32738. */
  32739. _material: Nullable<Material>;
  32740. /**
  32741. * 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.
  32742. * SPS internal tool, don't use it manually.
  32743. * @hidden
  32744. */
  32745. 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>);
  32746. }
  32747. /**
  32748. * Represents a Depth Sorted Particle in the solid particle system.
  32749. * @hidden
  32750. */
  32751. export class DepthSortedParticle {
  32752. /**
  32753. * Particle index
  32754. */
  32755. idx: number;
  32756. /**
  32757. * Index of the particle in the "indices" array
  32758. */
  32759. ind: number;
  32760. /**
  32761. * Length of the particle shape in the "indices" array
  32762. */
  32763. indicesLength: number;
  32764. /**
  32765. * Squared distance from the particle to the camera
  32766. */
  32767. sqDistance: number;
  32768. /**
  32769. * Material index when used with MultiMaterials
  32770. */
  32771. materialIndex: number;
  32772. /**
  32773. * Creates a new sorted particle
  32774. * @param materialIndex
  32775. */
  32776. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32777. }
  32778. /**
  32779. * Represents a solid particle vertex
  32780. */
  32781. export class SolidParticleVertex {
  32782. /**
  32783. * Vertex position
  32784. */
  32785. position: Vector3;
  32786. /**
  32787. * Vertex color
  32788. */
  32789. color: Color4;
  32790. /**
  32791. * Vertex UV
  32792. */
  32793. uv: Vector2;
  32794. /**
  32795. * Creates a new solid particle vertex
  32796. */
  32797. constructor();
  32798. /** Vertex x coordinate */
  32799. get x(): number;
  32800. set x(val: number);
  32801. /** Vertex y coordinate */
  32802. get y(): number;
  32803. set y(val: number);
  32804. /** Vertex z coordinate */
  32805. get z(): number;
  32806. set z(val: number);
  32807. }
  32808. }
  32809. declare module "babylonjs/Collisions/meshCollisionData" {
  32810. import { Collider } from "babylonjs/Collisions/collider";
  32811. import { Vector3 } from "babylonjs/Maths/math.vector";
  32812. import { Nullable } from "babylonjs/types";
  32813. import { Observer } from "babylonjs/Misc/observable";
  32814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32815. /**
  32816. * @hidden
  32817. */
  32818. export class _MeshCollisionData {
  32819. _checkCollisions: boolean;
  32820. _collisionMask: number;
  32821. _collisionGroup: number;
  32822. _surroundingMeshes: Nullable<AbstractMesh[]>;
  32823. _collider: Nullable<Collider>;
  32824. _oldPositionForCollisions: Vector3;
  32825. _diffPositionForCollisions: Vector3;
  32826. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32827. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32828. }
  32829. }
  32830. declare module "babylonjs/Meshes/abstractMesh" {
  32831. import { Observable } from "babylonjs/Misc/observable";
  32832. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  32833. import { Camera } from "babylonjs/Cameras/camera";
  32834. import { Scene, IDisposable } from "babylonjs/scene";
  32835. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32836. import { Node } from "babylonjs/node";
  32837. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  32838. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32839. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32840. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32841. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32842. import { Material } from "babylonjs/Materials/material";
  32843. import { Light } from "babylonjs/Lights/light";
  32844. import { Skeleton } from "babylonjs/Bones/skeleton";
  32845. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  32846. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  32847. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32848. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  32849. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  32850. import { Plane } from "babylonjs/Maths/math.plane";
  32851. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32852. import { Ray } from "babylonjs/Culling/ray";
  32853. import { Collider } from "babylonjs/Collisions/collider";
  32854. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32855. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  32856. /** @hidden */
  32857. class _FacetDataStorage {
  32858. facetPositions: Vector3[];
  32859. facetNormals: Vector3[];
  32860. facetPartitioning: number[][];
  32861. facetNb: number;
  32862. partitioningSubdivisions: number;
  32863. partitioningBBoxRatio: number;
  32864. facetDataEnabled: boolean;
  32865. facetParameters: any;
  32866. bbSize: Vector3;
  32867. subDiv: {
  32868. max: number;
  32869. X: number;
  32870. Y: number;
  32871. Z: number;
  32872. };
  32873. facetDepthSort: boolean;
  32874. facetDepthSortEnabled: boolean;
  32875. depthSortedIndices: IndicesArray;
  32876. depthSortedFacets: {
  32877. ind: number;
  32878. sqDistance: number;
  32879. }[];
  32880. facetDepthSortFunction: (f1: {
  32881. ind: number;
  32882. sqDistance: number;
  32883. }, f2: {
  32884. ind: number;
  32885. sqDistance: number;
  32886. }) => number;
  32887. facetDepthSortFrom: Vector3;
  32888. facetDepthSortOrigin: Vector3;
  32889. invertedMatrix: Matrix;
  32890. }
  32891. /**
  32892. * @hidden
  32893. **/
  32894. class _InternalAbstractMeshDataInfo {
  32895. _hasVertexAlpha: boolean;
  32896. _useVertexColors: boolean;
  32897. _numBoneInfluencers: number;
  32898. _applyFog: boolean;
  32899. _receiveShadows: boolean;
  32900. _facetData: _FacetDataStorage;
  32901. _visibility: number;
  32902. _skeleton: Nullable<Skeleton>;
  32903. _layerMask: number;
  32904. _computeBonesUsingShaders: boolean;
  32905. _isActive: boolean;
  32906. _onlyForInstances: boolean;
  32907. _isActiveIntermediate: boolean;
  32908. _onlyForInstancesIntermediate: boolean;
  32909. _actAsRegularMesh: boolean;
  32910. }
  32911. /**
  32912. * Class used to store all common mesh properties
  32913. */
  32914. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32915. /** No occlusion */
  32916. static OCCLUSION_TYPE_NONE: number;
  32917. /** Occlusion set to optimisitic */
  32918. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32919. /** Occlusion set to strict */
  32920. static OCCLUSION_TYPE_STRICT: number;
  32921. /** Use an accurante occlusion algorithm */
  32922. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32923. /** Use a conservative occlusion algorithm */
  32924. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32925. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32926. * Test order :
  32927. * Is the bounding sphere outside the frustum ?
  32928. * If not, are the bounding box vertices outside the frustum ?
  32929. * It not, then the cullable object is in the frustum.
  32930. */
  32931. static readonly CULLINGSTRATEGY_STANDARD: number;
  32932. /** Culling strategy : Bounding Sphere Only.
  32933. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32934. * It's also less accurate than the standard because some not visible objects can still be selected.
  32935. * Test : is the bounding sphere outside the frustum ?
  32936. * If not, then the cullable object is in the frustum.
  32937. */
  32938. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32939. /** Culling strategy : Optimistic Inclusion.
  32940. * This in an inclusion test first, then the standard exclusion test.
  32941. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32942. * 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.
  32943. * Anyway, it's as accurate as the standard strategy.
  32944. * Test :
  32945. * Is the cullable object bounding sphere center in the frustum ?
  32946. * If not, apply the default culling strategy.
  32947. */
  32948. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32949. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32950. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32951. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32952. * 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.
  32953. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32954. * Test :
  32955. * Is the cullable object bounding sphere center in the frustum ?
  32956. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32957. */
  32958. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32959. /**
  32960. * No billboard
  32961. */
  32962. static get BILLBOARDMODE_NONE(): number;
  32963. /** Billboard on X axis */
  32964. static get BILLBOARDMODE_X(): number;
  32965. /** Billboard on Y axis */
  32966. static get BILLBOARDMODE_Y(): number;
  32967. /** Billboard on Z axis */
  32968. static get BILLBOARDMODE_Z(): number;
  32969. /** Billboard on all axes */
  32970. static get BILLBOARDMODE_ALL(): number;
  32971. /** Billboard on using position instead of orientation */
  32972. static get BILLBOARDMODE_USE_POSITION(): number;
  32973. /** @hidden */
  32974. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32975. /**
  32976. * The culling strategy to use to check whether the mesh must be rendered or not.
  32977. * This value can be changed at any time and will be used on the next render mesh selection.
  32978. * The possible values are :
  32979. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32980. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32981. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32982. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32983. * Please read each static variable documentation to get details about the culling process.
  32984. * */
  32985. cullingStrategy: number;
  32986. /**
  32987. * Gets the number of facets in the mesh
  32988. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32989. */
  32990. get facetNb(): number;
  32991. /**
  32992. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32993. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32994. */
  32995. get partitioningSubdivisions(): number;
  32996. set partitioningSubdivisions(nb: number);
  32997. /**
  32998. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32999. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33000. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33001. */
  33002. get partitioningBBoxRatio(): number;
  33003. set partitioningBBoxRatio(ratio: number);
  33004. /**
  33005. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33006. * Works only for updatable meshes.
  33007. * Doesn't work with multi-materials
  33008. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33009. */
  33010. get mustDepthSortFacets(): boolean;
  33011. set mustDepthSortFacets(sort: boolean);
  33012. /**
  33013. * The location (Vector3) where the facet depth sort must be computed from.
  33014. * By default, the active camera position.
  33015. * Used only when facet depth sort is enabled
  33016. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33017. */
  33018. get facetDepthSortFrom(): Vector3;
  33019. set facetDepthSortFrom(location: Vector3);
  33020. /**
  33021. * gets a boolean indicating if facetData is enabled
  33022. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33023. */
  33024. get isFacetDataEnabled(): boolean;
  33025. /** @hidden */
  33026. _updateNonUniformScalingState(value: boolean): boolean;
  33027. /**
  33028. * An event triggered when this mesh collides with another one
  33029. */
  33030. onCollideObservable: Observable<AbstractMesh>;
  33031. /** Set a function to call when this mesh collides with another one */
  33032. set onCollide(callback: () => void);
  33033. /**
  33034. * An event triggered when the collision's position changes
  33035. */
  33036. onCollisionPositionChangeObservable: Observable<Vector3>;
  33037. /** Set a function to call when the collision's position changes */
  33038. set onCollisionPositionChange(callback: () => void);
  33039. /**
  33040. * An event triggered when material is changed
  33041. */
  33042. onMaterialChangedObservable: Observable<AbstractMesh>;
  33043. /**
  33044. * Gets or sets the orientation for POV movement & rotation
  33045. */
  33046. definedFacingForward: boolean;
  33047. /** @hidden */
  33048. _occlusionQuery: Nullable<WebGLQuery>;
  33049. /** @hidden */
  33050. _renderingGroup: Nullable<RenderingGroup>;
  33051. /**
  33052. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33053. */
  33054. get visibility(): number;
  33055. /**
  33056. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33057. */
  33058. set visibility(value: number);
  33059. /** Gets or sets the alpha index used to sort transparent meshes
  33060. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33061. */
  33062. alphaIndex: number;
  33063. /**
  33064. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33065. */
  33066. isVisible: boolean;
  33067. /**
  33068. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33069. */
  33070. isPickable: boolean;
  33071. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33072. showSubMeshesBoundingBox: boolean;
  33073. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33074. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33075. */
  33076. isBlocker: boolean;
  33077. /**
  33078. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33079. */
  33080. enablePointerMoveEvents: boolean;
  33081. /**
  33082. * Specifies the rendering group id for this mesh (0 by default)
  33083. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33084. */
  33085. renderingGroupId: number;
  33086. private _material;
  33087. /** Gets or sets current material */
  33088. get material(): Nullable<Material>;
  33089. set material(value: Nullable<Material>);
  33090. /**
  33091. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33092. * @see https://doc.babylonjs.com/babylon101/shadows
  33093. */
  33094. get receiveShadows(): boolean;
  33095. set receiveShadows(value: boolean);
  33096. /** Defines color to use when rendering outline */
  33097. outlineColor: Color3;
  33098. /** Define width to use when rendering outline */
  33099. outlineWidth: number;
  33100. /** Defines color to use when rendering overlay */
  33101. overlayColor: Color3;
  33102. /** Defines alpha to use when rendering overlay */
  33103. overlayAlpha: number;
  33104. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33105. get hasVertexAlpha(): boolean;
  33106. set hasVertexAlpha(value: boolean);
  33107. /** 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) */
  33108. get useVertexColors(): boolean;
  33109. set useVertexColors(value: boolean);
  33110. /**
  33111. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33112. */
  33113. get computeBonesUsingShaders(): boolean;
  33114. set computeBonesUsingShaders(value: boolean);
  33115. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33116. get numBoneInfluencers(): number;
  33117. set numBoneInfluencers(value: number);
  33118. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33119. get applyFog(): boolean;
  33120. set applyFog(value: boolean);
  33121. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33122. useOctreeForRenderingSelection: boolean;
  33123. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33124. useOctreeForPicking: boolean;
  33125. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33126. useOctreeForCollisions: boolean;
  33127. /**
  33128. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33129. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33130. */
  33131. get layerMask(): number;
  33132. set layerMask(value: number);
  33133. /**
  33134. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33135. */
  33136. alwaysSelectAsActiveMesh: boolean;
  33137. /**
  33138. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33139. */
  33140. doNotSyncBoundingInfo: boolean;
  33141. /**
  33142. * Gets or sets the current action manager
  33143. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33144. */
  33145. actionManager: Nullable<AbstractActionManager>;
  33146. private _meshCollisionData;
  33147. /**
  33148. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33149. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33150. */
  33151. ellipsoid: Vector3;
  33152. /**
  33153. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33154. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33155. */
  33156. ellipsoidOffset: Vector3;
  33157. /**
  33158. * Gets or sets a collision mask used to mask collisions (default is -1).
  33159. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33160. */
  33161. get collisionMask(): number;
  33162. set collisionMask(mask: number);
  33163. /**
  33164. * Gets or sets the current collision group mask (-1 by default).
  33165. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33166. */
  33167. get collisionGroup(): number;
  33168. set collisionGroup(mask: number);
  33169. /**
  33170. * Gets or sets current surrounding meshes (null by default).
  33171. *
  33172. * By default collision detection is tested against every mesh in the scene.
  33173. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33174. * meshes will be tested for the collision.
  33175. *
  33176. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33177. */
  33178. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33179. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33180. /**
  33181. * Defines edge width used when edgesRenderer is enabled
  33182. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33183. */
  33184. edgesWidth: number;
  33185. /**
  33186. * Defines edge color used when edgesRenderer is enabled
  33187. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33188. */
  33189. edgesColor: Color4;
  33190. /** @hidden */
  33191. _edgesRenderer: Nullable<IEdgesRenderer>;
  33192. /** @hidden */
  33193. _masterMesh: Nullable<AbstractMesh>;
  33194. /** @hidden */
  33195. _boundingInfo: Nullable<BoundingInfo>;
  33196. /** @hidden */
  33197. _renderId: number;
  33198. /**
  33199. * Gets or sets the list of subMeshes
  33200. * @see https://doc.babylonjs.com/how_to/multi_materials
  33201. */
  33202. subMeshes: SubMesh[];
  33203. /** @hidden */
  33204. _intersectionsInProgress: AbstractMesh[];
  33205. /** @hidden */
  33206. _unIndexed: boolean;
  33207. /** @hidden */
  33208. _lightSources: Light[];
  33209. /** Gets the list of lights affecting that mesh */
  33210. get lightSources(): Light[];
  33211. /** @hidden */
  33212. get _positions(): Nullable<Vector3[]>;
  33213. /** @hidden */
  33214. _waitingData: {
  33215. lods: Nullable<any>;
  33216. actions: Nullable<any>;
  33217. freezeWorldMatrix: Nullable<boolean>;
  33218. };
  33219. /** @hidden */
  33220. _bonesTransformMatrices: Nullable<Float32Array>;
  33221. /** @hidden */
  33222. _transformMatrixTexture: Nullable<RawTexture>;
  33223. /**
  33224. * Gets or sets a skeleton to apply skining transformations
  33225. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33226. */
  33227. set skeleton(value: Nullable<Skeleton>);
  33228. get skeleton(): Nullable<Skeleton>;
  33229. /**
  33230. * An event triggered when the mesh is rebuilt.
  33231. */
  33232. onRebuildObservable: Observable<AbstractMesh>;
  33233. /**
  33234. * Creates a new AbstractMesh
  33235. * @param name defines the name of the mesh
  33236. * @param scene defines the hosting scene
  33237. */
  33238. constructor(name: string, scene?: Nullable<Scene>);
  33239. /**
  33240. * Returns the string "AbstractMesh"
  33241. * @returns "AbstractMesh"
  33242. */
  33243. getClassName(): string;
  33244. /**
  33245. * Gets a string representation of the current mesh
  33246. * @param fullDetails defines a boolean indicating if full details must be included
  33247. * @returns a string representation of the current mesh
  33248. */
  33249. toString(fullDetails?: boolean): string;
  33250. /**
  33251. * @hidden
  33252. */
  33253. protected _getEffectiveParent(): Nullable<Node>;
  33254. /** @hidden */
  33255. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33256. /** @hidden */
  33257. _rebuild(): void;
  33258. /** @hidden */
  33259. _resyncLightSources(): void;
  33260. /** @hidden */
  33261. _resyncLightSource(light: Light): void;
  33262. /** @hidden */
  33263. _unBindEffect(): void;
  33264. /** @hidden */
  33265. _removeLightSource(light: Light, dispose: boolean): void;
  33266. private _markSubMeshesAsDirty;
  33267. /** @hidden */
  33268. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33269. /** @hidden */
  33270. _markSubMeshesAsAttributesDirty(): void;
  33271. /** @hidden */
  33272. _markSubMeshesAsMiscDirty(): void;
  33273. /**
  33274. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33275. */
  33276. get scaling(): Vector3;
  33277. set scaling(newScaling: Vector3);
  33278. /**
  33279. * Returns true if the mesh is blocked. Implemented by child classes
  33280. */
  33281. get isBlocked(): boolean;
  33282. /**
  33283. * Returns the mesh itself by default. Implemented by child classes
  33284. * @param camera defines the camera to use to pick the right LOD level
  33285. * @returns the currentAbstractMesh
  33286. */
  33287. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33288. /**
  33289. * Returns 0 by default. Implemented by child classes
  33290. * @returns an integer
  33291. */
  33292. getTotalVertices(): number;
  33293. /**
  33294. * Returns a positive integer : the total number of indices in this mesh geometry.
  33295. * @returns the numner of indices or zero if the mesh has no geometry.
  33296. */
  33297. getTotalIndices(): number;
  33298. /**
  33299. * Returns null by default. Implemented by child classes
  33300. * @returns null
  33301. */
  33302. getIndices(): Nullable<IndicesArray>;
  33303. /**
  33304. * Returns the array of the requested vertex data kind. Implemented by child classes
  33305. * @param kind defines the vertex data kind to use
  33306. * @returns null
  33307. */
  33308. getVerticesData(kind: string): Nullable<FloatArray>;
  33309. /**
  33310. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33311. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33312. * Note that a new underlying VertexBuffer object is created each call.
  33313. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33314. * @param kind defines vertex data kind:
  33315. * * VertexBuffer.PositionKind
  33316. * * VertexBuffer.UVKind
  33317. * * VertexBuffer.UV2Kind
  33318. * * VertexBuffer.UV3Kind
  33319. * * VertexBuffer.UV4Kind
  33320. * * VertexBuffer.UV5Kind
  33321. * * VertexBuffer.UV6Kind
  33322. * * VertexBuffer.ColorKind
  33323. * * VertexBuffer.MatricesIndicesKind
  33324. * * VertexBuffer.MatricesIndicesExtraKind
  33325. * * VertexBuffer.MatricesWeightsKind
  33326. * * VertexBuffer.MatricesWeightsExtraKind
  33327. * @param data defines the data source
  33328. * @param updatable defines if the data must be flagged as updatable (or static)
  33329. * @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
  33330. * @returns the current mesh
  33331. */
  33332. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33333. /**
  33334. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33335. * If the mesh has no geometry, it is simply returned as it is.
  33336. * @param kind defines vertex data kind:
  33337. * * VertexBuffer.PositionKind
  33338. * * VertexBuffer.UVKind
  33339. * * VertexBuffer.UV2Kind
  33340. * * VertexBuffer.UV3Kind
  33341. * * VertexBuffer.UV4Kind
  33342. * * VertexBuffer.UV5Kind
  33343. * * VertexBuffer.UV6Kind
  33344. * * VertexBuffer.ColorKind
  33345. * * VertexBuffer.MatricesIndicesKind
  33346. * * VertexBuffer.MatricesIndicesExtraKind
  33347. * * VertexBuffer.MatricesWeightsKind
  33348. * * VertexBuffer.MatricesWeightsExtraKind
  33349. * @param data defines the data source
  33350. * @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
  33351. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33352. * @returns the current mesh
  33353. */
  33354. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33355. /**
  33356. * Sets the mesh indices,
  33357. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33358. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33359. * @param totalVertices Defines the total number of vertices
  33360. * @returns the current mesh
  33361. */
  33362. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33363. /**
  33364. * Gets a boolean indicating if specific vertex data is present
  33365. * @param kind defines the vertex data kind to use
  33366. * @returns true is data kind is present
  33367. */
  33368. isVerticesDataPresent(kind: string): boolean;
  33369. /**
  33370. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33371. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33372. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33373. * @returns a BoundingInfo
  33374. */
  33375. getBoundingInfo(): BoundingInfo;
  33376. /**
  33377. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33378. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33379. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33380. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33381. * @returns the current mesh
  33382. */
  33383. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33384. /**
  33385. * Overwrite the current bounding info
  33386. * @param boundingInfo defines the new bounding info
  33387. * @returns the current mesh
  33388. */
  33389. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33390. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33391. get useBones(): boolean;
  33392. /** @hidden */
  33393. _preActivate(): void;
  33394. /** @hidden */
  33395. _preActivateForIntermediateRendering(renderId: number): void;
  33396. /** @hidden */
  33397. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33398. /** @hidden */
  33399. _postActivate(): void;
  33400. /** @hidden */
  33401. _freeze(): void;
  33402. /** @hidden */
  33403. _unFreeze(): void;
  33404. /**
  33405. * Gets the current world matrix
  33406. * @returns a Matrix
  33407. */
  33408. getWorldMatrix(): Matrix;
  33409. /** @hidden */
  33410. _getWorldMatrixDeterminant(): number;
  33411. /**
  33412. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33413. */
  33414. get isAnInstance(): boolean;
  33415. /**
  33416. * Gets a boolean indicating if this mesh has instances
  33417. */
  33418. get hasInstances(): boolean;
  33419. /**
  33420. * Gets a boolean indicating if this mesh has thin instances
  33421. */
  33422. get hasThinInstances(): boolean;
  33423. /**
  33424. * Perform relative position change from the point of view of behind the front of the mesh.
  33425. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33426. * Supports definition of mesh facing forward or backward
  33427. * @param amountRight defines the distance on the right axis
  33428. * @param amountUp defines the distance on the up axis
  33429. * @param amountForward defines the distance on the forward axis
  33430. * @returns the current mesh
  33431. */
  33432. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33433. /**
  33434. * Calculate relative position change from the point of view of behind the front of the mesh.
  33435. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33436. * Supports definition of mesh facing forward or backward
  33437. * @param amountRight defines the distance on the right axis
  33438. * @param amountUp defines the distance on the up axis
  33439. * @param amountForward defines the distance on the forward axis
  33440. * @returns the new displacement vector
  33441. */
  33442. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33443. /**
  33444. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33445. * Supports definition of mesh facing forward or backward
  33446. * @param flipBack defines the flip
  33447. * @param twirlClockwise defines the twirl
  33448. * @param tiltRight defines the tilt
  33449. * @returns the current mesh
  33450. */
  33451. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33452. /**
  33453. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33454. * Supports definition of mesh facing forward or backward.
  33455. * @param flipBack defines the flip
  33456. * @param twirlClockwise defines the twirl
  33457. * @param tiltRight defines the tilt
  33458. * @returns the new rotation vector
  33459. */
  33460. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33461. /**
  33462. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33463. * This means the mesh underlying bounding box and sphere are recomputed.
  33464. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33465. * @returns the current mesh
  33466. */
  33467. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33468. /** @hidden */
  33469. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33470. /** @hidden */
  33471. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33472. /** @hidden */
  33473. _updateBoundingInfo(): AbstractMesh;
  33474. /** @hidden */
  33475. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33476. /** @hidden */
  33477. protected _afterComputeWorldMatrix(): void;
  33478. /** @hidden */
  33479. get _effectiveMesh(): AbstractMesh;
  33480. /**
  33481. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33482. * A mesh is in the frustum if its bounding box intersects the frustum
  33483. * @param frustumPlanes defines the frustum to test
  33484. * @returns true if the mesh is in the frustum planes
  33485. */
  33486. isInFrustum(frustumPlanes: Plane[]): boolean;
  33487. /**
  33488. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33489. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33490. * @param frustumPlanes defines the frustum to test
  33491. * @returns true if the mesh is completely in the frustum planes
  33492. */
  33493. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33494. /**
  33495. * True if the mesh intersects another mesh or a SolidParticle object
  33496. * @param mesh defines a target mesh or SolidParticle to test
  33497. * @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)
  33498. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33499. * @returns true if there is an intersection
  33500. */
  33501. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33502. /**
  33503. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33504. * @param point defines the point to test
  33505. * @returns true if there is an intersection
  33506. */
  33507. intersectsPoint(point: Vector3): boolean;
  33508. /**
  33509. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33510. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33511. */
  33512. get checkCollisions(): boolean;
  33513. set checkCollisions(collisionEnabled: boolean);
  33514. /**
  33515. * Gets Collider object used to compute collisions (not physics)
  33516. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33517. */
  33518. get collider(): Nullable<Collider>;
  33519. /**
  33520. * Move the mesh using collision engine
  33521. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33522. * @param displacement defines the requested displacement vector
  33523. * @returns the current mesh
  33524. */
  33525. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33526. private _onCollisionPositionChange;
  33527. /** @hidden */
  33528. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33529. /** @hidden */
  33530. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33531. /** @hidden */
  33532. _checkCollision(collider: Collider): AbstractMesh;
  33533. /** @hidden */
  33534. _generatePointsArray(): boolean;
  33535. /**
  33536. * Checks if the passed Ray intersects with the mesh
  33537. * @param ray defines the ray to use
  33538. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33539. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33540. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33541. * @returns the picking info
  33542. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33543. */
  33544. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  33545. /**
  33546. * Clones the current mesh
  33547. * @param name defines the mesh name
  33548. * @param newParent defines the new mesh parent
  33549. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33550. * @returns the new mesh
  33551. */
  33552. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33553. /**
  33554. * Disposes all the submeshes of the current meshnp
  33555. * @returns the current mesh
  33556. */
  33557. releaseSubMeshes(): AbstractMesh;
  33558. /**
  33559. * Releases resources associated with this abstract mesh.
  33560. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33561. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33562. */
  33563. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33564. /**
  33565. * Adds the passed mesh as a child to the current mesh
  33566. * @param mesh defines the child mesh
  33567. * @returns the current mesh
  33568. */
  33569. addChild(mesh: AbstractMesh): AbstractMesh;
  33570. /**
  33571. * Removes the passed mesh from the current mesh children list
  33572. * @param mesh defines the child mesh
  33573. * @returns the current mesh
  33574. */
  33575. removeChild(mesh: AbstractMesh): AbstractMesh;
  33576. /** @hidden */
  33577. private _initFacetData;
  33578. /**
  33579. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33580. * This method can be called within the render loop.
  33581. * 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
  33582. * @returns the current mesh
  33583. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33584. */
  33585. updateFacetData(): AbstractMesh;
  33586. /**
  33587. * Returns the facetLocalNormals array.
  33588. * The normals are expressed in the mesh local spac
  33589. * @returns an array of Vector3
  33590. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33591. */
  33592. getFacetLocalNormals(): Vector3[];
  33593. /**
  33594. * Returns the facetLocalPositions array.
  33595. * The facet positions are expressed in the mesh local space
  33596. * @returns an array of Vector3
  33597. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33598. */
  33599. getFacetLocalPositions(): Vector3[];
  33600. /**
  33601. * Returns the facetLocalPartioning array
  33602. * @returns an array of array of numbers
  33603. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33604. */
  33605. getFacetLocalPartitioning(): number[][];
  33606. /**
  33607. * Returns the i-th facet position in the world system.
  33608. * This method allocates a new Vector3 per call
  33609. * @param i defines the facet index
  33610. * @returns a new Vector3
  33611. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33612. */
  33613. getFacetPosition(i: number): Vector3;
  33614. /**
  33615. * Sets the reference Vector3 with the i-th facet position in the world system
  33616. * @param i defines the facet index
  33617. * @param ref defines the target vector
  33618. * @returns the current mesh
  33619. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33620. */
  33621. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33622. /**
  33623. * Returns the i-th facet normal in the world system.
  33624. * This method allocates a new Vector3 per call
  33625. * @param i defines the facet index
  33626. * @returns a new Vector3
  33627. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33628. */
  33629. getFacetNormal(i: number): Vector3;
  33630. /**
  33631. * Sets the reference Vector3 with the i-th facet normal in the world system
  33632. * @param i defines the facet index
  33633. * @param ref defines the target vector
  33634. * @returns the current mesh
  33635. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33636. */
  33637. getFacetNormalToRef(i: number, ref: Vector3): this;
  33638. /**
  33639. * 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)
  33640. * @param x defines x coordinate
  33641. * @param y defines y coordinate
  33642. * @param z defines z coordinate
  33643. * @returns the array of facet indexes
  33644. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33645. */
  33646. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33647. /**
  33648. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33649. * @param projected sets as the (x,y,z) world projection on the facet
  33650. * @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
  33651. * @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
  33652. * @param x defines x coordinate
  33653. * @param y defines y coordinate
  33654. * @param z defines z coordinate
  33655. * @returns the face index if found (or null instead)
  33656. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33657. */
  33658. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33659. /**
  33660. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33661. * @param projected sets as the (x,y,z) local projection on the facet
  33662. * @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
  33663. * @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
  33664. * @param x defines x coordinate
  33665. * @param y defines y coordinate
  33666. * @param z defines z coordinate
  33667. * @returns the face index if found (or null instead)
  33668. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33669. */
  33670. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33671. /**
  33672. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33673. * @returns the parameters
  33674. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33675. */
  33676. getFacetDataParameters(): any;
  33677. /**
  33678. * Disables the feature FacetData and frees the related memory
  33679. * @returns the current mesh
  33680. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33681. */
  33682. disableFacetData(): AbstractMesh;
  33683. /**
  33684. * Updates the AbstractMesh indices array
  33685. * @param indices defines the data source
  33686. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33687. * @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)
  33688. * @returns the current mesh
  33689. */
  33690. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33691. /**
  33692. * Creates new normals data for the mesh
  33693. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  33694. * @returns the current mesh
  33695. */
  33696. createNormals(updatable: boolean): AbstractMesh;
  33697. /**
  33698. * Align the mesh with a normal
  33699. * @param normal defines the normal to use
  33700. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  33701. * @returns the current mesh
  33702. */
  33703. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  33704. /** @hidden */
  33705. _checkOcclusionQuery(): boolean;
  33706. /**
  33707. * Disables the mesh edge rendering mode
  33708. * @returns the currentAbstractMesh
  33709. */
  33710. disableEdgesRendering(): AbstractMesh;
  33711. /**
  33712. * Enables the edge rendering mode on the mesh.
  33713. * This mode makes the mesh edges visible
  33714. * @param epsilon defines the maximal distance between two angles to detect a face
  33715. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  33716. * @returns the currentAbstractMesh
  33717. * @see https://www.babylonjs-playground.com/#19O9TU#0
  33718. */
  33719. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  33720. /**
  33721. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  33722. * @returns an array of particle systems in the scene that use the mesh as an emitter
  33723. */
  33724. getConnectedParticleSystems(): IParticleSystem[];
  33725. }
  33726. }
  33727. declare module "babylonjs/Actions/actionEvent" {
  33728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33729. import { Nullable } from "babylonjs/types";
  33730. import { Sprite } from "babylonjs/Sprites/sprite";
  33731. import { Scene } from "babylonjs/scene";
  33732. import { Vector2 } from "babylonjs/Maths/math.vector";
  33733. /**
  33734. * Interface used to define ActionEvent
  33735. */
  33736. export interface IActionEvent {
  33737. /** The mesh or sprite that triggered the action */
  33738. source: any;
  33739. /** The X mouse cursor position at the time of the event */
  33740. pointerX: number;
  33741. /** The Y mouse cursor position at the time of the event */
  33742. pointerY: number;
  33743. /** The mesh that is currently pointed at (can be null) */
  33744. meshUnderPointer: Nullable<AbstractMesh>;
  33745. /** the original (browser) event that triggered the ActionEvent */
  33746. sourceEvent?: any;
  33747. /** additional data for the event */
  33748. additionalData?: any;
  33749. }
  33750. /**
  33751. * ActionEvent is the event being sent when an action is triggered.
  33752. */
  33753. export class ActionEvent implements IActionEvent {
  33754. /** The mesh or sprite that triggered the action */
  33755. source: any;
  33756. /** The X mouse cursor position at the time of the event */
  33757. pointerX: number;
  33758. /** The Y mouse cursor position at the time of the event */
  33759. pointerY: number;
  33760. /** The mesh that is currently pointed at (can be null) */
  33761. meshUnderPointer: Nullable<AbstractMesh>;
  33762. /** the original (browser) event that triggered the ActionEvent */
  33763. sourceEvent?: any;
  33764. /** additional data for the event */
  33765. additionalData?: any;
  33766. /**
  33767. * Creates a new ActionEvent
  33768. * @param source The mesh or sprite that triggered the action
  33769. * @param pointerX The X mouse cursor position at the time of the event
  33770. * @param pointerY The Y mouse cursor position at the time of the event
  33771. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  33772. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  33773. * @param additionalData additional data for the event
  33774. */
  33775. constructor(
  33776. /** The mesh or sprite that triggered the action */
  33777. source: any,
  33778. /** The X mouse cursor position at the time of the event */
  33779. pointerX: number,
  33780. /** The Y mouse cursor position at the time of the event */
  33781. pointerY: number,
  33782. /** The mesh that is currently pointed at (can be null) */
  33783. meshUnderPointer: Nullable<AbstractMesh>,
  33784. /** the original (browser) event that triggered the ActionEvent */
  33785. sourceEvent?: any,
  33786. /** additional data for the event */
  33787. additionalData?: any);
  33788. /**
  33789. * Helper function to auto-create an ActionEvent from a source mesh.
  33790. * @param source The source mesh that triggered the event
  33791. * @param evt The original (browser) event
  33792. * @param additionalData additional data for the event
  33793. * @returns the new ActionEvent
  33794. */
  33795. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  33796. /**
  33797. * Helper function to auto-create an ActionEvent from a source sprite
  33798. * @param source The source sprite that triggered the event
  33799. * @param scene Scene associated with the sprite
  33800. * @param evt The original (browser) event
  33801. * @param additionalData additional data for the event
  33802. * @returns the new ActionEvent
  33803. */
  33804. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  33805. /**
  33806. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  33807. * @param scene the scene where the event occurred
  33808. * @param evt The original (browser) event
  33809. * @returns the new ActionEvent
  33810. */
  33811. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  33812. /**
  33813. * Helper function to auto-create an ActionEvent from a primitive
  33814. * @param prim defines the target primitive
  33815. * @param pointerPos defines the pointer position
  33816. * @param evt The original (browser) event
  33817. * @param additionalData additional data for the event
  33818. * @returns the new ActionEvent
  33819. */
  33820. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  33821. }
  33822. }
  33823. declare module "babylonjs/Actions/abstractActionManager" {
  33824. import { IDisposable } from "babylonjs/scene";
  33825. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  33826. import { IAction } from "babylonjs/Actions/action";
  33827. import { Nullable } from "babylonjs/types";
  33828. /**
  33829. * Abstract class used to decouple action Manager from scene and meshes.
  33830. * Do not instantiate.
  33831. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33832. */
  33833. export abstract class AbstractActionManager implements IDisposable {
  33834. /** Gets the list of active triggers */
  33835. static Triggers: {
  33836. [key: string]: number;
  33837. };
  33838. /** Gets the cursor to use when hovering items */
  33839. hoverCursor: string;
  33840. /** Gets the list of actions */
  33841. actions: IAction[];
  33842. /**
  33843. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  33844. */
  33845. isRecursive: boolean;
  33846. /**
  33847. * Releases all associated resources
  33848. */
  33849. abstract dispose(): void;
  33850. /**
  33851. * Does this action manager has pointer triggers
  33852. */
  33853. abstract get hasPointerTriggers(): boolean;
  33854. /**
  33855. * Does this action manager has pick triggers
  33856. */
  33857. abstract get hasPickTriggers(): boolean;
  33858. /**
  33859. * Process a specific trigger
  33860. * @param trigger defines the trigger to process
  33861. * @param evt defines the event details to be processed
  33862. */
  33863. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33864. /**
  33865. * Does this action manager handles actions of any of the given triggers
  33866. * @param triggers defines the triggers to be tested
  33867. * @return a boolean indicating whether one (or more) of the triggers is handled
  33868. */
  33869. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33870. /**
  33871. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33872. * speed.
  33873. * @param triggerA defines the trigger to be tested
  33874. * @param triggerB defines the trigger to be tested
  33875. * @return a boolean indicating whether one (or more) of the triggers is handled
  33876. */
  33877. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33878. /**
  33879. * Does this action manager handles actions of a given trigger
  33880. * @param trigger defines the trigger to be tested
  33881. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33882. * @return whether the trigger is handled
  33883. */
  33884. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33885. /**
  33886. * Serialize this manager to a JSON object
  33887. * @param name defines the property name to store this manager
  33888. * @returns a JSON representation of this manager
  33889. */
  33890. abstract serialize(name: string): any;
  33891. /**
  33892. * Registers an action to this action manager
  33893. * @param action defines the action to be registered
  33894. * @return the action amended (prepared) after registration
  33895. */
  33896. abstract registerAction(action: IAction): Nullable<IAction>;
  33897. /**
  33898. * Unregisters an action to this action manager
  33899. * @param action defines the action to be unregistered
  33900. * @return a boolean indicating whether the action has been unregistered
  33901. */
  33902. abstract unregisterAction(action: IAction): Boolean;
  33903. /**
  33904. * Does exist one action manager with at least one trigger
  33905. **/
  33906. static get HasTriggers(): boolean;
  33907. /**
  33908. * Does exist one action manager with at least one pick trigger
  33909. **/
  33910. static get HasPickTriggers(): boolean;
  33911. /**
  33912. * Does exist one action manager that handles actions of a given trigger
  33913. * @param trigger defines the trigger to be tested
  33914. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33915. **/
  33916. static HasSpecificTrigger(trigger: number): boolean;
  33917. }
  33918. }
  33919. declare module "babylonjs/node" {
  33920. import { Scene } from "babylonjs/scene";
  33921. import { Nullable } from "babylonjs/types";
  33922. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  33923. import { Engine } from "babylonjs/Engines/engine";
  33924. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  33925. import { Observable } from "babylonjs/Misc/observable";
  33926. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33927. import { IInspectable } from "babylonjs/Misc/iInspectable";
  33928. import { Animatable } from "babylonjs/Animations/animatable";
  33929. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33930. import { Animation } from "babylonjs/Animations/animation";
  33931. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33933. /**
  33934. * Defines how a node can be built from a string name.
  33935. */
  33936. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33937. /**
  33938. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33939. */
  33940. export class Node implements IBehaviorAware<Node> {
  33941. /** @hidden */
  33942. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33943. private static _NodeConstructors;
  33944. /**
  33945. * Add a new node constructor
  33946. * @param type defines the type name of the node to construct
  33947. * @param constructorFunc defines the constructor function
  33948. */
  33949. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33950. /**
  33951. * Returns a node constructor based on type name
  33952. * @param type defines the type name
  33953. * @param name defines the new node name
  33954. * @param scene defines the hosting scene
  33955. * @param options defines optional options to transmit to constructors
  33956. * @returns the new constructor or null
  33957. */
  33958. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33959. /**
  33960. * Gets or sets the name of the node
  33961. */
  33962. name: string;
  33963. /**
  33964. * Gets or sets the id of the node
  33965. */
  33966. id: string;
  33967. /**
  33968. * Gets or sets the unique id of the node
  33969. */
  33970. uniqueId: number;
  33971. /**
  33972. * Gets or sets a string used to store user defined state for the node
  33973. */
  33974. state: string;
  33975. /**
  33976. * Gets or sets an object used to store user defined information for the node
  33977. */
  33978. metadata: any;
  33979. /**
  33980. * For internal use only. Please do not use.
  33981. */
  33982. reservedDataStore: any;
  33983. /**
  33984. * List of inspectable custom properties (used by the Inspector)
  33985. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33986. */
  33987. inspectableCustomProperties: IInspectable[];
  33988. private _doNotSerialize;
  33989. /**
  33990. * Gets or sets a boolean used to define if the node must be serialized
  33991. */
  33992. get doNotSerialize(): boolean;
  33993. set doNotSerialize(value: boolean);
  33994. /** @hidden */
  33995. _isDisposed: boolean;
  33996. /**
  33997. * Gets a list of Animations associated with the node
  33998. */
  33999. animations: import("babylonjs/Animations/animation").Animation[];
  34000. protected _ranges: {
  34001. [name: string]: Nullable<AnimationRange>;
  34002. };
  34003. /**
  34004. * Callback raised when the node is ready to be used
  34005. */
  34006. onReady: Nullable<(node: Node) => void>;
  34007. private _isEnabled;
  34008. private _isParentEnabled;
  34009. private _isReady;
  34010. /** @hidden */
  34011. _currentRenderId: number;
  34012. private _parentUpdateId;
  34013. /** @hidden */
  34014. _childUpdateId: number;
  34015. /** @hidden */
  34016. _waitingParentId: Nullable<string>;
  34017. /** @hidden */
  34018. _scene: Scene;
  34019. /** @hidden */
  34020. _cache: any;
  34021. private _parentNode;
  34022. private _children;
  34023. /** @hidden */
  34024. _worldMatrix: Matrix;
  34025. /** @hidden */
  34026. _worldMatrixDeterminant: number;
  34027. /** @hidden */
  34028. _worldMatrixDeterminantIsDirty: boolean;
  34029. /** @hidden */
  34030. private _sceneRootNodesIndex;
  34031. /**
  34032. * Gets a boolean indicating if the node has been disposed
  34033. * @returns true if the node was disposed
  34034. */
  34035. isDisposed(): boolean;
  34036. /**
  34037. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34038. * @see https://doc.babylonjs.com/how_to/parenting
  34039. */
  34040. set parent(parent: Nullable<Node>);
  34041. get parent(): Nullable<Node>;
  34042. /** @hidden */
  34043. _addToSceneRootNodes(): void;
  34044. /** @hidden */
  34045. _removeFromSceneRootNodes(): void;
  34046. private _animationPropertiesOverride;
  34047. /**
  34048. * Gets or sets the animation properties override
  34049. */
  34050. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34051. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34052. /**
  34053. * Gets a string idenfifying the name of the class
  34054. * @returns "Node" string
  34055. */
  34056. getClassName(): string;
  34057. /** @hidden */
  34058. readonly _isNode: boolean;
  34059. /**
  34060. * An event triggered when the mesh is disposed
  34061. */
  34062. onDisposeObservable: Observable<Node>;
  34063. private _onDisposeObserver;
  34064. /**
  34065. * Sets a callback that will be raised when the node will be disposed
  34066. */
  34067. set onDispose(callback: () => void);
  34068. /**
  34069. * Creates a new Node
  34070. * @param name the name and id to be given to this node
  34071. * @param scene the scene this node will be added to
  34072. */
  34073. constructor(name: string, scene?: Nullable<Scene>);
  34074. /**
  34075. * Gets the scene of the node
  34076. * @returns a scene
  34077. */
  34078. getScene(): Scene;
  34079. /**
  34080. * Gets the engine of the node
  34081. * @returns a Engine
  34082. */
  34083. getEngine(): Engine;
  34084. private _behaviors;
  34085. /**
  34086. * Attach a behavior to the node
  34087. * @see https://doc.babylonjs.com/features/behaviour
  34088. * @param behavior defines the behavior to attach
  34089. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34090. * @returns the current Node
  34091. */
  34092. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34093. /**
  34094. * Remove an attached behavior
  34095. * @see https://doc.babylonjs.com/features/behaviour
  34096. * @param behavior defines the behavior to attach
  34097. * @returns the current Node
  34098. */
  34099. removeBehavior(behavior: Behavior<Node>): Node;
  34100. /**
  34101. * Gets the list of attached behaviors
  34102. * @see https://doc.babylonjs.com/features/behaviour
  34103. */
  34104. get behaviors(): Behavior<Node>[];
  34105. /**
  34106. * Gets an attached behavior by name
  34107. * @param name defines the name of the behavior to look for
  34108. * @see https://doc.babylonjs.com/features/behaviour
  34109. * @returns null if behavior was not found else the requested behavior
  34110. */
  34111. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34112. /**
  34113. * Returns the latest update of the World matrix
  34114. * @returns a Matrix
  34115. */
  34116. getWorldMatrix(): Matrix;
  34117. /** @hidden */
  34118. _getWorldMatrixDeterminant(): number;
  34119. /**
  34120. * Returns directly the latest state of the mesh World matrix.
  34121. * A Matrix is returned.
  34122. */
  34123. get worldMatrixFromCache(): Matrix;
  34124. /** @hidden */
  34125. _initCache(): void;
  34126. /** @hidden */
  34127. updateCache(force?: boolean): void;
  34128. /** @hidden */
  34129. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34130. /** @hidden */
  34131. _updateCache(ignoreParentClass?: boolean): void;
  34132. /** @hidden */
  34133. _isSynchronized(): boolean;
  34134. /** @hidden */
  34135. _markSyncedWithParent(): void;
  34136. /** @hidden */
  34137. isSynchronizedWithParent(): boolean;
  34138. /** @hidden */
  34139. isSynchronized(): boolean;
  34140. /**
  34141. * Is this node ready to be used/rendered
  34142. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34143. * @return true if the node is ready
  34144. */
  34145. isReady(completeCheck?: boolean): boolean;
  34146. /**
  34147. * Is this node enabled?
  34148. * 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
  34149. * @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
  34150. * @return whether this node (and its parent) is enabled
  34151. */
  34152. isEnabled(checkAncestors?: boolean): boolean;
  34153. /** @hidden */
  34154. protected _syncParentEnabledState(): void;
  34155. /**
  34156. * Set the enabled state of this node
  34157. * @param value defines the new enabled state
  34158. */
  34159. setEnabled(value: boolean): void;
  34160. /**
  34161. * Is this node a descendant of the given node?
  34162. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34163. * @param ancestor defines the parent node to inspect
  34164. * @returns a boolean indicating if this node is a descendant of the given node
  34165. */
  34166. isDescendantOf(ancestor: Node): boolean;
  34167. /** @hidden */
  34168. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34169. /**
  34170. * Will return all nodes that have this node as ascendant
  34171. * @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
  34172. * @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
  34173. * @return all children nodes of all types
  34174. */
  34175. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34176. /**
  34177. * Get all child-meshes of this node
  34178. * @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)
  34179. * @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
  34180. * @returns an array of AbstractMesh
  34181. */
  34182. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34183. /**
  34184. * Get all direct children of this node
  34185. * @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
  34186. * @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)
  34187. * @returns an array of Node
  34188. */
  34189. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34190. /** @hidden */
  34191. _setReady(state: boolean): void;
  34192. /**
  34193. * Get an animation by name
  34194. * @param name defines the name of the animation to look for
  34195. * @returns null if not found else the requested animation
  34196. */
  34197. getAnimationByName(name: string): Nullable<Animation>;
  34198. /**
  34199. * Creates an animation range for this node
  34200. * @param name defines the name of the range
  34201. * @param from defines the starting key
  34202. * @param to defines the end key
  34203. */
  34204. createAnimationRange(name: string, from: number, to: number): void;
  34205. /**
  34206. * Delete a specific animation range
  34207. * @param name defines the name of the range to delete
  34208. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34209. */
  34210. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34211. /**
  34212. * Get an animation range by name
  34213. * @param name defines the name of the animation range to look for
  34214. * @returns null if not found else the requested animation range
  34215. */
  34216. getAnimationRange(name: string): Nullable<AnimationRange>;
  34217. /**
  34218. * Gets the list of all animation ranges defined on this node
  34219. * @returns an array
  34220. */
  34221. getAnimationRanges(): Nullable<AnimationRange>[];
  34222. /**
  34223. * Will start the animation sequence
  34224. * @param name defines the range frames for animation sequence
  34225. * @param loop defines if the animation should loop (false by default)
  34226. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34227. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34228. * @returns the object created for this animation. If range does not exist, it will return null
  34229. */
  34230. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34231. /**
  34232. * Serialize animation ranges into a JSON compatible object
  34233. * @returns serialization object
  34234. */
  34235. serializeAnimationRanges(): any;
  34236. /**
  34237. * Computes the world matrix of the node
  34238. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34239. * @returns the world matrix
  34240. */
  34241. computeWorldMatrix(force?: boolean): Matrix;
  34242. /**
  34243. * Releases resources associated with this node.
  34244. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34245. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34246. */
  34247. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34248. /**
  34249. * Parse animation range data from a serialization object and store them into a given node
  34250. * @param node defines where to store the animation ranges
  34251. * @param parsedNode defines the serialization object to read data from
  34252. * @param scene defines the hosting scene
  34253. */
  34254. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34255. /**
  34256. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34257. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34258. * @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
  34259. * @returns the new bounding vectors
  34260. */
  34261. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34262. min: Vector3;
  34263. max: Vector3;
  34264. };
  34265. }
  34266. }
  34267. declare module "babylonjs/Animations/animation" {
  34268. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34269. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34270. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34271. import { Nullable } from "babylonjs/types";
  34272. import { Scene } from "babylonjs/scene";
  34273. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34274. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34275. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34276. import { Node } from "babylonjs/node";
  34277. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34278. import { Size } from "babylonjs/Maths/math.size";
  34279. import { Animatable } from "babylonjs/Animations/animatable";
  34280. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34281. /**
  34282. * @hidden
  34283. */
  34284. export class _IAnimationState {
  34285. key: number;
  34286. repeatCount: number;
  34287. workValue?: any;
  34288. loopMode?: number;
  34289. offsetValue?: any;
  34290. highLimitValue?: any;
  34291. }
  34292. /**
  34293. * Class used to store any kind of animation
  34294. */
  34295. export class Animation {
  34296. /**Name of the animation */
  34297. name: string;
  34298. /**Property to animate */
  34299. targetProperty: string;
  34300. /**The frames per second of the animation */
  34301. framePerSecond: number;
  34302. /**The data type of the animation */
  34303. dataType: number;
  34304. /**The loop mode of the animation */
  34305. loopMode?: number | undefined;
  34306. /**Specifies if blending should be enabled */
  34307. enableBlending?: boolean | undefined;
  34308. /**
  34309. * Use matrix interpolation instead of using direct key value when animating matrices
  34310. */
  34311. static AllowMatricesInterpolation: boolean;
  34312. /**
  34313. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34314. */
  34315. static AllowMatrixDecomposeForInterpolation: boolean;
  34316. /** Define the Url to load snippets */
  34317. static SnippetUrl: string;
  34318. /** Snippet ID if the animation was created from the snippet server */
  34319. snippetId: string;
  34320. /**
  34321. * Stores the key frames of the animation
  34322. */
  34323. private _keys;
  34324. /**
  34325. * Stores the easing function of the animation
  34326. */
  34327. private _easingFunction;
  34328. /**
  34329. * @hidden Internal use only
  34330. */
  34331. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34332. /**
  34333. * The set of event that will be linked to this animation
  34334. */
  34335. private _events;
  34336. /**
  34337. * Stores an array of target property paths
  34338. */
  34339. targetPropertyPath: string[];
  34340. /**
  34341. * Stores the blending speed of the animation
  34342. */
  34343. blendingSpeed: number;
  34344. /**
  34345. * Stores the animation ranges for the animation
  34346. */
  34347. private _ranges;
  34348. /**
  34349. * @hidden Internal use
  34350. */
  34351. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34352. /**
  34353. * Sets up an animation
  34354. * @param property The property to animate
  34355. * @param animationType The animation type to apply
  34356. * @param framePerSecond The frames per second of the animation
  34357. * @param easingFunction The easing function used in the animation
  34358. * @returns The created animation
  34359. */
  34360. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34361. /**
  34362. * Create and start an animation on a node
  34363. * @param name defines the name of the global animation that will be run on all nodes
  34364. * @param node defines the root node where the animation will take place
  34365. * @param targetProperty defines property to animate
  34366. * @param framePerSecond defines the number of frame per second yo use
  34367. * @param totalFrame defines the number of frames in total
  34368. * @param from defines the initial value
  34369. * @param to defines the final value
  34370. * @param loopMode defines which loop mode you want to use (off by default)
  34371. * @param easingFunction defines the easing function to use (linear by default)
  34372. * @param onAnimationEnd defines the callback to call when animation end
  34373. * @returns the animatable created for this animation
  34374. */
  34375. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34376. /**
  34377. * Create and start an animation on a node and its descendants
  34378. * @param name defines the name of the global animation that will be run on all nodes
  34379. * @param node defines the root node where the animation will take place
  34380. * @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
  34381. * @param targetProperty defines property to animate
  34382. * @param framePerSecond defines the number of frame per second to use
  34383. * @param totalFrame defines the number of frames in total
  34384. * @param from defines the initial value
  34385. * @param to defines the final value
  34386. * @param loopMode defines which loop mode you want to use (off by default)
  34387. * @param easingFunction defines the easing function to use (linear by default)
  34388. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34389. * @returns the list of animatables created for all nodes
  34390. * @example https://www.babylonjs-playground.com/#MH0VLI
  34391. */
  34392. 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[]>;
  34393. /**
  34394. * Creates a new animation, merges it with the existing animations and starts it
  34395. * @param name Name of the animation
  34396. * @param node Node which contains the scene that begins the animations
  34397. * @param targetProperty Specifies which property to animate
  34398. * @param framePerSecond The frames per second of the animation
  34399. * @param totalFrame The total number of frames
  34400. * @param from The frame at the beginning of the animation
  34401. * @param to The frame at the end of the animation
  34402. * @param loopMode Specifies the loop mode of the animation
  34403. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34404. * @param onAnimationEnd Callback to run once the animation is complete
  34405. * @returns Nullable animation
  34406. */
  34407. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34408. /**
  34409. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34410. * @param sourceAnimation defines the Animation containing keyframes to convert
  34411. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34412. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34413. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34414. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34415. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34416. */
  34417. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34418. /**
  34419. * Transition property of an host to the target Value
  34420. * @param property The property to transition
  34421. * @param targetValue The target Value of the property
  34422. * @param host The object where the property to animate belongs
  34423. * @param scene Scene used to run the animation
  34424. * @param frameRate Framerate (in frame/s) to use
  34425. * @param transition The transition type we want to use
  34426. * @param duration The duration of the animation, in milliseconds
  34427. * @param onAnimationEnd Callback trigger at the end of the animation
  34428. * @returns Nullable animation
  34429. */
  34430. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34431. /**
  34432. * Return the array of runtime animations currently using this animation
  34433. */
  34434. get runtimeAnimations(): RuntimeAnimation[];
  34435. /**
  34436. * Specifies if any of the runtime animations are currently running
  34437. */
  34438. get hasRunningRuntimeAnimations(): boolean;
  34439. /**
  34440. * Initializes the animation
  34441. * @param name Name of the animation
  34442. * @param targetProperty Property to animate
  34443. * @param framePerSecond The frames per second of the animation
  34444. * @param dataType The data type of the animation
  34445. * @param loopMode The loop mode of the animation
  34446. * @param enableBlending Specifies if blending should be enabled
  34447. */
  34448. constructor(
  34449. /**Name of the animation */
  34450. name: string,
  34451. /**Property to animate */
  34452. targetProperty: string,
  34453. /**The frames per second of the animation */
  34454. framePerSecond: number,
  34455. /**The data type of the animation */
  34456. dataType: number,
  34457. /**The loop mode of the animation */
  34458. loopMode?: number | undefined,
  34459. /**Specifies if blending should be enabled */
  34460. enableBlending?: boolean | undefined);
  34461. /**
  34462. * Converts the animation to a string
  34463. * @param fullDetails support for multiple levels of logging within scene loading
  34464. * @returns String form of the animation
  34465. */
  34466. toString(fullDetails?: boolean): string;
  34467. /**
  34468. * Add an event to this animation
  34469. * @param event Event to add
  34470. */
  34471. addEvent(event: AnimationEvent): void;
  34472. /**
  34473. * Remove all events found at the given frame
  34474. * @param frame The frame to remove events from
  34475. */
  34476. removeEvents(frame: number): void;
  34477. /**
  34478. * Retrieves all the events from the animation
  34479. * @returns Events from the animation
  34480. */
  34481. getEvents(): AnimationEvent[];
  34482. /**
  34483. * Creates an animation range
  34484. * @param name Name of the animation range
  34485. * @param from Starting frame of the animation range
  34486. * @param to Ending frame of the animation
  34487. */
  34488. createRange(name: string, from: number, to: number): void;
  34489. /**
  34490. * Deletes an animation range by name
  34491. * @param name Name of the animation range to delete
  34492. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34493. */
  34494. deleteRange(name: string, deleteFrames?: boolean): void;
  34495. /**
  34496. * Gets the animation range by name, or null if not defined
  34497. * @param name Name of the animation range
  34498. * @returns Nullable animation range
  34499. */
  34500. getRange(name: string): Nullable<AnimationRange>;
  34501. /**
  34502. * Gets the key frames from the animation
  34503. * @returns The key frames of the animation
  34504. */
  34505. getKeys(): Array<IAnimationKey>;
  34506. /**
  34507. * Gets the highest frame rate of the animation
  34508. * @returns Highest frame rate of the animation
  34509. */
  34510. getHighestFrame(): number;
  34511. /**
  34512. * Gets the easing function of the animation
  34513. * @returns Easing function of the animation
  34514. */
  34515. getEasingFunction(): IEasingFunction;
  34516. /**
  34517. * Sets the easing function of the animation
  34518. * @param easingFunction A custom mathematical formula for animation
  34519. */
  34520. setEasingFunction(easingFunction: EasingFunction): void;
  34521. /**
  34522. * Interpolates a scalar linearly
  34523. * @param startValue Start value of the animation curve
  34524. * @param endValue End value of the animation curve
  34525. * @param gradient Scalar amount to interpolate
  34526. * @returns Interpolated scalar value
  34527. */
  34528. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34529. /**
  34530. * Interpolates a scalar cubically
  34531. * @param startValue Start value of the animation curve
  34532. * @param outTangent End tangent of the animation
  34533. * @param endValue End value of the animation curve
  34534. * @param inTangent Start tangent of the animation curve
  34535. * @param gradient Scalar amount to interpolate
  34536. * @returns Interpolated scalar value
  34537. */
  34538. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34539. /**
  34540. * Interpolates a quaternion using a spherical linear interpolation
  34541. * @param startValue Start value of the animation curve
  34542. * @param endValue End value of the animation curve
  34543. * @param gradient Scalar amount to interpolate
  34544. * @returns Interpolated quaternion value
  34545. */
  34546. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34547. /**
  34548. * Interpolates a quaternion cubically
  34549. * @param startValue Start value of the animation curve
  34550. * @param outTangent End tangent of the animation curve
  34551. * @param endValue End value of the animation curve
  34552. * @param inTangent Start tangent of the animation curve
  34553. * @param gradient Scalar amount to interpolate
  34554. * @returns Interpolated quaternion value
  34555. */
  34556. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34557. /**
  34558. * Interpolates a Vector3 linearl
  34559. * @param startValue Start value of the animation curve
  34560. * @param endValue End value of the animation curve
  34561. * @param gradient Scalar amount to interpolate
  34562. * @returns Interpolated scalar value
  34563. */
  34564. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34565. /**
  34566. * Interpolates a Vector3 cubically
  34567. * @param startValue Start value of the animation curve
  34568. * @param outTangent End tangent of the animation
  34569. * @param endValue End value of the animation curve
  34570. * @param inTangent Start tangent of the animation curve
  34571. * @param gradient Scalar amount to interpolate
  34572. * @returns InterpolatedVector3 value
  34573. */
  34574. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34575. /**
  34576. * Interpolates a Vector2 linearly
  34577. * @param startValue Start value of the animation curve
  34578. * @param endValue End value of the animation curve
  34579. * @param gradient Scalar amount to interpolate
  34580. * @returns Interpolated Vector2 value
  34581. */
  34582. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34583. /**
  34584. * Interpolates a Vector2 cubically
  34585. * @param startValue Start value of the animation curve
  34586. * @param outTangent End tangent of the animation
  34587. * @param endValue End value of the animation curve
  34588. * @param inTangent Start tangent of the animation curve
  34589. * @param gradient Scalar amount to interpolate
  34590. * @returns Interpolated Vector2 value
  34591. */
  34592. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34593. /**
  34594. * Interpolates a size linearly
  34595. * @param startValue Start value of the animation curve
  34596. * @param endValue End value of the animation curve
  34597. * @param gradient Scalar amount to interpolate
  34598. * @returns Interpolated Size value
  34599. */
  34600. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34601. /**
  34602. * Interpolates a Color3 linearly
  34603. * @param startValue Start value of the animation curve
  34604. * @param endValue End value of the animation curve
  34605. * @param gradient Scalar amount to interpolate
  34606. * @returns Interpolated Color3 value
  34607. */
  34608. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34609. /**
  34610. * Interpolates a Color4 linearly
  34611. * @param startValue Start value of the animation curve
  34612. * @param endValue End value of the animation curve
  34613. * @param gradient Scalar amount to interpolate
  34614. * @returns Interpolated Color3 value
  34615. */
  34616. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34617. /**
  34618. * @hidden Internal use only
  34619. */
  34620. _getKeyValue(value: any): any;
  34621. /**
  34622. * @hidden Internal use only
  34623. */
  34624. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34625. /**
  34626. * Defines the function to use to interpolate matrices
  34627. * @param startValue defines the start matrix
  34628. * @param endValue defines the end matrix
  34629. * @param gradient defines the gradient between both matrices
  34630. * @param result defines an optional target matrix where to store the interpolation
  34631. * @returns the interpolated matrix
  34632. */
  34633. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34634. /**
  34635. * Makes a copy of the animation
  34636. * @returns Cloned animation
  34637. */
  34638. clone(): Animation;
  34639. /**
  34640. * Sets the key frames of the animation
  34641. * @param values The animation key frames to set
  34642. */
  34643. setKeys(values: Array<IAnimationKey>): void;
  34644. /**
  34645. * Serializes the animation to an object
  34646. * @returns Serialized object
  34647. */
  34648. serialize(): any;
  34649. /**
  34650. * Float animation type
  34651. */
  34652. static readonly ANIMATIONTYPE_FLOAT: number;
  34653. /**
  34654. * Vector3 animation type
  34655. */
  34656. static readonly ANIMATIONTYPE_VECTOR3: number;
  34657. /**
  34658. * Quaternion animation type
  34659. */
  34660. static readonly ANIMATIONTYPE_QUATERNION: number;
  34661. /**
  34662. * Matrix animation type
  34663. */
  34664. static readonly ANIMATIONTYPE_MATRIX: number;
  34665. /**
  34666. * Color3 animation type
  34667. */
  34668. static readonly ANIMATIONTYPE_COLOR3: number;
  34669. /**
  34670. * Color3 animation type
  34671. */
  34672. static readonly ANIMATIONTYPE_COLOR4: number;
  34673. /**
  34674. * Vector2 animation type
  34675. */
  34676. static readonly ANIMATIONTYPE_VECTOR2: number;
  34677. /**
  34678. * Size animation type
  34679. */
  34680. static readonly ANIMATIONTYPE_SIZE: number;
  34681. /**
  34682. * Relative Loop Mode
  34683. */
  34684. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34685. /**
  34686. * Cycle Loop Mode
  34687. */
  34688. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34689. /**
  34690. * Constant Loop Mode
  34691. */
  34692. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  34693. /** @hidden */
  34694. static _UniversalLerp(left: any, right: any, amount: number): any;
  34695. /**
  34696. * Parses an animation object and creates an animation
  34697. * @param parsedAnimation Parsed animation object
  34698. * @returns Animation object
  34699. */
  34700. static Parse(parsedAnimation: any): Animation;
  34701. /**
  34702. * Appends the serialized animations from the source animations
  34703. * @param source Source containing the animations
  34704. * @param destination Target to store the animations
  34705. */
  34706. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34707. /**
  34708. * Creates a new animation or an array of animations from a snippet saved in a remote file
  34709. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  34710. * @param url defines the url to load from
  34711. * @returns a promise that will resolve to the new animation or an array of animations
  34712. */
  34713. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  34714. /**
  34715. * Creates an animation or an array of animations from a snippet saved by the Inspector
  34716. * @param snippetId defines the snippet to load
  34717. * @returns a promise that will resolve to the new animation or a new array of animations
  34718. */
  34719. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  34720. }
  34721. }
  34722. declare module "babylonjs/Animations/animatable.interface" {
  34723. import { Nullable } from "babylonjs/types";
  34724. import { Animation } from "babylonjs/Animations/animation";
  34725. /**
  34726. * Interface containing an array of animations
  34727. */
  34728. export interface IAnimatable {
  34729. /**
  34730. * Array of animations
  34731. */
  34732. animations: Nullable<Array<Animation>>;
  34733. }
  34734. }
  34735. declare module "babylonjs/Misc/decorators" {
  34736. import { Nullable } from "babylonjs/types";
  34737. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34738. import { Scene } from "babylonjs/scene";
  34739. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34740. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  34741. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  34742. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34743. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  34744. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34745. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34746. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34747. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34748. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34749. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34750. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34751. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34752. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34753. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34754. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34755. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34756. /**
  34757. * Decorator used to define property that can be serialized as reference to a camera
  34758. * @param sourceName defines the name of the property to decorate
  34759. */
  34760. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34761. /**
  34762. * Class used to help serialization objects
  34763. */
  34764. export class SerializationHelper {
  34765. /** @hidden */
  34766. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  34767. /** @hidden */
  34768. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  34769. /** @hidden */
  34770. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  34771. /** @hidden */
  34772. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  34773. /**
  34774. * Appends the serialized animations from the source animations
  34775. * @param source Source containing the animations
  34776. * @param destination Target to store the animations
  34777. */
  34778. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34779. /**
  34780. * Static function used to serialized a specific entity
  34781. * @param entity defines the entity to serialize
  34782. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  34783. * @returns a JSON compatible object representing the serialization of the entity
  34784. */
  34785. static Serialize<T>(entity: T, serializationObject?: any): any;
  34786. /**
  34787. * Creates a new entity from a serialization data object
  34788. * @param creationFunction defines a function used to instanciated the new entity
  34789. * @param source defines the source serialization data
  34790. * @param scene defines the hosting scene
  34791. * @param rootUrl defines the root url for resources
  34792. * @returns a new entity
  34793. */
  34794. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  34795. /**
  34796. * Clones an object
  34797. * @param creationFunction defines the function used to instanciate the new object
  34798. * @param source defines the source object
  34799. * @returns the cloned object
  34800. */
  34801. static Clone<T>(creationFunction: () => T, source: T): T;
  34802. /**
  34803. * Instanciates a new object based on a source one (some data will be shared between both object)
  34804. * @param creationFunction defines the function used to instanciate the new object
  34805. * @param source defines the source object
  34806. * @returns the new object
  34807. */
  34808. static Instanciate<T>(creationFunction: () => T, source: T): T;
  34809. }
  34810. }
  34811. declare module "babylonjs/Materials/Textures/baseTexture" {
  34812. import { Observable } from "babylonjs/Misc/observable";
  34813. import { Nullable } from "babylonjs/types";
  34814. import { Scene } from "babylonjs/scene";
  34815. import { Matrix } from "babylonjs/Maths/math.vector";
  34816. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34817. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34818. import { ISize } from "babylonjs/Maths/math.size";
  34819. import "babylonjs/Misc/fileTools";
  34820. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34821. /**
  34822. * Base class of all the textures in babylon.
  34823. * It groups all the common properties the materials, post process, lights... might need
  34824. * in order to make a correct use of the texture.
  34825. */
  34826. export class BaseTexture implements IAnimatable {
  34827. /**
  34828. * Default anisotropic filtering level for the application.
  34829. * It is set to 4 as a good tradeoff between perf and quality.
  34830. */
  34831. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34832. /**
  34833. * Gets or sets the unique id of the texture
  34834. */
  34835. uniqueId: number;
  34836. /**
  34837. * Define the name of the texture.
  34838. */
  34839. name: string;
  34840. /**
  34841. * Gets or sets an object used to store user defined information.
  34842. */
  34843. metadata: any;
  34844. /**
  34845. * For internal use only. Please do not use.
  34846. */
  34847. reservedDataStore: any;
  34848. private _hasAlpha;
  34849. /**
  34850. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  34851. */
  34852. set hasAlpha(value: boolean);
  34853. get hasAlpha(): boolean;
  34854. /**
  34855. * Defines if the alpha value should be determined via the rgb values.
  34856. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  34857. */
  34858. getAlphaFromRGB: boolean;
  34859. /**
  34860. * Intensity or strength of the texture.
  34861. * It is commonly used by materials to fine tune the intensity of the texture
  34862. */
  34863. level: number;
  34864. /**
  34865. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34866. * This is part of the texture as textures usually maps to one uv set.
  34867. */
  34868. coordinatesIndex: number;
  34869. private _coordinatesMode;
  34870. /**
  34871. * How a texture is mapped.
  34872. *
  34873. * | Value | Type | Description |
  34874. * | ----- | ----------------------------------- | ----------- |
  34875. * | 0 | EXPLICIT_MODE | |
  34876. * | 1 | SPHERICAL_MODE | |
  34877. * | 2 | PLANAR_MODE | |
  34878. * | 3 | CUBIC_MODE | |
  34879. * | 4 | PROJECTION_MODE | |
  34880. * | 5 | SKYBOX_MODE | |
  34881. * | 6 | INVCUBIC_MODE | |
  34882. * | 7 | EQUIRECTANGULAR_MODE | |
  34883. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34884. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34885. */
  34886. set coordinatesMode(value: number);
  34887. get coordinatesMode(): number;
  34888. /**
  34889. * | Value | Type | Description |
  34890. * | ----- | ------------------ | ----------- |
  34891. * | 0 | CLAMP_ADDRESSMODE | |
  34892. * | 1 | WRAP_ADDRESSMODE | |
  34893. * | 2 | MIRROR_ADDRESSMODE | |
  34894. */
  34895. wrapU: number;
  34896. /**
  34897. * | Value | Type | Description |
  34898. * | ----- | ------------------ | ----------- |
  34899. * | 0 | CLAMP_ADDRESSMODE | |
  34900. * | 1 | WRAP_ADDRESSMODE | |
  34901. * | 2 | MIRROR_ADDRESSMODE | |
  34902. */
  34903. wrapV: number;
  34904. /**
  34905. * | Value | Type | Description |
  34906. * | ----- | ------------------ | ----------- |
  34907. * | 0 | CLAMP_ADDRESSMODE | |
  34908. * | 1 | WRAP_ADDRESSMODE | |
  34909. * | 2 | MIRROR_ADDRESSMODE | |
  34910. */
  34911. wrapR: number;
  34912. /**
  34913. * With compliant hardware and browser (supporting anisotropic filtering)
  34914. * this defines the level of anisotropic filtering in the texture.
  34915. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34916. */
  34917. anisotropicFilteringLevel: number;
  34918. /**
  34919. * Define if the texture is a cube texture or if false a 2d texture.
  34920. */
  34921. get isCube(): boolean;
  34922. set isCube(value: boolean);
  34923. /**
  34924. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34925. */
  34926. get is3D(): boolean;
  34927. set is3D(value: boolean);
  34928. /**
  34929. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34930. */
  34931. get is2DArray(): boolean;
  34932. set is2DArray(value: boolean);
  34933. /**
  34934. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34935. * HDR texture are usually stored in linear space.
  34936. * This only impacts the PBR and Background materials
  34937. */
  34938. gammaSpace: boolean;
  34939. /**
  34940. * Gets or sets whether or not the texture contains RGBD data.
  34941. */
  34942. get isRGBD(): boolean;
  34943. set isRGBD(value: boolean);
  34944. /**
  34945. * Is Z inverted in the texture (useful in a cube texture).
  34946. */
  34947. invertZ: boolean;
  34948. /**
  34949. * Are mip maps generated for this texture or not.
  34950. */
  34951. get noMipmap(): boolean;
  34952. /**
  34953. * @hidden
  34954. */
  34955. lodLevelInAlpha: boolean;
  34956. /**
  34957. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34958. */
  34959. get lodGenerationOffset(): number;
  34960. set lodGenerationOffset(value: number);
  34961. /**
  34962. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34963. */
  34964. get lodGenerationScale(): number;
  34965. set lodGenerationScale(value: number);
  34966. /**
  34967. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34968. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34969. * average roughness values.
  34970. */
  34971. get linearSpecularLOD(): boolean;
  34972. set linearSpecularLOD(value: boolean);
  34973. /**
  34974. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34975. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34976. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34977. */
  34978. get irradianceTexture(): Nullable<BaseTexture>;
  34979. set irradianceTexture(value: Nullable<BaseTexture>);
  34980. /**
  34981. * Define if the texture is a render target.
  34982. */
  34983. isRenderTarget: boolean;
  34984. /**
  34985. * Define the unique id of the texture in the scene.
  34986. */
  34987. get uid(): string;
  34988. /** @hidden */
  34989. _prefiltered: boolean;
  34990. /**
  34991. * Return a string representation of the texture.
  34992. * @returns the texture as a string
  34993. */
  34994. toString(): string;
  34995. /**
  34996. * Get the class name of the texture.
  34997. * @returns "BaseTexture"
  34998. */
  34999. getClassName(): string;
  35000. /**
  35001. * Define the list of animation attached to the texture.
  35002. */
  35003. animations: import("babylonjs/Animations/animation").Animation[];
  35004. /**
  35005. * An event triggered when the texture is disposed.
  35006. */
  35007. onDisposeObservable: Observable<BaseTexture>;
  35008. private _onDisposeObserver;
  35009. /**
  35010. * Callback triggered when the texture has been disposed.
  35011. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35012. */
  35013. set onDispose(callback: () => void);
  35014. /**
  35015. * Define the current state of the loading sequence when in delayed load mode.
  35016. */
  35017. delayLoadState: number;
  35018. private _scene;
  35019. private _engine;
  35020. /** @hidden */
  35021. _texture: Nullable<InternalTexture>;
  35022. private _uid;
  35023. /**
  35024. * Define if the texture is preventinga material to render or not.
  35025. * If not and the texture is not ready, the engine will use a default black texture instead.
  35026. */
  35027. get isBlocking(): boolean;
  35028. /**
  35029. * Instantiates a new BaseTexture.
  35030. * Base class of all the textures in babylon.
  35031. * It groups all the common properties the materials, post process, lights... might need
  35032. * in order to make a correct use of the texture.
  35033. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35034. */
  35035. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35036. /**
  35037. * Get the scene the texture belongs to.
  35038. * @returns the scene or null if undefined
  35039. */
  35040. getScene(): Nullable<Scene>;
  35041. /** @hidden */
  35042. protected _getEngine(): Nullable<ThinEngine>;
  35043. /**
  35044. * Get the texture transform matrix used to offset tile the texture for istance.
  35045. * @returns the transformation matrix
  35046. */
  35047. getTextureMatrix(): Matrix;
  35048. /**
  35049. * Get the texture reflection matrix used to rotate/transform the reflection.
  35050. * @returns the reflection matrix
  35051. */
  35052. getReflectionTextureMatrix(): Matrix;
  35053. /**
  35054. * Get the underlying lower level texture from Babylon.
  35055. * @returns the insternal texture
  35056. */
  35057. getInternalTexture(): Nullable<InternalTexture>;
  35058. /**
  35059. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35060. * @returns true if ready or not blocking
  35061. */
  35062. isReadyOrNotBlocking(): boolean;
  35063. /**
  35064. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35065. * @returns true if fully ready
  35066. */
  35067. isReady(): boolean;
  35068. private _cachedSize;
  35069. /**
  35070. * Get the size of the texture.
  35071. * @returns the texture size.
  35072. */
  35073. getSize(): ISize;
  35074. /**
  35075. * Get the base size of the texture.
  35076. * It can be different from the size if the texture has been resized for POT for instance
  35077. * @returns the base size
  35078. */
  35079. getBaseSize(): ISize;
  35080. /**
  35081. * Update the sampling mode of the texture.
  35082. * Default is Trilinear mode.
  35083. *
  35084. * | Value | Type | Description |
  35085. * | ----- | ------------------ | ----------- |
  35086. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35087. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35088. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35089. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35090. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35091. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35092. * | 7 | NEAREST_LINEAR | |
  35093. * | 8 | NEAREST_NEAREST | |
  35094. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35095. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35096. * | 11 | LINEAR_LINEAR | |
  35097. * | 12 | LINEAR_NEAREST | |
  35098. *
  35099. * > _mag_: magnification filter (close to the viewer)
  35100. * > _min_: minification filter (far from the viewer)
  35101. * > _mip_: filter used between mip map levels
  35102. *@param samplingMode Define the new sampling mode of the texture
  35103. */
  35104. updateSamplingMode(samplingMode: number): void;
  35105. /**
  35106. * Scales the texture if is `canRescale()`
  35107. * @param ratio the resize factor we want to use to rescale
  35108. */
  35109. scale(ratio: number): void;
  35110. /**
  35111. * Get if the texture can rescale.
  35112. */
  35113. get canRescale(): boolean;
  35114. /** @hidden */
  35115. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35116. /** @hidden */
  35117. _rebuild(): void;
  35118. /**
  35119. * Triggers the load sequence in delayed load mode.
  35120. */
  35121. delayLoad(): void;
  35122. /**
  35123. * Clones the texture.
  35124. * @returns the cloned texture
  35125. */
  35126. clone(): Nullable<BaseTexture>;
  35127. /**
  35128. * Get the texture underlying type (INT, FLOAT...)
  35129. */
  35130. get textureType(): number;
  35131. /**
  35132. * Get the texture underlying format (RGB, RGBA...)
  35133. */
  35134. get textureFormat(): number;
  35135. /**
  35136. * Indicates that textures need to be re-calculated for all materials
  35137. */
  35138. protected _markAllSubMeshesAsTexturesDirty(): void;
  35139. /**
  35140. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35141. * This will returns an RGBA array buffer containing either in values (0-255) or
  35142. * float values (0-1) depending of the underlying buffer type.
  35143. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35144. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35145. * @param buffer defines a user defined buffer to fill with data (can be null)
  35146. * @returns The Array buffer containing the pixels data.
  35147. */
  35148. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35149. /**
  35150. * Release and destroy the underlying lower level texture aka internalTexture.
  35151. */
  35152. releaseInternalTexture(): void;
  35153. /** @hidden */
  35154. get _lodTextureHigh(): Nullable<BaseTexture>;
  35155. /** @hidden */
  35156. get _lodTextureMid(): Nullable<BaseTexture>;
  35157. /** @hidden */
  35158. get _lodTextureLow(): Nullable<BaseTexture>;
  35159. /**
  35160. * Dispose the texture and release its associated resources.
  35161. */
  35162. dispose(): void;
  35163. /**
  35164. * Serialize the texture into a JSON representation that can be parsed later on.
  35165. * @returns the JSON representation of the texture
  35166. */
  35167. serialize(): any;
  35168. /**
  35169. * Helper function to be called back once a list of texture contains only ready textures.
  35170. * @param textures Define the list of textures to wait for
  35171. * @param callback Define the callback triggered once the entire list will be ready
  35172. */
  35173. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35174. private static _isScene;
  35175. }
  35176. }
  35177. declare module "babylonjs/Materials/effect" {
  35178. import { Observable } from "babylonjs/Misc/observable";
  35179. import { Nullable } from "babylonjs/types";
  35180. import { IDisposable } from "babylonjs/scene";
  35181. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35182. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35183. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35184. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35185. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35186. import { Engine } from "babylonjs/Engines/engine";
  35187. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35188. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35189. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35190. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35191. /**
  35192. * Options to be used when creating an effect.
  35193. */
  35194. export interface IEffectCreationOptions {
  35195. /**
  35196. * Atrributes that will be used in the shader.
  35197. */
  35198. attributes: string[];
  35199. /**
  35200. * Uniform varible names that will be set in the shader.
  35201. */
  35202. uniformsNames: string[];
  35203. /**
  35204. * Uniform buffer variable names that will be set in the shader.
  35205. */
  35206. uniformBuffersNames: string[];
  35207. /**
  35208. * Sampler texture variable names that will be set in the shader.
  35209. */
  35210. samplers: string[];
  35211. /**
  35212. * Define statements that will be set in the shader.
  35213. */
  35214. defines: any;
  35215. /**
  35216. * Possible fallbacks for this effect to improve performance when needed.
  35217. */
  35218. fallbacks: Nullable<IEffectFallbacks>;
  35219. /**
  35220. * Callback that will be called when the shader is compiled.
  35221. */
  35222. onCompiled: Nullable<(effect: Effect) => void>;
  35223. /**
  35224. * Callback that will be called if an error occurs during shader compilation.
  35225. */
  35226. onError: Nullable<(effect: Effect, errors: string) => void>;
  35227. /**
  35228. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35229. */
  35230. indexParameters?: any;
  35231. /**
  35232. * Max number of lights that can be used in the shader.
  35233. */
  35234. maxSimultaneousLights?: number;
  35235. /**
  35236. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35237. */
  35238. transformFeedbackVaryings?: Nullable<string[]>;
  35239. /**
  35240. * 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
  35241. */
  35242. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35243. /**
  35244. * Is this effect rendering to several color attachments ?
  35245. */
  35246. multiTarget?: boolean;
  35247. }
  35248. /**
  35249. * Effect containing vertex and fragment shader that can be executed on an object.
  35250. */
  35251. export class Effect implements IDisposable {
  35252. /**
  35253. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35254. */
  35255. static ShadersRepository: string;
  35256. /**
  35257. * Enable logging of the shader code when a compilation error occurs
  35258. */
  35259. static LogShaderCodeOnCompilationError: boolean;
  35260. /**
  35261. * Name of the effect.
  35262. */
  35263. name: any;
  35264. /**
  35265. * String container all the define statements that should be set on the shader.
  35266. */
  35267. defines: string;
  35268. /**
  35269. * Callback that will be called when the shader is compiled.
  35270. */
  35271. onCompiled: Nullable<(effect: Effect) => void>;
  35272. /**
  35273. * Callback that will be called if an error occurs during shader compilation.
  35274. */
  35275. onError: Nullable<(effect: Effect, errors: string) => void>;
  35276. /**
  35277. * Callback that will be called when effect is bound.
  35278. */
  35279. onBind: Nullable<(effect: Effect) => void>;
  35280. /**
  35281. * Unique ID of the effect.
  35282. */
  35283. uniqueId: number;
  35284. /**
  35285. * Observable that will be called when the shader is compiled.
  35286. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35287. */
  35288. onCompileObservable: Observable<Effect>;
  35289. /**
  35290. * Observable that will be called if an error occurs during shader compilation.
  35291. */
  35292. onErrorObservable: Observable<Effect>;
  35293. /** @hidden */
  35294. _onBindObservable: Nullable<Observable<Effect>>;
  35295. /**
  35296. * @hidden
  35297. * Specifies if the effect was previously ready
  35298. */
  35299. _wasPreviouslyReady: boolean;
  35300. /**
  35301. * Observable that will be called when effect is bound.
  35302. */
  35303. get onBindObservable(): Observable<Effect>;
  35304. /** @hidden */
  35305. _bonesComputationForcedToCPU: boolean;
  35306. /** @hidden */
  35307. _multiTarget: boolean;
  35308. private static _uniqueIdSeed;
  35309. private _engine;
  35310. private _uniformBuffersNames;
  35311. private _uniformBuffersNamesList;
  35312. private _uniformsNames;
  35313. private _samplerList;
  35314. private _samplers;
  35315. private _isReady;
  35316. private _compilationError;
  35317. private _allFallbacksProcessed;
  35318. private _attributesNames;
  35319. private _attributes;
  35320. private _attributeLocationByName;
  35321. private _uniforms;
  35322. /**
  35323. * Key for the effect.
  35324. * @hidden
  35325. */
  35326. _key: string;
  35327. private _indexParameters;
  35328. private _fallbacks;
  35329. private _vertexSourceCode;
  35330. private _fragmentSourceCode;
  35331. private _vertexSourceCodeOverride;
  35332. private _fragmentSourceCodeOverride;
  35333. private _transformFeedbackVaryings;
  35334. /**
  35335. * Compiled shader to webGL program.
  35336. * @hidden
  35337. */
  35338. _pipelineContext: Nullable<IPipelineContext>;
  35339. private _valueCache;
  35340. private static _baseCache;
  35341. /**
  35342. * Instantiates an effect.
  35343. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35344. * @param baseName Name of the effect.
  35345. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35346. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35347. * @param samplers List of sampler variables that will be passed to the shader.
  35348. * @param engine Engine to be used to render the effect
  35349. * @param defines Define statements to be added to the shader.
  35350. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35351. * @param onCompiled Callback that will be called when the shader is compiled.
  35352. * @param onError Callback that will be called if an error occurs during shader compilation.
  35353. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35354. */
  35355. 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);
  35356. private _useFinalCode;
  35357. /**
  35358. * Unique key for this effect
  35359. */
  35360. get key(): string;
  35361. /**
  35362. * If the effect has been compiled and prepared.
  35363. * @returns if the effect is compiled and prepared.
  35364. */
  35365. isReady(): boolean;
  35366. private _isReadyInternal;
  35367. /**
  35368. * The engine the effect was initialized with.
  35369. * @returns the engine.
  35370. */
  35371. getEngine(): Engine;
  35372. /**
  35373. * The pipeline context for this effect
  35374. * @returns the associated pipeline context
  35375. */
  35376. getPipelineContext(): Nullable<IPipelineContext>;
  35377. /**
  35378. * The set of names of attribute variables for the shader.
  35379. * @returns An array of attribute names.
  35380. */
  35381. getAttributesNames(): string[];
  35382. /**
  35383. * Returns the attribute at the given index.
  35384. * @param index The index of the attribute.
  35385. * @returns The location of the attribute.
  35386. */
  35387. getAttributeLocation(index: number): number;
  35388. /**
  35389. * Returns the attribute based on the name of the variable.
  35390. * @param name of the attribute to look up.
  35391. * @returns the attribute location.
  35392. */
  35393. getAttributeLocationByName(name: string): number;
  35394. /**
  35395. * The number of attributes.
  35396. * @returns the numnber of attributes.
  35397. */
  35398. getAttributesCount(): number;
  35399. /**
  35400. * Gets the index of a uniform variable.
  35401. * @param uniformName of the uniform to look up.
  35402. * @returns the index.
  35403. */
  35404. getUniformIndex(uniformName: string): number;
  35405. /**
  35406. * Returns the attribute based on the name of the variable.
  35407. * @param uniformName of the uniform to look up.
  35408. * @returns the location of the uniform.
  35409. */
  35410. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35411. /**
  35412. * Returns an array of sampler variable names
  35413. * @returns The array of sampler variable names.
  35414. */
  35415. getSamplers(): string[];
  35416. /**
  35417. * Returns an array of uniform variable names
  35418. * @returns The array of uniform variable names.
  35419. */
  35420. getUniformNames(): string[];
  35421. /**
  35422. * Returns an array of uniform buffer variable names
  35423. * @returns The array of uniform buffer variable names.
  35424. */
  35425. getUniformBuffersNames(): string[];
  35426. /**
  35427. * Returns the index parameters used to create the effect
  35428. * @returns The index parameters object
  35429. */
  35430. getIndexParameters(): any;
  35431. /**
  35432. * The error from the last compilation.
  35433. * @returns the error string.
  35434. */
  35435. getCompilationError(): string;
  35436. /**
  35437. * Gets a boolean indicating that all fallbacks were used during compilation
  35438. * @returns true if all fallbacks were used
  35439. */
  35440. allFallbacksProcessed(): boolean;
  35441. /**
  35442. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35443. * @param func The callback to be used.
  35444. */
  35445. executeWhenCompiled(func: (effect: Effect) => void): void;
  35446. private _checkIsReady;
  35447. private _loadShader;
  35448. /**
  35449. * Gets the vertex shader source code of this effect
  35450. */
  35451. get vertexSourceCode(): string;
  35452. /**
  35453. * Gets the fragment shader source code of this effect
  35454. */
  35455. get fragmentSourceCode(): string;
  35456. /**
  35457. * Recompiles the webGL program
  35458. * @param vertexSourceCode The source code for the vertex shader.
  35459. * @param fragmentSourceCode The source code for the fragment shader.
  35460. * @param onCompiled Callback called when completed.
  35461. * @param onError Callback called on error.
  35462. * @hidden
  35463. */
  35464. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35465. /**
  35466. * Prepares the effect
  35467. * @hidden
  35468. */
  35469. _prepareEffect(): void;
  35470. private _getShaderCodeAndErrorLine;
  35471. private _processCompilationErrors;
  35472. /**
  35473. * Checks if the effect is supported. (Must be called after compilation)
  35474. */
  35475. get isSupported(): boolean;
  35476. /**
  35477. * Binds a texture to the engine to be used as output of the shader.
  35478. * @param channel Name of the output variable.
  35479. * @param texture Texture to bind.
  35480. * @hidden
  35481. */
  35482. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35483. /**
  35484. * Sets a texture on the engine to be used in the shader.
  35485. * @param channel Name of the sampler variable.
  35486. * @param texture Texture to set.
  35487. */
  35488. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35489. /**
  35490. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35491. * @param channel Name of the sampler variable.
  35492. * @param texture Texture to set.
  35493. */
  35494. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35495. /**
  35496. * Sets an array of textures on the engine to be used in the shader.
  35497. * @param channel Name of the variable.
  35498. * @param textures Textures to set.
  35499. */
  35500. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35501. /**
  35502. * 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)
  35503. * @param channel Name of the sampler variable.
  35504. * @param postProcess Post process to get the input texture from.
  35505. */
  35506. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35507. /**
  35508. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35509. * 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)
  35510. * @param channel Name of the sampler variable.
  35511. * @param postProcess Post process to get the output texture from.
  35512. */
  35513. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35514. /** @hidden */
  35515. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35516. /** @hidden */
  35517. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35518. /** @hidden */
  35519. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35520. /** @hidden */
  35521. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35522. /**
  35523. * Binds a buffer to a uniform.
  35524. * @param buffer Buffer to bind.
  35525. * @param name Name of the uniform variable to bind to.
  35526. */
  35527. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35528. /**
  35529. * Binds block to a uniform.
  35530. * @param blockName Name of the block to bind.
  35531. * @param index Index to bind.
  35532. */
  35533. bindUniformBlock(blockName: string, index: number): void;
  35534. /**
  35535. * Sets an interger value on a uniform variable.
  35536. * @param uniformName Name of the variable.
  35537. * @param value Value to be set.
  35538. * @returns this effect.
  35539. */
  35540. setInt(uniformName: string, value: number): Effect;
  35541. /**
  35542. * Sets an int array on a uniform variable.
  35543. * @param uniformName Name of the variable.
  35544. * @param array array to be set.
  35545. * @returns this effect.
  35546. */
  35547. setIntArray(uniformName: string, array: Int32Array): Effect;
  35548. /**
  35549. * 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)
  35550. * @param uniformName Name of the variable.
  35551. * @param array array to be set.
  35552. * @returns this effect.
  35553. */
  35554. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35555. /**
  35556. * 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)
  35557. * @param uniformName Name of the variable.
  35558. * @param array array to be set.
  35559. * @returns this effect.
  35560. */
  35561. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35562. /**
  35563. * 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)
  35564. * @param uniformName Name of the variable.
  35565. * @param array array to be set.
  35566. * @returns this effect.
  35567. */
  35568. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35569. /**
  35570. * Sets an float array on a uniform variable.
  35571. * @param uniformName Name of the variable.
  35572. * @param array array to be set.
  35573. * @returns this effect.
  35574. */
  35575. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35576. /**
  35577. * 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)
  35578. * @param uniformName Name of the variable.
  35579. * @param array array to be set.
  35580. * @returns this effect.
  35581. */
  35582. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35583. /**
  35584. * 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)
  35585. * @param uniformName Name of the variable.
  35586. * @param array array to be set.
  35587. * @returns this effect.
  35588. */
  35589. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35590. /**
  35591. * 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)
  35592. * @param uniformName Name of the variable.
  35593. * @param array array to be set.
  35594. * @returns this effect.
  35595. */
  35596. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35597. /**
  35598. * Sets an array on a uniform variable.
  35599. * @param uniformName Name of the variable.
  35600. * @param array array to be set.
  35601. * @returns this effect.
  35602. */
  35603. setArray(uniformName: string, array: number[]): Effect;
  35604. /**
  35605. * 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)
  35606. * @param uniformName Name of the variable.
  35607. * @param array array to be set.
  35608. * @returns this effect.
  35609. */
  35610. setArray2(uniformName: string, array: number[]): Effect;
  35611. /**
  35612. * 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)
  35613. * @param uniformName Name of the variable.
  35614. * @param array array to be set.
  35615. * @returns this effect.
  35616. */
  35617. setArray3(uniformName: string, array: number[]): Effect;
  35618. /**
  35619. * 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)
  35620. * @param uniformName Name of the variable.
  35621. * @param array array to be set.
  35622. * @returns this effect.
  35623. */
  35624. setArray4(uniformName: string, array: number[]): Effect;
  35625. /**
  35626. * Sets matrices on a uniform variable.
  35627. * @param uniformName Name of the variable.
  35628. * @param matrices matrices to be set.
  35629. * @returns this effect.
  35630. */
  35631. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35632. /**
  35633. * Sets matrix on a uniform variable.
  35634. * @param uniformName Name of the variable.
  35635. * @param matrix matrix to be set.
  35636. * @returns this effect.
  35637. */
  35638. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35639. /**
  35640. * 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)
  35641. * @param uniformName Name of the variable.
  35642. * @param matrix matrix to be set.
  35643. * @returns this effect.
  35644. */
  35645. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35646. /**
  35647. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35648. * @param uniformName Name of the variable.
  35649. * @param matrix matrix to be set.
  35650. * @returns this effect.
  35651. */
  35652. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35653. /**
  35654. * Sets a float on a uniform variable.
  35655. * @param uniformName Name of the variable.
  35656. * @param value value to be set.
  35657. * @returns this effect.
  35658. */
  35659. setFloat(uniformName: string, value: number): Effect;
  35660. /**
  35661. * Sets a boolean on a uniform variable.
  35662. * @param uniformName Name of the variable.
  35663. * @param bool value to be set.
  35664. * @returns this effect.
  35665. */
  35666. setBool(uniformName: string, bool: boolean): Effect;
  35667. /**
  35668. * Sets a Vector2 on a uniform variable.
  35669. * @param uniformName Name of the variable.
  35670. * @param vector2 vector2 to be set.
  35671. * @returns this effect.
  35672. */
  35673. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35674. /**
  35675. * Sets a float2 on a uniform variable.
  35676. * @param uniformName Name of the variable.
  35677. * @param x First float in float2.
  35678. * @param y Second float in float2.
  35679. * @returns this effect.
  35680. */
  35681. setFloat2(uniformName: string, x: number, y: number): Effect;
  35682. /**
  35683. * Sets a Vector3 on a uniform variable.
  35684. * @param uniformName Name of the variable.
  35685. * @param vector3 Value to be set.
  35686. * @returns this effect.
  35687. */
  35688. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  35689. /**
  35690. * Sets a float3 on a uniform variable.
  35691. * @param uniformName Name of the variable.
  35692. * @param x First float in float3.
  35693. * @param y Second float in float3.
  35694. * @param z Third float in float3.
  35695. * @returns this effect.
  35696. */
  35697. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  35698. /**
  35699. * Sets a Vector4 on a uniform variable.
  35700. * @param uniformName Name of the variable.
  35701. * @param vector4 Value to be set.
  35702. * @returns this effect.
  35703. */
  35704. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  35705. /**
  35706. * Sets a float4 on a uniform variable.
  35707. * @param uniformName Name of the variable.
  35708. * @param x First float in float4.
  35709. * @param y Second float in float4.
  35710. * @param z Third float in float4.
  35711. * @param w Fourth float in float4.
  35712. * @returns this effect.
  35713. */
  35714. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  35715. /**
  35716. * Sets a Color3 on a uniform variable.
  35717. * @param uniformName Name of the variable.
  35718. * @param color3 Value to be set.
  35719. * @returns this effect.
  35720. */
  35721. setColor3(uniformName: string, color3: IColor3Like): Effect;
  35722. /**
  35723. * Sets a Color4 on a uniform variable.
  35724. * @param uniformName Name of the variable.
  35725. * @param color3 Value to be set.
  35726. * @param alpha Alpha value to be set.
  35727. * @returns this effect.
  35728. */
  35729. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  35730. /**
  35731. * Sets a Color4 on a uniform variable
  35732. * @param uniformName defines the name of the variable
  35733. * @param color4 defines the value to be set
  35734. * @returns this effect.
  35735. */
  35736. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  35737. /** Release all associated resources */
  35738. dispose(): void;
  35739. /**
  35740. * This function will add a new shader to the shader store
  35741. * @param name the name of the shader
  35742. * @param pixelShader optional pixel shader content
  35743. * @param vertexShader optional vertex shader content
  35744. */
  35745. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  35746. /**
  35747. * Store of each shader (The can be looked up using effect.key)
  35748. */
  35749. static ShadersStore: {
  35750. [key: string]: string;
  35751. };
  35752. /**
  35753. * Store of each included file for a shader (The can be looked up using effect.key)
  35754. */
  35755. static IncludesShadersStore: {
  35756. [key: string]: string;
  35757. };
  35758. /**
  35759. * Resets the cache of effects.
  35760. */
  35761. static ResetCache(): void;
  35762. }
  35763. }
  35764. declare module "babylonjs/Engines/engineCapabilities" {
  35765. /**
  35766. * Interface used to describe the capabilities of the engine relatively to the current browser
  35767. */
  35768. export interface EngineCapabilities {
  35769. /** Maximum textures units per fragment shader */
  35770. maxTexturesImageUnits: number;
  35771. /** Maximum texture units per vertex shader */
  35772. maxVertexTextureImageUnits: number;
  35773. /** Maximum textures units in the entire pipeline */
  35774. maxCombinedTexturesImageUnits: number;
  35775. /** Maximum texture size */
  35776. maxTextureSize: number;
  35777. /** Maximum texture samples */
  35778. maxSamples?: number;
  35779. /** Maximum cube texture size */
  35780. maxCubemapTextureSize: number;
  35781. /** Maximum render texture size */
  35782. maxRenderTextureSize: number;
  35783. /** Maximum number of vertex attributes */
  35784. maxVertexAttribs: number;
  35785. /** Maximum number of varyings */
  35786. maxVaryingVectors: number;
  35787. /** Maximum number of uniforms per vertex shader */
  35788. maxVertexUniformVectors: number;
  35789. /** Maximum number of uniforms per fragment shader */
  35790. maxFragmentUniformVectors: number;
  35791. /** Defines if standard derivates (dx/dy) are supported */
  35792. standardDerivatives: boolean;
  35793. /** Defines if s3tc texture compression is supported */
  35794. s3tc?: WEBGL_compressed_texture_s3tc;
  35795. /** Defines if pvrtc texture compression is supported */
  35796. pvrtc: any;
  35797. /** Defines if etc1 texture compression is supported */
  35798. etc1: any;
  35799. /** Defines if etc2 texture compression is supported */
  35800. etc2: any;
  35801. /** Defines if astc texture compression is supported */
  35802. astc: any;
  35803. /** Defines if float textures are supported */
  35804. textureFloat: boolean;
  35805. /** Defines if vertex array objects are supported */
  35806. vertexArrayObject: boolean;
  35807. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  35808. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  35809. /** Gets the maximum level of anisotropy supported */
  35810. maxAnisotropy: number;
  35811. /** Defines if instancing is supported */
  35812. instancedArrays: boolean;
  35813. /** Defines if 32 bits indices are supported */
  35814. uintIndices: boolean;
  35815. /** Defines if high precision shaders are supported */
  35816. highPrecisionShaderSupported: boolean;
  35817. /** Defines if depth reading in the fragment shader is supported */
  35818. fragmentDepthSupported: boolean;
  35819. /** Defines if float texture linear filtering is supported*/
  35820. textureFloatLinearFiltering: boolean;
  35821. /** Defines if rendering to float textures is supported */
  35822. textureFloatRender: boolean;
  35823. /** Defines if half float textures are supported*/
  35824. textureHalfFloat: boolean;
  35825. /** Defines if half float texture linear filtering is supported*/
  35826. textureHalfFloatLinearFiltering: boolean;
  35827. /** Defines if rendering to half float textures is supported */
  35828. textureHalfFloatRender: boolean;
  35829. /** Defines if textureLOD shader command is supported */
  35830. textureLOD: boolean;
  35831. /** Defines if draw buffers extension is supported */
  35832. drawBuffersExtension: boolean;
  35833. /** Defines if depth textures are supported */
  35834. depthTextureExtension: boolean;
  35835. /** Defines if float color buffer are supported */
  35836. colorBufferFloat: boolean;
  35837. /** Gets disjoint timer query extension (null if not supported) */
  35838. timerQuery?: EXT_disjoint_timer_query;
  35839. /** Defines if timestamp can be used with timer query */
  35840. canUseTimestampForTimerQuery: boolean;
  35841. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  35842. multiview?: any;
  35843. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  35844. oculusMultiview?: any;
  35845. /** Function used to let the system compiles shaders in background */
  35846. parallelShaderCompile?: {
  35847. COMPLETION_STATUS_KHR: number;
  35848. };
  35849. /** Max number of texture samples for MSAA */
  35850. maxMSAASamples: number;
  35851. /** Defines if the blend min max extension is supported */
  35852. blendMinMax: boolean;
  35853. }
  35854. }
  35855. declare module "babylonjs/States/depthCullingState" {
  35856. import { Nullable } from "babylonjs/types";
  35857. /**
  35858. * @hidden
  35859. **/
  35860. export class DepthCullingState {
  35861. private _isDepthTestDirty;
  35862. private _isDepthMaskDirty;
  35863. private _isDepthFuncDirty;
  35864. private _isCullFaceDirty;
  35865. private _isCullDirty;
  35866. private _isZOffsetDirty;
  35867. private _isFrontFaceDirty;
  35868. private _depthTest;
  35869. private _depthMask;
  35870. private _depthFunc;
  35871. private _cull;
  35872. private _cullFace;
  35873. private _zOffset;
  35874. private _frontFace;
  35875. /**
  35876. * Initializes the state.
  35877. */
  35878. constructor();
  35879. get isDirty(): boolean;
  35880. get zOffset(): number;
  35881. set zOffset(value: number);
  35882. get cullFace(): Nullable<number>;
  35883. set cullFace(value: Nullable<number>);
  35884. get cull(): Nullable<boolean>;
  35885. set cull(value: Nullable<boolean>);
  35886. get depthFunc(): Nullable<number>;
  35887. set depthFunc(value: Nullable<number>);
  35888. get depthMask(): boolean;
  35889. set depthMask(value: boolean);
  35890. get depthTest(): boolean;
  35891. set depthTest(value: boolean);
  35892. get frontFace(): Nullable<number>;
  35893. set frontFace(value: Nullable<number>);
  35894. reset(): void;
  35895. apply(gl: WebGLRenderingContext): void;
  35896. }
  35897. }
  35898. declare module "babylonjs/States/stencilState" {
  35899. /**
  35900. * @hidden
  35901. **/
  35902. export class StencilState {
  35903. /** 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 */
  35904. static readonly ALWAYS: number;
  35905. /** Passed to stencilOperation to specify that stencil value must be kept */
  35906. static readonly KEEP: number;
  35907. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35908. static readonly REPLACE: number;
  35909. private _isStencilTestDirty;
  35910. private _isStencilMaskDirty;
  35911. private _isStencilFuncDirty;
  35912. private _isStencilOpDirty;
  35913. private _stencilTest;
  35914. private _stencilMask;
  35915. private _stencilFunc;
  35916. private _stencilFuncRef;
  35917. private _stencilFuncMask;
  35918. private _stencilOpStencilFail;
  35919. private _stencilOpDepthFail;
  35920. private _stencilOpStencilDepthPass;
  35921. get isDirty(): boolean;
  35922. get stencilFunc(): number;
  35923. set stencilFunc(value: number);
  35924. get stencilFuncRef(): number;
  35925. set stencilFuncRef(value: number);
  35926. get stencilFuncMask(): number;
  35927. set stencilFuncMask(value: number);
  35928. get stencilOpStencilFail(): number;
  35929. set stencilOpStencilFail(value: number);
  35930. get stencilOpDepthFail(): number;
  35931. set stencilOpDepthFail(value: number);
  35932. get stencilOpStencilDepthPass(): number;
  35933. set stencilOpStencilDepthPass(value: number);
  35934. get stencilMask(): number;
  35935. set stencilMask(value: number);
  35936. get stencilTest(): boolean;
  35937. set stencilTest(value: boolean);
  35938. constructor();
  35939. reset(): void;
  35940. apply(gl: WebGLRenderingContext): void;
  35941. }
  35942. }
  35943. declare module "babylonjs/States/alphaCullingState" {
  35944. /**
  35945. * @hidden
  35946. **/
  35947. export class AlphaState {
  35948. private _isAlphaBlendDirty;
  35949. private _isBlendFunctionParametersDirty;
  35950. private _isBlendEquationParametersDirty;
  35951. private _isBlendConstantsDirty;
  35952. private _alphaBlend;
  35953. private _blendFunctionParameters;
  35954. private _blendEquationParameters;
  35955. private _blendConstants;
  35956. /**
  35957. * Initializes the state.
  35958. */
  35959. constructor();
  35960. get isDirty(): boolean;
  35961. get alphaBlend(): boolean;
  35962. set alphaBlend(value: boolean);
  35963. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35964. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35965. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35966. reset(): void;
  35967. apply(gl: WebGLRenderingContext): void;
  35968. }
  35969. }
  35970. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  35971. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35972. /** @hidden */
  35973. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35974. attributeProcessor(attribute: string): string;
  35975. varyingProcessor(varying: string, isFragment: boolean): string;
  35976. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35977. }
  35978. }
  35979. declare module "babylonjs/Engines/instancingAttributeInfo" {
  35980. /**
  35981. * Interface for attribute information associated with buffer instanciation
  35982. */
  35983. export interface InstancingAttributeInfo {
  35984. /**
  35985. * Name of the GLSL attribute
  35986. * if attribute index is not specified, this is used to retrieve the index from the effect
  35987. */
  35988. attributeName: string;
  35989. /**
  35990. * Index/offset of the attribute in the vertex shader
  35991. * if not specified, this will be computes from the name.
  35992. */
  35993. index?: number;
  35994. /**
  35995. * size of the attribute, 1, 2, 3 or 4
  35996. */
  35997. attributeSize: number;
  35998. /**
  35999. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36000. */
  36001. offset: number;
  36002. /**
  36003. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36004. * default to 1
  36005. */
  36006. divisor?: number;
  36007. /**
  36008. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36009. * default is FLOAT
  36010. */
  36011. attributeType?: number;
  36012. /**
  36013. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36014. */
  36015. normalized?: boolean;
  36016. }
  36017. }
  36018. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36019. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36020. import { Nullable } from "babylonjs/types";
  36021. module "babylonjs/Engines/thinEngine" {
  36022. interface ThinEngine {
  36023. /**
  36024. * Update a video texture
  36025. * @param texture defines the texture to update
  36026. * @param video defines the video element to use
  36027. * @param invertY defines if data must be stored with Y axis inverted
  36028. */
  36029. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36030. }
  36031. }
  36032. }
  36033. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36034. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36035. import { Nullable } from "babylonjs/types";
  36036. module "babylonjs/Engines/thinEngine" {
  36037. interface ThinEngine {
  36038. /**
  36039. * Creates a dynamic texture
  36040. * @param width defines the width of the texture
  36041. * @param height defines the height of the texture
  36042. * @param generateMipMaps defines if the engine should generate the mip levels
  36043. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36044. * @returns the dynamic texture inside an InternalTexture
  36045. */
  36046. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36047. /**
  36048. * Update the content of a dynamic texture
  36049. * @param texture defines the texture to update
  36050. * @param canvas defines the canvas containing the source
  36051. * @param invertY defines if data must be stored with Y axis inverted
  36052. * @param premulAlpha defines if alpha is stored as premultiplied
  36053. * @param format defines the format of the data
  36054. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36055. */
  36056. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36057. }
  36058. }
  36059. }
  36060. declare module "babylonjs/Materials/Textures/videoTexture" {
  36061. import { Observable } from "babylonjs/Misc/observable";
  36062. import { Nullable } from "babylonjs/types";
  36063. import { Scene } from "babylonjs/scene";
  36064. import { Texture } from "babylonjs/Materials/Textures/texture";
  36065. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36066. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36067. /**
  36068. * Settings for finer control over video usage
  36069. */
  36070. export interface VideoTextureSettings {
  36071. /**
  36072. * Applies `autoplay` to video, if specified
  36073. */
  36074. autoPlay?: boolean;
  36075. /**
  36076. * Applies `loop` to video, if specified
  36077. */
  36078. loop?: boolean;
  36079. /**
  36080. * Automatically updates internal texture from video at every frame in the render loop
  36081. */
  36082. autoUpdateTexture: boolean;
  36083. /**
  36084. * Image src displayed during the video loading or until the user interacts with the video.
  36085. */
  36086. poster?: string;
  36087. }
  36088. /**
  36089. * If you want to display a video in your scene, this is the special texture for that.
  36090. * This special texture works similar to other textures, with the exception of a few parameters.
  36091. * @see https://doc.babylonjs.com/how_to/video_texture
  36092. */
  36093. export class VideoTexture extends Texture {
  36094. /**
  36095. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36096. */
  36097. readonly autoUpdateTexture: boolean;
  36098. /**
  36099. * The video instance used by the texture internally
  36100. */
  36101. readonly video: HTMLVideoElement;
  36102. private _onUserActionRequestedObservable;
  36103. /**
  36104. * Event triggerd when a dom action is required by the user to play the video.
  36105. * This happens due to recent changes in browser policies preventing video to auto start.
  36106. */
  36107. get onUserActionRequestedObservable(): Observable<Texture>;
  36108. private _generateMipMaps;
  36109. private _stillImageCaptured;
  36110. private _displayingPosterTexture;
  36111. private _settings;
  36112. private _createInternalTextureOnEvent;
  36113. private _frameId;
  36114. private _currentSrc;
  36115. /**
  36116. * Creates a video texture.
  36117. * If you want to display a video in your scene, this is the special texture for that.
  36118. * This special texture works similar to other textures, with the exception of a few parameters.
  36119. * @see https://doc.babylonjs.com/how_to/video_texture
  36120. * @param name optional name, will detect from video source, if not defined
  36121. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36122. * @param scene is obviously the current scene.
  36123. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36124. * @param invertY is false by default but can be used to invert video on Y axis
  36125. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36126. * @param settings allows finer control over video usage
  36127. */
  36128. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36129. private _getName;
  36130. private _getVideo;
  36131. private _createInternalTexture;
  36132. private reset;
  36133. /**
  36134. * @hidden Internal method to initiate `update`.
  36135. */
  36136. _rebuild(): void;
  36137. /**
  36138. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36139. */
  36140. update(): void;
  36141. /**
  36142. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36143. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36144. */
  36145. updateTexture(isVisible: boolean): void;
  36146. protected _updateInternalTexture: () => void;
  36147. /**
  36148. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36149. * @param url New url.
  36150. */
  36151. updateURL(url: string): void;
  36152. /**
  36153. * Clones the texture.
  36154. * @returns the cloned texture
  36155. */
  36156. clone(): VideoTexture;
  36157. /**
  36158. * Dispose the texture and release its associated resources.
  36159. */
  36160. dispose(): void;
  36161. /**
  36162. * Creates a video texture straight from a stream.
  36163. * @param scene Define the scene the texture should be created in
  36164. * @param stream Define the stream the texture should be created from
  36165. * @returns The created video texture as a promise
  36166. */
  36167. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36168. /**
  36169. * Creates a video texture straight from your WebCam video feed.
  36170. * @param scene Define the scene the texture should be created in
  36171. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36172. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36173. * @returns The created video texture as a promise
  36174. */
  36175. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36176. minWidth: number;
  36177. maxWidth: number;
  36178. minHeight: number;
  36179. maxHeight: number;
  36180. deviceId: string;
  36181. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36182. /**
  36183. * Creates a video texture straight from your WebCam video feed.
  36184. * @param scene Define the scene the texture should be created in
  36185. * @param onReady Define a callback to triggered once the texture will be ready
  36186. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36187. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36188. */
  36189. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36190. minWidth: number;
  36191. maxWidth: number;
  36192. minHeight: number;
  36193. maxHeight: number;
  36194. deviceId: string;
  36195. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36196. }
  36197. }
  36198. declare module "babylonjs/Engines/thinEngine" {
  36199. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36200. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36201. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36202. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36203. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36204. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36205. import { Observable } from "babylonjs/Misc/observable";
  36206. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36207. import { StencilState } from "babylonjs/States/stencilState";
  36208. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36209. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36210. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36211. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36212. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36213. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36214. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36215. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36216. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36217. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36218. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36219. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36220. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36221. import { WebRequest } from "babylonjs/Misc/webRequest";
  36222. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36223. /**
  36224. * Defines the interface used by objects working like Scene
  36225. * @hidden
  36226. */
  36227. export interface ISceneLike {
  36228. _addPendingData(data: any): void;
  36229. _removePendingData(data: any): void;
  36230. offlineProvider: IOfflineProvider;
  36231. }
  36232. /** Interface defining initialization parameters for Engine class */
  36233. export interface EngineOptions extends WebGLContextAttributes {
  36234. /**
  36235. * Defines if the engine should no exceed a specified device ratio
  36236. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36237. */
  36238. limitDeviceRatio?: number;
  36239. /**
  36240. * Defines if webvr should be enabled automatically
  36241. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36242. */
  36243. autoEnableWebVR?: boolean;
  36244. /**
  36245. * Defines if webgl2 should be turned off even if supported
  36246. * @see https://doc.babylonjs.com/features/webgl2
  36247. */
  36248. disableWebGL2Support?: boolean;
  36249. /**
  36250. * Defines if webaudio should be initialized as well
  36251. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36252. */
  36253. audioEngine?: boolean;
  36254. /**
  36255. * Defines if animations should run using a deterministic lock step
  36256. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36257. */
  36258. deterministicLockstep?: boolean;
  36259. /** Defines the maximum steps to use with deterministic lock step mode */
  36260. lockstepMaxSteps?: number;
  36261. /** Defines the seconds between each deterministic lock step */
  36262. timeStep?: number;
  36263. /**
  36264. * Defines that engine should ignore context lost events
  36265. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36266. */
  36267. doNotHandleContextLost?: boolean;
  36268. /**
  36269. * Defines that engine should ignore modifying touch action attribute and style
  36270. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36271. */
  36272. doNotHandleTouchAction?: boolean;
  36273. /**
  36274. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36275. */
  36276. useHighPrecisionFloats?: boolean;
  36277. /**
  36278. * Make the canvas XR Compatible for XR sessions
  36279. */
  36280. xrCompatible?: boolean;
  36281. /**
  36282. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36283. */
  36284. useHighPrecisionMatrix?: boolean;
  36285. }
  36286. /**
  36287. * The base engine class (root of all engines)
  36288. */
  36289. export class ThinEngine {
  36290. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36291. static ExceptionList: ({
  36292. key: string;
  36293. capture: string;
  36294. captureConstraint: number;
  36295. targets: string[];
  36296. } | {
  36297. key: string;
  36298. capture: null;
  36299. captureConstraint: null;
  36300. targets: string[];
  36301. })[];
  36302. /** @hidden */
  36303. static _TextureLoaders: IInternalTextureLoader[];
  36304. /**
  36305. * Returns the current npm package of the sdk
  36306. */
  36307. static get NpmPackage(): string;
  36308. /**
  36309. * Returns the current version of the framework
  36310. */
  36311. static get Version(): string;
  36312. /**
  36313. * Returns a string describing the current engine
  36314. */
  36315. get description(): string;
  36316. /**
  36317. * Gets or sets the epsilon value used by collision engine
  36318. */
  36319. static CollisionsEpsilon: number;
  36320. /**
  36321. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36322. */
  36323. static get ShadersRepository(): string;
  36324. static set ShadersRepository(value: string);
  36325. /** @hidden */
  36326. _shaderProcessor: IShaderProcessor;
  36327. /**
  36328. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36329. */
  36330. forcePOTTextures: boolean;
  36331. /**
  36332. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36333. */
  36334. isFullscreen: boolean;
  36335. /**
  36336. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36337. */
  36338. cullBackFaces: boolean;
  36339. /**
  36340. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36341. */
  36342. renderEvenInBackground: boolean;
  36343. /**
  36344. * Gets or sets a boolean indicating that cache can be kept between frames
  36345. */
  36346. preventCacheWipeBetweenFrames: boolean;
  36347. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36348. validateShaderPrograms: boolean;
  36349. /**
  36350. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36351. * This can provide greater z depth for distant objects.
  36352. */
  36353. useReverseDepthBuffer: boolean;
  36354. /**
  36355. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36356. */
  36357. disableUniformBuffers: boolean;
  36358. /** @hidden */
  36359. _uniformBuffers: UniformBuffer[];
  36360. /**
  36361. * Gets a boolean indicating that the engine supports uniform buffers
  36362. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36363. */
  36364. get supportsUniformBuffers(): boolean;
  36365. /** @hidden */
  36366. _gl: WebGLRenderingContext;
  36367. /** @hidden */
  36368. _webGLVersion: number;
  36369. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36370. protected _windowIsBackground: boolean;
  36371. protected _creationOptions: EngineOptions;
  36372. protected _highPrecisionShadersAllowed: boolean;
  36373. /** @hidden */
  36374. get _shouldUseHighPrecisionShader(): boolean;
  36375. /**
  36376. * Gets a boolean indicating that only power of 2 textures are supported
  36377. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36378. */
  36379. get needPOTTextures(): boolean;
  36380. /** @hidden */
  36381. _badOS: boolean;
  36382. /** @hidden */
  36383. _badDesktopOS: boolean;
  36384. private _hardwareScalingLevel;
  36385. /** @hidden */
  36386. _caps: EngineCapabilities;
  36387. private _isStencilEnable;
  36388. private _glVersion;
  36389. private _glRenderer;
  36390. private _glVendor;
  36391. /** @hidden */
  36392. _videoTextureSupported: boolean;
  36393. protected _renderingQueueLaunched: boolean;
  36394. protected _activeRenderLoops: (() => void)[];
  36395. /**
  36396. * Observable signaled when a context lost event is raised
  36397. */
  36398. onContextLostObservable: Observable<ThinEngine>;
  36399. /**
  36400. * Observable signaled when a context restored event is raised
  36401. */
  36402. onContextRestoredObservable: Observable<ThinEngine>;
  36403. private _onContextLost;
  36404. private _onContextRestored;
  36405. protected _contextWasLost: boolean;
  36406. /** @hidden */
  36407. _doNotHandleContextLost: boolean;
  36408. /**
  36409. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36410. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36411. */
  36412. get doNotHandleContextLost(): boolean;
  36413. set doNotHandleContextLost(value: boolean);
  36414. /**
  36415. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36416. */
  36417. disableVertexArrayObjects: boolean;
  36418. /** @hidden */
  36419. protected _colorWrite: boolean;
  36420. /** @hidden */
  36421. protected _colorWriteChanged: boolean;
  36422. /** @hidden */
  36423. protected _depthCullingState: DepthCullingState;
  36424. /** @hidden */
  36425. protected _stencilState: StencilState;
  36426. /** @hidden */
  36427. _alphaState: AlphaState;
  36428. /** @hidden */
  36429. _alphaMode: number;
  36430. /** @hidden */
  36431. _alphaEquation: number;
  36432. /** @hidden */
  36433. _internalTexturesCache: InternalTexture[];
  36434. /** @hidden */
  36435. protected _activeChannel: number;
  36436. private _currentTextureChannel;
  36437. /** @hidden */
  36438. protected _boundTexturesCache: {
  36439. [key: string]: Nullable<InternalTexture>;
  36440. };
  36441. /** @hidden */
  36442. protected _currentEffect: Nullable<Effect>;
  36443. /** @hidden */
  36444. protected _currentProgram: Nullable<WebGLProgram>;
  36445. private _compiledEffects;
  36446. private _vertexAttribArraysEnabled;
  36447. /** @hidden */
  36448. protected _cachedViewport: Nullable<IViewportLike>;
  36449. private _cachedVertexArrayObject;
  36450. /** @hidden */
  36451. protected _cachedVertexBuffers: any;
  36452. /** @hidden */
  36453. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36454. /** @hidden */
  36455. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36456. /** @hidden */
  36457. _currentRenderTarget: Nullable<InternalTexture>;
  36458. private _uintIndicesCurrentlySet;
  36459. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36460. /** @hidden */
  36461. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36462. /** @hidden */
  36463. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36464. private _currentBufferPointers;
  36465. private _currentInstanceLocations;
  36466. private _currentInstanceBuffers;
  36467. private _textureUnits;
  36468. /** @hidden */
  36469. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36470. /** @hidden */
  36471. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36472. /** @hidden */
  36473. _boundRenderFunction: any;
  36474. private _vaoRecordInProgress;
  36475. private _mustWipeVertexAttributes;
  36476. private _emptyTexture;
  36477. private _emptyCubeTexture;
  36478. private _emptyTexture3D;
  36479. private _emptyTexture2DArray;
  36480. /** @hidden */
  36481. _frameHandler: number;
  36482. private _nextFreeTextureSlots;
  36483. private _maxSimultaneousTextures;
  36484. private _activeRequests;
  36485. /** @hidden */
  36486. _transformTextureUrl: Nullable<(url: string) => string>;
  36487. protected get _supportsHardwareTextureRescaling(): boolean;
  36488. private _framebufferDimensionsObject;
  36489. /**
  36490. * sets the object from which width and height will be taken from when getting render width and height
  36491. * Will fallback to the gl object
  36492. * @param dimensions the framebuffer width and height that will be used.
  36493. */
  36494. set framebufferDimensionsObject(dimensions: Nullable<{
  36495. framebufferWidth: number;
  36496. framebufferHeight: number;
  36497. }>);
  36498. /**
  36499. * Gets the current viewport
  36500. */
  36501. get currentViewport(): Nullable<IViewportLike>;
  36502. /**
  36503. * Gets the default empty texture
  36504. */
  36505. get emptyTexture(): InternalTexture;
  36506. /**
  36507. * Gets the default empty 3D texture
  36508. */
  36509. get emptyTexture3D(): InternalTexture;
  36510. /**
  36511. * Gets the default empty 2D array texture
  36512. */
  36513. get emptyTexture2DArray(): InternalTexture;
  36514. /**
  36515. * Gets the default empty cube texture
  36516. */
  36517. get emptyCubeTexture(): InternalTexture;
  36518. /**
  36519. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36520. */
  36521. readonly premultipliedAlpha: boolean;
  36522. /**
  36523. * Observable event triggered before each texture is initialized
  36524. */
  36525. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36526. /**
  36527. * Creates a new engine
  36528. * @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
  36529. * @param antialias defines enable antialiasing (default: false)
  36530. * @param options defines further options to be sent to the getContext() function
  36531. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36532. */
  36533. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36534. private _rebuildInternalTextures;
  36535. private _rebuildEffects;
  36536. /**
  36537. * Gets a boolean indicating if all created effects are ready
  36538. * @returns true if all effects are ready
  36539. */
  36540. areAllEffectsReady(): boolean;
  36541. protected _rebuildBuffers(): void;
  36542. protected _initGLContext(): void;
  36543. /**
  36544. * Gets version of the current webGL context
  36545. */
  36546. get webGLVersion(): number;
  36547. /**
  36548. * Gets a string idenfifying the name of the class
  36549. * @returns "Engine" string
  36550. */
  36551. getClassName(): string;
  36552. /**
  36553. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36554. */
  36555. get isStencilEnable(): boolean;
  36556. /** @hidden */
  36557. _prepareWorkingCanvas(): void;
  36558. /**
  36559. * Reset the texture cache to empty state
  36560. */
  36561. resetTextureCache(): void;
  36562. /**
  36563. * Gets an object containing information about the current webGL context
  36564. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36565. */
  36566. getGlInfo(): {
  36567. vendor: string;
  36568. renderer: string;
  36569. version: string;
  36570. };
  36571. /**
  36572. * Defines the hardware scaling level.
  36573. * By default the hardware scaling level is computed from the window device ratio.
  36574. * 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.
  36575. * @param level defines the level to use
  36576. */
  36577. setHardwareScalingLevel(level: number): void;
  36578. /**
  36579. * Gets the current hardware scaling level.
  36580. * By default the hardware scaling level is computed from the window device ratio.
  36581. * 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.
  36582. * @returns a number indicating the current hardware scaling level
  36583. */
  36584. getHardwareScalingLevel(): number;
  36585. /**
  36586. * Gets the list of loaded textures
  36587. * @returns an array containing all loaded textures
  36588. */
  36589. getLoadedTexturesCache(): InternalTexture[];
  36590. /**
  36591. * Gets the object containing all engine capabilities
  36592. * @returns the EngineCapabilities object
  36593. */
  36594. getCaps(): EngineCapabilities;
  36595. /**
  36596. * stop executing a render loop function and remove it from the execution array
  36597. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36598. */
  36599. stopRenderLoop(renderFunction?: () => void): void;
  36600. /** @hidden */
  36601. _renderLoop(): void;
  36602. /**
  36603. * Gets the HTML canvas attached with the current webGL context
  36604. * @returns a HTML canvas
  36605. */
  36606. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36607. /**
  36608. * Gets host window
  36609. * @returns the host window object
  36610. */
  36611. getHostWindow(): Nullable<Window>;
  36612. /**
  36613. * Gets the current render width
  36614. * @param useScreen defines if screen size must be used (or the current render target if any)
  36615. * @returns a number defining the current render width
  36616. */
  36617. getRenderWidth(useScreen?: boolean): number;
  36618. /**
  36619. * Gets the current render height
  36620. * @param useScreen defines if screen size must be used (or the current render target if any)
  36621. * @returns a number defining the current render height
  36622. */
  36623. getRenderHeight(useScreen?: boolean): number;
  36624. /**
  36625. * Can be used to override the current requestAnimationFrame requester.
  36626. * @hidden
  36627. */
  36628. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36629. /**
  36630. * Register and execute a render loop. The engine can have more than one render function
  36631. * @param renderFunction defines the function to continuously execute
  36632. */
  36633. runRenderLoop(renderFunction: () => void): void;
  36634. /**
  36635. * Clear the current render buffer or the current render target (if any is set up)
  36636. * @param color defines the color to use
  36637. * @param backBuffer defines if the back buffer must be cleared
  36638. * @param depth defines if the depth buffer must be cleared
  36639. * @param stencil defines if the stencil buffer must be cleared
  36640. */
  36641. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36642. private _viewportCached;
  36643. /** @hidden */
  36644. _viewport(x: number, y: number, width: number, height: number): void;
  36645. /**
  36646. * Set the WebGL's viewport
  36647. * @param viewport defines the viewport element to be used
  36648. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36649. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36650. */
  36651. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36652. /**
  36653. * Begin a new frame
  36654. */
  36655. beginFrame(): void;
  36656. /**
  36657. * Enf the current frame
  36658. */
  36659. endFrame(): void;
  36660. /**
  36661. * Resize the view according to the canvas' size
  36662. */
  36663. resize(): void;
  36664. /**
  36665. * Force a specific size of the canvas
  36666. * @param width defines the new canvas' width
  36667. * @param height defines the new canvas' height
  36668. * @returns true if the size was changed
  36669. */
  36670. setSize(width: number, height: number): boolean;
  36671. /**
  36672. * Binds the frame buffer to the specified texture.
  36673. * @param texture The texture to render to or null for the default canvas
  36674. * @param faceIndex The face of the texture to render to in case of cube texture
  36675. * @param requiredWidth The width of the target to render to
  36676. * @param requiredHeight The height of the target to render to
  36677. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  36678. * @param lodLevel defines the lod level to bind to the frame buffer
  36679. * @param layer defines the 2d array index to bind to frame buffer to
  36680. */
  36681. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  36682. /** @hidden */
  36683. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  36684. /**
  36685. * Unbind the current render target texture from the webGL context
  36686. * @param texture defines the render target texture to unbind
  36687. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  36688. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  36689. */
  36690. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  36691. /**
  36692. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  36693. */
  36694. flushFramebuffer(): void;
  36695. /**
  36696. * Unbind the current render target and bind the default framebuffer
  36697. */
  36698. restoreDefaultFramebuffer(): void;
  36699. /** @hidden */
  36700. protected _resetVertexBufferBinding(): void;
  36701. /**
  36702. * Creates a vertex buffer
  36703. * @param data the data for the vertex buffer
  36704. * @returns the new WebGL static buffer
  36705. */
  36706. createVertexBuffer(data: DataArray): DataBuffer;
  36707. private _createVertexBuffer;
  36708. /**
  36709. * Creates a dynamic vertex buffer
  36710. * @param data the data for the dynamic vertex buffer
  36711. * @returns the new WebGL dynamic buffer
  36712. */
  36713. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  36714. protected _resetIndexBufferBinding(): void;
  36715. /**
  36716. * Creates a new index buffer
  36717. * @param indices defines the content of the index buffer
  36718. * @param updatable defines if the index buffer must be updatable
  36719. * @returns a new webGL buffer
  36720. */
  36721. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  36722. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  36723. /**
  36724. * Bind a webGL buffer to the webGL context
  36725. * @param buffer defines the buffer to bind
  36726. */
  36727. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  36728. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  36729. private bindBuffer;
  36730. /**
  36731. * update the bound buffer with the given data
  36732. * @param data defines the data to update
  36733. */
  36734. updateArrayBuffer(data: Float32Array): void;
  36735. private _vertexAttribPointer;
  36736. /** @hidden */
  36737. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  36738. private _bindVertexBuffersAttributes;
  36739. /**
  36740. * Records a vertex array object
  36741. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36742. * @param vertexBuffers defines the list of vertex buffers to store
  36743. * @param indexBuffer defines the index buffer to store
  36744. * @param effect defines the effect to store
  36745. * @returns the new vertex array object
  36746. */
  36747. recordVertexArrayObject(vertexBuffers: {
  36748. [key: string]: VertexBuffer;
  36749. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  36750. /**
  36751. * Bind a specific vertex array object
  36752. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36753. * @param vertexArrayObject defines the vertex array object to bind
  36754. * @param indexBuffer defines the index buffer to bind
  36755. */
  36756. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  36757. /**
  36758. * Bind webGl buffers directly to the webGL context
  36759. * @param vertexBuffer defines the vertex buffer to bind
  36760. * @param indexBuffer defines the index buffer to bind
  36761. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  36762. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  36763. * @param effect defines the effect associated with the vertex buffer
  36764. */
  36765. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  36766. private _unbindVertexArrayObject;
  36767. /**
  36768. * Bind a list of vertex buffers to the webGL context
  36769. * @param vertexBuffers defines the list of vertex buffers to bind
  36770. * @param indexBuffer defines the index buffer to bind
  36771. * @param effect defines the effect associated with the vertex buffers
  36772. */
  36773. bindBuffers(vertexBuffers: {
  36774. [key: string]: Nullable<VertexBuffer>;
  36775. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  36776. /**
  36777. * Unbind all instance attributes
  36778. */
  36779. unbindInstanceAttributes(): void;
  36780. /**
  36781. * Release and free the memory of a vertex array object
  36782. * @param vao defines the vertex array object to delete
  36783. */
  36784. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  36785. /** @hidden */
  36786. _releaseBuffer(buffer: DataBuffer): boolean;
  36787. protected _deleteBuffer(buffer: DataBuffer): void;
  36788. /**
  36789. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  36790. * @param instancesBuffer defines the webGL buffer to update and bind
  36791. * @param data defines the data to store in the buffer
  36792. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  36793. */
  36794. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  36795. /**
  36796. * Bind the content of a webGL buffer used with instantiation
  36797. * @param instancesBuffer defines the webGL buffer to bind
  36798. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  36799. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  36800. */
  36801. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  36802. /**
  36803. * Disable the instance attribute corresponding to the name in parameter
  36804. * @param name defines the name of the attribute to disable
  36805. */
  36806. disableInstanceAttributeByName(name: string): void;
  36807. /**
  36808. * Disable the instance attribute corresponding to the location in parameter
  36809. * @param attributeLocation defines the attribute location of the attribute to disable
  36810. */
  36811. disableInstanceAttribute(attributeLocation: number): void;
  36812. /**
  36813. * Disable the attribute corresponding to the location in parameter
  36814. * @param attributeLocation defines the attribute location of the attribute to disable
  36815. */
  36816. disableAttributeByIndex(attributeLocation: number): void;
  36817. /**
  36818. * Send a draw order
  36819. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36820. * @param indexStart defines the starting index
  36821. * @param indexCount defines the number of index to draw
  36822. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36823. */
  36824. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  36825. /**
  36826. * Draw a list of points
  36827. * @param verticesStart defines the index of first vertex to draw
  36828. * @param verticesCount defines the count of vertices to draw
  36829. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36830. */
  36831. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36832. /**
  36833. * Draw a list of unindexed primitives
  36834. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36835. * @param verticesStart defines the index of first vertex to draw
  36836. * @param verticesCount defines the count of vertices to draw
  36837. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36838. */
  36839. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36840. /**
  36841. * Draw a list of indexed primitives
  36842. * @param fillMode defines the primitive to use
  36843. * @param indexStart defines the starting index
  36844. * @param indexCount defines the number of index to draw
  36845. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36846. */
  36847. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  36848. /**
  36849. * Draw a list of unindexed primitives
  36850. * @param fillMode defines the primitive to use
  36851. * @param verticesStart defines the index of first vertex to draw
  36852. * @param verticesCount defines the count of vertices to draw
  36853. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36854. */
  36855. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36856. private _drawMode;
  36857. /** @hidden */
  36858. protected _reportDrawCall(): void;
  36859. /** @hidden */
  36860. _releaseEffect(effect: Effect): void;
  36861. /** @hidden */
  36862. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36863. /**
  36864. * Create a new effect (used to store vertex/fragment shaders)
  36865. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  36866. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  36867. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  36868. * @param samplers defines an array of string used to represent textures
  36869. * @param defines defines the string containing the defines to use to compile the shaders
  36870. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36871. * @param onCompiled defines a function to call when the effect creation is successful
  36872. * @param onError defines a function to call when the effect creation has failed
  36873. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36874. * @returns the new Effect
  36875. */
  36876. 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;
  36877. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36878. private _compileShader;
  36879. private _compileRawShader;
  36880. /** @hidden */
  36881. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36882. /**
  36883. * Directly creates a webGL program
  36884. * @param pipelineContext defines the pipeline context to attach to
  36885. * @param vertexCode defines the vertex shader code to use
  36886. * @param fragmentCode defines the fragment shader code to use
  36887. * @param context defines the webGL context to use (if not set, the current one will be used)
  36888. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36889. * @returns the new webGL program
  36890. */
  36891. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36892. /**
  36893. * Creates a webGL program
  36894. * @param pipelineContext defines the pipeline context to attach to
  36895. * @param vertexCode defines the vertex shader code to use
  36896. * @param fragmentCode defines the fragment shader code to use
  36897. * @param defines defines the string containing the defines to use to compile the shaders
  36898. * @param context defines the webGL context to use (if not set, the current one will be used)
  36899. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36900. * @returns the new webGL program
  36901. */
  36902. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36903. /**
  36904. * Creates a new pipeline context
  36905. * @returns the new pipeline
  36906. */
  36907. createPipelineContext(): IPipelineContext;
  36908. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36909. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36910. /** @hidden */
  36911. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36912. /** @hidden */
  36913. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36914. /** @hidden */
  36915. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36916. /**
  36917. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36918. * @param pipelineContext defines the pipeline context to use
  36919. * @param uniformsNames defines the list of uniform names
  36920. * @returns an array of webGL uniform locations
  36921. */
  36922. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36923. /**
  36924. * Gets the lsit of active attributes for a given webGL program
  36925. * @param pipelineContext defines the pipeline context to use
  36926. * @param attributesNames defines the list of attribute names to get
  36927. * @returns an array of indices indicating the offset of each attribute
  36928. */
  36929. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36930. /**
  36931. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36932. * @param effect defines the effect to activate
  36933. */
  36934. enableEffect(effect: Nullable<Effect>): void;
  36935. /**
  36936. * Set the value of an uniform to a number (int)
  36937. * @param uniform defines the webGL uniform location where to store the value
  36938. * @param value defines the int number to store
  36939. */
  36940. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36941. /**
  36942. * Set the value of an uniform to an array of int32
  36943. * @param uniform defines the webGL uniform location where to store the value
  36944. * @param array defines the array of int32 to store
  36945. */
  36946. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36947. /**
  36948. * Set the value of an uniform to an array of int32 (stored as vec2)
  36949. * @param uniform defines the webGL uniform location where to store the value
  36950. * @param array defines the array of int32 to store
  36951. */
  36952. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36953. /**
  36954. * Set the value of an uniform to an array of int32 (stored as vec3)
  36955. * @param uniform defines the webGL uniform location where to store the value
  36956. * @param array defines the array of int32 to store
  36957. */
  36958. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36959. /**
  36960. * Set the value of an uniform to an array of int32 (stored as vec4)
  36961. * @param uniform defines the webGL uniform location where to store the value
  36962. * @param array defines the array of int32 to store
  36963. */
  36964. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36965. /**
  36966. * Set the value of an uniform to an array of number
  36967. * @param uniform defines the webGL uniform location where to store the value
  36968. * @param array defines the array of number to store
  36969. */
  36970. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36971. /**
  36972. * Set the value of an uniform to an array of number (stored as vec2)
  36973. * @param uniform defines the webGL uniform location where to store the value
  36974. * @param array defines the array of number to store
  36975. */
  36976. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36977. /**
  36978. * Set the value of an uniform to an array of number (stored as vec3)
  36979. * @param uniform defines the webGL uniform location where to store the value
  36980. * @param array defines the array of number to store
  36981. */
  36982. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36983. /**
  36984. * Set the value of an uniform to an array of number (stored as vec4)
  36985. * @param uniform defines the webGL uniform location where to store the value
  36986. * @param array defines the array of number to store
  36987. */
  36988. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36989. /**
  36990. * Set the value of an uniform to an array of float32 (stored as matrices)
  36991. * @param uniform defines the webGL uniform location where to store the value
  36992. * @param matrices defines the array of float32 to store
  36993. */
  36994. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  36995. /**
  36996. * Set the value of an uniform to a matrix (3x3)
  36997. * @param uniform defines the webGL uniform location where to store the value
  36998. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36999. */
  37000. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37001. /**
  37002. * Set the value of an uniform to a matrix (2x2)
  37003. * @param uniform defines the webGL uniform location where to store the value
  37004. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37005. */
  37006. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37007. /**
  37008. * Set the value of an uniform to a number (float)
  37009. * @param uniform defines the webGL uniform location where to store the value
  37010. * @param value defines the float number to store
  37011. */
  37012. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37013. /**
  37014. * Set the value of an uniform to a vec2
  37015. * @param uniform defines the webGL uniform location where to store the value
  37016. * @param x defines the 1st component of the value
  37017. * @param y defines the 2nd component of the value
  37018. */
  37019. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  37020. /**
  37021. * Set the value of an uniform to a vec3
  37022. * @param uniform defines the webGL uniform location where to store the value
  37023. * @param x defines the 1st component of the value
  37024. * @param y defines the 2nd component of the value
  37025. * @param z defines the 3rd component of the value
  37026. */
  37027. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  37028. /**
  37029. * Set the value of an uniform to a vec4
  37030. * @param uniform defines the webGL uniform location where to store the value
  37031. * @param x defines the 1st component of the value
  37032. * @param y defines the 2nd component of the value
  37033. * @param z defines the 3rd component of the value
  37034. * @param w defines the 4th component of the value
  37035. */
  37036. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  37037. /**
  37038. * Apply all cached states (depth, culling, stencil and alpha)
  37039. */
  37040. applyStates(): void;
  37041. /**
  37042. * Enable or disable color writing
  37043. * @param enable defines the state to set
  37044. */
  37045. setColorWrite(enable: boolean): void;
  37046. /**
  37047. * Gets a boolean indicating if color writing is enabled
  37048. * @returns the current color writing state
  37049. */
  37050. getColorWrite(): boolean;
  37051. /**
  37052. * Gets the depth culling state manager
  37053. */
  37054. get depthCullingState(): DepthCullingState;
  37055. /**
  37056. * Gets the alpha state manager
  37057. */
  37058. get alphaState(): AlphaState;
  37059. /**
  37060. * Gets the stencil state manager
  37061. */
  37062. get stencilState(): StencilState;
  37063. /**
  37064. * Clears the list of texture accessible through engine.
  37065. * This can help preventing texture load conflict due to name collision.
  37066. */
  37067. clearInternalTexturesCache(): void;
  37068. /**
  37069. * Force the entire cache to be cleared
  37070. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37071. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37072. */
  37073. wipeCaches(bruteForce?: boolean): void;
  37074. /** @hidden */
  37075. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37076. min: number;
  37077. mag: number;
  37078. };
  37079. /** @hidden */
  37080. _createTexture(): WebGLTexture;
  37081. /**
  37082. * Usually called from Texture.ts.
  37083. * Passed information to create a WebGLTexture
  37084. * @param url defines a value which contains one of the following:
  37085. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37086. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37087. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37088. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37089. * @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)
  37090. * @param scene needed for loading to the correct scene
  37091. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37092. * @param onLoad optional callback to be called upon successful completion
  37093. * @param onError optional callback to be called upon failure
  37094. * @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
  37095. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37096. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37097. * @param forcedExtension defines the extension to use to pick the right loader
  37098. * @param mimeType defines an optional mime type
  37099. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37100. */
  37101. 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;
  37102. /**
  37103. * Loads an image as an HTMLImageElement.
  37104. * @param input url string, ArrayBuffer, or Blob to load
  37105. * @param onLoad callback called when the image successfully loads
  37106. * @param onError callback called when the image fails to load
  37107. * @param offlineProvider offline provider for caching
  37108. * @param mimeType optional mime type
  37109. * @returns the HTMLImageElement of the loaded image
  37110. * @hidden
  37111. */
  37112. 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>;
  37113. /**
  37114. * @hidden
  37115. */
  37116. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37117. private _unpackFlipYCached;
  37118. /**
  37119. * In case you are sharing the context with other applications, it might
  37120. * be interested to not cache the unpack flip y state to ensure a consistent
  37121. * value would be set.
  37122. */
  37123. enableUnpackFlipYCached: boolean;
  37124. /** @hidden */
  37125. _unpackFlipY(value: boolean): void;
  37126. /** @hidden */
  37127. _getUnpackAlignement(): number;
  37128. private _getTextureTarget;
  37129. /**
  37130. * Update the sampling mode of a given texture
  37131. * @param samplingMode defines the required sampling mode
  37132. * @param texture defines the texture to update
  37133. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37134. */
  37135. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37136. /**
  37137. * Update the sampling mode of a given texture
  37138. * @param texture defines the texture to update
  37139. * @param wrapU defines the texture wrap mode of the u coordinates
  37140. * @param wrapV defines the texture wrap mode of the v coordinates
  37141. * @param wrapR defines the texture wrap mode of the r coordinates
  37142. */
  37143. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37144. /** @hidden */
  37145. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37146. width: number;
  37147. height: number;
  37148. layers?: number;
  37149. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37150. /** @hidden */
  37151. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37152. /** @hidden */
  37153. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37154. /**
  37155. * Update a portion of an internal texture
  37156. * @param texture defines the texture to update
  37157. * @param imageData defines the data to store into the texture
  37158. * @param xOffset defines the x coordinates of the update rectangle
  37159. * @param yOffset defines the y coordinates of the update rectangle
  37160. * @param width defines the width of the update rectangle
  37161. * @param height defines the height of the update rectangle
  37162. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37163. * @param lod defines the lod level to update (0 by default)
  37164. */
  37165. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37166. /** @hidden */
  37167. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37168. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37169. private _prepareWebGLTexture;
  37170. /** @hidden */
  37171. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37172. private _getDepthStencilBuffer;
  37173. /** @hidden */
  37174. _releaseFramebufferObjects(texture: InternalTexture): void;
  37175. /** @hidden */
  37176. _releaseTexture(texture: InternalTexture): void;
  37177. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37178. protected _setProgram(program: WebGLProgram): void;
  37179. protected _boundUniforms: {
  37180. [key: number]: WebGLUniformLocation;
  37181. };
  37182. /**
  37183. * Binds an effect to the webGL context
  37184. * @param effect defines the effect to bind
  37185. */
  37186. bindSamplers(effect: Effect): void;
  37187. private _activateCurrentTexture;
  37188. /** @hidden */
  37189. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37190. /** @hidden */
  37191. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37192. /**
  37193. * Unbind all textures from the webGL context
  37194. */
  37195. unbindAllTextures(): void;
  37196. /**
  37197. * Sets a texture to the according uniform.
  37198. * @param channel The texture channel
  37199. * @param uniform The uniform to set
  37200. * @param texture The texture to apply
  37201. */
  37202. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37203. private _bindSamplerUniformToChannel;
  37204. private _getTextureWrapMode;
  37205. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37206. /**
  37207. * Sets an array of texture to the webGL context
  37208. * @param channel defines the channel where the texture array must be set
  37209. * @param uniform defines the associated uniform location
  37210. * @param textures defines the array of textures to bind
  37211. */
  37212. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37213. /** @hidden */
  37214. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37215. private _setTextureParameterFloat;
  37216. private _setTextureParameterInteger;
  37217. /**
  37218. * Unbind all vertex attributes from the webGL context
  37219. */
  37220. unbindAllAttributes(): void;
  37221. /**
  37222. * 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
  37223. */
  37224. releaseEffects(): void;
  37225. /**
  37226. * Dispose and release all associated resources
  37227. */
  37228. dispose(): void;
  37229. /**
  37230. * Attach a new callback raised when context lost event is fired
  37231. * @param callback defines the callback to call
  37232. */
  37233. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37234. /**
  37235. * Attach a new callback raised when context restored event is fired
  37236. * @param callback defines the callback to call
  37237. */
  37238. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37239. /**
  37240. * Get the current error code of the webGL context
  37241. * @returns the error code
  37242. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37243. */
  37244. getError(): number;
  37245. private _canRenderToFloatFramebuffer;
  37246. private _canRenderToHalfFloatFramebuffer;
  37247. private _canRenderToFramebuffer;
  37248. /** @hidden */
  37249. _getWebGLTextureType(type: number): number;
  37250. /** @hidden */
  37251. _getInternalFormat(format: number): number;
  37252. /** @hidden */
  37253. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37254. /** @hidden */
  37255. _getRGBAMultiSampleBufferFormat(type: number): number;
  37256. /** @hidden */
  37257. _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;
  37258. /**
  37259. * Loads a file from a url
  37260. * @param url url to load
  37261. * @param onSuccess callback called when the file successfully loads
  37262. * @param onProgress callback called while file is loading (if the server supports this mode)
  37263. * @param offlineProvider defines the offline provider for caching
  37264. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37265. * @param onError callback called when the file fails to load
  37266. * @returns a file request object
  37267. * @hidden
  37268. */
  37269. 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;
  37270. /**
  37271. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37272. * @param x defines the x coordinate of the rectangle where pixels must be read
  37273. * @param y defines the y coordinate of the rectangle where pixels must be read
  37274. * @param width defines the width of the rectangle where pixels must be read
  37275. * @param height defines the height of the rectangle where pixels must be read
  37276. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37277. * @returns a Uint8Array containing RGBA colors
  37278. */
  37279. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37280. private static _isSupported;
  37281. /**
  37282. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37283. * @returns true if the engine can be created
  37284. * @ignorenaming
  37285. */
  37286. static isSupported(): boolean;
  37287. /**
  37288. * Find the next highest power of two.
  37289. * @param x Number to start search from.
  37290. * @return Next highest power of two.
  37291. */
  37292. static CeilingPOT(x: number): number;
  37293. /**
  37294. * Find the next lowest power of two.
  37295. * @param x Number to start search from.
  37296. * @return Next lowest power of two.
  37297. */
  37298. static FloorPOT(x: number): number;
  37299. /**
  37300. * Find the nearest power of two.
  37301. * @param x Number to start search from.
  37302. * @return Next nearest power of two.
  37303. */
  37304. static NearestPOT(x: number): number;
  37305. /**
  37306. * Get the closest exponent of two
  37307. * @param value defines the value to approximate
  37308. * @param max defines the maximum value to return
  37309. * @param mode defines how to define the closest value
  37310. * @returns closest exponent of two of the given value
  37311. */
  37312. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37313. /**
  37314. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37315. * @param func - the function to be called
  37316. * @param requester - the object that will request the next frame. Falls back to window.
  37317. * @returns frame number
  37318. */
  37319. static QueueNewFrame(func: () => void, requester?: any): number;
  37320. /**
  37321. * Gets host document
  37322. * @returns the host document object
  37323. */
  37324. getHostDocument(): Nullable<Document>;
  37325. }
  37326. }
  37327. declare module "babylonjs/Maths/sphericalPolynomial" {
  37328. import { Vector3 } from "babylonjs/Maths/math.vector";
  37329. import { Color3 } from "babylonjs/Maths/math.color";
  37330. /**
  37331. * Class representing spherical harmonics coefficients to the 3rd degree
  37332. */
  37333. export class SphericalHarmonics {
  37334. /**
  37335. * Defines whether or not the harmonics have been prescaled for rendering.
  37336. */
  37337. preScaled: boolean;
  37338. /**
  37339. * The l0,0 coefficients of the spherical harmonics
  37340. */
  37341. l00: Vector3;
  37342. /**
  37343. * The l1,-1 coefficients of the spherical harmonics
  37344. */
  37345. l1_1: Vector3;
  37346. /**
  37347. * The l1,0 coefficients of the spherical harmonics
  37348. */
  37349. l10: Vector3;
  37350. /**
  37351. * The l1,1 coefficients of the spherical harmonics
  37352. */
  37353. l11: Vector3;
  37354. /**
  37355. * The l2,-2 coefficients of the spherical harmonics
  37356. */
  37357. l2_2: Vector3;
  37358. /**
  37359. * The l2,-1 coefficients of the spherical harmonics
  37360. */
  37361. l2_1: Vector3;
  37362. /**
  37363. * The l2,0 coefficients of the spherical harmonics
  37364. */
  37365. l20: Vector3;
  37366. /**
  37367. * The l2,1 coefficients of the spherical harmonics
  37368. */
  37369. l21: Vector3;
  37370. /**
  37371. * The l2,2 coefficients of the spherical harmonics
  37372. */
  37373. l22: Vector3;
  37374. /**
  37375. * Adds a light to the spherical harmonics
  37376. * @param direction the direction of the light
  37377. * @param color the color of the light
  37378. * @param deltaSolidAngle the delta solid angle of the light
  37379. */
  37380. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37381. /**
  37382. * Scales the spherical harmonics by the given amount
  37383. * @param scale the amount to scale
  37384. */
  37385. scaleInPlace(scale: number): void;
  37386. /**
  37387. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37388. *
  37389. * ```
  37390. * E_lm = A_l * L_lm
  37391. * ```
  37392. *
  37393. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37394. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37395. * the scaling factors are given in equation 9.
  37396. */
  37397. convertIncidentRadianceToIrradiance(): void;
  37398. /**
  37399. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37400. *
  37401. * ```
  37402. * L = (1/pi) * E * rho
  37403. * ```
  37404. *
  37405. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37406. */
  37407. convertIrradianceToLambertianRadiance(): void;
  37408. /**
  37409. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37410. * required operations at run time.
  37411. *
  37412. * This is simply done by scaling back the SH with Ylm constants parameter.
  37413. * The trigonometric part being applied by the shader at run time.
  37414. */
  37415. preScaleForRendering(): void;
  37416. /**
  37417. * Constructs a spherical harmonics from an array.
  37418. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37419. * @returns the spherical harmonics
  37420. */
  37421. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37422. /**
  37423. * Gets the spherical harmonics from polynomial
  37424. * @param polynomial the spherical polynomial
  37425. * @returns the spherical harmonics
  37426. */
  37427. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37428. }
  37429. /**
  37430. * Class representing spherical polynomial coefficients to the 3rd degree
  37431. */
  37432. export class SphericalPolynomial {
  37433. private _harmonics;
  37434. /**
  37435. * The spherical harmonics used to create the polynomials.
  37436. */
  37437. get preScaledHarmonics(): SphericalHarmonics;
  37438. /**
  37439. * The x coefficients of the spherical polynomial
  37440. */
  37441. x: Vector3;
  37442. /**
  37443. * The y coefficients of the spherical polynomial
  37444. */
  37445. y: Vector3;
  37446. /**
  37447. * The z coefficients of the spherical polynomial
  37448. */
  37449. z: Vector3;
  37450. /**
  37451. * The xx coefficients of the spherical polynomial
  37452. */
  37453. xx: Vector3;
  37454. /**
  37455. * The yy coefficients of the spherical polynomial
  37456. */
  37457. yy: Vector3;
  37458. /**
  37459. * The zz coefficients of the spherical polynomial
  37460. */
  37461. zz: Vector3;
  37462. /**
  37463. * The xy coefficients of the spherical polynomial
  37464. */
  37465. xy: Vector3;
  37466. /**
  37467. * The yz coefficients of the spherical polynomial
  37468. */
  37469. yz: Vector3;
  37470. /**
  37471. * The zx coefficients of the spherical polynomial
  37472. */
  37473. zx: Vector3;
  37474. /**
  37475. * Adds an ambient color to the spherical polynomial
  37476. * @param color the color to add
  37477. */
  37478. addAmbient(color: Color3): void;
  37479. /**
  37480. * Scales the spherical polynomial by the given amount
  37481. * @param scale the amount to scale
  37482. */
  37483. scaleInPlace(scale: number): void;
  37484. /**
  37485. * Gets the spherical polynomial from harmonics
  37486. * @param harmonics the spherical harmonics
  37487. * @returns the spherical polynomial
  37488. */
  37489. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37490. /**
  37491. * Constructs a spherical polynomial from an array.
  37492. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37493. * @returns the spherical polynomial
  37494. */
  37495. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37496. }
  37497. }
  37498. declare module "babylonjs/Materials/Textures/internalTexture" {
  37499. import { Observable } from "babylonjs/Misc/observable";
  37500. import { Nullable, int } from "babylonjs/types";
  37501. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37502. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37503. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37504. /**
  37505. * Defines the source of the internal texture
  37506. */
  37507. export enum InternalTextureSource {
  37508. /**
  37509. * The source of the texture data is unknown
  37510. */
  37511. Unknown = 0,
  37512. /**
  37513. * Texture data comes from an URL
  37514. */
  37515. Url = 1,
  37516. /**
  37517. * Texture data is only used for temporary storage
  37518. */
  37519. Temp = 2,
  37520. /**
  37521. * Texture data comes from raw data (ArrayBuffer)
  37522. */
  37523. Raw = 3,
  37524. /**
  37525. * Texture content is dynamic (video or dynamic texture)
  37526. */
  37527. Dynamic = 4,
  37528. /**
  37529. * Texture content is generated by rendering to it
  37530. */
  37531. RenderTarget = 5,
  37532. /**
  37533. * Texture content is part of a multi render target process
  37534. */
  37535. MultiRenderTarget = 6,
  37536. /**
  37537. * Texture data comes from a cube data file
  37538. */
  37539. Cube = 7,
  37540. /**
  37541. * Texture data comes from a raw cube data
  37542. */
  37543. CubeRaw = 8,
  37544. /**
  37545. * Texture data come from a prefiltered cube data file
  37546. */
  37547. CubePrefiltered = 9,
  37548. /**
  37549. * Texture content is raw 3D data
  37550. */
  37551. Raw3D = 10,
  37552. /**
  37553. * Texture content is raw 2D array data
  37554. */
  37555. Raw2DArray = 11,
  37556. /**
  37557. * Texture content is a depth texture
  37558. */
  37559. Depth = 12,
  37560. /**
  37561. * Texture data comes from a raw cube data encoded with RGBD
  37562. */
  37563. CubeRawRGBD = 13
  37564. }
  37565. /**
  37566. * Class used to store data associated with WebGL texture data for the engine
  37567. * This class should not be used directly
  37568. */
  37569. export class InternalTexture {
  37570. /** @hidden */
  37571. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37572. /**
  37573. * Defines if the texture is ready
  37574. */
  37575. isReady: boolean;
  37576. /**
  37577. * Defines if the texture is a cube texture
  37578. */
  37579. isCube: boolean;
  37580. /**
  37581. * Defines if the texture contains 3D data
  37582. */
  37583. is3D: boolean;
  37584. /**
  37585. * Defines if the texture contains 2D array data
  37586. */
  37587. is2DArray: boolean;
  37588. /**
  37589. * Defines if the texture contains multiview data
  37590. */
  37591. isMultiview: boolean;
  37592. /**
  37593. * Gets the URL used to load this texture
  37594. */
  37595. url: string;
  37596. /**
  37597. * Gets the sampling mode of the texture
  37598. */
  37599. samplingMode: number;
  37600. /**
  37601. * Gets a boolean indicating if the texture needs mipmaps generation
  37602. */
  37603. generateMipMaps: boolean;
  37604. /**
  37605. * Gets the number of samples used by the texture (WebGL2+ only)
  37606. */
  37607. samples: number;
  37608. /**
  37609. * Gets the type of the texture (int, float...)
  37610. */
  37611. type: number;
  37612. /**
  37613. * Gets the format of the texture (RGB, RGBA...)
  37614. */
  37615. format: number;
  37616. /**
  37617. * Observable called when the texture is loaded
  37618. */
  37619. onLoadedObservable: Observable<InternalTexture>;
  37620. /**
  37621. * Gets the width of the texture
  37622. */
  37623. width: number;
  37624. /**
  37625. * Gets the height of the texture
  37626. */
  37627. height: number;
  37628. /**
  37629. * Gets the depth of the texture
  37630. */
  37631. depth: number;
  37632. /**
  37633. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37634. */
  37635. baseWidth: number;
  37636. /**
  37637. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37638. */
  37639. baseHeight: number;
  37640. /**
  37641. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37642. */
  37643. baseDepth: number;
  37644. /**
  37645. * Gets a boolean indicating if the texture is inverted on Y axis
  37646. */
  37647. invertY: boolean;
  37648. /** @hidden */
  37649. _invertVScale: boolean;
  37650. /** @hidden */
  37651. _associatedChannel: number;
  37652. /** @hidden */
  37653. _source: InternalTextureSource;
  37654. /** @hidden */
  37655. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  37656. /** @hidden */
  37657. _bufferView: Nullable<ArrayBufferView>;
  37658. /** @hidden */
  37659. _bufferViewArray: Nullable<ArrayBufferView[]>;
  37660. /** @hidden */
  37661. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  37662. /** @hidden */
  37663. _size: number;
  37664. /** @hidden */
  37665. _extension: string;
  37666. /** @hidden */
  37667. _files: Nullable<string[]>;
  37668. /** @hidden */
  37669. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  37670. /** @hidden */
  37671. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  37672. /** @hidden */
  37673. _framebuffer: Nullable<WebGLFramebuffer>;
  37674. /** @hidden */
  37675. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  37676. /** @hidden */
  37677. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  37678. /** @hidden */
  37679. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  37680. /** @hidden */
  37681. _attachments: Nullable<number[]>;
  37682. /** @hidden */
  37683. _textureArray: Nullable<InternalTexture[]>;
  37684. /** @hidden */
  37685. _cachedCoordinatesMode: Nullable<number>;
  37686. /** @hidden */
  37687. _cachedWrapU: Nullable<number>;
  37688. /** @hidden */
  37689. _cachedWrapV: Nullable<number>;
  37690. /** @hidden */
  37691. _cachedWrapR: Nullable<number>;
  37692. /** @hidden */
  37693. _cachedAnisotropicFilteringLevel: Nullable<number>;
  37694. /** @hidden */
  37695. _isDisabled: boolean;
  37696. /** @hidden */
  37697. _compression: Nullable<string>;
  37698. /** @hidden */
  37699. _generateStencilBuffer: boolean;
  37700. /** @hidden */
  37701. _generateDepthBuffer: boolean;
  37702. /** @hidden */
  37703. _comparisonFunction: number;
  37704. /** @hidden */
  37705. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  37706. /** @hidden */
  37707. _lodGenerationScale: number;
  37708. /** @hidden */
  37709. _lodGenerationOffset: number;
  37710. /** @hidden */
  37711. _depthStencilTexture: Nullable<InternalTexture>;
  37712. /** @hidden */
  37713. _colorTextureArray: Nullable<WebGLTexture>;
  37714. /** @hidden */
  37715. _depthStencilTextureArray: Nullable<WebGLTexture>;
  37716. /** @hidden */
  37717. _lodTextureHigh: Nullable<BaseTexture>;
  37718. /** @hidden */
  37719. _lodTextureMid: Nullable<BaseTexture>;
  37720. /** @hidden */
  37721. _lodTextureLow: Nullable<BaseTexture>;
  37722. /** @hidden */
  37723. _isRGBD: boolean;
  37724. /** @hidden */
  37725. _linearSpecularLOD: boolean;
  37726. /** @hidden */
  37727. _irradianceTexture: Nullable<BaseTexture>;
  37728. /** @hidden */
  37729. _webGLTexture: Nullable<WebGLTexture>;
  37730. /** @hidden */
  37731. _references: number;
  37732. private _engine;
  37733. /**
  37734. * Gets the Engine the texture belongs to.
  37735. * @returns The babylon engine
  37736. */
  37737. getEngine(): ThinEngine;
  37738. /**
  37739. * Gets the data source type of the texture
  37740. */
  37741. get source(): InternalTextureSource;
  37742. /**
  37743. * Creates a new InternalTexture
  37744. * @param engine defines the engine to use
  37745. * @param source defines the type of data that will be used
  37746. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37747. */
  37748. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  37749. /**
  37750. * Increments the number of references (ie. the number of Texture that point to it)
  37751. */
  37752. incrementReferences(): void;
  37753. /**
  37754. * Change the size of the texture (not the size of the content)
  37755. * @param width defines the new width
  37756. * @param height defines the new height
  37757. * @param depth defines the new depth (1 by default)
  37758. */
  37759. updateSize(width: int, height: int, depth?: int): void;
  37760. /** @hidden */
  37761. _rebuild(): void;
  37762. /** @hidden */
  37763. _swapAndDie(target: InternalTexture): void;
  37764. /**
  37765. * Dispose the current allocated resources
  37766. */
  37767. dispose(): void;
  37768. }
  37769. }
  37770. declare module "babylonjs/Audio/analyser" {
  37771. import { Scene } from "babylonjs/scene";
  37772. /**
  37773. * Class used to work with sound analyzer using fast fourier transform (FFT)
  37774. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37775. */
  37776. export class Analyser {
  37777. /**
  37778. * Gets or sets the smoothing
  37779. * @ignorenaming
  37780. */
  37781. SMOOTHING: number;
  37782. /**
  37783. * Gets or sets the FFT table size
  37784. * @ignorenaming
  37785. */
  37786. FFT_SIZE: number;
  37787. /**
  37788. * Gets or sets the bar graph amplitude
  37789. * @ignorenaming
  37790. */
  37791. BARGRAPHAMPLITUDE: number;
  37792. /**
  37793. * Gets or sets the position of the debug canvas
  37794. * @ignorenaming
  37795. */
  37796. DEBUGCANVASPOS: {
  37797. x: number;
  37798. y: number;
  37799. };
  37800. /**
  37801. * Gets or sets the debug canvas size
  37802. * @ignorenaming
  37803. */
  37804. DEBUGCANVASSIZE: {
  37805. width: number;
  37806. height: number;
  37807. };
  37808. private _byteFreqs;
  37809. private _byteTime;
  37810. private _floatFreqs;
  37811. private _webAudioAnalyser;
  37812. private _debugCanvas;
  37813. private _debugCanvasContext;
  37814. private _scene;
  37815. private _registerFunc;
  37816. private _audioEngine;
  37817. /**
  37818. * Creates a new analyser
  37819. * @param scene defines hosting scene
  37820. */
  37821. constructor(scene: Scene);
  37822. /**
  37823. * Get the number of data values you will have to play with for the visualization
  37824. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  37825. * @returns a number
  37826. */
  37827. getFrequencyBinCount(): number;
  37828. /**
  37829. * Gets the current frequency data as a byte array
  37830. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37831. * @returns a Uint8Array
  37832. */
  37833. getByteFrequencyData(): Uint8Array;
  37834. /**
  37835. * Gets the current waveform as a byte array
  37836. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  37837. * @returns a Uint8Array
  37838. */
  37839. getByteTimeDomainData(): Uint8Array;
  37840. /**
  37841. * Gets the current frequency data as a float array
  37842. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37843. * @returns a Float32Array
  37844. */
  37845. getFloatFrequencyData(): Float32Array;
  37846. /**
  37847. * Renders the debug canvas
  37848. */
  37849. drawDebugCanvas(): void;
  37850. /**
  37851. * Stops rendering the debug canvas and removes it
  37852. */
  37853. stopDebugCanvas(): void;
  37854. /**
  37855. * Connects two audio nodes
  37856. * @param inputAudioNode defines first node to connect
  37857. * @param outputAudioNode defines second node to connect
  37858. */
  37859. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  37860. /**
  37861. * Releases all associated resources
  37862. */
  37863. dispose(): void;
  37864. }
  37865. }
  37866. declare module "babylonjs/Audio/audioEngine" {
  37867. import { IDisposable } from "babylonjs/scene";
  37868. import { Analyser } from "babylonjs/Audio/analyser";
  37869. import { Nullable } from "babylonjs/types";
  37870. import { Observable } from "babylonjs/Misc/observable";
  37871. /**
  37872. * This represents an audio engine and it is responsible
  37873. * to play, synchronize and analyse sounds throughout the application.
  37874. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37875. */
  37876. export interface IAudioEngine extends IDisposable {
  37877. /**
  37878. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37879. */
  37880. readonly canUseWebAudio: boolean;
  37881. /**
  37882. * Gets the current AudioContext if available.
  37883. */
  37884. readonly audioContext: Nullable<AudioContext>;
  37885. /**
  37886. * The master gain node defines the global audio volume of your audio engine.
  37887. */
  37888. readonly masterGain: GainNode;
  37889. /**
  37890. * Gets whether or not mp3 are supported by your browser.
  37891. */
  37892. readonly isMP3supported: boolean;
  37893. /**
  37894. * Gets whether or not ogg are supported by your browser.
  37895. */
  37896. readonly isOGGsupported: boolean;
  37897. /**
  37898. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37899. * @ignoreNaming
  37900. */
  37901. WarnedWebAudioUnsupported: boolean;
  37902. /**
  37903. * Defines if the audio engine relies on a custom unlocked button.
  37904. * In this case, the embedded button will not be displayed.
  37905. */
  37906. useCustomUnlockedButton: boolean;
  37907. /**
  37908. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37909. */
  37910. readonly unlocked: boolean;
  37911. /**
  37912. * Event raised when audio has been unlocked on the browser.
  37913. */
  37914. onAudioUnlockedObservable: Observable<AudioEngine>;
  37915. /**
  37916. * Event raised when audio has been locked on the browser.
  37917. */
  37918. onAudioLockedObservable: Observable<AudioEngine>;
  37919. /**
  37920. * Flags the audio engine in Locked state.
  37921. * This happens due to new browser policies preventing audio to autoplay.
  37922. */
  37923. lock(): void;
  37924. /**
  37925. * Unlocks the audio engine once a user action has been done on the dom.
  37926. * This is helpful to resume play once browser policies have been satisfied.
  37927. */
  37928. unlock(): void;
  37929. /**
  37930. * Gets the global volume sets on the master gain.
  37931. * @returns the global volume if set or -1 otherwise
  37932. */
  37933. getGlobalVolume(): number;
  37934. /**
  37935. * Sets the global volume of your experience (sets on the master gain).
  37936. * @param newVolume Defines the new global volume of the application
  37937. */
  37938. setGlobalVolume(newVolume: number): void;
  37939. /**
  37940. * Connect the audio engine to an audio analyser allowing some amazing
  37941. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37942. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37943. * @param analyser The analyser to connect to the engine
  37944. */
  37945. connectToAnalyser(analyser: Analyser): void;
  37946. }
  37947. /**
  37948. * This represents the default audio engine used in babylon.
  37949. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37950. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37951. */
  37952. export class AudioEngine implements IAudioEngine {
  37953. private _audioContext;
  37954. private _audioContextInitialized;
  37955. private _muteButton;
  37956. private _hostElement;
  37957. /**
  37958. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37959. */
  37960. canUseWebAudio: boolean;
  37961. /**
  37962. * The master gain node defines the global audio volume of your audio engine.
  37963. */
  37964. masterGain: GainNode;
  37965. /**
  37966. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37967. * @ignoreNaming
  37968. */
  37969. WarnedWebAudioUnsupported: boolean;
  37970. /**
  37971. * Gets whether or not mp3 are supported by your browser.
  37972. */
  37973. isMP3supported: boolean;
  37974. /**
  37975. * Gets whether or not ogg are supported by your browser.
  37976. */
  37977. isOGGsupported: boolean;
  37978. /**
  37979. * Gets whether audio has been unlocked on the device.
  37980. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37981. * a user interaction has happened.
  37982. */
  37983. unlocked: boolean;
  37984. /**
  37985. * Defines if the audio engine relies on a custom unlocked button.
  37986. * In this case, the embedded button will not be displayed.
  37987. */
  37988. useCustomUnlockedButton: boolean;
  37989. /**
  37990. * Event raised when audio has been unlocked on the browser.
  37991. */
  37992. onAudioUnlockedObservable: Observable<AudioEngine>;
  37993. /**
  37994. * Event raised when audio has been locked on the browser.
  37995. */
  37996. onAudioLockedObservable: Observable<AudioEngine>;
  37997. /**
  37998. * Gets the current AudioContext if available.
  37999. */
  38000. get audioContext(): Nullable<AudioContext>;
  38001. private _connectedAnalyser;
  38002. /**
  38003. * Instantiates a new audio engine.
  38004. *
  38005. * There should be only one per page as some browsers restrict the number
  38006. * of audio contexts you can create.
  38007. * @param hostElement defines the host element where to display the mute icon if necessary
  38008. */
  38009. constructor(hostElement?: Nullable<HTMLElement>);
  38010. /**
  38011. * Flags the audio engine in Locked state.
  38012. * This happens due to new browser policies preventing audio to autoplay.
  38013. */
  38014. lock(): void;
  38015. /**
  38016. * Unlocks the audio engine once a user action has been done on the dom.
  38017. * This is helpful to resume play once browser policies have been satisfied.
  38018. */
  38019. unlock(): void;
  38020. private _resumeAudioContext;
  38021. private _initializeAudioContext;
  38022. private _tryToRun;
  38023. private _triggerRunningState;
  38024. private _triggerSuspendedState;
  38025. private _displayMuteButton;
  38026. private _moveButtonToTopLeft;
  38027. private _onResize;
  38028. private _hideMuteButton;
  38029. /**
  38030. * Destroy and release the resources associated with the audio ccontext.
  38031. */
  38032. dispose(): void;
  38033. /**
  38034. * Gets the global volume sets on the master gain.
  38035. * @returns the global volume if set or -1 otherwise
  38036. */
  38037. getGlobalVolume(): number;
  38038. /**
  38039. * Sets the global volume of your experience (sets on the master gain).
  38040. * @param newVolume Defines the new global volume of the application
  38041. */
  38042. setGlobalVolume(newVolume: number): void;
  38043. /**
  38044. * Connect the audio engine to an audio analyser allowing some amazing
  38045. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38046. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38047. * @param analyser The analyser to connect to the engine
  38048. */
  38049. connectToAnalyser(analyser: Analyser): void;
  38050. }
  38051. }
  38052. declare module "babylonjs/Loading/loadingScreen" {
  38053. /**
  38054. * Interface used to present a loading screen while loading a scene
  38055. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38056. */
  38057. export interface ILoadingScreen {
  38058. /**
  38059. * Function called to display the loading screen
  38060. */
  38061. displayLoadingUI: () => void;
  38062. /**
  38063. * Function called to hide the loading screen
  38064. */
  38065. hideLoadingUI: () => void;
  38066. /**
  38067. * Gets or sets the color to use for the background
  38068. */
  38069. loadingUIBackgroundColor: string;
  38070. /**
  38071. * Gets or sets the text to display while loading
  38072. */
  38073. loadingUIText: string;
  38074. }
  38075. /**
  38076. * Class used for the default loading screen
  38077. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38078. */
  38079. export class DefaultLoadingScreen implements ILoadingScreen {
  38080. private _renderingCanvas;
  38081. private _loadingText;
  38082. private _loadingDivBackgroundColor;
  38083. private _loadingDiv;
  38084. private _loadingTextDiv;
  38085. /** Gets or sets the logo url to use for the default loading screen */
  38086. static DefaultLogoUrl: string;
  38087. /** Gets or sets the spinner url to use for the default loading screen */
  38088. static DefaultSpinnerUrl: string;
  38089. /**
  38090. * Creates a new default loading screen
  38091. * @param _renderingCanvas defines the canvas used to render the scene
  38092. * @param _loadingText defines the default text to display
  38093. * @param _loadingDivBackgroundColor defines the default background color
  38094. */
  38095. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38096. /**
  38097. * Function called to display the loading screen
  38098. */
  38099. displayLoadingUI(): void;
  38100. /**
  38101. * Function called to hide the loading screen
  38102. */
  38103. hideLoadingUI(): void;
  38104. /**
  38105. * Gets or sets the text to display while loading
  38106. */
  38107. set loadingUIText(text: string);
  38108. get loadingUIText(): string;
  38109. /**
  38110. * Gets or sets the color to use for the background
  38111. */
  38112. get loadingUIBackgroundColor(): string;
  38113. set loadingUIBackgroundColor(color: string);
  38114. private _resizeLoadingUI;
  38115. }
  38116. }
  38117. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38118. /**
  38119. * Interface for any object that can request an animation frame
  38120. */
  38121. export interface ICustomAnimationFrameRequester {
  38122. /**
  38123. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38124. */
  38125. renderFunction?: Function;
  38126. /**
  38127. * Called to request the next frame to render to
  38128. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38129. */
  38130. requestAnimationFrame: Function;
  38131. /**
  38132. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38133. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38134. */
  38135. requestID?: number;
  38136. }
  38137. }
  38138. declare module "babylonjs/Misc/performanceMonitor" {
  38139. /**
  38140. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38141. */
  38142. export class PerformanceMonitor {
  38143. private _enabled;
  38144. private _rollingFrameTime;
  38145. private _lastFrameTimeMs;
  38146. /**
  38147. * constructor
  38148. * @param frameSampleSize The number of samples required to saturate the sliding window
  38149. */
  38150. constructor(frameSampleSize?: number);
  38151. /**
  38152. * Samples current frame
  38153. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38154. */
  38155. sampleFrame(timeMs?: number): void;
  38156. /**
  38157. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38158. */
  38159. get averageFrameTime(): number;
  38160. /**
  38161. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38162. */
  38163. get averageFrameTimeVariance(): number;
  38164. /**
  38165. * Returns the frame time of the most recent frame
  38166. */
  38167. get instantaneousFrameTime(): number;
  38168. /**
  38169. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38170. */
  38171. get averageFPS(): number;
  38172. /**
  38173. * Returns the average framerate in frames per second using the most recent frame time
  38174. */
  38175. get instantaneousFPS(): number;
  38176. /**
  38177. * Returns true if enough samples have been taken to completely fill the sliding window
  38178. */
  38179. get isSaturated(): boolean;
  38180. /**
  38181. * Enables contributions to the sliding window sample set
  38182. */
  38183. enable(): void;
  38184. /**
  38185. * Disables contributions to the sliding window sample set
  38186. * Samples will not be interpolated over the disabled period
  38187. */
  38188. disable(): void;
  38189. /**
  38190. * Returns true if sampling is enabled
  38191. */
  38192. get isEnabled(): boolean;
  38193. /**
  38194. * Resets performance monitor
  38195. */
  38196. reset(): void;
  38197. }
  38198. /**
  38199. * RollingAverage
  38200. *
  38201. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38202. */
  38203. export class RollingAverage {
  38204. /**
  38205. * Current average
  38206. */
  38207. average: number;
  38208. /**
  38209. * Current variance
  38210. */
  38211. variance: number;
  38212. protected _samples: Array<number>;
  38213. protected _sampleCount: number;
  38214. protected _pos: number;
  38215. protected _m2: number;
  38216. /**
  38217. * constructor
  38218. * @param length The number of samples required to saturate the sliding window
  38219. */
  38220. constructor(length: number);
  38221. /**
  38222. * Adds a sample to the sample set
  38223. * @param v The sample value
  38224. */
  38225. add(v: number): void;
  38226. /**
  38227. * Returns previously added values or null if outside of history or outside the sliding window domain
  38228. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38229. * @return Value previously recorded with add() or null if outside of range
  38230. */
  38231. history(i: number): number;
  38232. /**
  38233. * Returns true if enough samples have been taken to completely fill the sliding window
  38234. * @return true if sample-set saturated
  38235. */
  38236. isSaturated(): boolean;
  38237. /**
  38238. * Resets the rolling average (equivalent to 0 samples taken so far)
  38239. */
  38240. reset(): void;
  38241. /**
  38242. * Wraps a value around the sample range boundaries
  38243. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38244. * @return Wrapped position in sample range
  38245. */
  38246. protected _wrapPosition(i: number): number;
  38247. }
  38248. }
  38249. declare module "babylonjs/Misc/perfCounter" {
  38250. /**
  38251. * This class is used to track a performance counter which is number based.
  38252. * The user has access to many properties which give statistics of different nature.
  38253. *
  38254. * The implementer can track two kinds of Performance Counter: time and count.
  38255. * 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.
  38256. * 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.
  38257. */
  38258. export class PerfCounter {
  38259. /**
  38260. * Gets or sets a global boolean to turn on and off all the counters
  38261. */
  38262. static Enabled: boolean;
  38263. /**
  38264. * Returns the smallest value ever
  38265. */
  38266. get min(): number;
  38267. /**
  38268. * Returns the biggest value ever
  38269. */
  38270. get max(): number;
  38271. /**
  38272. * Returns the average value since the performance counter is running
  38273. */
  38274. get average(): number;
  38275. /**
  38276. * Returns the average value of the last second the counter was monitored
  38277. */
  38278. get lastSecAverage(): number;
  38279. /**
  38280. * Returns the current value
  38281. */
  38282. get current(): number;
  38283. /**
  38284. * Gets the accumulated total
  38285. */
  38286. get total(): number;
  38287. /**
  38288. * Gets the total value count
  38289. */
  38290. get count(): number;
  38291. /**
  38292. * Creates a new counter
  38293. */
  38294. constructor();
  38295. /**
  38296. * Call this method to start monitoring a new frame.
  38297. * 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.
  38298. */
  38299. fetchNewFrame(): void;
  38300. /**
  38301. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38302. * @param newCount the count value to add to the monitored count
  38303. * @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.
  38304. */
  38305. addCount(newCount: number, fetchResult: boolean): void;
  38306. /**
  38307. * Start monitoring this performance counter
  38308. */
  38309. beginMonitoring(): void;
  38310. /**
  38311. * Compute the time lapsed since the previous beginMonitoring() call.
  38312. * @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
  38313. */
  38314. endMonitoring(newFrame?: boolean): void;
  38315. private _fetchResult;
  38316. private _startMonitoringTime;
  38317. private _min;
  38318. private _max;
  38319. private _average;
  38320. private _current;
  38321. private _totalValueCount;
  38322. private _totalAccumulated;
  38323. private _lastSecAverage;
  38324. private _lastSecAccumulated;
  38325. private _lastSecTime;
  38326. private _lastSecValueCount;
  38327. }
  38328. }
  38329. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  38330. module "babylonjs/Engines/thinEngine" {
  38331. interface ThinEngine {
  38332. /**
  38333. * Sets alpha constants used by some alpha blending modes
  38334. * @param r defines the red component
  38335. * @param g defines the green component
  38336. * @param b defines the blue component
  38337. * @param a defines the alpha component
  38338. */
  38339. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  38340. /**
  38341. * Sets the current alpha mode
  38342. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  38343. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  38344. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  38345. */
  38346. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  38347. /**
  38348. * Gets the current alpha mode
  38349. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  38350. * @returns the current alpha mode
  38351. */
  38352. getAlphaMode(): number;
  38353. /**
  38354. * Sets the current alpha equation
  38355. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  38356. */
  38357. setAlphaEquation(equation: number): void;
  38358. /**
  38359. * Gets the current alpha equation.
  38360. * @returns the current alpha equation
  38361. */
  38362. getAlphaEquation(): number;
  38363. }
  38364. }
  38365. }
  38366. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38367. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38368. import { Nullable } from "babylonjs/types";
  38369. module "babylonjs/Engines/thinEngine" {
  38370. interface ThinEngine {
  38371. /** @hidden */
  38372. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38373. }
  38374. }
  38375. }
  38376. declare module "babylonjs/Engines/engine" {
  38377. import { Observable } from "babylonjs/Misc/observable";
  38378. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  38379. import { Scene } from "babylonjs/scene";
  38380. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38381. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38382. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38383. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38384. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38385. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38386. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38387. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38388. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38389. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38390. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38391. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38392. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38393. import "babylonjs/Engines/Extensions/engine.alpha";
  38394. import "babylonjs/Engines/Extensions/engine.readTexture";
  38395. import { Material } from "babylonjs/Materials/material";
  38396. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38397. /**
  38398. * Defines the interface used by display changed events
  38399. */
  38400. export interface IDisplayChangedEventArgs {
  38401. /** Gets the vrDisplay object (if any) */
  38402. vrDisplay: Nullable<any>;
  38403. /** Gets a boolean indicating if webVR is supported */
  38404. vrSupported: boolean;
  38405. }
  38406. /**
  38407. * Defines the interface used by objects containing a viewport (like a camera)
  38408. */
  38409. interface IViewportOwnerLike {
  38410. /**
  38411. * Gets or sets the viewport
  38412. */
  38413. viewport: IViewportLike;
  38414. }
  38415. /**
  38416. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38417. */
  38418. export class Engine extends ThinEngine {
  38419. /** Defines that alpha blending is disabled */
  38420. static readonly ALPHA_DISABLE: number;
  38421. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38422. static readonly ALPHA_ADD: number;
  38423. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38424. static readonly ALPHA_COMBINE: number;
  38425. /** Defines that alpha blending to DEST - SRC * DEST */
  38426. static readonly ALPHA_SUBTRACT: number;
  38427. /** Defines that alpha blending to SRC * DEST */
  38428. static readonly ALPHA_MULTIPLY: number;
  38429. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38430. static readonly ALPHA_MAXIMIZED: number;
  38431. /** Defines that alpha blending to SRC + DEST */
  38432. static readonly ALPHA_ONEONE: number;
  38433. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38434. static readonly ALPHA_PREMULTIPLIED: number;
  38435. /**
  38436. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38437. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38438. */
  38439. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38440. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38441. static readonly ALPHA_INTERPOLATE: number;
  38442. /**
  38443. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38444. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38445. */
  38446. static readonly ALPHA_SCREENMODE: number;
  38447. /** Defines that the ressource is not delayed*/
  38448. static readonly DELAYLOADSTATE_NONE: number;
  38449. /** Defines that the ressource was successfully delay loaded */
  38450. static readonly DELAYLOADSTATE_LOADED: number;
  38451. /** Defines that the ressource is currently delay loading */
  38452. static readonly DELAYLOADSTATE_LOADING: number;
  38453. /** Defines that the ressource is delayed and has not started loading */
  38454. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38455. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38456. static readonly NEVER: number;
  38457. /** 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 */
  38458. static readonly ALWAYS: number;
  38459. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38460. static readonly LESS: number;
  38461. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38462. static readonly EQUAL: number;
  38463. /** 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 */
  38464. static readonly LEQUAL: number;
  38465. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38466. static readonly GREATER: number;
  38467. /** 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 */
  38468. static readonly GEQUAL: number;
  38469. /** 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 */
  38470. static readonly NOTEQUAL: number;
  38471. /** Passed to stencilOperation to specify that stencil value must be kept */
  38472. static readonly KEEP: number;
  38473. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38474. static readonly REPLACE: number;
  38475. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38476. static readonly INCR: number;
  38477. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38478. static readonly DECR: number;
  38479. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38480. static readonly INVERT: number;
  38481. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38482. static readonly INCR_WRAP: number;
  38483. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38484. static readonly DECR_WRAP: number;
  38485. /** Texture is not repeating outside of 0..1 UVs */
  38486. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38487. /** Texture is repeating outside of 0..1 UVs */
  38488. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38489. /** Texture is repeating and mirrored */
  38490. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38491. /** ALPHA */
  38492. static readonly TEXTUREFORMAT_ALPHA: number;
  38493. /** LUMINANCE */
  38494. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38495. /** LUMINANCE_ALPHA */
  38496. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38497. /** RGB */
  38498. static readonly TEXTUREFORMAT_RGB: number;
  38499. /** RGBA */
  38500. static readonly TEXTUREFORMAT_RGBA: number;
  38501. /** RED */
  38502. static readonly TEXTUREFORMAT_RED: number;
  38503. /** RED (2nd reference) */
  38504. static readonly TEXTUREFORMAT_R: number;
  38505. /** RG */
  38506. static readonly TEXTUREFORMAT_RG: number;
  38507. /** RED_INTEGER */
  38508. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38509. /** RED_INTEGER (2nd reference) */
  38510. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38511. /** RG_INTEGER */
  38512. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38513. /** RGB_INTEGER */
  38514. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38515. /** RGBA_INTEGER */
  38516. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38517. /** UNSIGNED_BYTE */
  38518. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38519. /** UNSIGNED_BYTE (2nd reference) */
  38520. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38521. /** FLOAT */
  38522. static readonly TEXTURETYPE_FLOAT: number;
  38523. /** HALF_FLOAT */
  38524. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38525. /** BYTE */
  38526. static readonly TEXTURETYPE_BYTE: number;
  38527. /** SHORT */
  38528. static readonly TEXTURETYPE_SHORT: number;
  38529. /** UNSIGNED_SHORT */
  38530. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38531. /** INT */
  38532. static readonly TEXTURETYPE_INT: number;
  38533. /** UNSIGNED_INT */
  38534. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38535. /** UNSIGNED_SHORT_4_4_4_4 */
  38536. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38537. /** UNSIGNED_SHORT_5_5_5_1 */
  38538. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38539. /** UNSIGNED_SHORT_5_6_5 */
  38540. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38541. /** UNSIGNED_INT_2_10_10_10_REV */
  38542. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38543. /** UNSIGNED_INT_24_8 */
  38544. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38545. /** UNSIGNED_INT_10F_11F_11F_REV */
  38546. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38547. /** UNSIGNED_INT_5_9_9_9_REV */
  38548. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38549. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38550. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38551. /** nearest is mag = nearest and min = nearest and mip = linear */
  38552. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38553. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38554. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38555. /** Trilinear is mag = linear and min = linear and mip = linear */
  38556. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38557. /** nearest is mag = nearest and min = nearest and mip = linear */
  38558. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38559. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38560. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38561. /** Trilinear is mag = linear and min = linear and mip = linear */
  38562. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38563. /** mag = nearest and min = nearest and mip = nearest */
  38564. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38565. /** mag = nearest and min = linear and mip = nearest */
  38566. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38567. /** mag = nearest and min = linear and mip = linear */
  38568. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38569. /** mag = nearest and min = linear and mip = none */
  38570. static readonly TEXTURE_NEAREST_LINEAR: number;
  38571. /** mag = nearest and min = nearest and mip = none */
  38572. static readonly TEXTURE_NEAREST_NEAREST: number;
  38573. /** mag = linear and min = nearest and mip = nearest */
  38574. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38575. /** mag = linear and min = nearest and mip = linear */
  38576. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38577. /** mag = linear and min = linear and mip = none */
  38578. static readonly TEXTURE_LINEAR_LINEAR: number;
  38579. /** mag = linear and min = nearest and mip = none */
  38580. static readonly TEXTURE_LINEAR_NEAREST: number;
  38581. /** Explicit coordinates mode */
  38582. static readonly TEXTURE_EXPLICIT_MODE: number;
  38583. /** Spherical coordinates mode */
  38584. static readonly TEXTURE_SPHERICAL_MODE: number;
  38585. /** Planar coordinates mode */
  38586. static readonly TEXTURE_PLANAR_MODE: number;
  38587. /** Cubic coordinates mode */
  38588. static readonly TEXTURE_CUBIC_MODE: number;
  38589. /** Projection coordinates mode */
  38590. static readonly TEXTURE_PROJECTION_MODE: number;
  38591. /** Skybox coordinates mode */
  38592. static readonly TEXTURE_SKYBOX_MODE: number;
  38593. /** Inverse Cubic coordinates mode */
  38594. static readonly TEXTURE_INVCUBIC_MODE: number;
  38595. /** Equirectangular coordinates mode */
  38596. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38597. /** Equirectangular Fixed coordinates mode */
  38598. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38599. /** Equirectangular Fixed Mirrored coordinates mode */
  38600. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38601. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38602. static readonly SCALEMODE_FLOOR: number;
  38603. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38604. static readonly SCALEMODE_NEAREST: number;
  38605. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38606. static readonly SCALEMODE_CEILING: number;
  38607. /**
  38608. * Returns the current npm package of the sdk
  38609. */
  38610. static get NpmPackage(): string;
  38611. /**
  38612. * Returns the current version of the framework
  38613. */
  38614. static get Version(): string;
  38615. /** Gets the list of created engines */
  38616. static get Instances(): Engine[];
  38617. /**
  38618. * Gets the latest created engine
  38619. */
  38620. static get LastCreatedEngine(): Nullable<Engine>;
  38621. /**
  38622. * Gets the latest created scene
  38623. */
  38624. static get LastCreatedScene(): Nullable<Scene>;
  38625. /**
  38626. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38627. * @param flag defines which part of the materials must be marked as dirty
  38628. * @param predicate defines a predicate used to filter which materials should be affected
  38629. */
  38630. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38631. /**
  38632. * Method called to create the default loading screen.
  38633. * This can be overriden in your own app.
  38634. * @param canvas The rendering canvas element
  38635. * @returns The loading screen
  38636. */
  38637. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38638. /**
  38639. * Method called to create the default rescale post process on each engine.
  38640. */
  38641. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38642. /**
  38643. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38644. **/
  38645. enableOfflineSupport: boolean;
  38646. /**
  38647. * 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)
  38648. **/
  38649. disableManifestCheck: boolean;
  38650. /**
  38651. * Gets the list of created scenes
  38652. */
  38653. scenes: Scene[];
  38654. /**
  38655. * Event raised when a new scene is created
  38656. */
  38657. onNewSceneAddedObservable: Observable<Scene>;
  38658. /**
  38659. * Gets the list of created postprocesses
  38660. */
  38661. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38662. /**
  38663. * Gets a boolean indicating if the pointer is currently locked
  38664. */
  38665. isPointerLock: boolean;
  38666. /**
  38667. * Observable event triggered each time the rendering canvas is resized
  38668. */
  38669. onResizeObservable: Observable<Engine>;
  38670. /**
  38671. * Observable event triggered each time the canvas loses focus
  38672. */
  38673. onCanvasBlurObservable: Observable<Engine>;
  38674. /**
  38675. * Observable event triggered each time the canvas gains focus
  38676. */
  38677. onCanvasFocusObservable: Observable<Engine>;
  38678. /**
  38679. * Observable event triggered each time the canvas receives pointerout event
  38680. */
  38681. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38682. /**
  38683. * Observable raised when the engine begins a new frame
  38684. */
  38685. onBeginFrameObservable: Observable<Engine>;
  38686. /**
  38687. * If set, will be used to request the next animation frame for the render loop
  38688. */
  38689. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  38690. /**
  38691. * Observable raised when the engine ends the current frame
  38692. */
  38693. onEndFrameObservable: Observable<Engine>;
  38694. /**
  38695. * Observable raised when the engine is about to compile a shader
  38696. */
  38697. onBeforeShaderCompilationObservable: Observable<Engine>;
  38698. /**
  38699. * Observable raised when the engine has jsut compiled a shader
  38700. */
  38701. onAfterShaderCompilationObservable: Observable<Engine>;
  38702. /**
  38703. * Gets the audio engine
  38704. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38705. * @ignorenaming
  38706. */
  38707. static audioEngine: IAudioEngine;
  38708. /**
  38709. * Default AudioEngine factory responsible of creating the Audio Engine.
  38710. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  38711. */
  38712. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  38713. /**
  38714. * Default offline support factory responsible of creating a tool used to store data locally.
  38715. * By default, this will create a Database object if the workload has been embedded.
  38716. */
  38717. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  38718. private _loadingScreen;
  38719. private _pointerLockRequested;
  38720. private _rescalePostProcess;
  38721. private _deterministicLockstep;
  38722. private _lockstepMaxSteps;
  38723. private _timeStep;
  38724. protected get _supportsHardwareTextureRescaling(): boolean;
  38725. private _fps;
  38726. private _deltaTime;
  38727. /** @hidden */
  38728. _drawCalls: PerfCounter;
  38729. /** 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 */
  38730. canvasTabIndex: number;
  38731. /**
  38732. * Turn this value on if you want to pause FPS computation when in background
  38733. */
  38734. disablePerformanceMonitorInBackground: boolean;
  38735. private _performanceMonitor;
  38736. /**
  38737. * Gets the performance monitor attached to this engine
  38738. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  38739. */
  38740. get performanceMonitor(): PerformanceMonitor;
  38741. private _onFocus;
  38742. private _onBlur;
  38743. private _onCanvasPointerOut;
  38744. private _onCanvasBlur;
  38745. private _onCanvasFocus;
  38746. private _onFullscreenChange;
  38747. private _onPointerLockChange;
  38748. /**
  38749. * Gets the HTML element used to attach event listeners
  38750. * @returns a HTML element
  38751. */
  38752. getInputElement(): Nullable<HTMLElement>;
  38753. /**
  38754. * Creates a new engine
  38755. * @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
  38756. * @param antialias defines enable antialiasing (default: false)
  38757. * @param options defines further options to be sent to the getContext() function
  38758. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38759. */
  38760. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38761. /**
  38762. * Gets current aspect ratio
  38763. * @param viewportOwner defines the camera to use to get the aspect ratio
  38764. * @param useScreen defines if screen size must be used (or the current render target if any)
  38765. * @returns a number defining the aspect ratio
  38766. */
  38767. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  38768. /**
  38769. * Gets current screen aspect ratio
  38770. * @returns a number defining the aspect ratio
  38771. */
  38772. getScreenAspectRatio(): number;
  38773. /**
  38774. * Gets the client rect of the HTML canvas attached with the current webGL context
  38775. * @returns a client rectanglee
  38776. */
  38777. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  38778. /**
  38779. * Gets the client rect of the HTML element used for events
  38780. * @returns a client rectanglee
  38781. */
  38782. getInputElementClientRect(): Nullable<ClientRect>;
  38783. /**
  38784. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  38785. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38786. * @returns true if engine is in deterministic lock step mode
  38787. */
  38788. isDeterministicLockStep(): boolean;
  38789. /**
  38790. * Gets the max steps when engine is running in deterministic lock step
  38791. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38792. * @returns the max steps
  38793. */
  38794. getLockstepMaxSteps(): number;
  38795. /**
  38796. * Returns the time in ms between steps when using deterministic lock step.
  38797. * @returns time step in (ms)
  38798. */
  38799. getTimeStep(): number;
  38800. /**
  38801. * Force the mipmap generation for the given render target texture
  38802. * @param texture defines the render target texture to use
  38803. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  38804. */
  38805. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  38806. /** States */
  38807. /**
  38808. * Set various states to the webGL context
  38809. * @param culling defines backface culling state
  38810. * @param zOffset defines the value to apply to zOffset (0 by default)
  38811. * @param force defines if states must be applied even if cache is up to date
  38812. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  38813. */
  38814. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  38815. /**
  38816. * Set the z offset to apply to current rendering
  38817. * @param value defines the offset to apply
  38818. */
  38819. setZOffset(value: number): void;
  38820. /**
  38821. * Gets the current value of the zOffset
  38822. * @returns the current zOffset state
  38823. */
  38824. getZOffset(): number;
  38825. /**
  38826. * Enable or disable depth buffering
  38827. * @param enable defines the state to set
  38828. */
  38829. setDepthBuffer(enable: boolean): void;
  38830. /**
  38831. * Gets a boolean indicating if depth writing is enabled
  38832. * @returns the current depth writing state
  38833. */
  38834. getDepthWrite(): boolean;
  38835. /**
  38836. * Enable or disable depth writing
  38837. * @param enable defines the state to set
  38838. */
  38839. setDepthWrite(enable: boolean): void;
  38840. /**
  38841. * Gets a boolean indicating if stencil buffer is enabled
  38842. * @returns the current stencil buffer state
  38843. */
  38844. getStencilBuffer(): boolean;
  38845. /**
  38846. * Enable or disable the stencil buffer
  38847. * @param enable defines if the stencil buffer must be enabled or disabled
  38848. */
  38849. setStencilBuffer(enable: boolean): void;
  38850. /**
  38851. * Gets the current stencil mask
  38852. * @returns a number defining the new stencil mask to use
  38853. */
  38854. getStencilMask(): number;
  38855. /**
  38856. * Sets the current stencil mask
  38857. * @param mask defines the new stencil mask to use
  38858. */
  38859. setStencilMask(mask: number): void;
  38860. /**
  38861. * Gets the current stencil function
  38862. * @returns a number defining the stencil function to use
  38863. */
  38864. getStencilFunction(): number;
  38865. /**
  38866. * Gets the current stencil reference value
  38867. * @returns a number defining the stencil reference value to use
  38868. */
  38869. getStencilFunctionReference(): number;
  38870. /**
  38871. * Gets the current stencil mask
  38872. * @returns a number defining the stencil mask to use
  38873. */
  38874. getStencilFunctionMask(): number;
  38875. /**
  38876. * Sets the current stencil function
  38877. * @param stencilFunc defines the new stencil function to use
  38878. */
  38879. setStencilFunction(stencilFunc: number): void;
  38880. /**
  38881. * Sets the current stencil reference
  38882. * @param reference defines the new stencil reference to use
  38883. */
  38884. setStencilFunctionReference(reference: number): void;
  38885. /**
  38886. * Sets the current stencil mask
  38887. * @param mask defines the new stencil mask to use
  38888. */
  38889. setStencilFunctionMask(mask: number): void;
  38890. /**
  38891. * Gets the current stencil operation when stencil fails
  38892. * @returns a number defining stencil operation to use when stencil fails
  38893. */
  38894. getStencilOperationFail(): number;
  38895. /**
  38896. * Gets the current stencil operation when depth fails
  38897. * @returns a number defining stencil operation to use when depth fails
  38898. */
  38899. getStencilOperationDepthFail(): number;
  38900. /**
  38901. * Gets the current stencil operation when stencil passes
  38902. * @returns a number defining stencil operation to use when stencil passes
  38903. */
  38904. getStencilOperationPass(): number;
  38905. /**
  38906. * Sets the stencil operation to use when stencil fails
  38907. * @param operation defines the stencil operation to use when stencil fails
  38908. */
  38909. setStencilOperationFail(operation: number): void;
  38910. /**
  38911. * Sets the stencil operation to use when depth fails
  38912. * @param operation defines the stencil operation to use when depth fails
  38913. */
  38914. setStencilOperationDepthFail(operation: number): void;
  38915. /**
  38916. * Sets the stencil operation to use when stencil passes
  38917. * @param operation defines the stencil operation to use when stencil passes
  38918. */
  38919. setStencilOperationPass(operation: number): void;
  38920. /**
  38921. * Sets a boolean indicating if the dithering state is enabled or disabled
  38922. * @param value defines the dithering state
  38923. */
  38924. setDitheringState(value: boolean): void;
  38925. /**
  38926. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  38927. * @param value defines the rasterizer state
  38928. */
  38929. setRasterizerState(value: boolean): void;
  38930. /**
  38931. * Gets the current depth function
  38932. * @returns a number defining the depth function
  38933. */
  38934. getDepthFunction(): Nullable<number>;
  38935. /**
  38936. * Sets the current depth function
  38937. * @param depthFunc defines the function to use
  38938. */
  38939. setDepthFunction(depthFunc: number): void;
  38940. /**
  38941. * Sets the current depth function to GREATER
  38942. */
  38943. setDepthFunctionToGreater(): void;
  38944. /**
  38945. * Sets the current depth function to GEQUAL
  38946. */
  38947. setDepthFunctionToGreaterOrEqual(): void;
  38948. /**
  38949. * Sets the current depth function to LESS
  38950. */
  38951. setDepthFunctionToLess(): void;
  38952. /**
  38953. * Sets the current depth function to LEQUAL
  38954. */
  38955. setDepthFunctionToLessOrEqual(): void;
  38956. private _cachedStencilBuffer;
  38957. private _cachedStencilFunction;
  38958. private _cachedStencilMask;
  38959. private _cachedStencilOperationPass;
  38960. private _cachedStencilOperationFail;
  38961. private _cachedStencilOperationDepthFail;
  38962. private _cachedStencilReference;
  38963. /**
  38964. * Caches the the state of the stencil buffer
  38965. */
  38966. cacheStencilState(): void;
  38967. /**
  38968. * Restores the state of the stencil buffer
  38969. */
  38970. restoreStencilState(): void;
  38971. /**
  38972. * Directly set the WebGL Viewport
  38973. * @param x defines the x coordinate of the viewport (in screen space)
  38974. * @param y defines the y coordinate of the viewport (in screen space)
  38975. * @param width defines the width of the viewport (in screen space)
  38976. * @param height defines the height of the viewport (in screen space)
  38977. * @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
  38978. */
  38979. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38980. /**
  38981. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38982. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38983. * @param y defines the y-coordinate of the corner of the clear rectangle
  38984. * @param width defines the width of the clear rectangle
  38985. * @param height defines the height of the clear rectangle
  38986. * @param clearColor defines the clear color
  38987. */
  38988. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38989. /**
  38990. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38991. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38992. * @param y defines the y-coordinate of the corner of the clear rectangle
  38993. * @param width defines the width of the clear rectangle
  38994. * @param height defines the height of the clear rectangle
  38995. */
  38996. enableScissor(x: number, y: number, width: number, height: number): void;
  38997. /**
  38998. * Disable previously set scissor test rectangle
  38999. */
  39000. disableScissor(): void;
  39001. protected _reportDrawCall(): void;
  39002. /**
  39003. * Initializes a webVR display and starts listening to display change events
  39004. * The onVRDisplayChangedObservable will be notified upon these changes
  39005. * @returns The onVRDisplayChangedObservable
  39006. */
  39007. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39008. /** @hidden */
  39009. _prepareVRComponent(): void;
  39010. /** @hidden */
  39011. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39012. /** @hidden */
  39013. _submitVRFrame(): void;
  39014. /**
  39015. * Call this function to leave webVR mode
  39016. * Will do nothing if webVR is not supported or if there is no webVR device
  39017. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39018. */
  39019. disableVR(): void;
  39020. /**
  39021. * Gets a boolean indicating that the system is in VR mode and is presenting
  39022. * @returns true if VR mode is engaged
  39023. */
  39024. isVRPresenting(): boolean;
  39025. /** @hidden */
  39026. _requestVRFrame(): void;
  39027. /** @hidden */
  39028. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39029. /**
  39030. * Gets the source code of the vertex shader associated with a specific webGL program
  39031. * @param program defines the program to use
  39032. * @returns a string containing the source code of the vertex shader associated with the program
  39033. */
  39034. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39035. /**
  39036. * Gets the source code of the fragment shader associated with a specific webGL program
  39037. * @param program defines the program to use
  39038. * @returns a string containing the source code of the fragment shader associated with the program
  39039. */
  39040. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39041. /**
  39042. * Sets a depth stencil texture from a render target to the according uniform.
  39043. * @param channel The texture channel
  39044. * @param uniform The uniform to set
  39045. * @param texture The render target texture containing the depth stencil texture to apply
  39046. */
  39047. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39048. /**
  39049. * Sets a texture to the webGL context from a postprocess
  39050. * @param channel defines the channel to use
  39051. * @param postProcess defines the source postprocess
  39052. */
  39053. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39054. /**
  39055. * Binds the output of the passed in post process to the texture channel specified
  39056. * @param channel The channel the texture should be bound to
  39057. * @param postProcess The post process which's output should be bound
  39058. */
  39059. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39060. protected _rebuildBuffers(): void;
  39061. /** @hidden */
  39062. _renderFrame(): void;
  39063. _renderLoop(): void;
  39064. /** @hidden */
  39065. _renderViews(): boolean;
  39066. /**
  39067. * Toggle full screen mode
  39068. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39069. */
  39070. switchFullscreen(requestPointerLock: boolean): void;
  39071. /**
  39072. * Enters full screen mode
  39073. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39074. */
  39075. enterFullscreen(requestPointerLock: boolean): void;
  39076. /**
  39077. * Exits full screen mode
  39078. */
  39079. exitFullscreen(): void;
  39080. /**
  39081. * Enters Pointerlock mode
  39082. */
  39083. enterPointerlock(): void;
  39084. /**
  39085. * Exits Pointerlock mode
  39086. */
  39087. exitPointerlock(): void;
  39088. /**
  39089. * Begin a new frame
  39090. */
  39091. beginFrame(): void;
  39092. /**
  39093. * Enf the current frame
  39094. */
  39095. endFrame(): void;
  39096. resize(): void;
  39097. /**
  39098. * Force a specific size of the canvas
  39099. * @param width defines the new canvas' width
  39100. * @param height defines the new canvas' height
  39101. * @returns true if the size was changed
  39102. */
  39103. setSize(width: number, height: number): boolean;
  39104. /**
  39105. * Updates a dynamic vertex buffer.
  39106. * @param vertexBuffer the vertex buffer to update
  39107. * @param data the data used to update the vertex buffer
  39108. * @param byteOffset the byte offset of the data
  39109. * @param byteLength the byte length of the data
  39110. */
  39111. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  39112. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39113. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39114. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39115. _releaseTexture(texture: InternalTexture): void;
  39116. /**
  39117. * @hidden
  39118. * Rescales a texture
  39119. * @param source input texutre
  39120. * @param destination destination texture
  39121. * @param scene scene to use to render the resize
  39122. * @param internalFormat format to use when resizing
  39123. * @param onComplete callback to be called when resize has completed
  39124. */
  39125. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39126. /**
  39127. * Gets the current framerate
  39128. * @returns a number representing the framerate
  39129. */
  39130. getFps(): number;
  39131. /**
  39132. * Gets the time spent between current and previous frame
  39133. * @returns a number representing the delta time in ms
  39134. */
  39135. getDeltaTime(): number;
  39136. private _measureFps;
  39137. /** @hidden */
  39138. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39139. /**
  39140. * Update a dynamic index buffer
  39141. * @param indexBuffer defines the target index buffer
  39142. * @param indices defines the data to update
  39143. * @param offset defines the offset in the target index buffer where update should start
  39144. */
  39145. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  39146. /**
  39147. * Updates the sample count of a render target texture
  39148. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39149. * @param texture defines the texture to update
  39150. * @param samples defines the sample count to set
  39151. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39152. */
  39153. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39154. /**
  39155. * Updates a depth texture Comparison Mode and Function.
  39156. * If the comparison Function is equal to 0, the mode will be set to none.
  39157. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39158. * @param texture The texture to set the comparison function for
  39159. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39160. */
  39161. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39162. /**
  39163. * Creates a webGL buffer to use with instanciation
  39164. * @param capacity defines the size of the buffer
  39165. * @returns the webGL buffer
  39166. */
  39167. createInstancesBuffer(capacity: number): DataBuffer;
  39168. /**
  39169. * Delete a webGL buffer used with instanciation
  39170. * @param buffer defines the webGL buffer to delete
  39171. */
  39172. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39173. private _clientWaitAsync;
  39174. /** @hidden */
  39175. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39176. dispose(): void;
  39177. private _disableTouchAction;
  39178. /**
  39179. * Display the loading screen
  39180. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39181. */
  39182. displayLoadingUI(): void;
  39183. /**
  39184. * Hide the loading screen
  39185. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39186. */
  39187. hideLoadingUI(): void;
  39188. /**
  39189. * Gets the current loading screen object
  39190. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39191. */
  39192. get loadingScreen(): ILoadingScreen;
  39193. /**
  39194. * Sets the current loading screen object
  39195. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39196. */
  39197. set loadingScreen(loadingScreen: ILoadingScreen);
  39198. /**
  39199. * Sets the current loading screen text
  39200. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39201. */
  39202. set loadingUIText(text: string);
  39203. /**
  39204. * Sets the current loading screen background color
  39205. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39206. */
  39207. set loadingUIBackgroundColor(color: string);
  39208. /** Pointerlock and fullscreen */
  39209. /**
  39210. * Ask the browser to promote the current element to pointerlock mode
  39211. * @param element defines the DOM element to promote
  39212. */
  39213. static _RequestPointerlock(element: HTMLElement): void;
  39214. /**
  39215. * Asks the browser to exit pointerlock mode
  39216. */
  39217. static _ExitPointerlock(): void;
  39218. /**
  39219. * Ask the browser to promote the current element to fullscreen rendering mode
  39220. * @param element defines the DOM element to promote
  39221. */
  39222. static _RequestFullscreen(element: HTMLElement): void;
  39223. /**
  39224. * Asks the browser to exit fullscreen mode
  39225. */
  39226. static _ExitFullscreen(): void;
  39227. }
  39228. }
  39229. declare module "babylonjs/Engines/engineStore" {
  39230. import { Nullable } from "babylonjs/types";
  39231. import { Engine } from "babylonjs/Engines/engine";
  39232. import { Scene } from "babylonjs/scene";
  39233. /**
  39234. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39235. * during the life time of the application.
  39236. */
  39237. export class EngineStore {
  39238. /** Gets the list of created engines */
  39239. static Instances: import("babylonjs/Engines/engine").Engine[];
  39240. /** @hidden */
  39241. static _LastCreatedScene: Nullable<Scene>;
  39242. /**
  39243. * Gets the latest created engine
  39244. */
  39245. static get LastCreatedEngine(): Nullable<Engine>;
  39246. /**
  39247. * Gets the latest created scene
  39248. */
  39249. static get LastCreatedScene(): Nullable<Scene>;
  39250. /**
  39251. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39252. * @ignorenaming
  39253. */
  39254. static UseFallbackTexture: boolean;
  39255. /**
  39256. * Texture content used if a texture cannot loaded
  39257. * @ignorenaming
  39258. */
  39259. static FallbackTexture: string;
  39260. }
  39261. }
  39262. declare module "babylonjs/Misc/promise" {
  39263. /**
  39264. * Helper class that provides a small promise polyfill
  39265. */
  39266. export class PromisePolyfill {
  39267. /**
  39268. * Static function used to check if the polyfill is required
  39269. * If this is the case then the function will inject the polyfill to window.Promise
  39270. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39271. */
  39272. static Apply(force?: boolean): void;
  39273. }
  39274. }
  39275. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39276. /**
  39277. * Interface for screenshot methods with describe argument called `size` as object with options
  39278. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39279. */
  39280. export interface IScreenshotSize {
  39281. /**
  39282. * number in pixels for canvas height
  39283. */
  39284. height?: number;
  39285. /**
  39286. * multiplier allowing render at a higher or lower resolution
  39287. * If value is defined then height and width will be ignored and taken from camera
  39288. */
  39289. precision?: number;
  39290. /**
  39291. * number in pixels for canvas width
  39292. */
  39293. width?: number;
  39294. }
  39295. }
  39296. declare module "babylonjs/Misc/tools" {
  39297. import { Nullable, float } from "babylonjs/types";
  39298. import { DomManagement } from "babylonjs/Misc/domManagement";
  39299. import { WebRequest } from "babylonjs/Misc/webRequest";
  39300. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39301. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39302. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39303. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39304. import { Camera } from "babylonjs/Cameras/camera";
  39305. import { Engine } from "babylonjs/Engines/engine";
  39306. interface IColor4Like {
  39307. r: float;
  39308. g: float;
  39309. b: float;
  39310. a: float;
  39311. }
  39312. /**
  39313. * Class containing a set of static utilities functions
  39314. */
  39315. export class Tools {
  39316. /**
  39317. * Gets or sets the base URL to use to load assets
  39318. */
  39319. static get BaseUrl(): string;
  39320. static set BaseUrl(value: string);
  39321. /**
  39322. * Enable/Disable Custom HTTP Request Headers globally.
  39323. * default = false
  39324. * @see CustomRequestHeaders
  39325. */
  39326. static UseCustomRequestHeaders: boolean;
  39327. /**
  39328. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39329. * i.e. when loading files, where the server/service expects an Authorization header
  39330. */
  39331. static CustomRequestHeaders: {
  39332. [key: string]: string;
  39333. };
  39334. /**
  39335. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39336. */
  39337. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39338. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39339. /**
  39340. * Default behaviour for cors in the application.
  39341. * It can be a string if the expected behavior is identical in the entire app.
  39342. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39343. */
  39344. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39345. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39346. /**
  39347. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39348. * @ignorenaming
  39349. */
  39350. static get UseFallbackTexture(): boolean;
  39351. static set UseFallbackTexture(value: boolean);
  39352. /**
  39353. * Use this object to register external classes like custom textures or material
  39354. * to allow the laoders to instantiate them
  39355. */
  39356. static get RegisteredExternalClasses(): {
  39357. [key: string]: Object;
  39358. };
  39359. static set RegisteredExternalClasses(classes: {
  39360. [key: string]: Object;
  39361. });
  39362. /**
  39363. * Texture content used if a texture cannot loaded
  39364. * @ignorenaming
  39365. */
  39366. static get fallbackTexture(): string;
  39367. static set fallbackTexture(value: string);
  39368. /**
  39369. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39370. * @param u defines the coordinate on X axis
  39371. * @param v defines the coordinate on Y axis
  39372. * @param width defines the width of the source data
  39373. * @param height defines the height of the source data
  39374. * @param pixels defines the source byte array
  39375. * @param color defines the output color
  39376. */
  39377. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39378. /**
  39379. * Interpolates between a and b via alpha
  39380. * @param a The lower value (returned when alpha = 0)
  39381. * @param b The upper value (returned when alpha = 1)
  39382. * @param alpha The interpolation-factor
  39383. * @return The mixed value
  39384. */
  39385. static Mix(a: number, b: number, alpha: number): number;
  39386. /**
  39387. * Tries to instantiate a new object from a given class name
  39388. * @param className defines the class name to instantiate
  39389. * @returns the new object or null if the system was not able to do the instantiation
  39390. */
  39391. static Instantiate(className: string): any;
  39392. /**
  39393. * Provides a slice function that will work even on IE
  39394. * @param data defines the array to slice
  39395. * @param start defines the start of the data (optional)
  39396. * @param end defines the end of the data (optional)
  39397. * @returns the new sliced array
  39398. */
  39399. static Slice<T>(data: T, start?: number, end?: number): T;
  39400. /**
  39401. * Polyfill for setImmediate
  39402. * @param action defines the action to execute after the current execution block
  39403. */
  39404. static SetImmediate(action: () => void): void;
  39405. /**
  39406. * Function indicating if a number is an exponent of 2
  39407. * @param value defines the value to test
  39408. * @returns true if the value is an exponent of 2
  39409. */
  39410. static IsExponentOfTwo(value: number): boolean;
  39411. private static _tmpFloatArray;
  39412. /**
  39413. * Returns the nearest 32-bit single precision float representation of a Number
  39414. * @param value A Number. If the parameter is of a different type, it will get converted
  39415. * to a number or to NaN if it cannot be converted
  39416. * @returns number
  39417. */
  39418. static FloatRound(value: number): number;
  39419. /**
  39420. * Extracts the filename from a path
  39421. * @param path defines the path to use
  39422. * @returns the filename
  39423. */
  39424. static GetFilename(path: string): string;
  39425. /**
  39426. * Extracts the "folder" part of a path (everything before the filename).
  39427. * @param uri The URI to extract the info from
  39428. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39429. * @returns The "folder" part of the path
  39430. */
  39431. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39432. /**
  39433. * Extracts text content from a DOM element hierarchy
  39434. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39435. */
  39436. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39437. /**
  39438. * Convert an angle in radians to degrees
  39439. * @param angle defines the angle to convert
  39440. * @returns the angle in degrees
  39441. */
  39442. static ToDegrees(angle: number): number;
  39443. /**
  39444. * Convert an angle in degrees to radians
  39445. * @param angle defines the angle to convert
  39446. * @returns the angle in radians
  39447. */
  39448. static ToRadians(angle: number): number;
  39449. /**
  39450. * Returns an array if obj is not an array
  39451. * @param obj defines the object to evaluate as an array
  39452. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39453. * @returns either obj directly if obj is an array or a new array containing obj
  39454. */
  39455. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39456. /**
  39457. * Gets the pointer prefix to use
  39458. * @param engine defines the engine we are finding the prefix for
  39459. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39460. */
  39461. static GetPointerPrefix(engine: Engine): string;
  39462. /**
  39463. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39464. * @param url define the url we are trying
  39465. * @param element define the dom element where to configure the cors policy
  39466. */
  39467. static SetCorsBehavior(url: string | string[], element: {
  39468. crossOrigin: string | null;
  39469. }): void;
  39470. /**
  39471. * Removes unwanted characters from an url
  39472. * @param url defines the url to clean
  39473. * @returns the cleaned url
  39474. */
  39475. static CleanUrl(url: string): string;
  39476. /**
  39477. * Gets or sets a function used to pre-process url before using them to load assets
  39478. */
  39479. static get PreprocessUrl(): (url: string) => string;
  39480. static set PreprocessUrl(processor: (url: string) => string);
  39481. /**
  39482. * Loads an image as an HTMLImageElement.
  39483. * @param input url string, ArrayBuffer, or Blob to load
  39484. * @param onLoad callback called when the image successfully loads
  39485. * @param onError callback called when the image fails to load
  39486. * @param offlineProvider offline provider for caching
  39487. * @param mimeType optional mime type
  39488. * @returns the HTMLImageElement of the loaded image
  39489. */
  39490. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39491. /**
  39492. * Loads a file from a url
  39493. * @param url url string, ArrayBuffer, or Blob to load
  39494. * @param onSuccess callback called when the file successfully loads
  39495. * @param onProgress callback called while file is loading (if the server supports this mode)
  39496. * @param offlineProvider defines the offline provider for caching
  39497. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39498. * @param onError callback called when the file fails to load
  39499. * @returns a file request object
  39500. */
  39501. 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;
  39502. /**
  39503. * Loads a file from a url
  39504. * @param url the file url to load
  39505. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39506. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39507. */
  39508. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39509. /**
  39510. * Load a script (identified by an url). When the url returns, the
  39511. * content of this file is added into a new script element, attached to the DOM (body element)
  39512. * @param scriptUrl defines the url of the script to laod
  39513. * @param onSuccess defines the callback called when the script is loaded
  39514. * @param onError defines the callback to call if an error occurs
  39515. * @param scriptId defines the id of the script element
  39516. */
  39517. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39518. /**
  39519. * Load an asynchronous script (identified by an url). When the url returns, the
  39520. * content of this file is added into a new script element, attached to the DOM (body element)
  39521. * @param scriptUrl defines the url of the script to laod
  39522. * @param scriptId defines the id of the script element
  39523. * @returns a promise request object
  39524. */
  39525. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39526. /**
  39527. * Loads a file from a blob
  39528. * @param fileToLoad defines the blob to use
  39529. * @param callback defines the callback to call when data is loaded
  39530. * @param progressCallback defines the callback to call during loading process
  39531. * @returns a file request object
  39532. */
  39533. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39534. /**
  39535. * Reads a file from a File object
  39536. * @param file defines the file to load
  39537. * @param onSuccess defines the callback to call when data is loaded
  39538. * @param onProgress defines the callback to call during loading process
  39539. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39540. * @param onError defines the callback to call when an error occurs
  39541. * @returns a file request object
  39542. */
  39543. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39544. /**
  39545. * Creates a data url from a given string content
  39546. * @param content defines the content to convert
  39547. * @returns the new data url link
  39548. */
  39549. static FileAsURL(content: string): string;
  39550. /**
  39551. * Format the given number to a specific decimal format
  39552. * @param value defines the number to format
  39553. * @param decimals defines the number of decimals to use
  39554. * @returns the formatted string
  39555. */
  39556. static Format(value: number, decimals?: number): string;
  39557. /**
  39558. * Tries to copy an object by duplicating every property
  39559. * @param source defines the source object
  39560. * @param destination defines the target object
  39561. * @param doNotCopyList defines a list of properties to avoid
  39562. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39563. */
  39564. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39565. /**
  39566. * Gets a boolean indicating if the given object has no own property
  39567. * @param obj defines the object to test
  39568. * @returns true if object has no own property
  39569. */
  39570. static IsEmpty(obj: any): boolean;
  39571. /**
  39572. * Function used to register events at window level
  39573. * @param windowElement defines the Window object to use
  39574. * @param events defines the events to register
  39575. */
  39576. static RegisterTopRootEvents(windowElement: Window, events: {
  39577. name: string;
  39578. handler: Nullable<(e: FocusEvent) => any>;
  39579. }[]): void;
  39580. /**
  39581. * Function used to unregister events from window level
  39582. * @param windowElement defines the Window object to use
  39583. * @param events defines the events to unregister
  39584. */
  39585. static UnregisterTopRootEvents(windowElement: Window, events: {
  39586. name: string;
  39587. handler: Nullable<(e: FocusEvent) => any>;
  39588. }[]): void;
  39589. /**
  39590. * @ignore
  39591. */
  39592. static _ScreenshotCanvas: HTMLCanvasElement;
  39593. /**
  39594. * Dumps the current bound framebuffer
  39595. * @param width defines the rendering width
  39596. * @param height defines the rendering height
  39597. * @param engine defines the hosting engine
  39598. * @param successCallback defines the callback triggered once the data are available
  39599. * @param mimeType defines the mime type of the result
  39600. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39601. */
  39602. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39603. /**
  39604. * Converts the canvas data to blob.
  39605. * This acts as a polyfill for browsers not supporting the to blob function.
  39606. * @param canvas Defines the canvas to extract the data from
  39607. * @param successCallback Defines the callback triggered once the data are available
  39608. * @param mimeType Defines the mime type of the result
  39609. */
  39610. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39611. /**
  39612. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39613. * @param successCallback defines the callback triggered once the data are available
  39614. * @param mimeType defines the mime type of the result
  39615. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39616. */
  39617. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39618. /**
  39619. * Downloads a blob in the browser
  39620. * @param blob defines the blob to download
  39621. * @param fileName defines the name of the downloaded file
  39622. */
  39623. static Download(blob: Blob, fileName: string): void;
  39624. /**
  39625. * Captures a screenshot of the current rendering
  39626. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39627. * @param engine defines the rendering engine
  39628. * @param camera defines the source camera
  39629. * @param size This parameter can be set to a single number or to an object with the
  39630. * following (optional) properties: precision, width, height. If a single number is passed,
  39631. * it will be used for both width and height. If an object is passed, the screenshot size
  39632. * will be derived from the parameters. The precision property is a multiplier allowing
  39633. * rendering at a higher or lower resolution
  39634. * @param successCallback defines the callback receives a single parameter which contains the
  39635. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39636. * src parameter of an <img> to display it
  39637. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39638. * Check your browser for supported MIME types
  39639. */
  39640. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39641. /**
  39642. * Captures a screenshot of the current rendering
  39643. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39644. * @param engine defines the rendering engine
  39645. * @param camera defines the source camera
  39646. * @param size This parameter can be set to a single number or to an object with the
  39647. * following (optional) properties: precision, width, height. If a single number is passed,
  39648. * it will be used for both width and height. If an object is passed, the screenshot size
  39649. * will be derived from the parameters. The precision property is a multiplier allowing
  39650. * rendering at a higher or lower resolution
  39651. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39652. * Check your browser for supported MIME types
  39653. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39654. * to the src parameter of an <img> to display it
  39655. */
  39656. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39657. /**
  39658. * Generates an image screenshot from the specified camera.
  39659. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39660. * @param engine The engine to use for rendering
  39661. * @param camera The camera to use for rendering
  39662. * @param size This parameter can be set to a single number or to an object with the
  39663. * following (optional) properties: precision, width, height. If a single number is passed,
  39664. * it will be used for both width and height. If an object is passed, the screenshot size
  39665. * will be derived from the parameters. The precision property is a multiplier allowing
  39666. * rendering at a higher or lower resolution
  39667. * @param successCallback The callback receives a single parameter which contains the
  39668. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39669. * src parameter of an <img> to display it
  39670. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39671. * Check your browser for supported MIME types
  39672. * @param samples Texture samples (default: 1)
  39673. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39674. * @param fileName A name for for the downloaded file.
  39675. */
  39676. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39677. /**
  39678. * Generates an image screenshot from the specified camera.
  39679. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39680. * @param engine The engine to use for rendering
  39681. * @param camera The camera to use for rendering
  39682. * @param size This parameter can be set to a single number or to an object with the
  39683. * following (optional) properties: precision, width, height. If a single number is passed,
  39684. * it will be used for both width and height. If an object is passed, the screenshot size
  39685. * will be derived from the parameters. The precision property is a multiplier allowing
  39686. * rendering at a higher or lower resolution
  39687. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39688. * Check your browser for supported MIME types
  39689. * @param samples Texture samples (default: 1)
  39690. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39691. * @param fileName A name for for the downloaded file.
  39692. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39693. * to the src parameter of an <img> to display it
  39694. */
  39695. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39696. /**
  39697. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39698. * Be aware Math.random() could cause collisions, but:
  39699. * "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"
  39700. * @returns a pseudo random id
  39701. */
  39702. static RandomId(): string;
  39703. /**
  39704. * Test if the given uri is a base64 string
  39705. * @param uri The uri to test
  39706. * @return True if the uri is a base64 string or false otherwise
  39707. */
  39708. static IsBase64(uri: string): boolean;
  39709. /**
  39710. * Decode the given base64 uri.
  39711. * @param uri The uri to decode
  39712. * @return The decoded base64 data.
  39713. */
  39714. static DecodeBase64(uri: string): ArrayBuffer;
  39715. /**
  39716. * Gets the absolute url.
  39717. * @param url the input url
  39718. * @return the absolute url
  39719. */
  39720. static GetAbsoluteUrl(url: string): string;
  39721. /**
  39722. * No log
  39723. */
  39724. static readonly NoneLogLevel: number;
  39725. /**
  39726. * Only message logs
  39727. */
  39728. static readonly MessageLogLevel: number;
  39729. /**
  39730. * Only warning logs
  39731. */
  39732. static readonly WarningLogLevel: number;
  39733. /**
  39734. * Only error logs
  39735. */
  39736. static readonly ErrorLogLevel: number;
  39737. /**
  39738. * All logs
  39739. */
  39740. static readonly AllLogLevel: number;
  39741. /**
  39742. * Gets a value indicating the number of loading errors
  39743. * @ignorenaming
  39744. */
  39745. static get errorsCount(): number;
  39746. /**
  39747. * Callback called when a new log is added
  39748. */
  39749. static OnNewCacheEntry: (entry: string) => void;
  39750. /**
  39751. * Log a message to the console
  39752. * @param message defines the message to log
  39753. */
  39754. static Log(message: string): void;
  39755. /**
  39756. * Write a warning message to the console
  39757. * @param message defines the message to log
  39758. */
  39759. static Warn(message: string): void;
  39760. /**
  39761. * Write an error message to the console
  39762. * @param message defines the message to log
  39763. */
  39764. static Error(message: string): void;
  39765. /**
  39766. * Gets current log cache (list of logs)
  39767. */
  39768. static get LogCache(): string;
  39769. /**
  39770. * Clears the log cache
  39771. */
  39772. static ClearLogCache(): void;
  39773. /**
  39774. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39775. */
  39776. static set LogLevels(level: number);
  39777. /**
  39778. * Checks if the window object exists
  39779. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  39780. */
  39781. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  39782. /**
  39783. * No performance log
  39784. */
  39785. static readonly PerformanceNoneLogLevel: number;
  39786. /**
  39787. * Use user marks to log performance
  39788. */
  39789. static readonly PerformanceUserMarkLogLevel: number;
  39790. /**
  39791. * Log performance to the console
  39792. */
  39793. static readonly PerformanceConsoleLogLevel: number;
  39794. private static _performance;
  39795. /**
  39796. * Sets the current performance log level
  39797. */
  39798. static set PerformanceLogLevel(level: number);
  39799. private static _StartPerformanceCounterDisabled;
  39800. private static _EndPerformanceCounterDisabled;
  39801. private static _StartUserMark;
  39802. private static _EndUserMark;
  39803. private static _StartPerformanceConsole;
  39804. private static _EndPerformanceConsole;
  39805. /**
  39806. * Starts a performance counter
  39807. */
  39808. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39809. /**
  39810. * Ends a specific performance coutner
  39811. */
  39812. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39813. /**
  39814. * Gets either window.performance.now() if supported or Date.now() else
  39815. */
  39816. static get Now(): number;
  39817. /**
  39818. * This method will return the name of the class used to create the instance of the given object.
  39819. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39820. * @param object the object to get the class name from
  39821. * @param isType defines if the object is actually a type
  39822. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39823. */
  39824. static GetClassName(object: any, isType?: boolean): string;
  39825. /**
  39826. * Gets the first element of an array satisfying a given predicate
  39827. * @param array defines the array to browse
  39828. * @param predicate defines the predicate to use
  39829. * @returns null if not found or the element
  39830. */
  39831. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39832. /**
  39833. * This method will return the name of the full name of the class, including its owning module (if any).
  39834. * 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).
  39835. * @param object the object to get the class name from
  39836. * @param isType defines if the object is actually a type
  39837. * @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.
  39838. * @ignorenaming
  39839. */
  39840. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39841. /**
  39842. * Returns a promise that resolves after the given amount of time.
  39843. * @param delay Number of milliseconds to delay
  39844. * @returns Promise that resolves after the given amount of time
  39845. */
  39846. static DelayAsync(delay: number): Promise<void>;
  39847. /**
  39848. * Utility function to detect if the current user agent is Safari
  39849. * @returns whether or not the current user agent is safari
  39850. */
  39851. static IsSafari(): boolean;
  39852. }
  39853. /**
  39854. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39855. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39856. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39857. * @param name The name of the class, case should be preserved
  39858. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39859. */
  39860. export function className(name: string, module?: string): (target: Object) => void;
  39861. /**
  39862. * An implementation of a loop for asynchronous functions.
  39863. */
  39864. export class AsyncLoop {
  39865. /**
  39866. * Defines the number of iterations for the loop
  39867. */
  39868. iterations: number;
  39869. /**
  39870. * Defines the current index of the loop.
  39871. */
  39872. index: number;
  39873. private _done;
  39874. private _fn;
  39875. private _successCallback;
  39876. /**
  39877. * Constructor.
  39878. * @param iterations the number of iterations.
  39879. * @param func the function to run each iteration
  39880. * @param successCallback the callback that will be called upon succesful execution
  39881. * @param offset starting offset.
  39882. */
  39883. constructor(
  39884. /**
  39885. * Defines the number of iterations for the loop
  39886. */
  39887. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39888. /**
  39889. * Execute the next iteration. Must be called after the last iteration was finished.
  39890. */
  39891. executeNext(): void;
  39892. /**
  39893. * Break the loop and run the success callback.
  39894. */
  39895. breakLoop(): void;
  39896. /**
  39897. * Create and run an async loop.
  39898. * @param iterations the number of iterations.
  39899. * @param fn the function to run each iteration
  39900. * @param successCallback the callback that will be called upon succesful execution
  39901. * @param offset starting offset.
  39902. * @returns the created async loop object
  39903. */
  39904. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39905. /**
  39906. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39907. * @param iterations total number of iterations
  39908. * @param syncedIterations number of synchronous iterations in each async iteration.
  39909. * @param fn the function to call each iteration.
  39910. * @param callback a success call back that will be called when iterating stops.
  39911. * @param breakFunction a break condition (optional)
  39912. * @param timeout timeout settings for the setTimeout function. default - 0.
  39913. * @returns the created async loop object
  39914. */
  39915. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39916. }
  39917. }
  39918. declare module "babylonjs/Misc/stringDictionary" {
  39919. import { Nullable } from "babylonjs/types";
  39920. /**
  39921. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39922. * The underlying implementation relies on an associative array to ensure the best performances.
  39923. * The value can be anything including 'null' but except 'undefined'
  39924. */
  39925. export class StringDictionary<T> {
  39926. /**
  39927. * This will clear this dictionary and copy the content from the 'source' one.
  39928. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39929. * @param source the dictionary to take the content from and copy to this dictionary
  39930. */
  39931. copyFrom(source: StringDictionary<T>): void;
  39932. /**
  39933. * Get a value based from its key
  39934. * @param key the given key to get the matching value from
  39935. * @return the value if found, otherwise undefined is returned
  39936. */
  39937. get(key: string): T | undefined;
  39938. /**
  39939. * Get a value from its key or add it if it doesn't exist.
  39940. * This method will ensure you that a given key/data will be present in the dictionary.
  39941. * @param key the given key to get the matching value from
  39942. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39943. * The factory will only be invoked if there's no data for the given key.
  39944. * @return the value corresponding to the key.
  39945. */
  39946. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39947. /**
  39948. * Get a value from its key if present in the dictionary otherwise add it
  39949. * @param key the key to get the value from
  39950. * @param val if there's no such key/value pair in the dictionary add it with this value
  39951. * @return the value corresponding to the key
  39952. */
  39953. getOrAdd(key: string, val: T): T;
  39954. /**
  39955. * Check if there's a given key in the dictionary
  39956. * @param key the key to check for
  39957. * @return true if the key is present, false otherwise
  39958. */
  39959. contains(key: string): boolean;
  39960. /**
  39961. * Add a new key and its corresponding value
  39962. * @param key the key to add
  39963. * @param value the value corresponding to the key
  39964. * @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
  39965. */
  39966. add(key: string, value: T): boolean;
  39967. /**
  39968. * Update a specific value associated to a key
  39969. * @param key defines the key to use
  39970. * @param value defines the value to store
  39971. * @returns true if the value was updated (or false if the key was not found)
  39972. */
  39973. set(key: string, value: T): boolean;
  39974. /**
  39975. * Get the element of the given key and remove it from the dictionary
  39976. * @param key defines the key to search
  39977. * @returns the value associated with the key or null if not found
  39978. */
  39979. getAndRemove(key: string): Nullable<T>;
  39980. /**
  39981. * Remove a key/value from the dictionary.
  39982. * @param key the key to remove
  39983. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39984. */
  39985. remove(key: string): boolean;
  39986. /**
  39987. * Clear the whole content of the dictionary
  39988. */
  39989. clear(): void;
  39990. /**
  39991. * Gets the current count
  39992. */
  39993. get count(): number;
  39994. /**
  39995. * Execute a callback on each key/val of the dictionary.
  39996. * Note that you can remove any element in this dictionary in the callback implementation
  39997. * @param callback the callback to execute on a given key/value pair
  39998. */
  39999. forEach(callback: (key: string, val: T) => void): void;
  40000. /**
  40001. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40002. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40003. * Note that you can remove any element in this dictionary in the callback implementation
  40004. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40005. * @returns the first item
  40006. */
  40007. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40008. private _count;
  40009. private _data;
  40010. }
  40011. }
  40012. declare module "babylonjs/Collisions/collisionCoordinator" {
  40013. import { Nullable } from "babylonjs/types";
  40014. import { Scene } from "babylonjs/scene";
  40015. import { Vector3 } from "babylonjs/Maths/math.vector";
  40016. import { Collider } from "babylonjs/Collisions/collider";
  40017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40018. /** @hidden */
  40019. export interface ICollisionCoordinator {
  40020. createCollider(): Collider;
  40021. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40022. init(scene: Scene): void;
  40023. }
  40024. /** @hidden */
  40025. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40026. private _scene;
  40027. private _scaledPosition;
  40028. private _scaledVelocity;
  40029. private _finalPosition;
  40030. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40031. createCollider(): Collider;
  40032. init(scene: Scene): void;
  40033. private _collideWithWorld;
  40034. }
  40035. }
  40036. declare module "babylonjs/Inputs/scene.inputManager" {
  40037. import { Nullable } from "babylonjs/types";
  40038. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40039. import { Vector2 } from "babylonjs/Maths/math.vector";
  40040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40041. import { Scene } from "babylonjs/scene";
  40042. /**
  40043. * Class used to manage all inputs for the scene.
  40044. */
  40045. export class InputManager {
  40046. /** The distance in pixel that you have to move to prevent some events */
  40047. static DragMovementThreshold: number;
  40048. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40049. static LongPressDelay: number;
  40050. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40051. static DoubleClickDelay: number;
  40052. /** If you need to check double click without raising a single click at first click, enable this flag */
  40053. static ExclusiveDoubleClickMode: boolean;
  40054. /** 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. */
  40055. private _alreadyAttached;
  40056. private _wheelEventName;
  40057. private _onPointerMove;
  40058. private _onPointerDown;
  40059. private _onPointerUp;
  40060. private _initClickEvent;
  40061. private _initActionManager;
  40062. private _delayedSimpleClick;
  40063. private _delayedSimpleClickTimeout;
  40064. private _previousDelayedSimpleClickTimeout;
  40065. private _meshPickProceed;
  40066. private _previousButtonPressed;
  40067. private _currentPickResult;
  40068. private _previousPickResult;
  40069. private _totalPointersPressed;
  40070. private _doubleClickOccured;
  40071. private _pointerOverMesh;
  40072. private _pickedDownMesh;
  40073. private _pickedUpMesh;
  40074. private _pointerX;
  40075. private _pointerY;
  40076. private _unTranslatedPointerX;
  40077. private _unTranslatedPointerY;
  40078. private _startingPointerPosition;
  40079. private _previousStartingPointerPosition;
  40080. private _startingPointerTime;
  40081. private _previousStartingPointerTime;
  40082. private _pointerCaptures;
  40083. private _onKeyDown;
  40084. private _onKeyUp;
  40085. private _onCanvasFocusObserver;
  40086. private _onCanvasBlurObserver;
  40087. private _scene;
  40088. /**
  40089. * Creates a new InputManager
  40090. * @param scene defines the hosting scene
  40091. */
  40092. constructor(scene: Scene);
  40093. /**
  40094. * Gets the mesh that is currently under the pointer
  40095. */
  40096. get meshUnderPointer(): Nullable<AbstractMesh>;
  40097. /**
  40098. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40099. */
  40100. get unTranslatedPointer(): Vector2;
  40101. /**
  40102. * Gets or sets the current on-screen X position of the pointer
  40103. */
  40104. get pointerX(): number;
  40105. set pointerX(value: number);
  40106. /**
  40107. * Gets or sets the current on-screen Y position of the pointer
  40108. */
  40109. get pointerY(): number;
  40110. set pointerY(value: number);
  40111. private _updatePointerPosition;
  40112. private _processPointerMove;
  40113. private _setRayOnPointerInfo;
  40114. private _checkPrePointerObservable;
  40115. /**
  40116. * Use this method to simulate a pointer move on a mesh
  40117. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40118. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40119. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40120. */
  40121. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40122. /**
  40123. * Use this method to simulate a pointer down on a mesh
  40124. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40125. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40126. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40127. */
  40128. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40129. private _processPointerDown;
  40130. /** @hidden */
  40131. _isPointerSwiping(): boolean;
  40132. /**
  40133. * Use this method to simulate a pointer up on a mesh
  40134. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40135. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40136. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40137. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40138. */
  40139. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40140. private _processPointerUp;
  40141. /**
  40142. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40143. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40144. * @returns true if the pointer was captured
  40145. */
  40146. isPointerCaptured(pointerId?: number): boolean;
  40147. /**
  40148. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40149. * @param attachUp defines if you want to attach events to pointerup
  40150. * @param attachDown defines if you want to attach events to pointerdown
  40151. * @param attachMove defines if you want to attach events to pointermove
  40152. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40153. */
  40154. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40155. /**
  40156. * Detaches all event handlers
  40157. */
  40158. detachControl(): void;
  40159. /**
  40160. * Force the value of meshUnderPointer
  40161. * @param mesh defines the mesh to use
  40162. */
  40163. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40164. /**
  40165. * Gets the mesh under the pointer
  40166. * @returns a Mesh or null if no mesh is under the pointer
  40167. */
  40168. getPointerOverMesh(): Nullable<AbstractMesh>;
  40169. }
  40170. }
  40171. declare module "babylonjs/Animations/animationGroup" {
  40172. import { Animatable } from "babylonjs/Animations/animatable";
  40173. import { Animation } from "babylonjs/Animations/animation";
  40174. import { Scene, IDisposable } from "babylonjs/scene";
  40175. import { Observable } from "babylonjs/Misc/observable";
  40176. import { Nullable } from "babylonjs/types";
  40177. import "babylonjs/Animations/animatable";
  40178. /**
  40179. * This class defines the direct association between an animation and a target
  40180. */
  40181. export class TargetedAnimation {
  40182. /**
  40183. * Animation to perform
  40184. */
  40185. animation: Animation;
  40186. /**
  40187. * Target to animate
  40188. */
  40189. target: any;
  40190. /**
  40191. * Returns the string "TargetedAnimation"
  40192. * @returns "TargetedAnimation"
  40193. */
  40194. getClassName(): string;
  40195. /**
  40196. * Serialize the object
  40197. * @returns the JSON object representing the current entity
  40198. */
  40199. serialize(): any;
  40200. }
  40201. /**
  40202. * Use this class to create coordinated animations on multiple targets
  40203. */
  40204. export class AnimationGroup implements IDisposable {
  40205. /** The name of the animation group */
  40206. name: string;
  40207. private _scene;
  40208. private _targetedAnimations;
  40209. private _animatables;
  40210. private _from;
  40211. private _to;
  40212. private _isStarted;
  40213. private _isPaused;
  40214. private _speedRatio;
  40215. private _loopAnimation;
  40216. private _isAdditive;
  40217. /**
  40218. * Gets or sets the unique id of the node
  40219. */
  40220. uniqueId: number;
  40221. /**
  40222. * This observable will notify when one animation have ended
  40223. */
  40224. onAnimationEndObservable: Observable<TargetedAnimation>;
  40225. /**
  40226. * Observer raised when one animation loops
  40227. */
  40228. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40229. /**
  40230. * Observer raised when all animations have looped
  40231. */
  40232. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40233. /**
  40234. * This observable will notify when all animations have ended.
  40235. */
  40236. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40237. /**
  40238. * This observable will notify when all animations have paused.
  40239. */
  40240. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40241. /**
  40242. * This observable will notify when all animations are playing.
  40243. */
  40244. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40245. /**
  40246. * Gets the first frame
  40247. */
  40248. get from(): number;
  40249. /**
  40250. * Gets the last frame
  40251. */
  40252. get to(): number;
  40253. /**
  40254. * Define if the animations are started
  40255. */
  40256. get isStarted(): boolean;
  40257. /**
  40258. * Gets a value indicating that the current group is playing
  40259. */
  40260. get isPlaying(): boolean;
  40261. /**
  40262. * Gets or sets the speed ratio to use for all animations
  40263. */
  40264. get speedRatio(): number;
  40265. /**
  40266. * Gets or sets the speed ratio to use for all animations
  40267. */
  40268. set speedRatio(value: number);
  40269. /**
  40270. * Gets or sets if all animations should loop or not
  40271. */
  40272. get loopAnimation(): boolean;
  40273. set loopAnimation(value: boolean);
  40274. /**
  40275. * Gets or sets if all animations should be evaluated additively
  40276. */
  40277. get isAdditive(): boolean;
  40278. set isAdditive(value: boolean);
  40279. /**
  40280. * Gets the targeted animations for this animation group
  40281. */
  40282. get targetedAnimations(): Array<TargetedAnimation>;
  40283. /**
  40284. * returning the list of animatables controlled by this animation group.
  40285. */
  40286. get animatables(): Array<Animatable>;
  40287. /**
  40288. * Gets the list of target animations
  40289. */
  40290. get children(): TargetedAnimation[];
  40291. /**
  40292. * Instantiates a new Animation Group.
  40293. * This helps managing several animations at once.
  40294. * @see https://doc.babylonjs.com/how_to/group
  40295. * @param name Defines the name of the group
  40296. * @param scene Defines the scene the group belongs to
  40297. */
  40298. constructor(
  40299. /** The name of the animation group */
  40300. name: string, scene?: Nullable<Scene>);
  40301. /**
  40302. * Add an animation (with its target) in the group
  40303. * @param animation defines the animation we want to add
  40304. * @param target defines the target of the animation
  40305. * @returns the TargetedAnimation object
  40306. */
  40307. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40308. /**
  40309. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40310. * It can add constant keys at begin or end
  40311. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40312. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40313. * @returns the animation group
  40314. */
  40315. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40316. private _animationLoopCount;
  40317. private _animationLoopFlags;
  40318. private _processLoop;
  40319. /**
  40320. * Start all animations on given targets
  40321. * @param loop defines if animations must loop
  40322. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40323. * @param from defines the from key (optional)
  40324. * @param to defines the to key (optional)
  40325. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40326. * @returns the current animation group
  40327. */
  40328. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40329. /**
  40330. * Pause all animations
  40331. * @returns the animation group
  40332. */
  40333. pause(): AnimationGroup;
  40334. /**
  40335. * Play all animations to initial state
  40336. * This function will start() the animations if they were not started or will restart() them if they were paused
  40337. * @param loop defines if animations must loop
  40338. * @returns the animation group
  40339. */
  40340. play(loop?: boolean): AnimationGroup;
  40341. /**
  40342. * Reset all animations to initial state
  40343. * @returns the animation group
  40344. */
  40345. reset(): AnimationGroup;
  40346. /**
  40347. * Restart animations from key 0
  40348. * @returns the animation group
  40349. */
  40350. restart(): AnimationGroup;
  40351. /**
  40352. * Stop all animations
  40353. * @returns the animation group
  40354. */
  40355. stop(): AnimationGroup;
  40356. /**
  40357. * Set animation weight for all animatables
  40358. * @param weight defines the weight to use
  40359. * @return the animationGroup
  40360. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40361. */
  40362. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40363. /**
  40364. * Synchronize and normalize all animatables with a source animatable
  40365. * @param root defines the root animatable to synchronize with
  40366. * @return the animationGroup
  40367. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40368. */
  40369. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40370. /**
  40371. * Goes to a specific frame in this animation group
  40372. * @param frame the frame number to go to
  40373. * @return the animationGroup
  40374. */
  40375. goToFrame(frame: number): AnimationGroup;
  40376. /**
  40377. * Dispose all associated resources
  40378. */
  40379. dispose(): void;
  40380. private _checkAnimationGroupEnded;
  40381. /**
  40382. * Clone the current animation group and returns a copy
  40383. * @param newName defines the name of the new group
  40384. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40385. * @returns the new aniamtion group
  40386. */
  40387. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40388. /**
  40389. * Serializes the animationGroup to an object
  40390. * @returns Serialized object
  40391. */
  40392. serialize(): any;
  40393. /**
  40394. * Returns a new AnimationGroup object parsed from the source provided.
  40395. * @param parsedAnimationGroup defines the source
  40396. * @param scene defines the scene that will receive the animationGroup
  40397. * @returns a new AnimationGroup
  40398. */
  40399. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40400. /**
  40401. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40402. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40403. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40404. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40405. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40406. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40407. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40408. */
  40409. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40410. /**
  40411. * Returns the string "AnimationGroup"
  40412. * @returns "AnimationGroup"
  40413. */
  40414. getClassName(): string;
  40415. /**
  40416. * Creates a detailled string about the object
  40417. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40418. * @returns a string representing the object
  40419. */
  40420. toString(fullDetails?: boolean): string;
  40421. }
  40422. }
  40423. declare module "babylonjs/scene" {
  40424. import { Nullable } from "babylonjs/types";
  40425. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40426. import { Observable } from "babylonjs/Misc/observable";
  40427. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40428. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40429. import { Geometry } from "babylonjs/Meshes/geometry";
  40430. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40431. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40433. import { Mesh } from "babylonjs/Meshes/mesh";
  40434. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40435. import { Bone } from "babylonjs/Bones/bone";
  40436. import { Skeleton } from "babylonjs/Bones/skeleton";
  40437. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40438. import { Camera } from "babylonjs/Cameras/camera";
  40439. import { AbstractScene } from "babylonjs/abstractScene";
  40440. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40441. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40442. import { Material } from "babylonjs/Materials/material";
  40443. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40444. import { Effect } from "babylonjs/Materials/effect";
  40445. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40446. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40447. import { Light } from "babylonjs/Lights/light";
  40448. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40449. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40450. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40451. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40452. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40453. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40454. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40455. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40456. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40457. import { Engine } from "babylonjs/Engines/engine";
  40458. import { Node } from "babylonjs/node";
  40459. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40460. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40461. import { WebRequest } from "babylonjs/Misc/webRequest";
  40462. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40463. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40464. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40465. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40466. import { Plane } from "babylonjs/Maths/math.plane";
  40467. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40468. import { Ray } from "babylonjs/Culling/ray";
  40469. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40470. import { Animation } from "babylonjs/Animations/animation";
  40471. import { Animatable } from "babylonjs/Animations/animatable";
  40472. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40473. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40474. import { Collider } from "babylonjs/Collisions/collider";
  40475. /**
  40476. * Define an interface for all classes that will hold resources
  40477. */
  40478. export interface IDisposable {
  40479. /**
  40480. * Releases all held resources
  40481. */
  40482. dispose(): void;
  40483. }
  40484. /** Interface defining initialization parameters for Scene class */
  40485. export interface SceneOptions {
  40486. /**
  40487. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40488. * It will improve performance when the number of geometries becomes important.
  40489. */
  40490. useGeometryUniqueIdsMap?: boolean;
  40491. /**
  40492. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40493. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40494. */
  40495. useMaterialMeshMap?: boolean;
  40496. /**
  40497. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40498. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40499. */
  40500. useClonedMeshMap?: boolean;
  40501. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40502. virtual?: boolean;
  40503. }
  40504. /**
  40505. * Represents a scene to be rendered by the engine.
  40506. * @see https://doc.babylonjs.com/features/scene
  40507. */
  40508. export class Scene extends AbstractScene implements IAnimatable {
  40509. /** The fog is deactivated */
  40510. static readonly FOGMODE_NONE: number;
  40511. /** The fog density is following an exponential function */
  40512. static readonly FOGMODE_EXP: number;
  40513. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40514. static readonly FOGMODE_EXP2: number;
  40515. /** The fog density is following a linear function. */
  40516. static readonly FOGMODE_LINEAR: number;
  40517. /**
  40518. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40519. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40520. */
  40521. static MinDeltaTime: number;
  40522. /**
  40523. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40524. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40525. */
  40526. static MaxDeltaTime: number;
  40527. /**
  40528. * Factory used to create the default material.
  40529. * @param name The name of the material to create
  40530. * @param scene The scene to create the material for
  40531. * @returns The default material
  40532. */
  40533. static DefaultMaterialFactory(scene: Scene): Material;
  40534. /**
  40535. * Factory used to create the a collision coordinator.
  40536. * @returns The collision coordinator
  40537. */
  40538. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40539. /** @hidden */
  40540. _inputManager: InputManager;
  40541. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40542. cameraToUseForPointers: Nullable<Camera>;
  40543. /** @hidden */
  40544. readonly _isScene: boolean;
  40545. /** @hidden */
  40546. _blockEntityCollection: boolean;
  40547. /**
  40548. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40549. */
  40550. autoClear: boolean;
  40551. /**
  40552. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40553. */
  40554. autoClearDepthAndStencil: boolean;
  40555. /**
  40556. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40557. */
  40558. clearColor: Color4;
  40559. /**
  40560. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40561. */
  40562. ambientColor: Color3;
  40563. /**
  40564. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40565. * It should only be one of the following (if not the default embedded one):
  40566. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40567. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40568. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40569. * The material properties need to be setup according to the type of texture in use.
  40570. */
  40571. environmentBRDFTexture: BaseTexture;
  40572. /** @hidden */
  40573. protected _environmentTexture: Nullable<BaseTexture>;
  40574. /**
  40575. * Texture used in all pbr material as the reflection texture.
  40576. * As in the majority of the scene they are the same (exception for multi room and so on),
  40577. * this is easier to reference from here than from all the materials.
  40578. */
  40579. get environmentTexture(): Nullable<BaseTexture>;
  40580. /**
  40581. * Texture used in all pbr material as the reflection texture.
  40582. * As in the majority of the scene they are the same (exception for multi room and so on),
  40583. * this is easier to set here than in all the materials.
  40584. */
  40585. set environmentTexture(value: Nullable<BaseTexture>);
  40586. /** @hidden */
  40587. protected _environmentIntensity: number;
  40588. /**
  40589. * Intensity of the environment in all pbr material.
  40590. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40591. * As in the majority of the scene they are the same (exception for multi room and so on),
  40592. * this is easier to reference from here than from all the materials.
  40593. */
  40594. get environmentIntensity(): number;
  40595. /**
  40596. * Intensity of the environment in all pbr material.
  40597. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40598. * As in the majority of the scene they are the same (exception for multi room and so on),
  40599. * this is easier to set here than in all the materials.
  40600. */
  40601. set environmentIntensity(value: number);
  40602. /** @hidden */
  40603. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40604. /**
  40605. * Default image processing configuration used either in the rendering
  40606. * Forward main pass or through the imageProcessingPostProcess if present.
  40607. * As in the majority of the scene they are the same (exception for multi camera),
  40608. * this is easier to reference from here than from all the materials and post process.
  40609. *
  40610. * No setter as we it is a shared configuration, you can set the values instead.
  40611. */
  40612. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40613. private _forceWireframe;
  40614. /**
  40615. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40616. */
  40617. set forceWireframe(value: boolean);
  40618. get forceWireframe(): boolean;
  40619. private _skipFrustumClipping;
  40620. /**
  40621. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40622. */
  40623. set skipFrustumClipping(value: boolean);
  40624. get skipFrustumClipping(): boolean;
  40625. private _forcePointsCloud;
  40626. /**
  40627. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40628. */
  40629. set forcePointsCloud(value: boolean);
  40630. get forcePointsCloud(): boolean;
  40631. /**
  40632. * Gets or sets the active clipplane 1
  40633. */
  40634. clipPlane: Nullable<Plane>;
  40635. /**
  40636. * Gets or sets the active clipplane 2
  40637. */
  40638. clipPlane2: Nullable<Plane>;
  40639. /**
  40640. * Gets or sets the active clipplane 3
  40641. */
  40642. clipPlane3: Nullable<Plane>;
  40643. /**
  40644. * Gets or sets the active clipplane 4
  40645. */
  40646. clipPlane4: Nullable<Plane>;
  40647. /**
  40648. * Gets or sets the active clipplane 5
  40649. */
  40650. clipPlane5: Nullable<Plane>;
  40651. /**
  40652. * Gets or sets the active clipplane 6
  40653. */
  40654. clipPlane6: Nullable<Plane>;
  40655. /**
  40656. * Gets or sets a boolean indicating if animations are enabled
  40657. */
  40658. animationsEnabled: boolean;
  40659. private _animationPropertiesOverride;
  40660. /**
  40661. * Gets or sets the animation properties override
  40662. */
  40663. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40664. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40665. /**
  40666. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40667. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40668. */
  40669. useConstantAnimationDeltaTime: boolean;
  40670. /**
  40671. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40672. * Please note that it requires to run a ray cast through the scene on every frame
  40673. */
  40674. constantlyUpdateMeshUnderPointer: boolean;
  40675. /**
  40676. * Defines the HTML cursor to use when hovering over interactive elements
  40677. */
  40678. hoverCursor: string;
  40679. /**
  40680. * Defines the HTML default cursor to use (empty by default)
  40681. */
  40682. defaultCursor: string;
  40683. /**
  40684. * Defines whether cursors are handled by the scene.
  40685. */
  40686. doNotHandleCursors: boolean;
  40687. /**
  40688. * This is used to call preventDefault() on pointer down
  40689. * in order to block unwanted artifacts like system double clicks
  40690. */
  40691. preventDefaultOnPointerDown: boolean;
  40692. /**
  40693. * This is used to call preventDefault() on pointer up
  40694. * in order to block unwanted artifacts like system double clicks
  40695. */
  40696. preventDefaultOnPointerUp: boolean;
  40697. /**
  40698. * Gets or sets user defined metadata
  40699. */
  40700. metadata: any;
  40701. /**
  40702. * For internal use only. Please do not use.
  40703. */
  40704. reservedDataStore: any;
  40705. /**
  40706. * Gets the name of the plugin used to load this scene (null by default)
  40707. */
  40708. loadingPluginName: string;
  40709. /**
  40710. * Use this array to add regular expressions used to disable offline support for specific urls
  40711. */
  40712. disableOfflineSupportExceptionRules: RegExp[];
  40713. /**
  40714. * An event triggered when the scene is disposed.
  40715. */
  40716. onDisposeObservable: Observable<Scene>;
  40717. private _onDisposeObserver;
  40718. /** Sets a function to be executed when this scene is disposed. */
  40719. set onDispose(callback: () => void);
  40720. /**
  40721. * An event triggered before rendering the scene (right after animations and physics)
  40722. */
  40723. onBeforeRenderObservable: Observable<Scene>;
  40724. private _onBeforeRenderObserver;
  40725. /** Sets a function to be executed before rendering this scene */
  40726. set beforeRender(callback: Nullable<() => void>);
  40727. /**
  40728. * An event triggered after rendering the scene
  40729. */
  40730. onAfterRenderObservable: Observable<Scene>;
  40731. /**
  40732. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  40733. */
  40734. onAfterRenderCameraObservable: Observable<Camera>;
  40735. private _onAfterRenderObserver;
  40736. /** Sets a function to be executed after rendering this scene */
  40737. set afterRender(callback: Nullable<() => void>);
  40738. /**
  40739. * An event triggered before animating the scene
  40740. */
  40741. onBeforeAnimationsObservable: Observable<Scene>;
  40742. /**
  40743. * An event triggered after animations processing
  40744. */
  40745. onAfterAnimationsObservable: Observable<Scene>;
  40746. /**
  40747. * An event triggered before draw calls are ready to be sent
  40748. */
  40749. onBeforeDrawPhaseObservable: Observable<Scene>;
  40750. /**
  40751. * An event triggered after draw calls have been sent
  40752. */
  40753. onAfterDrawPhaseObservable: Observable<Scene>;
  40754. /**
  40755. * An event triggered when the scene is ready
  40756. */
  40757. onReadyObservable: Observable<Scene>;
  40758. /**
  40759. * An event triggered before rendering a camera
  40760. */
  40761. onBeforeCameraRenderObservable: Observable<Camera>;
  40762. private _onBeforeCameraRenderObserver;
  40763. /** Sets a function to be executed before rendering a camera*/
  40764. set beforeCameraRender(callback: () => void);
  40765. /**
  40766. * An event triggered after rendering a camera
  40767. */
  40768. onAfterCameraRenderObservable: Observable<Camera>;
  40769. private _onAfterCameraRenderObserver;
  40770. /** Sets a function to be executed after rendering a camera*/
  40771. set afterCameraRender(callback: () => void);
  40772. /**
  40773. * An event triggered when active meshes evaluation is about to start
  40774. */
  40775. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  40776. /**
  40777. * An event triggered when active meshes evaluation is done
  40778. */
  40779. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  40780. /**
  40781. * An event triggered when particles rendering is about to start
  40782. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40783. */
  40784. onBeforeParticlesRenderingObservable: Observable<Scene>;
  40785. /**
  40786. * An event triggered when particles rendering is done
  40787. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40788. */
  40789. onAfterParticlesRenderingObservable: Observable<Scene>;
  40790. /**
  40791. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  40792. */
  40793. onDataLoadedObservable: Observable<Scene>;
  40794. /**
  40795. * An event triggered when a camera is created
  40796. */
  40797. onNewCameraAddedObservable: Observable<Camera>;
  40798. /**
  40799. * An event triggered when a camera is removed
  40800. */
  40801. onCameraRemovedObservable: Observable<Camera>;
  40802. /**
  40803. * An event triggered when a light is created
  40804. */
  40805. onNewLightAddedObservable: Observable<Light>;
  40806. /**
  40807. * An event triggered when a light is removed
  40808. */
  40809. onLightRemovedObservable: Observable<Light>;
  40810. /**
  40811. * An event triggered when a geometry is created
  40812. */
  40813. onNewGeometryAddedObservable: Observable<Geometry>;
  40814. /**
  40815. * An event triggered when a geometry is removed
  40816. */
  40817. onGeometryRemovedObservable: Observable<Geometry>;
  40818. /**
  40819. * An event triggered when a transform node is created
  40820. */
  40821. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  40822. /**
  40823. * An event triggered when a transform node is removed
  40824. */
  40825. onTransformNodeRemovedObservable: Observable<TransformNode>;
  40826. /**
  40827. * An event triggered when a mesh is created
  40828. */
  40829. onNewMeshAddedObservable: Observable<AbstractMesh>;
  40830. /**
  40831. * An event triggered when a mesh is removed
  40832. */
  40833. onMeshRemovedObservable: Observable<AbstractMesh>;
  40834. /**
  40835. * An event triggered when a skeleton is created
  40836. */
  40837. onNewSkeletonAddedObservable: Observable<Skeleton>;
  40838. /**
  40839. * An event triggered when a skeleton is removed
  40840. */
  40841. onSkeletonRemovedObservable: Observable<Skeleton>;
  40842. /**
  40843. * An event triggered when a material is created
  40844. */
  40845. onNewMaterialAddedObservable: Observable<Material>;
  40846. /**
  40847. * An event triggered when a material is removed
  40848. */
  40849. onMaterialRemovedObservable: Observable<Material>;
  40850. /**
  40851. * An event triggered when a texture is created
  40852. */
  40853. onNewTextureAddedObservable: Observable<BaseTexture>;
  40854. /**
  40855. * An event triggered when a texture is removed
  40856. */
  40857. onTextureRemovedObservable: Observable<BaseTexture>;
  40858. /**
  40859. * An event triggered when render targets are about to be rendered
  40860. * Can happen multiple times per frame.
  40861. */
  40862. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  40863. /**
  40864. * An event triggered when render targets were rendered.
  40865. * Can happen multiple times per frame.
  40866. */
  40867. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  40868. /**
  40869. * An event triggered before calculating deterministic simulation step
  40870. */
  40871. onBeforeStepObservable: Observable<Scene>;
  40872. /**
  40873. * An event triggered after calculating deterministic simulation step
  40874. */
  40875. onAfterStepObservable: Observable<Scene>;
  40876. /**
  40877. * An event triggered when the activeCamera property is updated
  40878. */
  40879. onActiveCameraChanged: Observable<Scene>;
  40880. /**
  40881. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  40882. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40883. * 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)
  40884. */
  40885. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40886. /**
  40887. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  40888. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40889. * 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)
  40890. */
  40891. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40892. /**
  40893. * This Observable will when a mesh has been imported into the scene.
  40894. */
  40895. onMeshImportedObservable: Observable<AbstractMesh>;
  40896. /**
  40897. * This Observable will when an animation file has been imported into the scene.
  40898. */
  40899. onAnimationFileImportedObservable: Observable<Scene>;
  40900. /**
  40901. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  40902. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  40903. */
  40904. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  40905. /** @hidden */
  40906. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  40907. /**
  40908. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  40909. */
  40910. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  40911. /**
  40912. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  40913. */
  40914. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  40915. /**
  40916. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  40917. */
  40918. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  40919. /** Callback called when a pointer move is detected */
  40920. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40921. /** Callback called when a pointer down is detected */
  40922. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40923. /** Callback called when a pointer up is detected */
  40924. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  40925. /** Callback called when a pointer pick is detected */
  40926. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  40927. /**
  40928. * 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).
  40929. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  40930. */
  40931. onPrePointerObservable: Observable<PointerInfoPre>;
  40932. /**
  40933. * Observable event triggered each time an input event is received from the rendering canvas
  40934. */
  40935. onPointerObservable: Observable<PointerInfo>;
  40936. /**
  40937. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  40938. */
  40939. get unTranslatedPointer(): Vector2;
  40940. /**
  40941. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  40942. */
  40943. static get DragMovementThreshold(): number;
  40944. static set DragMovementThreshold(value: number);
  40945. /**
  40946. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  40947. */
  40948. static get LongPressDelay(): number;
  40949. static set LongPressDelay(value: number);
  40950. /**
  40951. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  40952. */
  40953. static get DoubleClickDelay(): number;
  40954. static set DoubleClickDelay(value: number);
  40955. /** If you need to check double click without raising a single click at first click, enable this flag */
  40956. static get ExclusiveDoubleClickMode(): boolean;
  40957. static set ExclusiveDoubleClickMode(value: boolean);
  40958. /** @hidden */
  40959. _mirroredCameraPosition: Nullable<Vector3>;
  40960. /**
  40961. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  40962. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  40963. */
  40964. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  40965. /**
  40966. * Observable event triggered each time an keyboard event is received from the hosting window
  40967. */
  40968. onKeyboardObservable: Observable<KeyboardInfo>;
  40969. private _useRightHandedSystem;
  40970. /**
  40971. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  40972. */
  40973. set useRightHandedSystem(value: boolean);
  40974. get useRightHandedSystem(): boolean;
  40975. private _timeAccumulator;
  40976. private _currentStepId;
  40977. private _currentInternalStep;
  40978. /**
  40979. * Sets the step Id used by deterministic lock step
  40980. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40981. * @param newStepId defines the step Id
  40982. */
  40983. setStepId(newStepId: number): void;
  40984. /**
  40985. * Gets the step Id used by deterministic lock step
  40986. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40987. * @returns the step Id
  40988. */
  40989. getStepId(): number;
  40990. /**
  40991. * Gets the internal step used by deterministic lock step
  40992. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40993. * @returns the internal step
  40994. */
  40995. getInternalStep(): number;
  40996. private _fogEnabled;
  40997. /**
  40998. * Gets or sets a boolean indicating if fog is enabled on this scene
  40999. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41000. * (Default is true)
  41001. */
  41002. set fogEnabled(value: boolean);
  41003. get fogEnabled(): boolean;
  41004. private _fogMode;
  41005. /**
  41006. * Gets or sets the fog mode to use
  41007. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41008. * | mode | value |
  41009. * | --- | --- |
  41010. * | FOGMODE_NONE | 0 |
  41011. * | FOGMODE_EXP | 1 |
  41012. * | FOGMODE_EXP2 | 2 |
  41013. * | FOGMODE_LINEAR | 3 |
  41014. */
  41015. set fogMode(value: number);
  41016. get fogMode(): number;
  41017. /**
  41018. * Gets or sets the fog color to use
  41019. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41020. * (Default is Color3(0.2, 0.2, 0.3))
  41021. */
  41022. fogColor: Color3;
  41023. /**
  41024. * Gets or sets the fog density to use
  41025. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41026. * (Default is 0.1)
  41027. */
  41028. fogDensity: number;
  41029. /**
  41030. * Gets or sets the fog start distance to use
  41031. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41032. * (Default is 0)
  41033. */
  41034. fogStart: number;
  41035. /**
  41036. * Gets or sets the fog end distance to use
  41037. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41038. * (Default is 1000)
  41039. */
  41040. fogEnd: number;
  41041. /**
  41042. * Flag indicating that the frame buffer binding is handled by another component
  41043. */
  41044. prePass: boolean;
  41045. private _shadowsEnabled;
  41046. /**
  41047. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41048. */
  41049. set shadowsEnabled(value: boolean);
  41050. get shadowsEnabled(): boolean;
  41051. private _lightsEnabled;
  41052. /**
  41053. * Gets or sets a boolean indicating if lights are enabled on this scene
  41054. */
  41055. set lightsEnabled(value: boolean);
  41056. get lightsEnabled(): boolean;
  41057. /** All of the active cameras added to this scene. */
  41058. activeCameras: Camera[];
  41059. /** @hidden */
  41060. _activeCamera: Nullable<Camera>;
  41061. /** Gets or sets the current active camera */
  41062. get activeCamera(): Nullable<Camera>;
  41063. set activeCamera(value: Nullable<Camera>);
  41064. private _defaultMaterial;
  41065. /** The default material used on meshes when no material is affected */
  41066. get defaultMaterial(): Material;
  41067. /** The default material used on meshes when no material is affected */
  41068. set defaultMaterial(value: Material);
  41069. private _texturesEnabled;
  41070. /**
  41071. * Gets or sets a boolean indicating if textures are enabled on this scene
  41072. */
  41073. set texturesEnabled(value: boolean);
  41074. get texturesEnabled(): boolean;
  41075. /**
  41076. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41077. */
  41078. physicsEnabled: boolean;
  41079. /**
  41080. * Gets or sets a boolean indicating if particles are enabled on this scene
  41081. */
  41082. particlesEnabled: boolean;
  41083. /**
  41084. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41085. */
  41086. spritesEnabled: boolean;
  41087. private _skeletonsEnabled;
  41088. /**
  41089. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41090. */
  41091. set skeletonsEnabled(value: boolean);
  41092. get skeletonsEnabled(): boolean;
  41093. /**
  41094. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41095. */
  41096. lensFlaresEnabled: boolean;
  41097. /**
  41098. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41099. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41100. */
  41101. collisionsEnabled: boolean;
  41102. private _collisionCoordinator;
  41103. /** @hidden */
  41104. get collisionCoordinator(): ICollisionCoordinator;
  41105. /**
  41106. * Defines the gravity applied to this scene (used only for collisions)
  41107. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41108. */
  41109. gravity: Vector3;
  41110. /**
  41111. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41112. */
  41113. postProcessesEnabled: boolean;
  41114. /**
  41115. * The list of postprocesses added to the scene
  41116. */
  41117. postProcesses: PostProcess[];
  41118. /**
  41119. * Gets the current postprocess manager
  41120. */
  41121. postProcessManager: PostProcessManager;
  41122. /**
  41123. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41124. */
  41125. renderTargetsEnabled: boolean;
  41126. /**
  41127. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41128. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41129. */
  41130. dumpNextRenderTargets: boolean;
  41131. /**
  41132. * The list of user defined render targets added to the scene
  41133. */
  41134. customRenderTargets: RenderTargetTexture[];
  41135. /**
  41136. * Defines if texture loading must be delayed
  41137. * If true, textures will only be loaded when they need to be rendered
  41138. */
  41139. useDelayedTextureLoading: boolean;
  41140. /**
  41141. * Gets the list of meshes imported to the scene through SceneLoader
  41142. */
  41143. importedMeshesFiles: String[];
  41144. /**
  41145. * Gets or sets a boolean indicating if probes are enabled on this scene
  41146. */
  41147. probesEnabled: boolean;
  41148. /**
  41149. * Gets or sets the current offline provider to use to store scene data
  41150. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41151. */
  41152. offlineProvider: IOfflineProvider;
  41153. /**
  41154. * Gets or sets the action manager associated with the scene
  41155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41156. */
  41157. actionManager: AbstractActionManager;
  41158. private _meshesForIntersections;
  41159. /**
  41160. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41161. */
  41162. proceduralTexturesEnabled: boolean;
  41163. private _engine;
  41164. private _totalVertices;
  41165. /** @hidden */
  41166. _activeIndices: PerfCounter;
  41167. /** @hidden */
  41168. _activeParticles: PerfCounter;
  41169. /** @hidden */
  41170. _activeBones: PerfCounter;
  41171. private _animationRatio;
  41172. /** @hidden */
  41173. _animationTimeLast: number;
  41174. /** @hidden */
  41175. _animationTime: number;
  41176. /**
  41177. * Gets or sets a general scale for animation speed
  41178. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41179. */
  41180. animationTimeScale: number;
  41181. /** @hidden */
  41182. _cachedMaterial: Nullable<Material>;
  41183. /** @hidden */
  41184. _cachedEffect: Nullable<Effect>;
  41185. /** @hidden */
  41186. _cachedVisibility: Nullable<number>;
  41187. private _renderId;
  41188. private _frameId;
  41189. private _executeWhenReadyTimeoutId;
  41190. private _intermediateRendering;
  41191. private _viewUpdateFlag;
  41192. private _projectionUpdateFlag;
  41193. /** @hidden */
  41194. _toBeDisposed: Nullable<IDisposable>[];
  41195. private _activeRequests;
  41196. /** @hidden */
  41197. _pendingData: any[];
  41198. private _isDisposed;
  41199. /**
  41200. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41201. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41202. */
  41203. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41204. private _activeMeshes;
  41205. private _processedMaterials;
  41206. private _renderTargets;
  41207. /** @hidden */
  41208. _activeParticleSystems: SmartArray<IParticleSystem>;
  41209. private _activeSkeletons;
  41210. private _softwareSkinnedMeshes;
  41211. private _renderingManager;
  41212. /** @hidden */
  41213. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41214. private _transformMatrix;
  41215. private _sceneUbo;
  41216. /** @hidden */
  41217. _viewMatrix: Matrix;
  41218. private _projectionMatrix;
  41219. /** @hidden */
  41220. _forcedViewPosition: Nullable<Vector3>;
  41221. /** @hidden */
  41222. _frustumPlanes: Plane[];
  41223. /**
  41224. * Gets the list of frustum planes (built from the active camera)
  41225. */
  41226. get frustumPlanes(): Plane[];
  41227. /**
  41228. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41229. * This is useful if there are more lights that the maximum simulteanous authorized
  41230. */
  41231. requireLightSorting: boolean;
  41232. /** @hidden */
  41233. readonly useMaterialMeshMap: boolean;
  41234. /** @hidden */
  41235. readonly useClonedMeshMap: boolean;
  41236. private _externalData;
  41237. private _uid;
  41238. /**
  41239. * @hidden
  41240. * Backing store of defined scene components.
  41241. */
  41242. _components: ISceneComponent[];
  41243. /**
  41244. * @hidden
  41245. * Backing store of defined scene components.
  41246. */
  41247. _serializableComponents: ISceneSerializableComponent[];
  41248. /**
  41249. * List of components to register on the next registration step.
  41250. */
  41251. private _transientComponents;
  41252. /**
  41253. * Registers the transient components if needed.
  41254. */
  41255. private _registerTransientComponents;
  41256. /**
  41257. * @hidden
  41258. * Add a component to the scene.
  41259. * Note that the ccomponent could be registered on th next frame if this is called after
  41260. * the register component stage.
  41261. * @param component Defines the component to add to the scene
  41262. */
  41263. _addComponent(component: ISceneComponent): void;
  41264. /**
  41265. * @hidden
  41266. * Gets a component from the scene.
  41267. * @param name defines the name of the component to retrieve
  41268. * @returns the component or null if not present
  41269. */
  41270. _getComponent(name: string): Nullable<ISceneComponent>;
  41271. /**
  41272. * @hidden
  41273. * Defines the actions happening before camera updates.
  41274. */
  41275. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41276. /**
  41277. * @hidden
  41278. * Defines the actions happening before clear the canvas.
  41279. */
  41280. _beforeClearStage: Stage<SimpleStageAction>;
  41281. /**
  41282. * @hidden
  41283. * Defines the actions when collecting render targets for the frame.
  41284. */
  41285. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41286. /**
  41287. * @hidden
  41288. * Defines the actions happening for one camera in the frame.
  41289. */
  41290. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41291. /**
  41292. * @hidden
  41293. * Defines the actions happening during the per mesh ready checks.
  41294. */
  41295. _isReadyForMeshStage: Stage<MeshStageAction>;
  41296. /**
  41297. * @hidden
  41298. * Defines the actions happening before evaluate active mesh checks.
  41299. */
  41300. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41301. /**
  41302. * @hidden
  41303. * Defines the actions happening during the evaluate sub mesh checks.
  41304. */
  41305. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41306. /**
  41307. * @hidden
  41308. * Defines the actions happening during the active mesh stage.
  41309. */
  41310. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41311. /**
  41312. * @hidden
  41313. * Defines the actions happening during the per camera render target step.
  41314. */
  41315. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41316. /**
  41317. * @hidden
  41318. * Defines the actions happening just before the active camera is drawing.
  41319. */
  41320. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41321. /**
  41322. * @hidden
  41323. * Defines the actions happening just before a render target is drawing.
  41324. */
  41325. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41326. /**
  41327. * @hidden
  41328. * Defines the actions happening just before a rendering group is drawing.
  41329. */
  41330. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41331. /**
  41332. * @hidden
  41333. * Defines the actions happening just before a mesh is drawing.
  41334. */
  41335. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41336. /**
  41337. * @hidden
  41338. * Defines the actions happening just after a mesh has been drawn.
  41339. */
  41340. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41341. /**
  41342. * @hidden
  41343. * Defines the actions happening just after a rendering group has been drawn.
  41344. */
  41345. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41346. /**
  41347. * @hidden
  41348. * Defines the actions happening just after the active camera has been drawn.
  41349. */
  41350. _afterCameraDrawStage: Stage<CameraStageAction>;
  41351. /**
  41352. * @hidden
  41353. * Defines the actions happening just after a render target has been drawn.
  41354. */
  41355. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41356. /**
  41357. * @hidden
  41358. * Defines the actions happening just after rendering all cameras and computing intersections.
  41359. */
  41360. _afterRenderStage: Stage<SimpleStageAction>;
  41361. /**
  41362. * @hidden
  41363. * Defines the actions happening when a pointer move event happens.
  41364. */
  41365. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41366. /**
  41367. * @hidden
  41368. * Defines the actions happening when a pointer down event happens.
  41369. */
  41370. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41371. /**
  41372. * @hidden
  41373. * Defines the actions happening when a pointer up event happens.
  41374. */
  41375. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41376. /**
  41377. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41378. */
  41379. private geometriesByUniqueId;
  41380. /**
  41381. * Creates a new Scene
  41382. * @param engine defines the engine to use to render this scene
  41383. * @param options defines the scene options
  41384. */
  41385. constructor(engine: Engine, options?: SceneOptions);
  41386. /**
  41387. * Gets a string idenfifying the name of the class
  41388. * @returns "Scene" string
  41389. */
  41390. getClassName(): string;
  41391. private _defaultMeshCandidates;
  41392. /**
  41393. * @hidden
  41394. */
  41395. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41396. private _defaultSubMeshCandidates;
  41397. /**
  41398. * @hidden
  41399. */
  41400. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41401. /**
  41402. * Sets the default candidate providers for the scene.
  41403. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41404. * and getCollidingSubMeshCandidates to their default function
  41405. */
  41406. setDefaultCandidateProviders(): void;
  41407. /**
  41408. * Gets the mesh that is currently under the pointer
  41409. */
  41410. get meshUnderPointer(): Nullable<AbstractMesh>;
  41411. /**
  41412. * Gets or sets the current on-screen X position of the pointer
  41413. */
  41414. get pointerX(): number;
  41415. set pointerX(value: number);
  41416. /**
  41417. * Gets or sets the current on-screen Y position of the pointer
  41418. */
  41419. get pointerY(): number;
  41420. set pointerY(value: number);
  41421. /**
  41422. * Gets the cached material (ie. the latest rendered one)
  41423. * @returns the cached material
  41424. */
  41425. getCachedMaterial(): Nullable<Material>;
  41426. /**
  41427. * Gets the cached effect (ie. the latest rendered one)
  41428. * @returns the cached effect
  41429. */
  41430. getCachedEffect(): Nullable<Effect>;
  41431. /**
  41432. * Gets the cached visibility state (ie. the latest rendered one)
  41433. * @returns the cached visibility state
  41434. */
  41435. getCachedVisibility(): Nullable<number>;
  41436. /**
  41437. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41438. * @param material defines the current material
  41439. * @param effect defines the current effect
  41440. * @param visibility defines the current visibility state
  41441. * @returns true if one parameter is not cached
  41442. */
  41443. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41444. /**
  41445. * Gets the engine associated with the scene
  41446. * @returns an Engine
  41447. */
  41448. getEngine(): Engine;
  41449. /**
  41450. * Gets the total number of vertices rendered per frame
  41451. * @returns the total number of vertices rendered per frame
  41452. */
  41453. getTotalVertices(): number;
  41454. /**
  41455. * Gets the performance counter for total vertices
  41456. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41457. */
  41458. get totalVerticesPerfCounter(): PerfCounter;
  41459. /**
  41460. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41461. * @returns the total number of active indices rendered per frame
  41462. */
  41463. getActiveIndices(): number;
  41464. /**
  41465. * Gets the performance counter for active indices
  41466. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41467. */
  41468. get totalActiveIndicesPerfCounter(): PerfCounter;
  41469. /**
  41470. * Gets the total number of active particles rendered per frame
  41471. * @returns the total number of active particles rendered per frame
  41472. */
  41473. getActiveParticles(): number;
  41474. /**
  41475. * Gets the performance counter for active particles
  41476. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41477. */
  41478. get activeParticlesPerfCounter(): PerfCounter;
  41479. /**
  41480. * Gets the total number of active bones rendered per frame
  41481. * @returns the total number of active bones rendered per frame
  41482. */
  41483. getActiveBones(): number;
  41484. /**
  41485. * Gets the performance counter for active bones
  41486. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41487. */
  41488. get activeBonesPerfCounter(): PerfCounter;
  41489. /**
  41490. * Gets the array of active meshes
  41491. * @returns an array of AbstractMesh
  41492. */
  41493. getActiveMeshes(): SmartArray<AbstractMesh>;
  41494. /**
  41495. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41496. * @returns a number
  41497. */
  41498. getAnimationRatio(): number;
  41499. /**
  41500. * Gets an unique Id for the current render phase
  41501. * @returns a number
  41502. */
  41503. getRenderId(): number;
  41504. /**
  41505. * Gets an unique Id for the current frame
  41506. * @returns a number
  41507. */
  41508. getFrameId(): number;
  41509. /** Call this function if you want to manually increment the render Id*/
  41510. incrementRenderId(): void;
  41511. private _createUbo;
  41512. /**
  41513. * Use this method to simulate a pointer move on a mesh
  41514. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41515. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41516. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41517. * @returns the current scene
  41518. */
  41519. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41520. /**
  41521. * Use this method to simulate a pointer down on a mesh
  41522. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41523. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41524. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41525. * @returns the current scene
  41526. */
  41527. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41528. /**
  41529. * Use this method to simulate a pointer up on a mesh
  41530. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41531. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41532. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41533. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41534. * @returns the current scene
  41535. */
  41536. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41537. /**
  41538. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41539. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41540. * @returns true if the pointer was captured
  41541. */
  41542. isPointerCaptured(pointerId?: number): boolean;
  41543. /**
  41544. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41545. * @param attachUp defines if you want to attach events to pointerup
  41546. * @param attachDown defines if you want to attach events to pointerdown
  41547. * @param attachMove defines if you want to attach events to pointermove
  41548. */
  41549. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41550. /** Detaches all event handlers*/
  41551. detachControl(): void;
  41552. /**
  41553. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41554. * Delay loaded resources are not taking in account
  41555. * @return true if all required resources are ready
  41556. */
  41557. isReady(): boolean;
  41558. /** Resets all cached information relative to material (including effect and visibility) */
  41559. resetCachedMaterial(): void;
  41560. /**
  41561. * Registers a function to be called before every frame render
  41562. * @param func defines the function to register
  41563. */
  41564. registerBeforeRender(func: () => void): void;
  41565. /**
  41566. * Unregisters a function called before every frame render
  41567. * @param func defines the function to unregister
  41568. */
  41569. unregisterBeforeRender(func: () => void): void;
  41570. /**
  41571. * Registers a function to be called after every frame render
  41572. * @param func defines the function to register
  41573. */
  41574. registerAfterRender(func: () => void): void;
  41575. /**
  41576. * Unregisters a function called after every frame render
  41577. * @param func defines the function to unregister
  41578. */
  41579. unregisterAfterRender(func: () => void): void;
  41580. private _executeOnceBeforeRender;
  41581. /**
  41582. * The provided function will run before render once and will be disposed afterwards.
  41583. * A timeout delay can be provided so that the function will be executed in N ms.
  41584. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41585. * @param func The function to be executed.
  41586. * @param timeout optional delay in ms
  41587. */
  41588. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41589. /** @hidden */
  41590. _addPendingData(data: any): void;
  41591. /** @hidden */
  41592. _removePendingData(data: any): void;
  41593. /**
  41594. * Returns the number of items waiting to be loaded
  41595. * @returns the number of items waiting to be loaded
  41596. */
  41597. getWaitingItemsCount(): number;
  41598. /**
  41599. * Returns a boolean indicating if the scene is still loading data
  41600. */
  41601. get isLoading(): boolean;
  41602. /**
  41603. * Registers a function to be executed when the scene is ready
  41604. * @param {Function} func - the function to be executed
  41605. */
  41606. executeWhenReady(func: () => void): void;
  41607. /**
  41608. * Returns a promise that resolves when the scene is ready
  41609. * @returns A promise that resolves when the scene is ready
  41610. */
  41611. whenReadyAsync(): Promise<void>;
  41612. /** @hidden */
  41613. _checkIsReady(): void;
  41614. /**
  41615. * Gets all animatable attached to the scene
  41616. */
  41617. get animatables(): Animatable[];
  41618. /**
  41619. * Resets the last animation time frame.
  41620. * Useful to override when animations start running when loading a scene for the first time.
  41621. */
  41622. resetLastAnimationTimeFrame(): void;
  41623. /**
  41624. * Gets the current view matrix
  41625. * @returns a Matrix
  41626. */
  41627. getViewMatrix(): Matrix;
  41628. /**
  41629. * Gets the current projection matrix
  41630. * @returns a Matrix
  41631. */
  41632. getProjectionMatrix(): Matrix;
  41633. /**
  41634. * Gets the current transform matrix
  41635. * @returns a Matrix made of View * Projection
  41636. */
  41637. getTransformMatrix(): Matrix;
  41638. /**
  41639. * Sets the current transform matrix
  41640. * @param viewL defines the View matrix to use
  41641. * @param projectionL defines the Projection matrix to use
  41642. * @param viewR defines the right View matrix to use (if provided)
  41643. * @param projectionR defines the right Projection matrix to use (if provided)
  41644. */
  41645. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41646. /**
  41647. * Gets the uniform buffer used to store scene data
  41648. * @returns a UniformBuffer
  41649. */
  41650. getSceneUniformBuffer(): UniformBuffer;
  41651. /**
  41652. * Gets an unique (relatively to the current scene) Id
  41653. * @returns an unique number for the scene
  41654. */
  41655. getUniqueId(): number;
  41656. /**
  41657. * Add a mesh to the list of scene's meshes
  41658. * @param newMesh defines the mesh to add
  41659. * @param recursive if all child meshes should also be added to the scene
  41660. */
  41661. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41662. /**
  41663. * Remove a mesh for the list of scene's meshes
  41664. * @param toRemove defines the mesh to remove
  41665. * @param recursive if all child meshes should also be removed from the scene
  41666. * @returns the index where the mesh was in the mesh list
  41667. */
  41668. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41669. /**
  41670. * Add a transform node to the list of scene's transform nodes
  41671. * @param newTransformNode defines the transform node to add
  41672. */
  41673. addTransformNode(newTransformNode: TransformNode): void;
  41674. /**
  41675. * Remove a transform node for the list of scene's transform nodes
  41676. * @param toRemove defines the transform node to remove
  41677. * @returns the index where the transform node was in the transform node list
  41678. */
  41679. removeTransformNode(toRemove: TransformNode): number;
  41680. /**
  41681. * Remove a skeleton for the list of scene's skeletons
  41682. * @param toRemove defines the skeleton to remove
  41683. * @returns the index where the skeleton was in the skeleton list
  41684. */
  41685. removeSkeleton(toRemove: Skeleton): number;
  41686. /**
  41687. * Remove a morph target for the list of scene's morph targets
  41688. * @param toRemove defines the morph target to remove
  41689. * @returns the index where the morph target was in the morph target list
  41690. */
  41691. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41692. /**
  41693. * Remove a light for the list of scene's lights
  41694. * @param toRemove defines the light to remove
  41695. * @returns the index where the light was in the light list
  41696. */
  41697. removeLight(toRemove: Light): number;
  41698. /**
  41699. * Remove a camera for the list of scene's cameras
  41700. * @param toRemove defines the camera to remove
  41701. * @returns the index where the camera was in the camera list
  41702. */
  41703. removeCamera(toRemove: Camera): number;
  41704. /**
  41705. * Remove a particle system for the list of scene's particle systems
  41706. * @param toRemove defines the particle system to remove
  41707. * @returns the index where the particle system was in the particle system list
  41708. */
  41709. removeParticleSystem(toRemove: IParticleSystem): number;
  41710. /**
  41711. * Remove a animation for the list of scene's animations
  41712. * @param toRemove defines the animation to remove
  41713. * @returns the index where the animation was in the animation list
  41714. */
  41715. removeAnimation(toRemove: Animation): number;
  41716. /**
  41717. * Will stop the animation of the given target
  41718. * @param target - the target
  41719. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  41720. * @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)
  41721. */
  41722. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  41723. /**
  41724. * Removes the given animation group from this scene.
  41725. * @param toRemove The animation group to remove
  41726. * @returns The index of the removed animation group
  41727. */
  41728. removeAnimationGroup(toRemove: AnimationGroup): number;
  41729. /**
  41730. * Removes the given multi-material from this scene.
  41731. * @param toRemove The multi-material to remove
  41732. * @returns The index of the removed multi-material
  41733. */
  41734. removeMultiMaterial(toRemove: MultiMaterial): number;
  41735. /**
  41736. * Removes the given material from this scene.
  41737. * @param toRemove The material to remove
  41738. * @returns The index of the removed material
  41739. */
  41740. removeMaterial(toRemove: Material): number;
  41741. /**
  41742. * Removes the given action manager from this scene.
  41743. * @param toRemove The action manager to remove
  41744. * @returns The index of the removed action manager
  41745. */
  41746. removeActionManager(toRemove: AbstractActionManager): number;
  41747. /**
  41748. * Removes the given texture from this scene.
  41749. * @param toRemove The texture to remove
  41750. * @returns The index of the removed texture
  41751. */
  41752. removeTexture(toRemove: BaseTexture): number;
  41753. /**
  41754. * Adds the given light to this scene
  41755. * @param newLight The light to add
  41756. */
  41757. addLight(newLight: Light): void;
  41758. /**
  41759. * Sorts the list list based on light priorities
  41760. */
  41761. sortLightsByPriority(): void;
  41762. /**
  41763. * Adds the given camera to this scene
  41764. * @param newCamera The camera to add
  41765. */
  41766. addCamera(newCamera: Camera): void;
  41767. /**
  41768. * Adds the given skeleton to this scene
  41769. * @param newSkeleton The skeleton to add
  41770. */
  41771. addSkeleton(newSkeleton: Skeleton): void;
  41772. /**
  41773. * Adds the given particle system to this scene
  41774. * @param newParticleSystem The particle system to add
  41775. */
  41776. addParticleSystem(newParticleSystem: IParticleSystem): void;
  41777. /**
  41778. * Adds the given animation to this scene
  41779. * @param newAnimation The animation to add
  41780. */
  41781. addAnimation(newAnimation: Animation): void;
  41782. /**
  41783. * Adds the given animation group to this scene.
  41784. * @param newAnimationGroup The animation group to add
  41785. */
  41786. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  41787. /**
  41788. * Adds the given multi-material to this scene
  41789. * @param newMultiMaterial The multi-material to add
  41790. */
  41791. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  41792. /**
  41793. * Adds the given material to this scene
  41794. * @param newMaterial The material to add
  41795. */
  41796. addMaterial(newMaterial: Material): void;
  41797. /**
  41798. * Adds the given morph target to this scene
  41799. * @param newMorphTargetManager The morph target to add
  41800. */
  41801. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  41802. /**
  41803. * Adds the given geometry to this scene
  41804. * @param newGeometry The geometry to add
  41805. */
  41806. addGeometry(newGeometry: Geometry): void;
  41807. /**
  41808. * Adds the given action manager to this scene
  41809. * @param newActionManager The action manager to add
  41810. */
  41811. addActionManager(newActionManager: AbstractActionManager): void;
  41812. /**
  41813. * Adds the given texture to this scene.
  41814. * @param newTexture The texture to add
  41815. */
  41816. addTexture(newTexture: BaseTexture): void;
  41817. /**
  41818. * Switch active camera
  41819. * @param newCamera defines the new active camera
  41820. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  41821. */
  41822. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  41823. /**
  41824. * sets the active camera of the scene using its ID
  41825. * @param id defines the camera's ID
  41826. * @return the new active camera or null if none found.
  41827. */
  41828. setActiveCameraByID(id: string): Nullable<Camera>;
  41829. /**
  41830. * sets the active camera of the scene using its name
  41831. * @param name defines the camera's name
  41832. * @returns the new active camera or null if none found.
  41833. */
  41834. setActiveCameraByName(name: string): Nullable<Camera>;
  41835. /**
  41836. * get an animation group using its name
  41837. * @param name defines the material's name
  41838. * @return the animation group or null if none found.
  41839. */
  41840. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  41841. /**
  41842. * Get a material using its unique id
  41843. * @param uniqueId defines the material's unique id
  41844. * @return the material or null if none found.
  41845. */
  41846. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  41847. /**
  41848. * get a material using its id
  41849. * @param id defines the material's ID
  41850. * @return the material or null if none found.
  41851. */
  41852. getMaterialByID(id: string): Nullable<Material>;
  41853. /**
  41854. * Gets a the last added material using a given id
  41855. * @param id defines the material's ID
  41856. * @return the last material with the given id or null if none found.
  41857. */
  41858. getLastMaterialByID(id: string): Nullable<Material>;
  41859. /**
  41860. * Gets a material using its name
  41861. * @param name defines the material's name
  41862. * @return the material or null if none found.
  41863. */
  41864. getMaterialByName(name: string): Nullable<Material>;
  41865. /**
  41866. * Get a texture using its unique id
  41867. * @param uniqueId defines the texture's unique id
  41868. * @return the texture or null if none found.
  41869. */
  41870. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  41871. /**
  41872. * Gets a camera using its id
  41873. * @param id defines the id to look for
  41874. * @returns the camera or null if not found
  41875. */
  41876. getCameraByID(id: string): Nullable<Camera>;
  41877. /**
  41878. * Gets a camera using its unique id
  41879. * @param uniqueId defines the unique id to look for
  41880. * @returns the camera or null if not found
  41881. */
  41882. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  41883. /**
  41884. * Gets a camera using its name
  41885. * @param name defines the camera's name
  41886. * @return the camera or null if none found.
  41887. */
  41888. getCameraByName(name: string): Nullable<Camera>;
  41889. /**
  41890. * Gets a bone using its id
  41891. * @param id defines the bone's id
  41892. * @return the bone or null if not found
  41893. */
  41894. getBoneByID(id: string): Nullable<Bone>;
  41895. /**
  41896. * Gets a bone using its id
  41897. * @param name defines the bone's name
  41898. * @return the bone or null if not found
  41899. */
  41900. getBoneByName(name: string): Nullable<Bone>;
  41901. /**
  41902. * Gets a light node using its name
  41903. * @param name defines the the light's name
  41904. * @return the light or null if none found.
  41905. */
  41906. getLightByName(name: string): Nullable<Light>;
  41907. /**
  41908. * Gets a light node using its id
  41909. * @param id defines the light's id
  41910. * @return the light or null if none found.
  41911. */
  41912. getLightByID(id: string): Nullable<Light>;
  41913. /**
  41914. * Gets a light node using its scene-generated unique ID
  41915. * @param uniqueId defines the light's unique id
  41916. * @return the light or null if none found.
  41917. */
  41918. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  41919. /**
  41920. * Gets a particle system by id
  41921. * @param id defines the particle system id
  41922. * @return the corresponding system or null if none found
  41923. */
  41924. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  41925. /**
  41926. * Gets a geometry using its ID
  41927. * @param id defines the geometry's id
  41928. * @return the geometry or null if none found.
  41929. */
  41930. getGeometryByID(id: string): Nullable<Geometry>;
  41931. private _getGeometryByUniqueID;
  41932. /**
  41933. * Add a new geometry to this scene
  41934. * @param geometry defines the geometry to be added to the scene.
  41935. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  41936. * @return a boolean defining if the geometry was added or not
  41937. */
  41938. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  41939. /**
  41940. * Removes an existing geometry
  41941. * @param geometry defines the geometry to be removed from the scene
  41942. * @return a boolean defining if the geometry was removed or not
  41943. */
  41944. removeGeometry(geometry: Geometry): boolean;
  41945. /**
  41946. * Gets the list of geometries attached to the scene
  41947. * @returns an array of Geometry
  41948. */
  41949. getGeometries(): Geometry[];
  41950. /**
  41951. * Gets the first added mesh found of a given ID
  41952. * @param id defines the id to search for
  41953. * @return the mesh found or null if not found at all
  41954. */
  41955. getMeshByID(id: string): Nullable<AbstractMesh>;
  41956. /**
  41957. * Gets a list of meshes using their id
  41958. * @param id defines the id to search for
  41959. * @returns a list of meshes
  41960. */
  41961. getMeshesByID(id: string): Array<AbstractMesh>;
  41962. /**
  41963. * Gets the first added transform node found of a given ID
  41964. * @param id defines the id to search for
  41965. * @return the found transform node or null if not found at all.
  41966. */
  41967. getTransformNodeByID(id: string): Nullable<TransformNode>;
  41968. /**
  41969. * Gets a transform node with its auto-generated unique id
  41970. * @param uniqueId efines the unique id to search for
  41971. * @return the found transform node or null if not found at all.
  41972. */
  41973. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  41974. /**
  41975. * Gets a list of transform nodes using their id
  41976. * @param id defines the id to search for
  41977. * @returns a list of transform nodes
  41978. */
  41979. getTransformNodesByID(id: string): Array<TransformNode>;
  41980. /**
  41981. * Gets a mesh with its auto-generated unique id
  41982. * @param uniqueId defines the unique id to search for
  41983. * @return the found mesh or null if not found at all.
  41984. */
  41985. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  41986. /**
  41987. * Gets a the last added mesh using a given id
  41988. * @param id defines the id to search for
  41989. * @return the found mesh or null if not found at all.
  41990. */
  41991. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  41992. /**
  41993. * Gets a the last added node (Mesh, Camera, Light) using a given id
  41994. * @param id defines the id to search for
  41995. * @return the found node or null if not found at all
  41996. */
  41997. getLastEntryByID(id: string): Nullable<Node>;
  41998. /**
  41999. * Gets a node (Mesh, Camera, Light) using a given id
  42000. * @param id defines the id to search for
  42001. * @return the found node or null if not found at all
  42002. */
  42003. getNodeByID(id: string): Nullable<Node>;
  42004. /**
  42005. * Gets a node (Mesh, Camera, Light) using a given name
  42006. * @param name defines the name to search for
  42007. * @return the found node or null if not found at all.
  42008. */
  42009. getNodeByName(name: string): Nullable<Node>;
  42010. /**
  42011. * Gets a mesh using a given name
  42012. * @param name defines the name to search for
  42013. * @return the found mesh or null if not found at all.
  42014. */
  42015. getMeshByName(name: string): Nullable<AbstractMesh>;
  42016. /**
  42017. * Gets a transform node using a given name
  42018. * @param name defines the name to search for
  42019. * @return the found transform node or null if not found at all.
  42020. */
  42021. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42022. /**
  42023. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42024. * @param id defines the id to search for
  42025. * @return the found skeleton or null if not found at all.
  42026. */
  42027. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42028. /**
  42029. * Gets a skeleton using a given auto generated unique id
  42030. * @param uniqueId defines the unique id to search for
  42031. * @return the found skeleton or null if not found at all.
  42032. */
  42033. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42034. /**
  42035. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42036. * @param id defines the id to search for
  42037. * @return the found skeleton or null if not found at all.
  42038. */
  42039. getSkeletonById(id: string): Nullable<Skeleton>;
  42040. /**
  42041. * Gets a skeleton using a given name
  42042. * @param name defines the name to search for
  42043. * @return the found skeleton or null if not found at all.
  42044. */
  42045. getSkeletonByName(name: string): Nullable<Skeleton>;
  42046. /**
  42047. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42048. * @param id defines the id to search for
  42049. * @return the found morph target manager or null if not found at all.
  42050. */
  42051. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42052. /**
  42053. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42054. * @param id defines the id to search for
  42055. * @return the found morph target or null if not found at all.
  42056. */
  42057. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42058. /**
  42059. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42060. * @param name defines the name to search for
  42061. * @return the found morph target or null if not found at all.
  42062. */
  42063. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42064. /**
  42065. * Gets a boolean indicating if the given mesh is active
  42066. * @param mesh defines the mesh to look for
  42067. * @returns true if the mesh is in the active list
  42068. */
  42069. isActiveMesh(mesh: AbstractMesh): boolean;
  42070. /**
  42071. * Return a unique id as a string which can serve as an identifier for the scene
  42072. */
  42073. get uid(): string;
  42074. /**
  42075. * Add an externaly attached data from its key.
  42076. * This method call will fail and return false, if such key already exists.
  42077. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42078. * @param key the unique key that identifies the data
  42079. * @param data the data object to associate to the key for this Engine instance
  42080. * @return true if no such key were already present and the data was added successfully, false otherwise
  42081. */
  42082. addExternalData<T>(key: string, data: T): boolean;
  42083. /**
  42084. * Get an externaly attached data from its key
  42085. * @param key the unique key that identifies the data
  42086. * @return the associated data, if present (can be null), or undefined if not present
  42087. */
  42088. getExternalData<T>(key: string): Nullable<T>;
  42089. /**
  42090. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42091. * @param key the unique key that identifies the data
  42092. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42093. * @return the associated data, can be null if the factory returned null.
  42094. */
  42095. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42096. /**
  42097. * Remove an externaly attached data from the Engine instance
  42098. * @param key the unique key that identifies the data
  42099. * @return true if the data was successfully removed, false if it doesn't exist
  42100. */
  42101. removeExternalData(key: string): boolean;
  42102. private _evaluateSubMesh;
  42103. /**
  42104. * Clear the processed materials smart array preventing retention point in material dispose.
  42105. */
  42106. freeProcessedMaterials(): void;
  42107. private _preventFreeActiveMeshesAndRenderingGroups;
  42108. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42109. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42110. * when disposing several meshes in a row or a hierarchy of meshes.
  42111. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42112. */
  42113. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42114. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42115. /**
  42116. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42117. */
  42118. freeActiveMeshes(): void;
  42119. /**
  42120. * Clear the info related to rendering groups preventing retention points during dispose.
  42121. */
  42122. freeRenderingGroups(): void;
  42123. /** @hidden */
  42124. _isInIntermediateRendering(): boolean;
  42125. /**
  42126. * Lambda returning the list of potentially active meshes.
  42127. */
  42128. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42129. /**
  42130. * Lambda returning the list of potentially active sub meshes.
  42131. */
  42132. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42133. /**
  42134. * Lambda returning the list of potentially intersecting sub meshes.
  42135. */
  42136. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42137. /**
  42138. * Lambda returning the list of potentially colliding sub meshes.
  42139. */
  42140. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42141. private _activeMeshesFrozen;
  42142. private _skipEvaluateActiveMeshesCompletely;
  42143. /**
  42144. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42145. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42146. * @returns the current scene
  42147. */
  42148. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42149. /**
  42150. * Use this function to restart evaluating active meshes on every frame
  42151. * @returns the current scene
  42152. */
  42153. unfreezeActiveMeshes(): Scene;
  42154. private _evaluateActiveMeshes;
  42155. private _activeMesh;
  42156. /**
  42157. * Update the transform matrix to update from the current active camera
  42158. * @param force defines a boolean used to force the update even if cache is up to date
  42159. */
  42160. updateTransformMatrix(force?: boolean): void;
  42161. private _bindFrameBuffer;
  42162. /** @hidden */
  42163. _allowPostProcessClearColor: boolean;
  42164. /** @hidden */
  42165. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42166. private _processSubCameras;
  42167. private _checkIntersections;
  42168. /** @hidden */
  42169. _advancePhysicsEngineStep(step: number): void;
  42170. /**
  42171. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42172. */
  42173. getDeterministicFrameTime: () => number;
  42174. /** @hidden */
  42175. _animate(): void;
  42176. /** Execute all animations (for a frame) */
  42177. animate(): void;
  42178. /**
  42179. * Render the scene
  42180. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42181. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42182. */
  42183. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42184. /**
  42185. * Freeze all materials
  42186. * A frozen material will not be updatable but should be faster to render
  42187. */
  42188. freezeMaterials(): void;
  42189. /**
  42190. * Unfreeze all materials
  42191. * A frozen material will not be updatable but should be faster to render
  42192. */
  42193. unfreezeMaterials(): void;
  42194. /**
  42195. * Releases all held ressources
  42196. */
  42197. dispose(): void;
  42198. /**
  42199. * Gets if the scene is already disposed
  42200. */
  42201. get isDisposed(): boolean;
  42202. /**
  42203. * Call this function to reduce memory footprint of the scene.
  42204. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42205. */
  42206. clearCachedVertexData(): void;
  42207. /**
  42208. * This function will remove the local cached buffer data from texture.
  42209. * It will save memory but will prevent the texture from being rebuilt
  42210. */
  42211. cleanCachedTextureBuffer(): void;
  42212. /**
  42213. * Get the world extend vectors with an optional filter
  42214. *
  42215. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42216. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42217. */
  42218. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42219. min: Vector3;
  42220. max: Vector3;
  42221. };
  42222. /**
  42223. * Creates a ray that can be used to pick in the scene
  42224. * @param x defines the x coordinate of the origin (on-screen)
  42225. * @param y defines the y coordinate of the origin (on-screen)
  42226. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42227. * @param camera defines the camera to use for the picking
  42228. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42229. * @returns a Ray
  42230. */
  42231. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42232. /**
  42233. * Creates a ray that can be used to pick in the scene
  42234. * @param x defines the x coordinate of the origin (on-screen)
  42235. * @param y defines the y coordinate of the origin (on-screen)
  42236. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42237. * @param result defines the ray where to store the picking ray
  42238. * @param camera defines the camera to use for the picking
  42239. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42240. * @returns the current scene
  42241. */
  42242. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42243. /**
  42244. * Creates a ray that can be used to pick in the scene
  42245. * @param x defines the x coordinate of the origin (on-screen)
  42246. * @param y defines the y coordinate of the origin (on-screen)
  42247. * @param camera defines the camera to use for the picking
  42248. * @returns a Ray
  42249. */
  42250. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42251. /**
  42252. * Creates a ray that can be used to pick in the scene
  42253. * @param x defines the x coordinate of the origin (on-screen)
  42254. * @param y defines the y coordinate of the origin (on-screen)
  42255. * @param result defines the ray where to store the picking ray
  42256. * @param camera defines the camera to use for the picking
  42257. * @returns the current scene
  42258. */
  42259. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42260. /** Launch a ray to try to pick a mesh in the scene
  42261. * @param x position on screen
  42262. * @param y position on screen
  42263. * @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
  42264. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42265. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42266. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42267. * @returns a PickingInfo
  42268. */
  42269. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42270. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42271. * @param x position on screen
  42272. * @param y position on screen
  42273. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  42274. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42275. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42276. * @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)
  42277. */
  42278. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42279. /** Use the given ray to pick a mesh in the scene
  42280. * @param ray The ray to use to pick meshes
  42281. * @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
  42282. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42283. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42284. * @returns a PickingInfo
  42285. */
  42286. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42287. /**
  42288. * Launch a ray to try to pick a mesh in the scene
  42289. * @param x X position on screen
  42290. * @param y Y position on screen
  42291. * @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
  42292. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42293. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42294. * @returns an array of PickingInfo
  42295. */
  42296. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42297. /**
  42298. * Launch a ray to try to pick a mesh in the scene
  42299. * @param ray Ray to use
  42300. * @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
  42301. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42302. * @returns an array of PickingInfo
  42303. */
  42304. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42305. /**
  42306. * Force the value of meshUnderPointer
  42307. * @param mesh defines the mesh to use
  42308. */
  42309. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  42310. /**
  42311. * Gets the mesh under the pointer
  42312. * @returns a Mesh or null if no mesh is under the pointer
  42313. */
  42314. getPointerOverMesh(): Nullable<AbstractMesh>;
  42315. /** @hidden */
  42316. _rebuildGeometries(): void;
  42317. /** @hidden */
  42318. _rebuildTextures(): void;
  42319. private _getByTags;
  42320. /**
  42321. * Get a list of meshes by tags
  42322. * @param tagsQuery defines the tags query to use
  42323. * @param forEach defines a predicate used to filter results
  42324. * @returns an array of Mesh
  42325. */
  42326. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42327. /**
  42328. * Get a list of cameras by tags
  42329. * @param tagsQuery defines the tags query to use
  42330. * @param forEach defines a predicate used to filter results
  42331. * @returns an array of Camera
  42332. */
  42333. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42334. /**
  42335. * Get a list of lights by tags
  42336. * @param tagsQuery defines the tags query to use
  42337. * @param forEach defines a predicate used to filter results
  42338. * @returns an array of Light
  42339. */
  42340. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42341. /**
  42342. * Get a list of materials by tags
  42343. * @param tagsQuery defines the tags query to use
  42344. * @param forEach defines a predicate used to filter results
  42345. * @returns an array of Material
  42346. */
  42347. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42348. /**
  42349. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42350. * This allowed control for front to back rendering or reversly depending of the special needs.
  42351. *
  42352. * @param renderingGroupId The rendering group id corresponding to its index
  42353. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42354. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42355. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42356. */
  42357. 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;
  42358. /**
  42359. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42360. *
  42361. * @param renderingGroupId The rendering group id corresponding to its index
  42362. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42363. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42364. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42365. */
  42366. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42367. /**
  42368. * Gets the current auto clear configuration for one rendering group of the rendering
  42369. * manager.
  42370. * @param index the rendering group index to get the information for
  42371. * @returns The auto clear setup for the requested rendering group
  42372. */
  42373. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42374. private _blockMaterialDirtyMechanism;
  42375. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42376. get blockMaterialDirtyMechanism(): boolean;
  42377. set blockMaterialDirtyMechanism(value: boolean);
  42378. /**
  42379. * Will flag all materials as dirty to trigger new shader compilation
  42380. * @param flag defines the flag used to specify which material part must be marked as dirty
  42381. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42382. */
  42383. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42384. /** @hidden */
  42385. _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;
  42386. /** @hidden */
  42387. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42388. /** @hidden */
  42389. _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;
  42390. /** @hidden */
  42391. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42392. /** @hidden */
  42393. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42394. /** @hidden */
  42395. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42396. }
  42397. }
  42398. declare module "babylonjs/assetContainer" {
  42399. import { AbstractScene } from "babylonjs/abstractScene";
  42400. import { Scene } from "babylonjs/scene";
  42401. import { Mesh } from "babylonjs/Meshes/mesh";
  42402. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42403. import { Skeleton } from "babylonjs/Bones/skeleton";
  42404. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42405. import { Animatable } from "babylonjs/Animations/animatable";
  42406. import { Nullable } from "babylonjs/types";
  42407. import { Node } from "babylonjs/node";
  42408. /**
  42409. * Set of assets to keep when moving a scene into an asset container.
  42410. */
  42411. export class KeepAssets extends AbstractScene {
  42412. }
  42413. /**
  42414. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42415. */
  42416. export class InstantiatedEntries {
  42417. /**
  42418. * List of new root nodes (eg. nodes with no parent)
  42419. */
  42420. rootNodes: TransformNode[];
  42421. /**
  42422. * List of new skeletons
  42423. */
  42424. skeletons: Skeleton[];
  42425. /**
  42426. * List of new animation groups
  42427. */
  42428. animationGroups: AnimationGroup[];
  42429. }
  42430. /**
  42431. * Container with a set of assets that can be added or removed from a scene.
  42432. */
  42433. export class AssetContainer extends AbstractScene {
  42434. private _wasAddedToScene;
  42435. /**
  42436. * The scene the AssetContainer belongs to.
  42437. */
  42438. scene: Scene;
  42439. /**
  42440. * Instantiates an AssetContainer.
  42441. * @param scene The scene the AssetContainer belongs to.
  42442. */
  42443. constructor(scene: Scene);
  42444. /**
  42445. * Instantiate or clone all meshes and add the new ones to the scene.
  42446. * Skeletons and animation groups will all be cloned
  42447. * @param nameFunction defines an optional function used to get new names for clones
  42448. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42449. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42450. */
  42451. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42452. /**
  42453. * Adds all the assets from the container to the scene.
  42454. */
  42455. addAllToScene(): void;
  42456. /**
  42457. * Removes all the assets in the container from the scene
  42458. */
  42459. removeAllFromScene(): void;
  42460. /**
  42461. * Disposes all the assets in the container
  42462. */
  42463. dispose(): void;
  42464. private _moveAssets;
  42465. /**
  42466. * Removes all the assets contained in the scene and adds them to the container.
  42467. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42468. */
  42469. moveAllFromScene(keepAssets?: KeepAssets): void;
  42470. /**
  42471. * 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.
  42472. * @returns the root mesh
  42473. */
  42474. createRootMesh(): Mesh;
  42475. /**
  42476. * Merge animations (direct and animation groups) from this asset container into a scene
  42477. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42478. * @param animatables set of animatables to retarget to a node from the scene
  42479. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42480. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42481. */
  42482. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42483. }
  42484. }
  42485. declare module "babylonjs/abstractScene" {
  42486. import { Scene } from "babylonjs/scene";
  42487. import { Nullable } from "babylonjs/types";
  42488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42489. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42490. import { Geometry } from "babylonjs/Meshes/geometry";
  42491. import { Skeleton } from "babylonjs/Bones/skeleton";
  42492. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42493. import { AssetContainer } from "babylonjs/assetContainer";
  42494. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42495. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42496. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42497. import { Material } from "babylonjs/Materials/material";
  42498. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42499. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42500. import { Camera } from "babylonjs/Cameras/camera";
  42501. import { Light } from "babylonjs/Lights/light";
  42502. import { Node } from "babylonjs/node";
  42503. import { Animation } from "babylonjs/Animations/animation";
  42504. /**
  42505. * Defines how the parser contract is defined.
  42506. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42507. */
  42508. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42509. /**
  42510. * Defines how the individual parser contract is defined.
  42511. * These parser can parse an individual asset
  42512. */
  42513. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42514. /**
  42515. * Base class of the scene acting as a container for the different elements composing a scene.
  42516. * This class is dynamically extended by the different components of the scene increasing
  42517. * flexibility and reducing coupling
  42518. */
  42519. export abstract class AbstractScene {
  42520. /**
  42521. * Stores the list of available parsers in the application.
  42522. */
  42523. private static _BabylonFileParsers;
  42524. /**
  42525. * Stores the list of available individual parsers in the application.
  42526. */
  42527. private static _IndividualBabylonFileParsers;
  42528. /**
  42529. * Adds a parser in the list of available ones
  42530. * @param name Defines the name of the parser
  42531. * @param parser Defines the parser to add
  42532. */
  42533. static AddParser(name: string, parser: BabylonFileParser): void;
  42534. /**
  42535. * Gets a general parser from the list of avaialble ones
  42536. * @param name Defines the name of the parser
  42537. * @returns the requested parser or null
  42538. */
  42539. static GetParser(name: string): Nullable<BabylonFileParser>;
  42540. /**
  42541. * Adds n individual parser in the list of available ones
  42542. * @param name Defines the name of the parser
  42543. * @param parser Defines the parser to add
  42544. */
  42545. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42546. /**
  42547. * Gets an individual parser from the list of avaialble ones
  42548. * @param name Defines the name of the parser
  42549. * @returns the requested parser or null
  42550. */
  42551. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42552. /**
  42553. * Parser json data and populate both a scene and its associated container object
  42554. * @param jsonData Defines the data to parse
  42555. * @param scene Defines the scene to parse the data for
  42556. * @param container Defines the container attached to the parsing sequence
  42557. * @param rootUrl Defines the root url of the data
  42558. */
  42559. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42560. /**
  42561. * Gets the list of root nodes (ie. nodes with no parent)
  42562. */
  42563. rootNodes: Node[];
  42564. /** All of the cameras added to this scene
  42565. * @see https://doc.babylonjs.com/babylon101/cameras
  42566. */
  42567. cameras: Camera[];
  42568. /**
  42569. * All of the lights added to this scene
  42570. * @see https://doc.babylonjs.com/babylon101/lights
  42571. */
  42572. lights: Light[];
  42573. /**
  42574. * All of the (abstract) meshes added to this scene
  42575. */
  42576. meshes: AbstractMesh[];
  42577. /**
  42578. * The list of skeletons added to the scene
  42579. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42580. */
  42581. skeletons: Skeleton[];
  42582. /**
  42583. * All of the particle systems added to this scene
  42584. * @see https://doc.babylonjs.com/babylon101/particles
  42585. */
  42586. particleSystems: IParticleSystem[];
  42587. /**
  42588. * Gets a list of Animations associated with the scene
  42589. */
  42590. animations: Animation[];
  42591. /**
  42592. * All of the animation groups added to this scene
  42593. * @see https://doc.babylonjs.com/how_to/group
  42594. */
  42595. animationGroups: AnimationGroup[];
  42596. /**
  42597. * All of the multi-materials added to this scene
  42598. * @see https://doc.babylonjs.com/how_to/multi_materials
  42599. */
  42600. multiMaterials: MultiMaterial[];
  42601. /**
  42602. * All of the materials added to this scene
  42603. * In the context of a Scene, it is not supposed to be modified manually.
  42604. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42605. * Note also that the order of the Material within the array is not significant and might change.
  42606. * @see https://doc.babylonjs.com/babylon101/materials
  42607. */
  42608. materials: Material[];
  42609. /**
  42610. * The list of morph target managers added to the scene
  42611. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42612. */
  42613. morphTargetManagers: MorphTargetManager[];
  42614. /**
  42615. * The list of geometries used in the scene.
  42616. */
  42617. geometries: Geometry[];
  42618. /**
  42619. * All of the tranform nodes added to this scene
  42620. * In the context of a Scene, it is not supposed to be modified manually.
  42621. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42622. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42623. * @see https://doc.babylonjs.com/how_to/transformnode
  42624. */
  42625. transformNodes: TransformNode[];
  42626. /**
  42627. * ActionManagers available on the scene.
  42628. */
  42629. actionManagers: AbstractActionManager[];
  42630. /**
  42631. * Textures to keep.
  42632. */
  42633. textures: BaseTexture[];
  42634. /**
  42635. * Environment texture for the scene
  42636. */
  42637. environmentTexture: Nullable<BaseTexture>;
  42638. /**
  42639. * @returns all meshes, lights, cameras, transformNodes and bones
  42640. */
  42641. getNodes(): Array<Node>;
  42642. }
  42643. }
  42644. declare module "babylonjs/Audio/sound" {
  42645. import { Observable } from "babylonjs/Misc/observable";
  42646. import { Vector3 } from "babylonjs/Maths/math.vector";
  42647. import { Nullable } from "babylonjs/types";
  42648. import { Scene } from "babylonjs/scene";
  42649. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42650. /**
  42651. * Interface used to define options for Sound class
  42652. */
  42653. export interface ISoundOptions {
  42654. /**
  42655. * Does the sound autoplay once loaded.
  42656. */
  42657. autoplay?: boolean;
  42658. /**
  42659. * Does the sound loop after it finishes playing once.
  42660. */
  42661. loop?: boolean;
  42662. /**
  42663. * Sound's volume
  42664. */
  42665. volume?: number;
  42666. /**
  42667. * Is it a spatial sound?
  42668. */
  42669. spatialSound?: boolean;
  42670. /**
  42671. * Maximum distance to hear that sound
  42672. */
  42673. maxDistance?: number;
  42674. /**
  42675. * Uses user defined attenuation function
  42676. */
  42677. useCustomAttenuation?: boolean;
  42678. /**
  42679. * Define the roll off factor of spatial sounds.
  42680. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42681. */
  42682. rolloffFactor?: number;
  42683. /**
  42684. * Define the reference distance the sound should be heard perfectly.
  42685. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42686. */
  42687. refDistance?: number;
  42688. /**
  42689. * Define the distance attenuation model the sound will follow.
  42690. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42691. */
  42692. distanceModel?: string;
  42693. /**
  42694. * Defines the playback speed (1 by default)
  42695. */
  42696. playbackRate?: number;
  42697. /**
  42698. * Defines if the sound is from a streaming source
  42699. */
  42700. streaming?: boolean;
  42701. /**
  42702. * Defines an optional length (in seconds) inside the sound file
  42703. */
  42704. length?: number;
  42705. /**
  42706. * Defines an optional offset (in seconds) inside the sound file
  42707. */
  42708. offset?: number;
  42709. /**
  42710. * If true, URLs will not be required to state the audio file codec to use.
  42711. */
  42712. skipCodecCheck?: boolean;
  42713. }
  42714. /**
  42715. * Defines a sound that can be played in the application.
  42716. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  42717. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42718. */
  42719. export class Sound {
  42720. /**
  42721. * The name of the sound in the scene.
  42722. */
  42723. name: string;
  42724. /**
  42725. * Does the sound autoplay once loaded.
  42726. */
  42727. autoplay: boolean;
  42728. /**
  42729. * Does the sound loop after it finishes playing once.
  42730. */
  42731. loop: boolean;
  42732. /**
  42733. * Does the sound use a custom attenuation curve to simulate the falloff
  42734. * happening when the source gets further away from the camera.
  42735. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42736. */
  42737. useCustomAttenuation: boolean;
  42738. /**
  42739. * The sound track id this sound belongs to.
  42740. */
  42741. soundTrackId: number;
  42742. /**
  42743. * Is this sound currently played.
  42744. */
  42745. isPlaying: boolean;
  42746. /**
  42747. * Is this sound currently paused.
  42748. */
  42749. isPaused: boolean;
  42750. /**
  42751. * Does this sound enables spatial sound.
  42752. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42753. */
  42754. spatialSound: boolean;
  42755. /**
  42756. * Define the reference distance the sound should be heard perfectly.
  42757. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42758. */
  42759. refDistance: number;
  42760. /**
  42761. * Define the roll off factor of spatial sounds.
  42762. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42763. */
  42764. rolloffFactor: number;
  42765. /**
  42766. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  42767. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42768. */
  42769. maxDistance: number;
  42770. /**
  42771. * Define the distance attenuation model the sound will follow.
  42772. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42773. */
  42774. distanceModel: string;
  42775. /**
  42776. * @hidden
  42777. * Back Compat
  42778. **/
  42779. onended: () => any;
  42780. /**
  42781. * Gets or sets an object used to store user defined information for the sound.
  42782. */
  42783. metadata: any;
  42784. /**
  42785. * Observable event when the current playing sound finishes.
  42786. */
  42787. onEndedObservable: Observable<Sound>;
  42788. private _panningModel;
  42789. private _playbackRate;
  42790. private _streaming;
  42791. private _startTime;
  42792. private _startOffset;
  42793. private _position;
  42794. /** @hidden */
  42795. _positionInEmitterSpace: boolean;
  42796. private _localDirection;
  42797. private _volume;
  42798. private _isReadyToPlay;
  42799. private _isDirectional;
  42800. private _readyToPlayCallback;
  42801. private _audioBuffer;
  42802. private _soundSource;
  42803. private _streamingSource;
  42804. private _soundPanner;
  42805. private _soundGain;
  42806. private _inputAudioNode;
  42807. private _outputAudioNode;
  42808. private _coneInnerAngle;
  42809. private _coneOuterAngle;
  42810. private _coneOuterGain;
  42811. private _scene;
  42812. private _connectedTransformNode;
  42813. private _customAttenuationFunction;
  42814. private _registerFunc;
  42815. private _isOutputConnected;
  42816. private _htmlAudioElement;
  42817. private _urlType;
  42818. private _length?;
  42819. private _offset?;
  42820. /** @hidden */
  42821. static _SceneComponentInitialization: (scene: Scene) => void;
  42822. /**
  42823. * Create a sound and attach it to a scene
  42824. * @param name Name of your sound
  42825. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  42826. * @param scene defines the scene the sound belongs to
  42827. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  42828. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  42829. */
  42830. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  42831. /**
  42832. * Release the sound and its associated resources
  42833. */
  42834. dispose(): void;
  42835. /**
  42836. * Gets if the sounds is ready to be played or not.
  42837. * @returns true if ready, otherwise false
  42838. */
  42839. isReady(): boolean;
  42840. private _soundLoaded;
  42841. /**
  42842. * Sets the data of the sound from an audiobuffer
  42843. * @param audioBuffer The audioBuffer containing the data
  42844. */
  42845. setAudioBuffer(audioBuffer: AudioBuffer): void;
  42846. /**
  42847. * Updates the current sounds options such as maxdistance, loop...
  42848. * @param options A JSON object containing values named as the object properties
  42849. */
  42850. updateOptions(options: ISoundOptions): void;
  42851. private _createSpatialParameters;
  42852. private _updateSpatialParameters;
  42853. /**
  42854. * Switch the panning model to HRTF:
  42855. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42856. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42857. */
  42858. switchPanningModelToHRTF(): void;
  42859. /**
  42860. * Switch the panning model to Equal Power:
  42861. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42862. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42863. */
  42864. switchPanningModelToEqualPower(): void;
  42865. private _switchPanningModel;
  42866. /**
  42867. * Connect this sound to a sound track audio node like gain...
  42868. * @param soundTrackAudioNode the sound track audio node to connect to
  42869. */
  42870. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  42871. /**
  42872. * Transform this sound into a directional source
  42873. * @param coneInnerAngle Size of the inner cone in degree
  42874. * @param coneOuterAngle Size of the outer cone in degree
  42875. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  42876. */
  42877. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  42878. /**
  42879. * Gets or sets the inner angle for the directional cone.
  42880. */
  42881. get directionalConeInnerAngle(): number;
  42882. /**
  42883. * Gets or sets the inner angle for the directional cone.
  42884. */
  42885. set directionalConeInnerAngle(value: number);
  42886. /**
  42887. * Gets or sets the outer angle for the directional cone.
  42888. */
  42889. get directionalConeOuterAngle(): number;
  42890. /**
  42891. * Gets or sets the outer angle for the directional cone.
  42892. */
  42893. set directionalConeOuterAngle(value: number);
  42894. /**
  42895. * Sets the position of the emitter if spatial sound is enabled
  42896. * @param newPosition Defines the new posisiton
  42897. */
  42898. setPosition(newPosition: Vector3): void;
  42899. /**
  42900. * Sets the local direction of the emitter if spatial sound is enabled
  42901. * @param newLocalDirection Defines the new local direction
  42902. */
  42903. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  42904. private _updateDirection;
  42905. /** @hidden */
  42906. updateDistanceFromListener(): void;
  42907. /**
  42908. * Sets a new custom attenuation function for the sound.
  42909. * @param callback Defines the function used for the attenuation
  42910. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42911. */
  42912. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  42913. /**
  42914. * Play the sound
  42915. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  42916. * @param offset (optional) Start the sound at a specific time in seconds
  42917. * @param length (optional) Sound duration (in seconds)
  42918. */
  42919. play(time?: number, offset?: number, length?: number): void;
  42920. private _onended;
  42921. /**
  42922. * Stop the sound
  42923. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  42924. */
  42925. stop(time?: number): void;
  42926. /**
  42927. * Put the sound in pause
  42928. */
  42929. pause(): void;
  42930. /**
  42931. * Sets a dedicated volume for this sounds
  42932. * @param newVolume Define the new volume of the sound
  42933. * @param time Define time for gradual change to new volume
  42934. */
  42935. setVolume(newVolume: number, time?: number): void;
  42936. /**
  42937. * Set the sound play back rate
  42938. * @param newPlaybackRate Define the playback rate the sound should be played at
  42939. */
  42940. setPlaybackRate(newPlaybackRate: number): void;
  42941. /**
  42942. * Gets the volume of the sound.
  42943. * @returns the volume of the sound
  42944. */
  42945. getVolume(): number;
  42946. /**
  42947. * Attach the sound to a dedicated mesh
  42948. * @param transformNode The transform node to connect the sound with
  42949. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42950. */
  42951. attachToMesh(transformNode: TransformNode): void;
  42952. /**
  42953. * Detach the sound from the previously attached mesh
  42954. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42955. */
  42956. detachFromMesh(): void;
  42957. private _onRegisterAfterWorldMatrixUpdate;
  42958. /**
  42959. * Clone the current sound in the scene.
  42960. * @returns the new sound clone
  42961. */
  42962. clone(): Nullable<Sound>;
  42963. /**
  42964. * Gets the current underlying audio buffer containing the data
  42965. * @returns the audio buffer
  42966. */
  42967. getAudioBuffer(): Nullable<AudioBuffer>;
  42968. /**
  42969. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  42970. * @returns the source node
  42971. */
  42972. getSoundSource(): Nullable<AudioBufferSourceNode>;
  42973. /**
  42974. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  42975. * @returns the gain node
  42976. */
  42977. getSoundGain(): Nullable<GainNode>;
  42978. /**
  42979. * Serializes the Sound in a JSON representation
  42980. * @returns the JSON representation of the sound
  42981. */
  42982. serialize(): any;
  42983. /**
  42984. * Parse a JSON representation of a sound to innstantiate in a given scene
  42985. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  42986. * @param scene Define the scene the new parsed sound should be created in
  42987. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  42988. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  42989. * @returns the newly parsed sound
  42990. */
  42991. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  42992. }
  42993. }
  42994. declare module "babylonjs/Actions/directAudioActions" {
  42995. import { Action } from "babylonjs/Actions/action";
  42996. import { Condition } from "babylonjs/Actions/condition";
  42997. import { Sound } from "babylonjs/Audio/sound";
  42998. /**
  42999. * This defines an action helpful to play a defined sound on a triggered action.
  43000. */
  43001. export class PlaySoundAction extends Action {
  43002. private _sound;
  43003. /**
  43004. * Instantiate the action
  43005. * @param triggerOptions defines the trigger options
  43006. * @param sound defines the sound to play
  43007. * @param condition defines the trigger related conditions
  43008. */
  43009. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43010. /** @hidden */
  43011. _prepare(): void;
  43012. /**
  43013. * Execute the action and play the sound.
  43014. */
  43015. execute(): void;
  43016. /**
  43017. * Serializes the actions and its related information.
  43018. * @param parent defines the object to serialize in
  43019. * @returns the serialized object
  43020. */
  43021. serialize(parent: any): any;
  43022. }
  43023. /**
  43024. * This defines an action helpful to stop a defined sound on a triggered action.
  43025. */
  43026. export class StopSoundAction extends Action {
  43027. private _sound;
  43028. /**
  43029. * Instantiate the action
  43030. * @param triggerOptions defines the trigger options
  43031. * @param sound defines the sound to stop
  43032. * @param condition defines the trigger related conditions
  43033. */
  43034. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43035. /** @hidden */
  43036. _prepare(): void;
  43037. /**
  43038. * Execute the action and stop the sound.
  43039. */
  43040. execute(): void;
  43041. /**
  43042. * Serializes the actions and its related information.
  43043. * @param parent defines the object to serialize in
  43044. * @returns the serialized object
  43045. */
  43046. serialize(parent: any): any;
  43047. }
  43048. }
  43049. declare module "babylonjs/Actions/interpolateValueAction" {
  43050. import { Action } from "babylonjs/Actions/action";
  43051. import { Condition } from "babylonjs/Actions/condition";
  43052. import { Observable } from "babylonjs/Misc/observable";
  43053. /**
  43054. * This defines an action responsible to change the value of a property
  43055. * by interpolating between its current value and the newly set one once triggered.
  43056. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43057. */
  43058. export class InterpolateValueAction extends Action {
  43059. /**
  43060. * Defines the path of the property where the value should be interpolated
  43061. */
  43062. propertyPath: string;
  43063. /**
  43064. * Defines the target value at the end of the interpolation.
  43065. */
  43066. value: any;
  43067. /**
  43068. * Defines the time it will take for the property to interpolate to the value.
  43069. */
  43070. duration: number;
  43071. /**
  43072. * Defines if the other scene animations should be stopped when the action has been triggered
  43073. */
  43074. stopOtherAnimations?: boolean;
  43075. /**
  43076. * Defines a callback raised once the interpolation animation has been done.
  43077. */
  43078. onInterpolationDone?: () => void;
  43079. /**
  43080. * Observable triggered once the interpolation animation has been done.
  43081. */
  43082. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43083. private _target;
  43084. private _effectiveTarget;
  43085. private _property;
  43086. /**
  43087. * Instantiate the action
  43088. * @param triggerOptions defines the trigger options
  43089. * @param target defines the object containing the value to interpolate
  43090. * @param propertyPath defines the path to the property in the target object
  43091. * @param value defines the target value at the end of the interpolation
  43092. * @param duration deines the time it will take for the property to interpolate to the value.
  43093. * @param condition defines the trigger related conditions
  43094. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43095. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43096. */
  43097. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43098. /** @hidden */
  43099. _prepare(): void;
  43100. /**
  43101. * Execute the action starts the value interpolation.
  43102. */
  43103. execute(): void;
  43104. /**
  43105. * Serializes the actions and its related information.
  43106. * @param parent defines the object to serialize in
  43107. * @returns the serialized object
  43108. */
  43109. serialize(parent: any): any;
  43110. }
  43111. }
  43112. declare module "babylonjs/Actions/index" {
  43113. export * from "babylonjs/Actions/abstractActionManager";
  43114. export * from "babylonjs/Actions/action";
  43115. export * from "babylonjs/Actions/actionEvent";
  43116. export * from "babylonjs/Actions/actionManager";
  43117. export * from "babylonjs/Actions/condition";
  43118. export * from "babylonjs/Actions/directActions";
  43119. export * from "babylonjs/Actions/directAudioActions";
  43120. export * from "babylonjs/Actions/interpolateValueAction";
  43121. }
  43122. declare module "babylonjs/Animations/index" {
  43123. export * from "babylonjs/Animations/animatable";
  43124. export * from "babylonjs/Animations/animation";
  43125. export * from "babylonjs/Animations/animationGroup";
  43126. export * from "babylonjs/Animations/animationPropertiesOverride";
  43127. export * from "babylonjs/Animations/easing";
  43128. export * from "babylonjs/Animations/runtimeAnimation";
  43129. export * from "babylonjs/Animations/animationEvent";
  43130. export * from "babylonjs/Animations/animationGroup";
  43131. export * from "babylonjs/Animations/animationKey";
  43132. export * from "babylonjs/Animations/animationRange";
  43133. export * from "babylonjs/Animations/animatable.interface";
  43134. }
  43135. declare module "babylonjs/Audio/soundTrack" {
  43136. import { Sound } from "babylonjs/Audio/sound";
  43137. import { Analyser } from "babylonjs/Audio/analyser";
  43138. import { Scene } from "babylonjs/scene";
  43139. /**
  43140. * Options allowed during the creation of a sound track.
  43141. */
  43142. export interface ISoundTrackOptions {
  43143. /**
  43144. * The volume the sound track should take during creation
  43145. */
  43146. volume?: number;
  43147. /**
  43148. * Define if the sound track is the main sound track of the scene
  43149. */
  43150. mainTrack?: boolean;
  43151. }
  43152. /**
  43153. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43154. * It will be also used in a future release to apply effects on a specific track.
  43155. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43156. */
  43157. export class SoundTrack {
  43158. /**
  43159. * The unique identifier of the sound track in the scene.
  43160. */
  43161. id: number;
  43162. /**
  43163. * The list of sounds included in the sound track.
  43164. */
  43165. soundCollection: Array<Sound>;
  43166. private _outputAudioNode;
  43167. private _scene;
  43168. private _connectedAnalyser;
  43169. private _options;
  43170. private _isInitialized;
  43171. /**
  43172. * Creates a new sound track.
  43173. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43174. * @param scene Define the scene the sound track belongs to
  43175. * @param options
  43176. */
  43177. constructor(scene: Scene, options?: ISoundTrackOptions);
  43178. private _initializeSoundTrackAudioGraph;
  43179. /**
  43180. * Release the sound track and its associated resources
  43181. */
  43182. dispose(): void;
  43183. /**
  43184. * Adds a sound to this sound track
  43185. * @param sound define the cound to add
  43186. * @ignoreNaming
  43187. */
  43188. AddSound(sound: Sound): void;
  43189. /**
  43190. * Removes a sound to this sound track
  43191. * @param sound define the cound to remove
  43192. * @ignoreNaming
  43193. */
  43194. RemoveSound(sound: Sound): void;
  43195. /**
  43196. * Set a global volume for the full sound track.
  43197. * @param newVolume Define the new volume of the sound track
  43198. */
  43199. setVolume(newVolume: number): void;
  43200. /**
  43201. * Switch the panning model to HRTF:
  43202. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43203. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43204. */
  43205. switchPanningModelToHRTF(): void;
  43206. /**
  43207. * Switch the panning model to Equal Power:
  43208. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43209. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43210. */
  43211. switchPanningModelToEqualPower(): void;
  43212. /**
  43213. * Connect the sound track to an audio analyser allowing some amazing
  43214. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43215. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43216. * @param analyser The analyser to connect to the engine
  43217. */
  43218. connectToAnalyser(analyser: Analyser): void;
  43219. }
  43220. }
  43221. declare module "babylonjs/Audio/audioSceneComponent" {
  43222. import { Sound } from "babylonjs/Audio/sound";
  43223. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43224. import { Nullable } from "babylonjs/types";
  43225. import { Vector3 } from "babylonjs/Maths/math.vector";
  43226. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43227. import { Scene } from "babylonjs/scene";
  43228. import { AbstractScene } from "babylonjs/abstractScene";
  43229. import "babylonjs/Audio/audioEngine";
  43230. module "babylonjs/abstractScene" {
  43231. interface AbstractScene {
  43232. /**
  43233. * The list of sounds used in the scene.
  43234. */
  43235. sounds: Nullable<Array<Sound>>;
  43236. }
  43237. }
  43238. module "babylonjs/scene" {
  43239. interface Scene {
  43240. /**
  43241. * @hidden
  43242. * Backing field
  43243. */
  43244. _mainSoundTrack: SoundTrack;
  43245. /**
  43246. * The main sound track played by the scene.
  43247. * It cotains your primary collection of sounds.
  43248. */
  43249. mainSoundTrack: SoundTrack;
  43250. /**
  43251. * The list of sound tracks added to the scene
  43252. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43253. */
  43254. soundTracks: Nullable<Array<SoundTrack>>;
  43255. /**
  43256. * Gets a sound using a given name
  43257. * @param name defines the name to search for
  43258. * @return the found sound or null if not found at all.
  43259. */
  43260. getSoundByName(name: string): Nullable<Sound>;
  43261. /**
  43262. * Gets or sets if audio support is enabled
  43263. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43264. */
  43265. audioEnabled: boolean;
  43266. /**
  43267. * Gets or sets if audio will be output to headphones
  43268. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43269. */
  43270. headphone: boolean;
  43271. /**
  43272. * Gets or sets custom audio listener position provider
  43273. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43274. */
  43275. audioListenerPositionProvider: Nullable<() => Vector3>;
  43276. /**
  43277. * Gets or sets a refresh rate when using 3D audio positioning
  43278. */
  43279. audioPositioningRefreshRate: number;
  43280. }
  43281. }
  43282. /**
  43283. * Defines the sound scene component responsible to manage any sounds
  43284. * in a given scene.
  43285. */
  43286. export class AudioSceneComponent implements ISceneSerializableComponent {
  43287. /**
  43288. * The component name helpfull to identify the component in the list of scene components.
  43289. */
  43290. readonly name: string;
  43291. /**
  43292. * The scene the component belongs to.
  43293. */
  43294. scene: Scene;
  43295. private _audioEnabled;
  43296. /**
  43297. * Gets whether audio is enabled or not.
  43298. * Please use related enable/disable method to switch state.
  43299. */
  43300. get audioEnabled(): boolean;
  43301. private _headphone;
  43302. /**
  43303. * Gets whether audio is outputing to headphone or not.
  43304. * Please use the according Switch methods to change output.
  43305. */
  43306. get headphone(): boolean;
  43307. /**
  43308. * Gets or sets a refresh rate when using 3D audio positioning
  43309. */
  43310. audioPositioningRefreshRate: number;
  43311. private _audioListenerPositionProvider;
  43312. /**
  43313. * Gets the current audio listener position provider
  43314. */
  43315. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43316. /**
  43317. * Sets a custom listener position for all sounds in the scene
  43318. * By default, this is the position of the first active camera
  43319. */
  43320. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43321. /**
  43322. * Creates a new instance of the component for the given scene
  43323. * @param scene Defines the scene to register the component in
  43324. */
  43325. constructor(scene: Scene);
  43326. /**
  43327. * Registers the component in a given scene
  43328. */
  43329. register(): void;
  43330. /**
  43331. * Rebuilds the elements related to this component in case of
  43332. * context lost for instance.
  43333. */
  43334. rebuild(): void;
  43335. /**
  43336. * Serializes the component data to the specified json object
  43337. * @param serializationObject The object to serialize to
  43338. */
  43339. serialize(serializationObject: any): void;
  43340. /**
  43341. * Adds all the elements from the container to the scene
  43342. * @param container the container holding the elements
  43343. */
  43344. addFromContainer(container: AbstractScene): void;
  43345. /**
  43346. * Removes all the elements in the container from the scene
  43347. * @param container contains the elements to remove
  43348. * @param dispose if the removed element should be disposed (default: false)
  43349. */
  43350. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43351. /**
  43352. * Disposes the component and the associated ressources.
  43353. */
  43354. dispose(): void;
  43355. /**
  43356. * Disables audio in the associated scene.
  43357. */
  43358. disableAudio(): void;
  43359. /**
  43360. * Enables audio in the associated scene.
  43361. */
  43362. enableAudio(): void;
  43363. /**
  43364. * Switch audio to headphone output.
  43365. */
  43366. switchAudioModeForHeadphones(): void;
  43367. /**
  43368. * Switch audio to normal speakers.
  43369. */
  43370. switchAudioModeForNormalSpeakers(): void;
  43371. private _cachedCameraDirection;
  43372. private _cachedCameraPosition;
  43373. private _lastCheck;
  43374. private _afterRender;
  43375. }
  43376. }
  43377. declare module "babylonjs/Audio/weightedsound" {
  43378. import { Sound } from "babylonjs/Audio/sound";
  43379. /**
  43380. * Wraps one or more Sound objects and selects one with random weight for playback.
  43381. */
  43382. export class WeightedSound {
  43383. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43384. loop: boolean;
  43385. private _coneInnerAngle;
  43386. private _coneOuterAngle;
  43387. private _volume;
  43388. /** A Sound is currently playing. */
  43389. isPlaying: boolean;
  43390. /** A Sound is currently paused. */
  43391. isPaused: boolean;
  43392. private _sounds;
  43393. private _weights;
  43394. private _currentIndex?;
  43395. /**
  43396. * Creates a new WeightedSound from the list of sounds given.
  43397. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43398. * @param sounds Array of Sounds that will be selected from.
  43399. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43400. */
  43401. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43402. /**
  43403. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43404. */
  43405. get directionalConeInnerAngle(): number;
  43406. /**
  43407. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43408. */
  43409. set directionalConeInnerAngle(value: number);
  43410. /**
  43411. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43412. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43413. */
  43414. get directionalConeOuterAngle(): number;
  43415. /**
  43416. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43417. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43418. */
  43419. set directionalConeOuterAngle(value: number);
  43420. /**
  43421. * Playback volume.
  43422. */
  43423. get volume(): number;
  43424. /**
  43425. * Playback volume.
  43426. */
  43427. set volume(value: number);
  43428. private _onended;
  43429. /**
  43430. * Suspend playback
  43431. */
  43432. pause(): void;
  43433. /**
  43434. * Stop playback
  43435. */
  43436. stop(): void;
  43437. /**
  43438. * Start playback.
  43439. * @param startOffset Position the clip head at a specific time in seconds.
  43440. */
  43441. play(startOffset?: number): void;
  43442. }
  43443. }
  43444. declare module "babylonjs/Audio/index" {
  43445. export * from "babylonjs/Audio/analyser";
  43446. export * from "babylonjs/Audio/audioEngine";
  43447. export * from "babylonjs/Audio/audioSceneComponent";
  43448. export * from "babylonjs/Audio/sound";
  43449. export * from "babylonjs/Audio/soundTrack";
  43450. export * from "babylonjs/Audio/weightedsound";
  43451. }
  43452. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43453. import { Behavior } from "babylonjs/Behaviors/behavior";
  43454. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43455. import { BackEase } from "babylonjs/Animations/easing";
  43456. /**
  43457. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43458. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43459. */
  43460. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43461. /**
  43462. * Gets the name of the behavior.
  43463. */
  43464. get name(): string;
  43465. /**
  43466. * The easing function used by animations
  43467. */
  43468. static EasingFunction: BackEase;
  43469. /**
  43470. * The easing mode used by animations
  43471. */
  43472. static EasingMode: number;
  43473. /**
  43474. * The duration of the animation, in milliseconds
  43475. */
  43476. transitionDuration: number;
  43477. /**
  43478. * Length of the distance animated by the transition when lower radius is reached
  43479. */
  43480. lowerRadiusTransitionRange: number;
  43481. /**
  43482. * Length of the distance animated by the transition when upper radius is reached
  43483. */
  43484. upperRadiusTransitionRange: number;
  43485. private _autoTransitionRange;
  43486. /**
  43487. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43488. */
  43489. get autoTransitionRange(): boolean;
  43490. /**
  43491. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43492. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43493. */
  43494. set autoTransitionRange(value: boolean);
  43495. private _attachedCamera;
  43496. private _onAfterCheckInputsObserver;
  43497. private _onMeshTargetChangedObserver;
  43498. /**
  43499. * Initializes the behavior.
  43500. */
  43501. init(): void;
  43502. /**
  43503. * Attaches the behavior to its arc rotate camera.
  43504. * @param camera Defines the camera to attach the behavior to
  43505. */
  43506. attach(camera: ArcRotateCamera): void;
  43507. /**
  43508. * Detaches the behavior from its current arc rotate camera.
  43509. */
  43510. detach(): void;
  43511. private _radiusIsAnimating;
  43512. private _radiusBounceTransition;
  43513. private _animatables;
  43514. private _cachedWheelPrecision;
  43515. /**
  43516. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43517. * @param radiusLimit The limit to check against.
  43518. * @return Bool to indicate if at limit.
  43519. */
  43520. private _isRadiusAtLimit;
  43521. /**
  43522. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43523. * @param radiusDelta The delta by which to animate to. Can be negative.
  43524. */
  43525. private _applyBoundRadiusAnimation;
  43526. /**
  43527. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43528. */
  43529. protected _clearAnimationLocks(): void;
  43530. /**
  43531. * Stops and removes all animations that have been applied to the camera
  43532. */
  43533. stopAllAnimations(): void;
  43534. }
  43535. }
  43536. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43537. import { Behavior } from "babylonjs/Behaviors/behavior";
  43538. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43539. import { ExponentialEase } from "babylonjs/Animations/easing";
  43540. import { Nullable } from "babylonjs/types";
  43541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43542. import { Vector3 } from "babylonjs/Maths/math.vector";
  43543. /**
  43544. * 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.
  43545. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43546. */
  43547. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43548. /**
  43549. * Gets the name of the behavior.
  43550. */
  43551. get name(): string;
  43552. private _mode;
  43553. private _radiusScale;
  43554. private _positionScale;
  43555. private _defaultElevation;
  43556. private _elevationReturnTime;
  43557. private _elevationReturnWaitTime;
  43558. private _zoomStopsAnimation;
  43559. private _framingTime;
  43560. /**
  43561. * The easing function used by animations
  43562. */
  43563. static EasingFunction: ExponentialEase;
  43564. /**
  43565. * The easing mode used by animations
  43566. */
  43567. static EasingMode: number;
  43568. /**
  43569. * Sets the current mode used by the behavior
  43570. */
  43571. set mode(mode: number);
  43572. /**
  43573. * Gets current mode used by the behavior.
  43574. */
  43575. get mode(): number;
  43576. /**
  43577. * Sets the scale applied to the radius (1 by default)
  43578. */
  43579. set radiusScale(radius: number);
  43580. /**
  43581. * Gets the scale applied to the radius
  43582. */
  43583. get radiusScale(): number;
  43584. /**
  43585. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43586. */
  43587. set positionScale(scale: number);
  43588. /**
  43589. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43590. */
  43591. get positionScale(): number;
  43592. /**
  43593. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43594. * behaviour is triggered, in radians.
  43595. */
  43596. set defaultElevation(elevation: number);
  43597. /**
  43598. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43599. * behaviour is triggered, in radians.
  43600. */
  43601. get defaultElevation(): number;
  43602. /**
  43603. * Sets the time (in milliseconds) taken to return to the default beta position.
  43604. * Negative value indicates camera should not return to default.
  43605. */
  43606. set elevationReturnTime(speed: number);
  43607. /**
  43608. * Gets the time (in milliseconds) taken to return to the default beta position.
  43609. * Negative value indicates camera should not return to default.
  43610. */
  43611. get elevationReturnTime(): number;
  43612. /**
  43613. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43614. */
  43615. set elevationReturnWaitTime(time: number);
  43616. /**
  43617. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43618. */
  43619. get elevationReturnWaitTime(): number;
  43620. /**
  43621. * Sets the flag that indicates if user zooming should stop animation.
  43622. */
  43623. set zoomStopsAnimation(flag: boolean);
  43624. /**
  43625. * Gets the flag that indicates if user zooming should stop animation.
  43626. */
  43627. get zoomStopsAnimation(): boolean;
  43628. /**
  43629. * Sets the transition time when framing the mesh, in milliseconds
  43630. */
  43631. set framingTime(time: number);
  43632. /**
  43633. * Gets the transition time when framing the mesh, in milliseconds
  43634. */
  43635. get framingTime(): number;
  43636. /**
  43637. * Define if the behavior should automatically change the configured
  43638. * camera limits and sensibilities.
  43639. */
  43640. autoCorrectCameraLimitsAndSensibility: boolean;
  43641. private _onPrePointerObservableObserver;
  43642. private _onAfterCheckInputsObserver;
  43643. private _onMeshTargetChangedObserver;
  43644. private _attachedCamera;
  43645. private _isPointerDown;
  43646. private _lastInteractionTime;
  43647. /**
  43648. * Initializes the behavior.
  43649. */
  43650. init(): void;
  43651. /**
  43652. * Attaches the behavior to its arc rotate camera.
  43653. * @param camera Defines the camera to attach the behavior to
  43654. */
  43655. attach(camera: ArcRotateCamera): void;
  43656. /**
  43657. * Detaches the behavior from its current arc rotate camera.
  43658. */
  43659. detach(): void;
  43660. private _animatables;
  43661. private _betaIsAnimating;
  43662. private _betaTransition;
  43663. private _radiusTransition;
  43664. private _vectorTransition;
  43665. /**
  43666. * Targets the given mesh and updates zoom level accordingly.
  43667. * @param mesh The mesh to target.
  43668. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43669. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43670. */
  43671. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43672. /**
  43673. * Targets the given mesh with its children and updates zoom level accordingly.
  43674. * @param mesh The mesh to target.
  43675. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43676. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43677. */
  43678. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43679. /**
  43680. * Targets the given meshes with their children and updates zoom level accordingly.
  43681. * @param meshes The mesh to target.
  43682. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43683. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43684. */
  43685. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43686. /**
  43687. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  43688. * @param minimumWorld Determines the smaller position of the bounding box extend
  43689. * @param maximumWorld Determines the bigger position of the bounding box extend
  43690. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43691. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43692. */
  43693. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43694. /**
  43695. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  43696. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  43697. * frustum width.
  43698. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  43699. * to fully enclose the mesh in the viewing frustum.
  43700. */
  43701. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  43702. /**
  43703. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  43704. * is automatically returned to its default position (expected to be above ground plane).
  43705. */
  43706. private _maintainCameraAboveGround;
  43707. /**
  43708. * Returns the frustum slope based on the canvas ratio and camera FOV
  43709. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  43710. */
  43711. private _getFrustumSlope;
  43712. /**
  43713. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  43714. */
  43715. private _clearAnimationLocks;
  43716. /**
  43717. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43718. */
  43719. private _applyUserInteraction;
  43720. /**
  43721. * Stops and removes all animations that have been applied to the camera
  43722. */
  43723. stopAllAnimations(): void;
  43724. /**
  43725. * Gets a value indicating if the user is moving the camera
  43726. */
  43727. get isUserIsMoving(): boolean;
  43728. /**
  43729. * The camera can move all the way towards the mesh.
  43730. */
  43731. static IgnoreBoundsSizeMode: number;
  43732. /**
  43733. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  43734. */
  43735. static FitFrustumSidesMode: number;
  43736. }
  43737. }
  43738. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  43739. import { Nullable } from "babylonjs/types";
  43740. import { Camera } from "babylonjs/Cameras/camera";
  43741. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43742. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43743. /**
  43744. * Base class for Camera Pointer Inputs.
  43745. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  43746. * for example usage.
  43747. */
  43748. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  43749. /**
  43750. * Defines the camera the input is attached to.
  43751. */
  43752. abstract camera: Camera;
  43753. /**
  43754. * Whether keyboard modifier keys are pressed at time of last mouse event.
  43755. */
  43756. protected _altKey: boolean;
  43757. protected _ctrlKey: boolean;
  43758. protected _metaKey: boolean;
  43759. protected _shiftKey: boolean;
  43760. /**
  43761. * Which mouse buttons were pressed at time of last mouse event.
  43762. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  43763. */
  43764. protected _buttonsPressed: number;
  43765. /**
  43766. * Defines the buttons associated with the input to handle camera move.
  43767. */
  43768. buttons: number[];
  43769. /**
  43770. * Attach the input controls to a specific dom element to get the input from.
  43771. * @param element Defines the element the controls should be listened from
  43772. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43773. */
  43774. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43775. /**
  43776. * Detach the current controls from the specified dom element.
  43777. * @param element Defines the element to stop listening the inputs from
  43778. */
  43779. detachControl(element: Nullable<HTMLElement>): void;
  43780. /**
  43781. * Gets the class name of the current input.
  43782. * @returns the class name
  43783. */
  43784. getClassName(): string;
  43785. /**
  43786. * Get the friendly name associated with the input class.
  43787. * @returns the input friendly name
  43788. */
  43789. getSimpleName(): string;
  43790. /**
  43791. * Called on pointer POINTERDOUBLETAP event.
  43792. * Override this method to provide functionality on POINTERDOUBLETAP event.
  43793. */
  43794. protected onDoubleTap(type: string): void;
  43795. /**
  43796. * Called on pointer POINTERMOVE event if only a single touch is active.
  43797. * Override this method to provide functionality.
  43798. */
  43799. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43800. /**
  43801. * Called on pointer POINTERMOVE event if multiple touches are active.
  43802. * Override this method to provide functionality.
  43803. */
  43804. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43805. /**
  43806. * Called on JS contextmenu event.
  43807. * Override this method to provide functionality.
  43808. */
  43809. protected onContextMenu(evt: PointerEvent): void;
  43810. /**
  43811. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43812. * press.
  43813. * Override this method to provide functionality.
  43814. */
  43815. protected onButtonDown(evt: PointerEvent): void;
  43816. /**
  43817. * Called each time a new POINTERUP event occurs. Ie, for each button
  43818. * release.
  43819. * Override this method to provide functionality.
  43820. */
  43821. protected onButtonUp(evt: PointerEvent): void;
  43822. /**
  43823. * Called when window becomes inactive.
  43824. * Override this method to provide functionality.
  43825. */
  43826. protected onLostFocus(): void;
  43827. private _pointerInput;
  43828. private _observer;
  43829. private _onLostFocus;
  43830. private pointA;
  43831. private pointB;
  43832. }
  43833. }
  43834. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  43835. import { Nullable } from "babylonjs/types";
  43836. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43837. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  43838. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43839. /**
  43840. * Manage the pointers inputs to control an arc rotate camera.
  43841. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43842. */
  43843. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  43844. /**
  43845. * Defines the camera the input is attached to.
  43846. */
  43847. camera: ArcRotateCamera;
  43848. /**
  43849. * Gets the class name of the current input.
  43850. * @returns the class name
  43851. */
  43852. getClassName(): string;
  43853. /**
  43854. * Defines the buttons associated with the input to handle camera move.
  43855. */
  43856. buttons: number[];
  43857. /**
  43858. * Defines the pointer angular sensibility along the X axis or how fast is
  43859. * the camera rotating.
  43860. */
  43861. angularSensibilityX: number;
  43862. /**
  43863. * Defines the pointer angular sensibility along the Y axis or how fast is
  43864. * the camera rotating.
  43865. */
  43866. angularSensibilityY: number;
  43867. /**
  43868. * Defines the pointer pinch precision or how fast is the camera zooming.
  43869. */
  43870. pinchPrecision: number;
  43871. /**
  43872. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43873. * from 0.
  43874. * It defines the percentage of current camera.radius to use as delta when
  43875. * pinch zoom is used.
  43876. */
  43877. pinchDeltaPercentage: number;
  43878. /**
  43879. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43880. * that any object in the plane at the camera's target point will scale
  43881. * perfectly with finger motion.
  43882. * Overrides pinchDeltaPercentage and pinchPrecision.
  43883. */
  43884. useNaturalPinchZoom: boolean;
  43885. /**
  43886. * Defines the pointer panning sensibility or how fast is the camera moving.
  43887. */
  43888. panningSensibility: number;
  43889. /**
  43890. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  43891. */
  43892. multiTouchPanning: boolean;
  43893. /**
  43894. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  43895. * zoom (pinch) through multitouch.
  43896. */
  43897. multiTouchPanAndZoom: boolean;
  43898. /**
  43899. * Revers pinch action direction.
  43900. */
  43901. pinchInwards: boolean;
  43902. private _isPanClick;
  43903. private _twoFingerActivityCount;
  43904. private _isPinching;
  43905. /**
  43906. * Called on pointer POINTERMOVE event if only a single touch is active.
  43907. */
  43908. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43909. /**
  43910. * Called on pointer POINTERDOUBLETAP event.
  43911. */
  43912. protected onDoubleTap(type: string): void;
  43913. /**
  43914. * Called on pointer POINTERMOVE event if multiple touches are active.
  43915. */
  43916. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43917. /**
  43918. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43919. * press.
  43920. */
  43921. protected onButtonDown(evt: PointerEvent): void;
  43922. /**
  43923. * Called each time a new POINTERUP event occurs. Ie, for each button
  43924. * release.
  43925. */
  43926. protected onButtonUp(evt: PointerEvent): void;
  43927. /**
  43928. * Called when window becomes inactive.
  43929. */
  43930. protected onLostFocus(): void;
  43931. }
  43932. }
  43933. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  43934. import { Nullable } from "babylonjs/types";
  43935. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43936. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43937. /**
  43938. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  43939. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43940. */
  43941. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  43942. /**
  43943. * Defines the camera the input is attached to.
  43944. */
  43945. camera: ArcRotateCamera;
  43946. /**
  43947. * Defines the list of key codes associated with the up action (increase alpha)
  43948. */
  43949. keysUp: number[];
  43950. /**
  43951. * Defines the list of key codes associated with the down action (decrease alpha)
  43952. */
  43953. keysDown: number[];
  43954. /**
  43955. * Defines the list of key codes associated with the left action (increase beta)
  43956. */
  43957. keysLeft: number[];
  43958. /**
  43959. * Defines the list of key codes associated with the right action (decrease beta)
  43960. */
  43961. keysRight: number[];
  43962. /**
  43963. * Defines the list of key codes associated with the reset action.
  43964. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  43965. */
  43966. keysReset: number[];
  43967. /**
  43968. * Defines the panning sensibility of the inputs.
  43969. * (How fast is the camera panning)
  43970. */
  43971. panningSensibility: number;
  43972. /**
  43973. * Defines the zooming sensibility of the inputs.
  43974. * (How fast is the camera zooming)
  43975. */
  43976. zoomingSensibility: number;
  43977. /**
  43978. * Defines whether maintaining the alt key down switch the movement mode from
  43979. * orientation to zoom.
  43980. */
  43981. useAltToZoom: boolean;
  43982. /**
  43983. * Rotation speed of the camera
  43984. */
  43985. angularSpeed: number;
  43986. private _keys;
  43987. private _ctrlPressed;
  43988. private _altPressed;
  43989. private _onCanvasBlurObserver;
  43990. private _onKeyboardObserver;
  43991. private _engine;
  43992. private _scene;
  43993. /**
  43994. * Attach the input controls to a specific dom element to get the input from.
  43995. * @param element Defines the element the controls should be listened from
  43996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43997. */
  43998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43999. /**
  44000. * Detach the current controls from the specified dom element.
  44001. * @param element Defines the element to stop listening the inputs from
  44002. */
  44003. detachControl(element: Nullable<HTMLElement>): void;
  44004. /**
  44005. * Update the current camera state depending on the inputs that have been used this frame.
  44006. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44007. */
  44008. checkInputs(): void;
  44009. /**
  44010. * Gets the class name of the current intput.
  44011. * @returns the class name
  44012. */
  44013. getClassName(): string;
  44014. /**
  44015. * Get the friendly name associated with the input class.
  44016. * @returns the input friendly name
  44017. */
  44018. getSimpleName(): string;
  44019. }
  44020. }
  44021. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44022. import { Nullable } from "babylonjs/types";
  44023. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44024. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44025. /**
  44026. * Manage the mouse wheel inputs to control an arc rotate camera.
  44027. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44028. */
  44029. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44030. /**
  44031. * Defines the camera the input is attached to.
  44032. */
  44033. camera: ArcRotateCamera;
  44034. /**
  44035. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44036. */
  44037. wheelPrecision: number;
  44038. /**
  44039. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44040. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44041. */
  44042. wheelDeltaPercentage: number;
  44043. private _wheel;
  44044. private _observer;
  44045. private computeDeltaFromMouseWheelLegacyEvent;
  44046. /**
  44047. * Attach the input controls to a specific dom element to get the input from.
  44048. * @param element Defines the element the controls should be listened from
  44049. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44050. */
  44051. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44052. /**
  44053. * Detach the current controls from the specified dom element.
  44054. * @param element Defines the element to stop listening the inputs from
  44055. */
  44056. detachControl(element: Nullable<HTMLElement>): void;
  44057. /**
  44058. * Gets the class name of the current intput.
  44059. * @returns the class name
  44060. */
  44061. getClassName(): string;
  44062. /**
  44063. * Get the friendly name associated with the input class.
  44064. * @returns the input friendly name
  44065. */
  44066. getSimpleName(): string;
  44067. }
  44068. }
  44069. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44070. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44071. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44072. /**
  44073. * Default Inputs manager for the ArcRotateCamera.
  44074. * It groups all the default supported inputs for ease of use.
  44075. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44076. */
  44077. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44078. /**
  44079. * Instantiates a new ArcRotateCameraInputsManager.
  44080. * @param camera Defines the camera the inputs belong to
  44081. */
  44082. constructor(camera: ArcRotateCamera);
  44083. /**
  44084. * Add mouse wheel input support to the input manager.
  44085. * @returns the current input manager
  44086. */
  44087. addMouseWheel(): ArcRotateCameraInputsManager;
  44088. /**
  44089. * Add pointers input support to the input manager.
  44090. * @returns the current input manager
  44091. */
  44092. addPointers(): ArcRotateCameraInputsManager;
  44093. /**
  44094. * Add keyboard input support to the input manager.
  44095. * @returns the current input manager
  44096. */
  44097. addKeyboard(): ArcRotateCameraInputsManager;
  44098. }
  44099. }
  44100. declare module "babylonjs/Cameras/arcRotateCamera" {
  44101. import { Observable } from "babylonjs/Misc/observable";
  44102. import { Nullable } from "babylonjs/types";
  44103. import { Scene } from "babylonjs/scene";
  44104. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44106. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44107. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44108. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44109. import { Camera } from "babylonjs/Cameras/camera";
  44110. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44111. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44112. import { Collider } from "babylonjs/Collisions/collider";
  44113. /**
  44114. * This represents an orbital type of camera.
  44115. *
  44116. * 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.
  44117. * 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.
  44118. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44119. */
  44120. export class ArcRotateCamera extends TargetCamera {
  44121. /**
  44122. * Defines the rotation angle of the camera along the longitudinal axis.
  44123. */
  44124. alpha: number;
  44125. /**
  44126. * Defines the rotation angle of the camera along the latitudinal axis.
  44127. */
  44128. beta: number;
  44129. /**
  44130. * Defines the radius of the camera from it s target point.
  44131. */
  44132. radius: number;
  44133. protected _target: Vector3;
  44134. protected _targetHost: Nullable<AbstractMesh>;
  44135. /**
  44136. * Defines the target point of the camera.
  44137. * The camera looks towards it form the radius distance.
  44138. */
  44139. get target(): Vector3;
  44140. set target(value: Vector3);
  44141. /**
  44142. * Define the current local position of the camera in the scene
  44143. */
  44144. get position(): Vector3;
  44145. set position(newPosition: Vector3);
  44146. protected _upVector: Vector3;
  44147. protected _upToYMatrix: Matrix;
  44148. protected _YToUpMatrix: Matrix;
  44149. /**
  44150. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44151. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44152. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44153. */
  44154. set upVector(vec: Vector3);
  44155. get upVector(): Vector3;
  44156. /**
  44157. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44158. */
  44159. setMatUp(): void;
  44160. /**
  44161. * Current inertia value on the longitudinal axis.
  44162. * The bigger this number the longer it will take for the camera to stop.
  44163. */
  44164. inertialAlphaOffset: number;
  44165. /**
  44166. * Current inertia value on the latitudinal axis.
  44167. * The bigger this number the longer it will take for the camera to stop.
  44168. */
  44169. inertialBetaOffset: number;
  44170. /**
  44171. * Current inertia value on the radius axis.
  44172. * The bigger this number the longer it will take for the camera to stop.
  44173. */
  44174. inertialRadiusOffset: number;
  44175. /**
  44176. * Minimum allowed angle on the longitudinal axis.
  44177. * This can help limiting how the Camera is able to move in the scene.
  44178. */
  44179. lowerAlphaLimit: Nullable<number>;
  44180. /**
  44181. * Maximum allowed angle on the longitudinal axis.
  44182. * This can help limiting how the Camera is able to move in the scene.
  44183. */
  44184. upperAlphaLimit: Nullable<number>;
  44185. /**
  44186. * Minimum allowed angle on the latitudinal axis.
  44187. * This can help limiting how the Camera is able to move in the scene.
  44188. */
  44189. lowerBetaLimit: number;
  44190. /**
  44191. * Maximum allowed angle on the latitudinal axis.
  44192. * This can help limiting how the Camera is able to move in the scene.
  44193. */
  44194. upperBetaLimit: number;
  44195. /**
  44196. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44197. * This can help limiting how the Camera is able to move in the scene.
  44198. */
  44199. lowerRadiusLimit: Nullable<number>;
  44200. /**
  44201. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44202. * This can help limiting how the Camera is able to move in the scene.
  44203. */
  44204. upperRadiusLimit: Nullable<number>;
  44205. /**
  44206. * Defines the current inertia value used during panning of the camera along the X axis.
  44207. */
  44208. inertialPanningX: number;
  44209. /**
  44210. * Defines the current inertia value used during panning of the camera along the Y axis.
  44211. */
  44212. inertialPanningY: number;
  44213. /**
  44214. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44215. * Basically if your fingers moves away from more than this distance you will be considered
  44216. * in pinch mode.
  44217. */
  44218. pinchToPanMaxDistance: number;
  44219. /**
  44220. * Defines the maximum distance the camera can pan.
  44221. * This could help keeping the cammera always in your scene.
  44222. */
  44223. panningDistanceLimit: Nullable<number>;
  44224. /**
  44225. * Defines the target of the camera before paning.
  44226. */
  44227. panningOriginTarget: Vector3;
  44228. /**
  44229. * Defines the value of the inertia used during panning.
  44230. * 0 would mean stop inertia and one would mean no decelleration at all.
  44231. */
  44232. panningInertia: number;
  44233. /**
  44234. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44235. */
  44236. get angularSensibilityX(): number;
  44237. set angularSensibilityX(value: number);
  44238. /**
  44239. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44240. */
  44241. get angularSensibilityY(): number;
  44242. set angularSensibilityY(value: number);
  44243. /**
  44244. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44245. */
  44246. get pinchPrecision(): number;
  44247. set pinchPrecision(value: number);
  44248. /**
  44249. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44250. * It will be used instead of pinchDeltaPrecision if different from 0.
  44251. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44252. */
  44253. get pinchDeltaPercentage(): number;
  44254. set pinchDeltaPercentage(value: number);
  44255. /**
  44256. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44257. * and pinch delta percentage.
  44258. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44259. * that any object in the plane at the camera's target point will scale
  44260. * perfectly with finger motion.
  44261. */
  44262. get useNaturalPinchZoom(): boolean;
  44263. set useNaturalPinchZoom(value: boolean);
  44264. /**
  44265. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44266. */
  44267. get panningSensibility(): number;
  44268. set panningSensibility(value: number);
  44269. /**
  44270. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44271. */
  44272. get keysUp(): number[];
  44273. set keysUp(value: number[]);
  44274. /**
  44275. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44276. */
  44277. get keysDown(): number[];
  44278. set keysDown(value: number[]);
  44279. /**
  44280. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44281. */
  44282. get keysLeft(): number[];
  44283. set keysLeft(value: number[]);
  44284. /**
  44285. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44286. */
  44287. get keysRight(): number[];
  44288. set keysRight(value: number[]);
  44289. /**
  44290. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44291. */
  44292. get wheelPrecision(): number;
  44293. set wheelPrecision(value: number);
  44294. /**
  44295. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44296. * It will be used instead of pinchDeltaPrecision if different from 0.
  44297. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44298. */
  44299. get wheelDeltaPercentage(): number;
  44300. set wheelDeltaPercentage(value: number);
  44301. /**
  44302. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44303. */
  44304. zoomOnFactor: number;
  44305. /**
  44306. * Defines a screen offset for the camera position.
  44307. */
  44308. targetScreenOffset: Vector2;
  44309. /**
  44310. * Allows the camera to be completely reversed.
  44311. * If false the camera can not arrive upside down.
  44312. */
  44313. allowUpsideDown: boolean;
  44314. /**
  44315. * Define if double tap/click is used to restore the previously saved state of the camera.
  44316. */
  44317. useInputToRestoreState: boolean;
  44318. /** @hidden */
  44319. _viewMatrix: Matrix;
  44320. /** @hidden */
  44321. _useCtrlForPanning: boolean;
  44322. /** @hidden */
  44323. _panningMouseButton: number;
  44324. /**
  44325. * Defines the input associated to the camera.
  44326. */
  44327. inputs: ArcRotateCameraInputsManager;
  44328. /** @hidden */
  44329. _reset: () => void;
  44330. /**
  44331. * Defines the allowed panning axis.
  44332. */
  44333. panningAxis: Vector3;
  44334. protected _localDirection: Vector3;
  44335. protected _transformedDirection: Vector3;
  44336. private _bouncingBehavior;
  44337. /**
  44338. * Gets the bouncing behavior of the camera if it has been enabled.
  44339. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44340. */
  44341. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44342. /**
  44343. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44344. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44345. */
  44346. get useBouncingBehavior(): boolean;
  44347. set useBouncingBehavior(value: boolean);
  44348. private _framingBehavior;
  44349. /**
  44350. * Gets the framing behavior of the camera if it has been enabled.
  44351. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44352. */
  44353. get framingBehavior(): Nullable<FramingBehavior>;
  44354. /**
  44355. * Defines if the framing behavior of the camera is enabled on the camera.
  44356. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44357. */
  44358. get useFramingBehavior(): boolean;
  44359. set useFramingBehavior(value: boolean);
  44360. private _autoRotationBehavior;
  44361. /**
  44362. * Gets the auto rotation behavior of the camera if it has been enabled.
  44363. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44364. */
  44365. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44366. /**
  44367. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44368. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44369. */
  44370. get useAutoRotationBehavior(): boolean;
  44371. set useAutoRotationBehavior(value: boolean);
  44372. /**
  44373. * Observable triggered when the mesh target has been changed on the camera.
  44374. */
  44375. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44376. /**
  44377. * Event raised when the camera is colliding with a mesh.
  44378. */
  44379. onCollide: (collidedMesh: AbstractMesh) => void;
  44380. /**
  44381. * Defines whether the camera should check collision with the objects oh the scene.
  44382. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44383. */
  44384. checkCollisions: boolean;
  44385. /**
  44386. * Defines the collision radius of the camera.
  44387. * This simulates a sphere around the camera.
  44388. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44389. */
  44390. collisionRadius: Vector3;
  44391. protected _collider: Collider;
  44392. protected _previousPosition: Vector3;
  44393. protected _collisionVelocity: Vector3;
  44394. protected _newPosition: Vector3;
  44395. protected _previousAlpha: number;
  44396. protected _previousBeta: number;
  44397. protected _previousRadius: number;
  44398. protected _collisionTriggered: boolean;
  44399. protected _targetBoundingCenter: Nullable<Vector3>;
  44400. private _computationVector;
  44401. /**
  44402. * Instantiates a new ArcRotateCamera in a given scene
  44403. * @param name Defines the name of the camera
  44404. * @param alpha Defines the camera rotation along the logitudinal axis
  44405. * @param beta Defines the camera rotation along the latitudinal axis
  44406. * @param radius Defines the camera distance from its target
  44407. * @param target Defines the camera target
  44408. * @param scene Defines the scene the camera belongs to
  44409. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44410. */
  44411. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44412. /** @hidden */
  44413. _initCache(): void;
  44414. /** @hidden */
  44415. _updateCache(ignoreParentClass?: boolean): void;
  44416. protected _getTargetPosition(): Vector3;
  44417. private _storedAlpha;
  44418. private _storedBeta;
  44419. private _storedRadius;
  44420. private _storedTarget;
  44421. private _storedTargetScreenOffset;
  44422. /**
  44423. * Stores the current state of the camera (alpha, beta, radius and target)
  44424. * @returns the camera itself
  44425. */
  44426. storeState(): Camera;
  44427. /**
  44428. * @hidden
  44429. * Restored camera state. You must call storeState() first
  44430. */
  44431. _restoreStateValues(): boolean;
  44432. /** @hidden */
  44433. _isSynchronizedViewMatrix(): boolean;
  44434. /**
  44435. * Attached controls to the current camera.
  44436. * @param element Defines the element the controls should be listened from
  44437. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44438. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44439. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44440. */
  44441. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44442. /**
  44443. * Detach the current controls from the camera.
  44444. * The camera will stop reacting to inputs.
  44445. * @param element Defines the element to stop listening the inputs from
  44446. */
  44447. detachControl(element: HTMLElement): void;
  44448. /** @hidden */
  44449. _checkInputs(): void;
  44450. protected _checkLimits(): void;
  44451. /**
  44452. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44453. */
  44454. rebuildAnglesAndRadius(): void;
  44455. /**
  44456. * Use a position to define the current camera related information like alpha, beta and radius
  44457. * @param position Defines the position to set the camera at
  44458. */
  44459. setPosition(position: Vector3): void;
  44460. /**
  44461. * Defines the target the camera should look at.
  44462. * This will automatically adapt alpha beta and radius to fit within the new target.
  44463. * @param target Defines the new target as a Vector or a mesh
  44464. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44465. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44466. */
  44467. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44468. /** @hidden */
  44469. _getViewMatrix(): Matrix;
  44470. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44471. /**
  44472. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44473. * @param meshes Defines the mesh to zoom on
  44474. * @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)
  44475. */
  44476. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44477. /**
  44478. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44479. * The target will be changed but the radius
  44480. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44481. * @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)
  44482. */
  44483. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44484. min: Vector3;
  44485. max: Vector3;
  44486. distance: number;
  44487. }, doNotUpdateMaxZ?: boolean): void;
  44488. /**
  44489. * @override
  44490. * Override Camera.createRigCamera
  44491. */
  44492. createRigCamera(name: string, cameraIndex: number): Camera;
  44493. /**
  44494. * @hidden
  44495. * @override
  44496. * Override Camera._updateRigCameras
  44497. */
  44498. _updateRigCameras(): void;
  44499. /**
  44500. * Destroy the camera and release the current resources hold by it.
  44501. */
  44502. dispose(): void;
  44503. /**
  44504. * Gets the current object class name.
  44505. * @return the class name
  44506. */
  44507. getClassName(): string;
  44508. }
  44509. }
  44510. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44511. import { Behavior } from "babylonjs/Behaviors/behavior";
  44512. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44513. /**
  44514. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44515. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44516. */
  44517. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44518. /**
  44519. * Gets the name of the behavior.
  44520. */
  44521. get name(): string;
  44522. private _zoomStopsAnimation;
  44523. private _idleRotationSpeed;
  44524. private _idleRotationWaitTime;
  44525. private _idleRotationSpinupTime;
  44526. /**
  44527. * Sets the flag that indicates if user zooming should stop animation.
  44528. */
  44529. set zoomStopsAnimation(flag: boolean);
  44530. /**
  44531. * Gets the flag that indicates if user zooming should stop animation.
  44532. */
  44533. get zoomStopsAnimation(): boolean;
  44534. /**
  44535. * Sets the default speed at which the camera rotates around the model.
  44536. */
  44537. set idleRotationSpeed(speed: number);
  44538. /**
  44539. * Gets the default speed at which the camera rotates around the model.
  44540. */
  44541. get idleRotationSpeed(): number;
  44542. /**
  44543. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44544. */
  44545. set idleRotationWaitTime(time: number);
  44546. /**
  44547. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44548. */
  44549. get idleRotationWaitTime(): number;
  44550. /**
  44551. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44552. */
  44553. set idleRotationSpinupTime(time: number);
  44554. /**
  44555. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44556. */
  44557. get idleRotationSpinupTime(): number;
  44558. /**
  44559. * Gets a value indicating if the camera is currently rotating because of this behavior
  44560. */
  44561. get rotationInProgress(): boolean;
  44562. private _onPrePointerObservableObserver;
  44563. private _onAfterCheckInputsObserver;
  44564. private _attachedCamera;
  44565. private _isPointerDown;
  44566. private _lastFrameTime;
  44567. private _lastInteractionTime;
  44568. private _cameraRotationSpeed;
  44569. /**
  44570. * Initializes the behavior.
  44571. */
  44572. init(): void;
  44573. /**
  44574. * Attaches the behavior to its arc rotate camera.
  44575. * @param camera Defines the camera to attach the behavior to
  44576. */
  44577. attach(camera: ArcRotateCamera): void;
  44578. /**
  44579. * Detaches the behavior from its current arc rotate camera.
  44580. */
  44581. detach(): void;
  44582. /**
  44583. * Returns true if user is scrolling.
  44584. * @return true if user is scrolling.
  44585. */
  44586. private _userIsZooming;
  44587. private _lastFrameRadius;
  44588. private _shouldAnimationStopForInteraction;
  44589. /**
  44590. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44591. */
  44592. private _applyUserInteraction;
  44593. private _userIsMoving;
  44594. }
  44595. }
  44596. declare module "babylonjs/Behaviors/Cameras/index" {
  44597. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44598. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44599. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44600. }
  44601. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44602. import { Mesh } from "babylonjs/Meshes/mesh";
  44603. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44604. import { Behavior } from "babylonjs/Behaviors/behavior";
  44605. /**
  44606. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44607. */
  44608. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44609. private ui;
  44610. /**
  44611. * The name of the behavior
  44612. */
  44613. name: string;
  44614. /**
  44615. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44616. */
  44617. distanceAwayFromFace: number;
  44618. /**
  44619. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44620. */
  44621. distanceAwayFromBottomOfFace: number;
  44622. private _faceVectors;
  44623. private _target;
  44624. private _scene;
  44625. private _onRenderObserver;
  44626. private _tmpMatrix;
  44627. private _tmpVector;
  44628. /**
  44629. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44630. * @param ui The transform node that should be attched to the mesh
  44631. */
  44632. constructor(ui: TransformNode);
  44633. /**
  44634. * Initializes the behavior
  44635. */
  44636. init(): void;
  44637. private _closestFace;
  44638. private _zeroVector;
  44639. private _lookAtTmpMatrix;
  44640. private _lookAtToRef;
  44641. /**
  44642. * Attaches the AttachToBoxBehavior to the passed in mesh
  44643. * @param target The mesh that the specified node will be attached to
  44644. */
  44645. attach(target: Mesh): void;
  44646. /**
  44647. * Detaches the behavior from the mesh
  44648. */
  44649. detach(): void;
  44650. }
  44651. }
  44652. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44653. import { Behavior } from "babylonjs/Behaviors/behavior";
  44654. import { Mesh } from "babylonjs/Meshes/mesh";
  44655. /**
  44656. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44657. */
  44658. export class FadeInOutBehavior implements Behavior<Mesh> {
  44659. /**
  44660. * Time in milliseconds to delay before fading in (Default: 0)
  44661. */
  44662. delay: number;
  44663. /**
  44664. * Time in milliseconds for the mesh to fade in (Default: 300)
  44665. */
  44666. fadeInTime: number;
  44667. private _millisecondsPerFrame;
  44668. private _hovered;
  44669. private _hoverValue;
  44670. private _ownerNode;
  44671. /**
  44672. * Instatiates the FadeInOutBehavior
  44673. */
  44674. constructor();
  44675. /**
  44676. * The name of the behavior
  44677. */
  44678. get name(): string;
  44679. /**
  44680. * Initializes the behavior
  44681. */
  44682. init(): void;
  44683. /**
  44684. * Attaches the fade behavior on the passed in mesh
  44685. * @param ownerNode The mesh that will be faded in/out once attached
  44686. */
  44687. attach(ownerNode: Mesh): void;
  44688. /**
  44689. * Detaches the behavior from the mesh
  44690. */
  44691. detach(): void;
  44692. /**
  44693. * Triggers the mesh to begin fading in or out
  44694. * @param value if the object should fade in or out (true to fade in)
  44695. */
  44696. fadeIn(value: boolean): void;
  44697. private _update;
  44698. private _setAllVisibility;
  44699. }
  44700. }
  44701. declare module "babylonjs/Misc/pivotTools" {
  44702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44703. /**
  44704. * Class containing a set of static utilities functions for managing Pivots
  44705. * @hidden
  44706. */
  44707. export class PivotTools {
  44708. private static _PivotCached;
  44709. private static _OldPivotPoint;
  44710. private static _PivotTranslation;
  44711. private static _PivotTmpVector;
  44712. /** @hidden */
  44713. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  44714. /** @hidden */
  44715. static _RestorePivotPoint(mesh: AbstractMesh): void;
  44716. }
  44717. }
  44718. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  44719. import { Scene } from "babylonjs/scene";
  44720. import { Vector4 } from "babylonjs/Maths/math.vector";
  44721. import { Mesh } from "babylonjs/Meshes/mesh";
  44722. import { Nullable } from "babylonjs/types";
  44723. import { Plane } from "babylonjs/Maths/math.plane";
  44724. /**
  44725. * Class containing static functions to help procedurally build meshes
  44726. */
  44727. export class PlaneBuilder {
  44728. /**
  44729. * Creates a plane mesh
  44730. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  44731. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  44732. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  44733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44736. * @param name defines the name of the mesh
  44737. * @param options defines the options used to create the mesh
  44738. * @param scene defines the hosting scene
  44739. * @returns the plane mesh
  44740. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  44741. */
  44742. static CreatePlane(name: string, options: {
  44743. size?: number;
  44744. width?: number;
  44745. height?: number;
  44746. sideOrientation?: number;
  44747. frontUVs?: Vector4;
  44748. backUVs?: Vector4;
  44749. updatable?: boolean;
  44750. sourcePlane?: Plane;
  44751. }, scene?: Nullable<Scene>): Mesh;
  44752. }
  44753. }
  44754. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  44755. import { Behavior } from "babylonjs/Behaviors/behavior";
  44756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44757. import { Observable } from "babylonjs/Misc/observable";
  44758. import { Vector3 } from "babylonjs/Maths/math.vector";
  44759. import { Ray } from "babylonjs/Culling/ray";
  44760. import "babylonjs/Meshes/Builders/planeBuilder";
  44761. /**
  44762. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  44763. */
  44764. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  44765. private static _AnyMouseID;
  44766. /**
  44767. * Abstract mesh the behavior is set on
  44768. */
  44769. attachedNode: AbstractMesh;
  44770. private _dragPlane;
  44771. private _scene;
  44772. private _pointerObserver;
  44773. private _beforeRenderObserver;
  44774. private static _planeScene;
  44775. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  44776. /**
  44777. * 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)
  44778. */
  44779. maxDragAngle: number;
  44780. /**
  44781. * @hidden
  44782. */
  44783. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  44784. /**
  44785. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44786. */
  44787. currentDraggingPointerID: number;
  44788. /**
  44789. * The last position where the pointer hit the drag plane in world space
  44790. */
  44791. lastDragPosition: Vector3;
  44792. /**
  44793. * If the behavior is currently in a dragging state
  44794. */
  44795. dragging: boolean;
  44796. /**
  44797. * 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)
  44798. */
  44799. dragDeltaRatio: number;
  44800. /**
  44801. * If the drag plane orientation should be updated during the dragging (Default: true)
  44802. */
  44803. updateDragPlane: boolean;
  44804. private _debugMode;
  44805. private _moving;
  44806. /**
  44807. * Fires each time the attached mesh is dragged with the pointer
  44808. * * delta between last drag position and current drag position in world space
  44809. * * dragDistance along the drag axis
  44810. * * dragPlaneNormal normal of the current drag plane used during the drag
  44811. * * dragPlanePoint in world space where the drag intersects the drag plane
  44812. */
  44813. onDragObservable: Observable<{
  44814. delta: Vector3;
  44815. dragPlanePoint: Vector3;
  44816. dragPlaneNormal: Vector3;
  44817. dragDistance: number;
  44818. pointerId: number;
  44819. }>;
  44820. /**
  44821. * Fires each time a drag begins (eg. mouse down on mesh)
  44822. */
  44823. onDragStartObservable: Observable<{
  44824. dragPlanePoint: Vector3;
  44825. pointerId: number;
  44826. }>;
  44827. /**
  44828. * Fires each time a drag ends (eg. mouse release after drag)
  44829. */
  44830. onDragEndObservable: Observable<{
  44831. dragPlanePoint: Vector3;
  44832. pointerId: number;
  44833. }>;
  44834. /**
  44835. * If the attached mesh should be moved when dragged
  44836. */
  44837. moveAttached: boolean;
  44838. /**
  44839. * If the drag behavior will react to drag events (Default: true)
  44840. */
  44841. enabled: boolean;
  44842. /**
  44843. * If pointer events should start and release the drag (Default: true)
  44844. */
  44845. startAndReleaseDragOnPointerEvents: boolean;
  44846. /**
  44847. * If camera controls should be detached during the drag
  44848. */
  44849. detachCameraControls: boolean;
  44850. /**
  44851. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  44852. */
  44853. useObjectOrientationForDragging: boolean;
  44854. private _options;
  44855. /**
  44856. * Gets the options used by the behavior
  44857. */
  44858. get options(): {
  44859. dragAxis?: Vector3;
  44860. dragPlaneNormal?: Vector3;
  44861. };
  44862. /**
  44863. * Sets the options used by the behavior
  44864. */
  44865. set options(options: {
  44866. dragAxis?: Vector3;
  44867. dragPlaneNormal?: Vector3;
  44868. });
  44869. /**
  44870. * Creates a pointer drag behavior that can be attached to a mesh
  44871. * @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)
  44872. */
  44873. constructor(options?: {
  44874. dragAxis?: Vector3;
  44875. dragPlaneNormal?: Vector3;
  44876. });
  44877. /**
  44878. * Predicate to determine if it is valid to move the object to a new position when it is moved
  44879. */
  44880. validateDrag: (targetPosition: Vector3) => boolean;
  44881. /**
  44882. * The name of the behavior
  44883. */
  44884. get name(): string;
  44885. /**
  44886. * Initializes the behavior
  44887. */
  44888. init(): void;
  44889. private _tmpVector;
  44890. private _alternatePickedPoint;
  44891. private _worldDragAxis;
  44892. private _targetPosition;
  44893. private _attachedElement;
  44894. /**
  44895. * Attaches the drag behavior the passed in mesh
  44896. * @param ownerNode The mesh that will be dragged around once attached
  44897. * @param predicate Predicate to use for pick filtering
  44898. */
  44899. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  44900. /**
  44901. * Force relase the drag action by code.
  44902. */
  44903. releaseDrag(): void;
  44904. private _startDragRay;
  44905. private _lastPointerRay;
  44906. /**
  44907. * Simulates the start of a pointer drag event on the behavior
  44908. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  44909. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  44910. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  44911. */
  44912. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  44913. private _startDrag;
  44914. private _dragDelta;
  44915. private _moveDrag;
  44916. private _pickWithRayOnDragPlane;
  44917. private _pointA;
  44918. private _pointC;
  44919. private _localAxis;
  44920. private _lookAt;
  44921. private _updateDragPlanePosition;
  44922. /**
  44923. * Detaches the behavior from the mesh
  44924. */
  44925. detach(): void;
  44926. }
  44927. }
  44928. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  44929. import { Mesh } from "babylonjs/Meshes/mesh";
  44930. import { Behavior } from "babylonjs/Behaviors/behavior";
  44931. /**
  44932. * A behavior that when attached to a mesh will allow the mesh to be scaled
  44933. */
  44934. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  44935. private _dragBehaviorA;
  44936. private _dragBehaviorB;
  44937. private _startDistance;
  44938. private _initialScale;
  44939. private _targetScale;
  44940. private _ownerNode;
  44941. private _sceneRenderObserver;
  44942. /**
  44943. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  44944. */
  44945. constructor();
  44946. /**
  44947. * The name of the behavior
  44948. */
  44949. get name(): string;
  44950. /**
  44951. * Initializes the behavior
  44952. */
  44953. init(): void;
  44954. private _getCurrentDistance;
  44955. /**
  44956. * Attaches the scale behavior the passed in mesh
  44957. * @param ownerNode The mesh that will be scaled around once attached
  44958. */
  44959. attach(ownerNode: Mesh): void;
  44960. /**
  44961. * Detaches the behavior from the mesh
  44962. */
  44963. detach(): void;
  44964. }
  44965. }
  44966. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  44967. import { Behavior } from "babylonjs/Behaviors/behavior";
  44968. import { Mesh } from "babylonjs/Meshes/mesh";
  44969. import { Observable } from "babylonjs/Misc/observable";
  44970. /**
  44971. * 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
  44972. */
  44973. export class SixDofDragBehavior implements Behavior<Mesh> {
  44974. private static _virtualScene;
  44975. private _ownerNode;
  44976. private _sceneRenderObserver;
  44977. private _scene;
  44978. private _targetPosition;
  44979. private _virtualOriginMesh;
  44980. private _virtualDragMesh;
  44981. private _pointerObserver;
  44982. private _moving;
  44983. private _startingOrientation;
  44984. private _attachedElement;
  44985. /**
  44986. * 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)
  44987. */
  44988. private zDragFactor;
  44989. /**
  44990. * If the object should rotate to face the drag origin
  44991. */
  44992. rotateDraggedObject: boolean;
  44993. /**
  44994. * If the behavior is currently in a dragging state
  44995. */
  44996. dragging: boolean;
  44997. /**
  44998. * 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)
  44999. */
  45000. dragDeltaRatio: number;
  45001. /**
  45002. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45003. */
  45004. currentDraggingPointerID: number;
  45005. /**
  45006. * If camera controls should be detached during the drag
  45007. */
  45008. detachCameraControls: boolean;
  45009. /**
  45010. * Fires each time a drag starts
  45011. */
  45012. onDragStartObservable: Observable<{}>;
  45013. /**
  45014. * Fires each time a drag ends (eg. mouse release after drag)
  45015. */
  45016. onDragEndObservable: Observable<{}>;
  45017. /**
  45018. * 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
  45019. */
  45020. constructor();
  45021. /**
  45022. * The name of the behavior
  45023. */
  45024. get name(): string;
  45025. /**
  45026. * Initializes the behavior
  45027. */
  45028. init(): void;
  45029. /**
  45030. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45031. */
  45032. private get _pointerCamera();
  45033. /**
  45034. * Attaches the scale behavior the passed in mesh
  45035. * @param ownerNode The mesh that will be scaled around once attached
  45036. */
  45037. attach(ownerNode: Mesh): void;
  45038. /**
  45039. * Detaches the behavior from the mesh
  45040. */
  45041. detach(): void;
  45042. }
  45043. }
  45044. declare module "babylonjs/Behaviors/Meshes/index" {
  45045. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45046. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45047. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45048. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45049. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45050. }
  45051. declare module "babylonjs/Behaviors/index" {
  45052. export * from "babylonjs/Behaviors/behavior";
  45053. export * from "babylonjs/Behaviors/Cameras/index";
  45054. export * from "babylonjs/Behaviors/Meshes/index";
  45055. }
  45056. declare module "babylonjs/Bones/boneIKController" {
  45057. import { Bone } from "babylonjs/Bones/bone";
  45058. import { Vector3 } from "babylonjs/Maths/math.vector";
  45059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45060. import { Nullable } from "babylonjs/types";
  45061. /**
  45062. * Class used to apply inverse kinematics to bones
  45063. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45064. */
  45065. export class BoneIKController {
  45066. private static _tmpVecs;
  45067. private static _tmpQuat;
  45068. private static _tmpMats;
  45069. /**
  45070. * Gets or sets the target mesh
  45071. */
  45072. targetMesh: AbstractMesh;
  45073. /** Gets or sets the mesh used as pole */
  45074. poleTargetMesh: AbstractMesh;
  45075. /**
  45076. * Gets or sets the bone used as pole
  45077. */
  45078. poleTargetBone: Nullable<Bone>;
  45079. /**
  45080. * Gets or sets the target position
  45081. */
  45082. targetPosition: Vector3;
  45083. /**
  45084. * Gets or sets the pole target position
  45085. */
  45086. poleTargetPosition: Vector3;
  45087. /**
  45088. * Gets or sets the pole target local offset
  45089. */
  45090. poleTargetLocalOffset: Vector3;
  45091. /**
  45092. * Gets or sets the pole angle
  45093. */
  45094. poleAngle: number;
  45095. /**
  45096. * Gets or sets the mesh associated with the controller
  45097. */
  45098. mesh: AbstractMesh;
  45099. /**
  45100. * 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)
  45101. */
  45102. slerpAmount: number;
  45103. private _bone1Quat;
  45104. private _bone1Mat;
  45105. private _bone2Ang;
  45106. private _bone1;
  45107. private _bone2;
  45108. private _bone1Length;
  45109. private _bone2Length;
  45110. private _maxAngle;
  45111. private _maxReach;
  45112. private _rightHandedSystem;
  45113. private _bendAxis;
  45114. private _slerping;
  45115. private _adjustRoll;
  45116. /**
  45117. * Gets or sets maximum allowed angle
  45118. */
  45119. get maxAngle(): number;
  45120. set maxAngle(value: number);
  45121. /**
  45122. * Creates a new BoneIKController
  45123. * @param mesh defines the mesh to control
  45124. * @param bone defines the bone to control
  45125. * @param options defines options to set up the controller
  45126. */
  45127. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45128. targetMesh?: AbstractMesh;
  45129. poleTargetMesh?: AbstractMesh;
  45130. poleTargetBone?: Bone;
  45131. poleTargetLocalOffset?: Vector3;
  45132. poleAngle?: number;
  45133. bendAxis?: Vector3;
  45134. maxAngle?: number;
  45135. slerpAmount?: number;
  45136. });
  45137. private _setMaxAngle;
  45138. /**
  45139. * Force the controller to update the bones
  45140. */
  45141. update(): void;
  45142. }
  45143. }
  45144. declare module "babylonjs/Bones/boneLookController" {
  45145. import { Vector3 } from "babylonjs/Maths/math.vector";
  45146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45147. import { Bone } from "babylonjs/Bones/bone";
  45148. import { Space } from "babylonjs/Maths/math.axis";
  45149. /**
  45150. * Class used to make a bone look toward a point in space
  45151. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45152. */
  45153. export class BoneLookController {
  45154. private static _tmpVecs;
  45155. private static _tmpQuat;
  45156. private static _tmpMats;
  45157. /**
  45158. * The target Vector3 that the bone will look at
  45159. */
  45160. target: Vector3;
  45161. /**
  45162. * The mesh that the bone is attached to
  45163. */
  45164. mesh: AbstractMesh;
  45165. /**
  45166. * The bone that will be looking to the target
  45167. */
  45168. bone: Bone;
  45169. /**
  45170. * The up axis of the coordinate system that is used when the bone is rotated
  45171. */
  45172. upAxis: Vector3;
  45173. /**
  45174. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45175. */
  45176. upAxisSpace: Space;
  45177. /**
  45178. * Used to make an adjustment to the yaw of the bone
  45179. */
  45180. adjustYaw: number;
  45181. /**
  45182. * Used to make an adjustment to the pitch of the bone
  45183. */
  45184. adjustPitch: number;
  45185. /**
  45186. * Used to make an adjustment to the roll of the bone
  45187. */
  45188. adjustRoll: number;
  45189. /**
  45190. * 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)
  45191. */
  45192. slerpAmount: number;
  45193. private _minYaw;
  45194. private _maxYaw;
  45195. private _minPitch;
  45196. private _maxPitch;
  45197. private _minYawSin;
  45198. private _minYawCos;
  45199. private _maxYawSin;
  45200. private _maxYawCos;
  45201. private _midYawConstraint;
  45202. private _minPitchTan;
  45203. private _maxPitchTan;
  45204. private _boneQuat;
  45205. private _slerping;
  45206. private _transformYawPitch;
  45207. private _transformYawPitchInv;
  45208. private _firstFrameSkipped;
  45209. private _yawRange;
  45210. private _fowardAxis;
  45211. /**
  45212. * Gets or sets the minimum yaw angle that the bone can look to
  45213. */
  45214. get minYaw(): number;
  45215. set minYaw(value: number);
  45216. /**
  45217. * Gets or sets the maximum yaw angle that the bone can look to
  45218. */
  45219. get maxYaw(): number;
  45220. set maxYaw(value: number);
  45221. /**
  45222. * Gets or sets the minimum pitch angle that the bone can look to
  45223. */
  45224. get minPitch(): number;
  45225. set minPitch(value: number);
  45226. /**
  45227. * Gets or sets the maximum pitch angle that the bone can look to
  45228. */
  45229. get maxPitch(): number;
  45230. set maxPitch(value: number);
  45231. /**
  45232. * Create a BoneLookController
  45233. * @param mesh the mesh that the bone belongs to
  45234. * @param bone the bone that will be looking to the target
  45235. * @param target the target Vector3 to look at
  45236. * @param options optional settings:
  45237. * * maxYaw: the maximum angle the bone will yaw to
  45238. * * minYaw: the minimum angle the bone will yaw to
  45239. * * maxPitch: the maximum angle the bone will pitch to
  45240. * * minPitch: the minimum angle the bone will yaw to
  45241. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45242. * * upAxis: the up axis of the coordinate system
  45243. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45244. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45245. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45246. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45247. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45248. * * adjustRoll: used to make an adjustment to the roll of the bone
  45249. **/
  45250. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45251. maxYaw?: number;
  45252. minYaw?: number;
  45253. maxPitch?: number;
  45254. minPitch?: number;
  45255. slerpAmount?: number;
  45256. upAxis?: Vector3;
  45257. upAxisSpace?: Space;
  45258. yawAxis?: Vector3;
  45259. pitchAxis?: Vector3;
  45260. adjustYaw?: number;
  45261. adjustPitch?: number;
  45262. adjustRoll?: number;
  45263. });
  45264. /**
  45265. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45266. */
  45267. update(): void;
  45268. private _getAngleDiff;
  45269. private _getAngleBetween;
  45270. private _isAngleBetween;
  45271. }
  45272. }
  45273. declare module "babylonjs/Bones/index" {
  45274. export * from "babylonjs/Bones/bone";
  45275. export * from "babylonjs/Bones/boneIKController";
  45276. export * from "babylonjs/Bones/boneLookController";
  45277. export * from "babylonjs/Bones/skeleton";
  45278. }
  45279. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45280. import { Nullable } from "babylonjs/types";
  45281. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45282. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45283. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45284. /**
  45285. * Manage the gamepad inputs to control an arc rotate camera.
  45286. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45287. */
  45288. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45289. /**
  45290. * Defines the camera the input is attached to.
  45291. */
  45292. camera: ArcRotateCamera;
  45293. /**
  45294. * Defines the gamepad the input is gathering event from.
  45295. */
  45296. gamepad: Nullable<Gamepad>;
  45297. /**
  45298. * Defines the gamepad rotation sensiblity.
  45299. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45300. */
  45301. gamepadRotationSensibility: number;
  45302. /**
  45303. * Defines the gamepad move sensiblity.
  45304. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45305. */
  45306. gamepadMoveSensibility: number;
  45307. private _yAxisScale;
  45308. /**
  45309. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45310. */
  45311. get invertYAxis(): boolean;
  45312. set invertYAxis(value: boolean);
  45313. private _onGamepadConnectedObserver;
  45314. private _onGamepadDisconnectedObserver;
  45315. /**
  45316. * Attach the input controls to a specific dom element to get the input from.
  45317. * @param element Defines the element the controls should be listened from
  45318. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45319. */
  45320. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45321. /**
  45322. * Detach the current controls from the specified dom element.
  45323. * @param element Defines the element to stop listening the inputs from
  45324. */
  45325. detachControl(element: Nullable<HTMLElement>): void;
  45326. /**
  45327. * Update the current camera state depending on the inputs that have been used this frame.
  45328. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45329. */
  45330. checkInputs(): void;
  45331. /**
  45332. * Gets the class name of the current intput.
  45333. * @returns the class name
  45334. */
  45335. getClassName(): string;
  45336. /**
  45337. * Get the friendly name associated with the input class.
  45338. * @returns the input friendly name
  45339. */
  45340. getSimpleName(): string;
  45341. }
  45342. }
  45343. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45344. import { Nullable } from "babylonjs/types";
  45345. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45346. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45347. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45348. interface ArcRotateCameraInputsManager {
  45349. /**
  45350. * Add orientation input support to the input manager.
  45351. * @returns the current input manager
  45352. */
  45353. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45354. }
  45355. }
  45356. /**
  45357. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45358. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45359. */
  45360. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45361. /**
  45362. * Defines the camera the input is attached to.
  45363. */
  45364. camera: ArcRotateCamera;
  45365. /**
  45366. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45367. */
  45368. alphaCorrection: number;
  45369. /**
  45370. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45371. */
  45372. gammaCorrection: number;
  45373. private _alpha;
  45374. private _gamma;
  45375. private _dirty;
  45376. private _deviceOrientationHandler;
  45377. /**
  45378. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45379. */
  45380. constructor();
  45381. /**
  45382. * Attach the input controls to a specific dom element to get the input from.
  45383. * @param element Defines the element the controls should be listened from
  45384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45385. */
  45386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45387. /** @hidden */
  45388. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45389. /**
  45390. * Update the current camera state depending on the inputs that have been used this frame.
  45391. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45392. */
  45393. checkInputs(): void;
  45394. /**
  45395. * Detach the current controls from the specified dom element.
  45396. * @param element Defines the element to stop listening the inputs from
  45397. */
  45398. detachControl(element: Nullable<HTMLElement>): void;
  45399. /**
  45400. * Gets the class name of the current intput.
  45401. * @returns the class name
  45402. */
  45403. getClassName(): string;
  45404. /**
  45405. * Get the friendly name associated with the input class.
  45406. * @returns the input friendly name
  45407. */
  45408. getSimpleName(): string;
  45409. }
  45410. }
  45411. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45412. import { Nullable } from "babylonjs/types";
  45413. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45414. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45415. /**
  45416. * Listen to mouse events to control the camera.
  45417. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45418. */
  45419. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45420. /**
  45421. * Defines the camera the input is attached to.
  45422. */
  45423. camera: FlyCamera;
  45424. /**
  45425. * Defines if touch is enabled. (Default is true.)
  45426. */
  45427. touchEnabled: boolean;
  45428. /**
  45429. * Defines the buttons associated with the input to handle camera rotation.
  45430. */
  45431. buttons: number[];
  45432. /**
  45433. * Assign buttons for Yaw control.
  45434. */
  45435. buttonsYaw: number[];
  45436. /**
  45437. * Assign buttons for Pitch control.
  45438. */
  45439. buttonsPitch: number[];
  45440. /**
  45441. * Assign buttons for Roll control.
  45442. */
  45443. buttonsRoll: number[];
  45444. /**
  45445. * Detect if any button is being pressed while mouse is moved.
  45446. * -1 = Mouse locked.
  45447. * 0 = Left button.
  45448. * 1 = Middle Button.
  45449. * 2 = Right Button.
  45450. */
  45451. activeButton: number;
  45452. /**
  45453. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45454. * Higher values reduce its sensitivity.
  45455. */
  45456. angularSensibility: number;
  45457. private _mousemoveCallback;
  45458. private _observer;
  45459. private _rollObserver;
  45460. private previousPosition;
  45461. private noPreventDefault;
  45462. private element;
  45463. /**
  45464. * Listen to mouse events to control the camera.
  45465. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45466. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45467. */
  45468. constructor(touchEnabled?: boolean);
  45469. /**
  45470. * Attach the mouse control to the HTML DOM element.
  45471. * @param element Defines the element that listens to the input events.
  45472. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45473. */
  45474. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45475. /**
  45476. * Detach the current controls from the specified dom element.
  45477. * @param element Defines the element to stop listening the inputs from
  45478. */
  45479. detachControl(element: Nullable<HTMLElement>): void;
  45480. /**
  45481. * Gets the class name of the current input.
  45482. * @returns the class name.
  45483. */
  45484. getClassName(): string;
  45485. /**
  45486. * Get the friendly name associated with the input class.
  45487. * @returns the input's friendly name.
  45488. */
  45489. getSimpleName(): string;
  45490. private _pointerInput;
  45491. private _onMouseMove;
  45492. /**
  45493. * Rotate camera by mouse offset.
  45494. */
  45495. private rotateCamera;
  45496. }
  45497. }
  45498. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45499. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45500. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45501. /**
  45502. * Default Inputs manager for the FlyCamera.
  45503. * It groups all the default supported inputs for ease of use.
  45504. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45505. */
  45506. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45507. /**
  45508. * Instantiates a new FlyCameraInputsManager.
  45509. * @param camera Defines the camera the inputs belong to.
  45510. */
  45511. constructor(camera: FlyCamera);
  45512. /**
  45513. * Add keyboard input support to the input manager.
  45514. * @returns the new FlyCameraKeyboardMoveInput().
  45515. */
  45516. addKeyboard(): FlyCameraInputsManager;
  45517. /**
  45518. * Add mouse input support to the input manager.
  45519. * @param touchEnabled Enable touch screen support.
  45520. * @returns the new FlyCameraMouseInput().
  45521. */
  45522. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45523. }
  45524. }
  45525. declare module "babylonjs/Cameras/flyCamera" {
  45526. import { Scene } from "babylonjs/scene";
  45527. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45529. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45530. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45531. /**
  45532. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45533. * such as in a 3D Space Shooter or a Flight Simulator.
  45534. */
  45535. export class FlyCamera extends TargetCamera {
  45536. /**
  45537. * Define the collision ellipsoid of the camera.
  45538. * This is helpful for simulating a camera body, like a player's body.
  45539. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45540. */
  45541. ellipsoid: Vector3;
  45542. /**
  45543. * Define an offset for the position of the ellipsoid around the camera.
  45544. * This can be helpful if the camera is attached away from the player's body center,
  45545. * such as at its head.
  45546. */
  45547. ellipsoidOffset: Vector3;
  45548. /**
  45549. * Enable or disable collisions of the camera with the rest of the scene objects.
  45550. */
  45551. checkCollisions: boolean;
  45552. /**
  45553. * Enable or disable gravity on the camera.
  45554. */
  45555. applyGravity: boolean;
  45556. /**
  45557. * Define the current direction the camera is moving to.
  45558. */
  45559. cameraDirection: Vector3;
  45560. /**
  45561. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45562. * This overrides and empties cameraRotation.
  45563. */
  45564. rotationQuaternion: Quaternion;
  45565. /**
  45566. * Track Roll to maintain the wanted Rolling when looking around.
  45567. */
  45568. _trackRoll: number;
  45569. /**
  45570. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45571. */
  45572. rollCorrect: number;
  45573. /**
  45574. * Mimic a banked turn, Rolling the camera when Yawing.
  45575. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45576. */
  45577. bankedTurn: boolean;
  45578. /**
  45579. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45580. */
  45581. bankedTurnLimit: number;
  45582. /**
  45583. * Value of 0 disables the banked Roll.
  45584. * Value of 1 is equal to the Yaw angle in radians.
  45585. */
  45586. bankedTurnMultiplier: number;
  45587. /**
  45588. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45589. */
  45590. inputs: FlyCameraInputsManager;
  45591. /**
  45592. * Gets the input sensibility for mouse input.
  45593. * Higher values reduce sensitivity.
  45594. */
  45595. get angularSensibility(): number;
  45596. /**
  45597. * Sets the input sensibility for a mouse input.
  45598. * Higher values reduce sensitivity.
  45599. */
  45600. set angularSensibility(value: number);
  45601. /**
  45602. * Get the keys for camera movement forward.
  45603. */
  45604. get keysForward(): number[];
  45605. /**
  45606. * Set the keys for camera movement forward.
  45607. */
  45608. set keysForward(value: number[]);
  45609. /**
  45610. * Get the keys for camera movement backward.
  45611. */
  45612. get keysBackward(): number[];
  45613. set keysBackward(value: number[]);
  45614. /**
  45615. * Get the keys for camera movement up.
  45616. */
  45617. get keysUp(): number[];
  45618. /**
  45619. * Set the keys for camera movement up.
  45620. */
  45621. set keysUp(value: number[]);
  45622. /**
  45623. * Get the keys for camera movement down.
  45624. */
  45625. get keysDown(): number[];
  45626. /**
  45627. * Set the keys for camera movement down.
  45628. */
  45629. set keysDown(value: number[]);
  45630. /**
  45631. * Get the keys for camera movement left.
  45632. */
  45633. get keysLeft(): number[];
  45634. /**
  45635. * Set the keys for camera movement left.
  45636. */
  45637. set keysLeft(value: number[]);
  45638. /**
  45639. * Set the keys for camera movement right.
  45640. */
  45641. get keysRight(): number[];
  45642. /**
  45643. * Set the keys for camera movement right.
  45644. */
  45645. set keysRight(value: number[]);
  45646. /**
  45647. * Event raised when the camera collides with a mesh in the scene.
  45648. */
  45649. onCollide: (collidedMesh: AbstractMesh) => void;
  45650. private _collider;
  45651. private _needMoveForGravity;
  45652. private _oldPosition;
  45653. private _diffPosition;
  45654. private _newPosition;
  45655. /** @hidden */
  45656. _localDirection: Vector3;
  45657. /** @hidden */
  45658. _transformedDirection: Vector3;
  45659. /**
  45660. * Instantiates a FlyCamera.
  45661. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45662. * such as in a 3D Space Shooter or a Flight Simulator.
  45663. * @param name Define the name of the camera in the scene.
  45664. * @param position Define the starting position of the camera in the scene.
  45665. * @param scene Define the scene the camera belongs to.
  45666. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45667. */
  45668. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45669. /**
  45670. * Attach a control to the HTML DOM element.
  45671. * @param element Defines the element that listens to the input events.
  45672. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  45673. */
  45674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45675. /**
  45676. * Detach a control from the HTML DOM element.
  45677. * The camera will stop reacting to that input.
  45678. * @param element Defines the element that listens to the input events.
  45679. */
  45680. detachControl(element: HTMLElement): void;
  45681. private _collisionMask;
  45682. /**
  45683. * Get the mask that the camera ignores in collision events.
  45684. */
  45685. get collisionMask(): number;
  45686. /**
  45687. * Set the mask that the camera ignores in collision events.
  45688. */
  45689. set collisionMask(mask: number);
  45690. /** @hidden */
  45691. _collideWithWorld(displacement: Vector3): void;
  45692. /** @hidden */
  45693. private _onCollisionPositionChange;
  45694. /** @hidden */
  45695. _checkInputs(): void;
  45696. /** @hidden */
  45697. _decideIfNeedsToMove(): boolean;
  45698. /** @hidden */
  45699. _updatePosition(): void;
  45700. /**
  45701. * Restore the Roll to its target value at the rate specified.
  45702. * @param rate - Higher means slower restoring.
  45703. * @hidden
  45704. */
  45705. restoreRoll(rate: number): void;
  45706. /**
  45707. * Destroy the camera and release the current resources held by it.
  45708. */
  45709. dispose(): void;
  45710. /**
  45711. * Get the current object class name.
  45712. * @returns the class name.
  45713. */
  45714. getClassName(): string;
  45715. }
  45716. }
  45717. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  45718. import { Nullable } from "babylonjs/types";
  45719. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45720. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45721. /**
  45722. * Listen to keyboard events to control the camera.
  45723. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45724. */
  45725. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  45726. /**
  45727. * Defines the camera the input is attached to.
  45728. */
  45729. camera: FlyCamera;
  45730. /**
  45731. * The list of keyboard keys used to control the forward move of the camera.
  45732. */
  45733. keysForward: number[];
  45734. /**
  45735. * The list of keyboard keys used to control the backward move of the camera.
  45736. */
  45737. keysBackward: number[];
  45738. /**
  45739. * The list of keyboard keys used to control the forward move of the camera.
  45740. */
  45741. keysUp: number[];
  45742. /**
  45743. * The list of keyboard keys used to control the backward move of the camera.
  45744. */
  45745. keysDown: number[];
  45746. /**
  45747. * The list of keyboard keys used to control the right strafe move of the camera.
  45748. */
  45749. keysRight: number[];
  45750. /**
  45751. * The list of keyboard keys used to control the left strafe move of the camera.
  45752. */
  45753. keysLeft: number[];
  45754. private _keys;
  45755. private _onCanvasBlurObserver;
  45756. private _onKeyboardObserver;
  45757. private _engine;
  45758. private _scene;
  45759. /**
  45760. * Attach the input controls to a specific dom element to get the input from.
  45761. * @param element Defines the element the controls should be listened from
  45762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45763. */
  45764. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45765. /**
  45766. * Detach the current controls from the specified dom element.
  45767. * @param element Defines the element to stop listening the inputs from
  45768. */
  45769. detachControl(element: Nullable<HTMLElement>): void;
  45770. /**
  45771. * Gets the class name of the current intput.
  45772. * @returns the class name
  45773. */
  45774. getClassName(): string;
  45775. /** @hidden */
  45776. _onLostFocus(e: FocusEvent): void;
  45777. /**
  45778. * Get the friendly name associated with the input class.
  45779. * @returns the input friendly name
  45780. */
  45781. getSimpleName(): string;
  45782. /**
  45783. * Update the current camera state depending on the inputs that have been used this frame.
  45784. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45785. */
  45786. checkInputs(): void;
  45787. }
  45788. }
  45789. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  45790. import { Nullable } from "babylonjs/types";
  45791. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45792. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45793. /**
  45794. * Manage the mouse wheel inputs to control a follow camera.
  45795. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45796. */
  45797. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  45798. /**
  45799. * Defines the camera the input is attached to.
  45800. */
  45801. camera: FollowCamera;
  45802. /**
  45803. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  45804. */
  45805. axisControlRadius: boolean;
  45806. /**
  45807. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  45808. */
  45809. axisControlHeight: boolean;
  45810. /**
  45811. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  45812. */
  45813. axisControlRotation: boolean;
  45814. /**
  45815. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  45816. * relation to mouseWheel events.
  45817. */
  45818. wheelPrecision: number;
  45819. /**
  45820. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45821. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45822. */
  45823. wheelDeltaPercentage: number;
  45824. private _wheel;
  45825. private _observer;
  45826. /**
  45827. * Attach the input controls to a specific dom element to get the input from.
  45828. * @param element Defines the element the controls should be listened from
  45829. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45830. */
  45831. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45832. /**
  45833. * Detach the current controls from the specified dom element.
  45834. * @param element Defines the element to stop listening the inputs from
  45835. */
  45836. detachControl(element: Nullable<HTMLElement>): void;
  45837. /**
  45838. * Gets the class name of the current intput.
  45839. * @returns the class name
  45840. */
  45841. getClassName(): string;
  45842. /**
  45843. * Get the friendly name associated with the input class.
  45844. * @returns the input friendly name
  45845. */
  45846. getSimpleName(): string;
  45847. }
  45848. }
  45849. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  45850. import { Nullable } from "babylonjs/types";
  45851. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45852. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  45853. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  45854. /**
  45855. * Manage the pointers inputs to control an follow camera.
  45856. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45857. */
  45858. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  45859. /**
  45860. * Defines the camera the input is attached to.
  45861. */
  45862. camera: FollowCamera;
  45863. /**
  45864. * Gets the class name of the current input.
  45865. * @returns the class name
  45866. */
  45867. getClassName(): string;
  45868. /**
  45869. * Defines the pointer angular sensibility along the X axis or how fast is
  45870. * the camera rotating.
  45871. * A negative number will reverse the axis direction.
  45872. */
  45873. angularSensibilityX: number;
  45874. /**
  45875. * Defines the pointer angular sensibility along the Y axis or how fast is
  45876. * the camera rotating.
  45877. * A negative number will reverse the axis direction.
  45878. */
  45879. angularSensibilityY: number;
  45880. /**
  45881. * Defines the pointer pinch precision or how fast is the camera zooming.
  45882. * A negative number will reverse the axis direction.
  45883. */
  45884. pinchPrecision: number;
  45885. /**
  45886. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45887. * from 0.
  45888. * It defines the percentage of current camera.radius to use as delta when
  45889. * pinch zoom is used.
  45890. */
  45891. pinchDeltaPercentage: number;
  45892. /**
  45893. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  45894. */
  45895. axisXControlRadius: boolean;
  45896. /**
  45897. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  45898. */
  45899. axisXControlHeight: boolean;
  45900. /**
  45901. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  45902. */
  45903. axisXControlRotation: boolean;
  45904. /**
  45905. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  45906. */
  45907. axisYControlRadius: boolean;
  45908. /**
  45909. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  45910. */
  45911. axisYControlHeight: boolean;
  45912. /**
  45913. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  45914. */
  45915. axisYControlRotation: boolean;
  45916. /**
  45917. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  45918. */
  45919. axisPinchControlRadius: boolean;
  45920. /**
  45921. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  45922. */
  45923. axisPinchControlHeight: boolean;
  45924. /**
  45925. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  45926. */
  45927. axisPinchControlRotation: boolean;
  45928. /**
  45929. * Log error messages if basic misconfiguration has occurred.
  45930. */
  45931. warningEnable: boolean;
  45932. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45933. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45934. private _warningCounter;
  45935. private _warning;
  45936. }
  45937. }
  45938. declare module "babylonjs/Cameras/followCameraInputsManager" {
  45939. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45940. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45941. /**
  45942. * Default Inputs manager for the FollowCamera.
  45943. * It groups all the default supported inputs for ease of use.
  45944. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45945. */
  45946. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  45947. /**
  45948. * Instantiates a new FollowCameraInputsManager.
  45949. * @param camera Defines the camera the inputs belong to
  45950. */
  45951. constructor(camera: FollowCamera);
  45952. /**
  45953. * Add keyboard input support to the input manager.
  45954. * @returns the current input manager
  45955. */
  45956. addKeyboard(): FollowCameraInputsManager;
  45957. /**
  45958. * Add mouse wheel input support to the input manager.
  45959. * @returns the current input manager
  45960. */
  45961. addMouseWheel(): FollowCameraInputsManager;
  45962. /**
  45963. * Add pointers input support to the input manager.
  45964. * @returns the current input manager
  45965. */
  45966. addPointers(): FollowCameraInputsManager;
  45967. /**
  45968. * Add orientation input support to the input manager.
  45969. * @returns the current input manager
  45970. */
  45971. addVRDeviceOrientation(): FollowCameraInputsManager;
  45972. }
  45973. }
  45974. declare module "babylonjs/Cameras/followCamera" {
  45975. import { Nullable } from "babylonjs/types";
  45976. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45977. import { Scene } from "babylonjs/scene";
  45978. import { Vector3 } from "babylonjs/Maths/math.vector";
  45979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45980. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  45981. /**
  45982. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  45983. * an arc rotate version arcFollowCamera are available.
  45984. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45985. */
  45986. export class FollowCamera extends TargetCamera {
  45987. /**
  45988. * Distance the follow camera should follow an object at
  45989. */
  45990. radius: number;
  45991. /**
  45992. * Minimum allowed distance of the camera to the axis of rotation
  45993. * (The camera can not get closer).
  45994. * This can help limiting how the Camera is able to move in the scene.
  45995. */
  45996. lowerRadiusLimit: Nullable<number>;
  45997. /**
  45998. * Maximum allowed distance of the camera to the axis of rotation
  45999. * (The camera can not get further).
  46000. * This can help limiting how the Camera is able to move in the scene.
  46001. */
  46002. upperRadiusLimit: Nullable<number>;
  46003. /**
  46004. * Define a rotation offset between the camera and the object it follows
  46005. */
  46006. rotationOffset: number;
  46007. /**
  46008. * Minimum allowed angle to camera position relative to target object.
  46009. * This can help limiting how the Camera is able to move in the scene.
  46010. */
  46011. lowerRotationOffsetLimit: Nullable<number>;
  46012. /**
  46013. * Maximum allowed angle to camera position relative to target object.
  46014. * This can help limiting how the Camera is able to move in the scene.
  46015. */
  46016. upperRotationOffsetLimit: Nullable<number>;
  46017. /**
  46018. * Define a height offset between the camera and the object it follows.
  46019. * It can help following an object from the top (like a car chaing a plane)
  46020. */
  46021. heightOffset: number;
  46022. /**
  46023. * Minimum allowed height of camera position relative to target object.
  46024. * This can help limiting how the Camera is able to move in the scene.
  46025. */
  46026. lowerHeightOffsetLimit: Nullable<number>;
  46027. /**
  46028. * Maximum allowed height of camera position relative to target object.
  46029. * This can help limiting how the Camera is able to move in the scene.
  46030. */
  46031. upperHeightOffsetLimit: Nullable<number>;
  46032. /**
  46033. * Define how fast the camera can accelerate to follow it s target.
  46034. */
  46035. cameraAcceleration: number;
  46036. /**
  46037. * Define the speed limit of the camera following an object.
  46038. */
  46039. maxCameraSpeed: number;
  46040. /**
  46041. * Define the target of the camera.
  46042. */
  46043. lockedTarget: Nullable<AbstractMesh>;
  46044. /**
  46045. * Defines the input associated with the camera.
  46046. */
  46047. inputs: FollowCameraInputsManager;
  46048. /**
  46049. * Instantiates the follow camera.
  46050. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46051. * @param name Define the name of the camera in the scene
  46052. * @param position Define the position of the camera
  46053. * @param scene Define the scene the camera belong to
  46054. * @param lockedTarget Define the target of the camera
  46055. */
  46056. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46057. private _follow;
  46058. /**
  46059. * Attached controls to the current camera.
  46060. * @param element Defines the element the controls should be listened from
  46061. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46062. */
  46063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46064. /**
  46065. * Detach the current controls from the camera.
  46066. * The camera will stop reacting to inputs.
  46067. * @param element Defines the element to stop listening the inputs from
  46068. */
  46069. detachControl(element: HTMLElement): void;
  46070. /** @hidden */
  46071. _checkInputs(): void;
  46072. private _checkLimits;
  46073. /**
  46074. * Gets the camera class name.
  46075. * @returns the class name
  46076. */
  46077. getClassName(): string;
  46078. }
  46079. /**
  46080. * Arc Rotate version of the follow camera.
  46081. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46082. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46083. */
  46084. export class ArcFollowCamera extends TargetCamera {
  46085. /** The longitudinal angle of the camera */
  46086. alpha: number;
  46087. /** The latitudinal angle of the camera */
  46088. beta: number;
  46089. /** The radius of the camera from its target */
  46090. radius: number;
  46091. /** Define the camera target (the mesh it should follow) */
  46092. target: Nullable<AbstractMesh>;
  46093. private _cartesianCoordinates;
  46094. /**
  46095. * Instantiates a new ArcFollowCamera
  46096. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46097. * @param name Define the name of the camera
  46098. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46099. * @param beta Define the rotation angle of the camera around the elevation axis
  46100. * @param radius Define the radius of the camera from its target point
  46101. * @param target Define the target of the camera
  46102. * @param scene Define the scene the camera belongs to
  46103. */
  46104. constructor(name: string,
  46105. /** The longitudinal angle of the camera */
  46106. alpha: number,
  46107. /** The latitudinal angle of the camera */
  46108. beta: number,
  46109. /** The radius of the camera from its target */
  46110. radius: number,
  46111. /** Define the camera target (the mesh it should follow) */
  46112. target: Nullable<AbstractMesh>, scene: Scene);
  46113. private _follow;
  46114. /** @hidden */
  46115. _checkInputs(): void;
  46116. /**
  46117. * Returns the class name of the object.
  46118. * It is mostly used internally for serialization purposes.
  46119. */
  46120. getClassName(): string;
  46121. }
  46122. }
  46123. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46124. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46125. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46126. import { Nullable } from "babylonjs/types";
  46127. /**
  46128. * Manage the keyboard inputs to control the movement of a follow camera.
  46129. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46130. */
  46131. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46132. /**
  46133. * Defines the camera the input is attached to.
  46134. */
  46135. camera: FollowCamera;
  46136. /**
  46137. * Defines the list of key codes associated with the up action (increase heightOffset)
  46138. */
  46139. keysHeightOffsetIncr: number[];
  46140. /**
  46141. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46142. */
  46143. keysHeightOffsetDecr: number[];
  46144. /**
  46145. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46146. */
  46147. keysHeightOffsetModifierAlt: boolean;
  46148. /**
  46149. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46150. */
  46151. keysHeightOffsetModifierCtrl: boolean;
  46152. /**
  46153. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46154. */
  46155. keysHeightOffsetModifierShift: boolean;
  46156. /**
  46157. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46158. */
  46159. keysRotationOffsetIncr: number[];
  46160. /**
  46161. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46162. */
  46163. keysRotationOffsetDecr: number[];
  46164. /**
  46165. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46166. */
  46167. keysRotationOffsetModifierAlt: boolean;
  46168. /**
  46169. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46170. */
  46171. keysRotationOffsetModifierCtrl: boolean;
  46172. /**
  46173. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46174. */
  46175. keysRotationOffsetModifierShift: boolean;
  46176. /**
  46177. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46178. */
  46179. keysRadiusIncr: number[];
  46180. /**
  46181. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46182. */
  46183. keysRadiusDecr: number[];
  46184. /**
  46185. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46186. */
  46187. keysRadiusModifierAlt: boolean;
  46188. /**
  46189. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46190. */
  46191. keysRadiusModifierCtrl: boolean;
  46192. /**
  46193. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46194. */
  46195. keysRadiusModifierShift: boolean;
  46196. /**
  46197. * Defines the rate of change of heightOffset.
  46198. */
  46199. heightSensibility: number;
  46200. /**
  46201. * Defines the rate of change of rotationOffset.
  46202. */
  46203. rotationSensibility: number;
  46204. /**
  46205. * Defines the rate of change of radius.
  46206. */
  46207. radiusSensibility: number;
  46208. private _keys;
  46209. private _ctrlPressed;
  46210. private _altPressed;
  46211. private _shiftPressed;
  46212. private _onCanvasBlurObserver;
  46213. private _onKeyboardObserver;
  46214. private _engine;
  46215. private _scene;
  46216. /**
  46217. * Attach the input controls to a specific dom element to get the input from.
  46218. * @param element Defines the element the controls should be listened from
  46219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46220. */
  46221. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46222. /**
  46223. * Detach the current controls from the specified dom element.
  46224. * @param element Defines the element to stop listening the inputs from
  46225. */
  46226. detachControl(element: Nullable<HTMLElement>): void;
  46227. /**
  46228. * Update the current camera state depending on the inputs that have been used this frame.
  46229. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46230. */
  46231. checkInputs(): void;
  46232. /**
  46233. * Gets the class name of the current input.
  46234. * @returns the class name
  46235. */
  46236. getClassName(): string;
  46237. /**
  46238. * Get the friendly name associated with the input class.
  46239. * @returns the input friendly name
  46240. */
  46241. getSimpleName(): string;
  46242. /**
  46243. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46244. * allow modification of the heightOffset value.
  46245. */
  46246. private _modifierHeightOffset;
  46247. /**
  46248. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46249. * allow modification of the rotationOffset value.
  46250. */
  46251. private _modifierRotationOffset;
  46252. /**
  46253. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46254. * allow modification of the radius value.
  46255. */
  46256. private _modifierRadius;
  46257. }
  46258. }
  46259. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46260. import { Nullable } from "babylonjs/types";
  46261. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46262. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46263. import { Observable } from "babylonjs/Misc/observable";
  46264. module "babylonjs/Cameras/freeCameraInputsManager" {
  46265. interface FreeCameraInputsManager {
  46266. /**
  46267. * @hidden
  46268. */
  46269. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46270. /**
  46271. * Add orientation input support to the input manager.
  46272. * @returns the current input manager
  46273. */
  46274. addDeviceOrientation(): FreeCameraInputsManager;
  46275. }
  46276. }
  46277. /**
  46278. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46279. * Screen rotation is taken into account.
  46280. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46281. */
  46282. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46283. private _camera;
  46284. private _screenOrientationAngle;
  46285. private _constantTranform;
  46286. private _screenQuaternion;
  46287. private _alpha;
  46288. private _beta;
  46289. private _gamma;
  46290. /**
  46291. * Can be used to detect if a device orientation sensor is available on a device
  46292. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46293. * @returns a promise that will resolve on orientation change
  46294. */
  46295. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46296. /**
  46297. * @hidden
  46298. */
  46299. _onDeviceOrientationChangedObservable: Observable<void>;
  46300. /**
  46301. * Instantiates a new input
  46302. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46303. */
  46304. constructor();
  46305. /**
  46306. * Define the camera controlled by the input.
  46307. */
  46308. get camera(): FreeCamera;
  46309. set camera(camera: FreeCamera);
  46310. /**
  46311. * Attach the input controls to a specific dom element to get the input from.
  46312. * @param element Defines the element the controls should be listened from
  46313. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46314. */
  46315. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46316. private _orientationChanged;
  46317. private _deviceOrientation;
  46318. /**
  46319. * Detach the current controls from the specified dom element.
  46320. * @param element Defines the element to stop listening the inputs from
  46321. */
  46322. detachControl(element: Nullable<HTMLElement>): void;
  46323. /**
  46324. * Update the current camera state depending on the inputs that have been used this frame.
  46325. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46326. */
  46327. checkInputs(): void;
  46328. /**
  46329. * Gets the class name of the current intput.
  46330. * @returns the class name
  46331. */
  46332. getClassName(): string;
  46333. /**
  46334. * Get the friendly name associated with the input class.
  46335. * @returns the input friendly name
  46336. */
  46337. getSimpleName(): string;
  46338. }
  46339. }
  46340. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46341. import { Nullable } from "babylonjs/types";
  46342. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46343. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46344. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46345. /**
  46346. * Manage the gamepad inputs to control a free camera.
  46347. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46348. */
  46349. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46350. /**
  46351. * Define the camera the input is attached to.
  46352. */
  46353. camera: FreeCamera;
  46354. /**
  46355. * Define the Gamepad controlling the input
  46356. */
  46357. gamepad: Nullable<Gamepad>;
  46358. /**
  46359. * Defines the gamepad rotation sensiblity.
  46360. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46361. */
  46362. gamepadAngularSensibility: number;
  46363. /**
  46364. * Defines the gamepad move sensiblity.
  46365. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46366. */
  46367. gamepadMoveSensibility: number;
  46368. private _yAxisScale;
  46369. /**
  46370. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46371. */
  46372. get invertYAxis(): boolean;
  46373. set invertYAxis(value: boolean);
  46374. private _onGamepadConnectedObserver;
  46375. private _onGamepadDisconnectedObserver;
  46376. private _cameraTransform;
  46377. private _deltaTransform;
  46378. private _vector3;
  46379. private _vector2;
  46380. /**
  46381. * Attach the input controls to a specific dom element to get the input from.
  46382. * @param element Defines the element the controls should be listened from
  46383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46384. */
  46385. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46386. /**
  46387. * Detach the current controls from the specified dom element.
  46388. * @param element Defines the element to stop listening the inputs from
  46389. */
  46390. detachControl(element: Nullable<HTMLElement>): void;
  46391. /**
  46392. * Update the current camera state depending on the inputs that have been used this frame.
  46393. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46394. */
  46395. checkInputs(): void;
  46396. /**
  46397. * Gets the class name of the current intput.
  46398. * @returns the class name
  46399. */
  46400. getClassName(): string;
  46401. /**
  46402. * Get the friendly name associated with the input class.
  46403. * @returns the input friendly name
  46404. */
  46405. getSimpleName(): string;
  46406. }
  46407. }
  46408. declare module "babylonjs/Misc/virtualJoystick" {
  46409. import { Nullable } from "babylonjs/types";
  46410. import { Vector3 } from "babylonjs/Maths/math.vector";
  46411. /**
  46412. * Defines the potential axis of a Joystick
  46413. */
  46414. export enum JoystickAxis {
  46415. /** X axis */
  46416. X = 0,
  46417. /** Y axis */
  46418. Y = 1,
  46419. /** Z axis */
  46420. Z = 2
  46421. }
  46422. /**
  46423. * Represents the different customization options available
  46424. * for VirtualJoystick
  46425. */
  46426. interface VirtualJoystickCustomizations {
  46427. /**
  46428. * Size of the joystick's puck
  46429. */
  46430. puckSize: number;
  46431. /**
  46432. * Size of the joystick's container
  46433. */
  46434. containerSize: number;
  46435. /**
  46436. * Color of the joystick && puck
  46437. */
  46438. color: string;
  46439. /**
  46440. * Image URL for the joystick's puck
  46441. */
  46442. puckImage?: string;
  46443. /**
  46444. * Image URL for the joystick's container
  46445. */
  46446. containerImage?: string;
  46447. /**
  46448. * Defines the unmoving position of the joystick container
  46449. */
  46450. position?: {
  46451. x: number;
  46452. y: number;
  46453. };
  46454. /**
  46455. * Defines whether or not the joystick container is always visible
  46456. */
  46457. alwaysVisible: boolean;
  46458. /**
  46459. * Defines whether or not to limit the movement of the puck to the joystick's container
  46460. */
  46461. limitToContainer: boolean;
  46462. }
  46463. /**
  46464. * Class used to define virtual joystick (used in touch mode)
  46465. */
  46466. export class VirtualJoystick {
  46467. /**
  46468. * Gets or sets a boolean indicating that left and right values must be inverted
  46469. */
  46470. reverseLeftRight: boolean;
  46471. /**
  46472. * Gets or sets a boolean indicating that up and down values must be inverted
  46473. */
  46474. reverseUpDown: boolean;
  46475. /**
  46476. * Gets the offset value for the position (ie. the change of the position value)
  46477. */
  46478. deltaPosition: Vector3;
  46479. /**
  46480. * Gets a boolean indicating if the virtual joystick was pressed
  46481. */
  46482. pressed: boolean;
  46483. /**
  46484. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46485. */
  46486. static Canvas: Nullable<HTMLCanvasElement>;
  46487. /**
  46488. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46489. */
  46490. limitToContainer: boolean;
  46491. private static _globalJoystickIndex;
  46492. private static _alwaysVisibleSticks;
  46493. private static vjCanvasContext;
  46494. private static vjCanvasWidth;
  46495. private static vjCanvasHeight;
  46496. private static halfWidth;
  46497. private static _GetDefaultOptions;
  46498. private _action;
  46499. private _axisTargetedByLeftAndRight;
  46500. private _axisTargetedByUpAndDown;
  46501. private _joystickSensibility;
  46502. private _inversedSensibility;
  46503. private _joystickPointerID;
  46504. private _joystickColor;
  46505. private _joystickPointerPos;
  46506. private _joystickPreviousPointerPos;
  46507. private _joystickPointerStartPos;
  46508. private _deltaJoystickVector;
  46509. private _leftJoystick;
  46510. private _touches;
  46511. private _joystickPosition;
  46512. private _alwaysVisible;
  46513. private _puckImage;
  46514. private _containerImage;
  46515. private _joystickPuckSize;
  46516. private _joystickContainerSize;
  46517. private _clearPuckSize;
  46518. private _clearContainerSize;
  46519. private _clearPuckSizeOffset;
  46520. private _clearContainerSizeOffset;
  46521. private _onPointerDownHandlerRef;
  46522. private _onPointerMoveHandlerRef;
  46523. private _onPointerUpHandlerRef;
  46524. private _onResize;
  46525. /**
  46526. * Creates a new virtual joystick
  46527. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46528. * @param customizations Defines the options we want to customize the VirtualJoystick
  46529. */
  46530. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46531. /**
  46532. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46533. * @param newJoystickSensibility defines the new sensibility
  46534. */
  46535. setJoystickSensibility(newJoystickSensibility: number): void;
  46536. private _onPointerDown;
  46537. private _onPointerMove;
  46538. private _onPointerUp;
  46539. /**
  46540. * Change the color of the virtual joystick
  46541. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46542. */
  46543. setJoystickColor(newColor: string): void;
  46544. /**
  46545. * Size of the joystick's container
  46546. */
  46547. set containerSize(newSize: number);
  46548. get containerSize(): number;
  46549. /**
  46550. * Size of the joystick's puck
  46551. */
  46552. set puckSize(newSize: number);
  46553. get puckSize(): number;
  46554. /**
  46555. * Clears the set position of the joystick
  46556. */
  46557. clearPosition(): void;
  46558. /**
  46559. * Defines whether or not the joystick container is always visible
  46560. */
  46561. set alwaysVisible(value: boolean);
  46562. get alwaysVisible(): boolean;
  46563. /**
  46564. * Sets the constant position of the Joystick container
  46565. * @param x X axis coordinate
  46566. * @param y Y axis coordinate
  46567. */
  46568. setPosition(x: number, y: number): void;
  46569. /**
  46570. * Defines a callback to call when the joystick is touched
  46571. * @param action defines the callback
  46572. */
  46573. setActionOnTouch(action: () => any): void;
  46574. /**
  46575. * Defines which axis you'd like to control for left & right
  46576. * @param axis defines the axis to use
  46577. */
  46578. setAxisForLeftRight(axis: JoystickAxis): void;
  46579. /**
  46580. * Defines which axis you'd like to control for up & down
  46581. * @param axis defines the axis to use
  46582. */
  46583. setAxisForUpDown(axis: JoystickAxis): void;
  46584. /**
  46585. * Clears the canvas from the previous puck / container draw
  46586. */
  46587. private _clearPreviousDraw;
  46588. /**
  46589. * Loads `urlPath` to be used for the container's image
  46590. * @param urlPath defines the urlPath of an image to use
  46591. */
  46592. setContainerImage(urlPath: string): void;
  46593. /**
  46594. * Loads `urlPath` to be used for the puck's image
  46595. * @param urlPath defines the urlPath of an image to use
  46596. */
  46597. setPuckImage(urlPath: string): void;
  46598. /**
  46599. * Draws the Virtual Joystick's container
  46600. */
  46601. private _drawContainer;
  46602. /**
  46603. * Draws the Virtual Joystick's puck
  46604. */
  46605. private _drawPuck;
  46606. private _drawVirtualJoystick;
  46607. /**
  46608. * Release internal HTML canvas
  46609. */
  46610. releaseCanvas(): void;
  46611. }
  46612. }
  46613. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46614. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46615. import { Nullable } from "babylonjs/types";
  46616. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46617. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46618. module "babylonjs/Cameras/freeCameraInputsManager" {
  46619. interface FreeCameraInputsManager {
  46620. /**
  46621. * Add virtual joystick input support to the input manager.
  46622. * @returns the current input manager
  46623. */
  46624. addVirtualJoystick(): FreeCameraInputsManager;
  46625. }
  46626. }
  46627. /**
  46628. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46629. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46630. */
  46631. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46632. /**
  46633. * Defines the camera the input is attached to.
  46634. */
  46635. camera: FreeCamera;
  46636. private _leftjoystick;
  46637. private _rightjoystick;
  46638. /**
  46639. * Gets the left stick of the virtual joystick.
  46640. * @returns The virtual Joystick
  46641. */
  46642. getLeftJoystick(): VirtualJoystick;
  46643. /**
  46644. * Gets the right stick of the virtual joystick.
  46645. * @returns The virtual Joystick
  46646. */
  46647. getRightJoystick(): VirtualJoystick;
  46648. /**
  46649. * Update the current camera state depending on the inputs that have been used this frame.
  46650. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46651. */
  46652. checkInputs(): void;
  46653. /**
  46654. * Attach the input controls to a specific dom element to get the input from.
  46655. * @param element Defines the element the controls should be listened from
  46656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46657. */
  46658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46659. /**
  46660. * Detach the current controls from the specified dom element.
  46661. * @param element Defines the element to stop listening the inputs from
  46662. */
  46663. detachControl(element: Nullable<HTMLElement>): void;
  46664. /**
  46665. * Gets the class name of the current intput.
  46666. * @returns the class name
  46667. */
  46668. getClassName(): string;
  46669. /**
  46670. * Get the friendly name associated with the input class.
  46671. * @returns the input friendly name
  46672. */
  46673. getSimpleName(): string;
  46674. }
  46675. }
  46676. declare module "babylonjs/Cameras/Inputs/index" {
  46677. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  46678. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  46679. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  46680. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  46681. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46682. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  46683. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  46684. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  46685. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  46686. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  46687. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46688. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  46689. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  46690. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  46691. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  46692. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46693. }
  46694. declare module "babylonjs/Cameras/touchCamera" {
  46695. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46696. import { Scene } from "babylonjs/scene";
  46697. import { Vector3 } from "babylonjs/Maths/math.vector";
  46698. /**
  46699. * This represents a FPS type of camera controlled by touch.
  46700. * This is like a universal camera minus the Gamepad controls.
  46701. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46702. */
  46703. export class TouchCamera extends FreeCamera {
  46704. /**
  46705. * Defines the touch sensibility for rotation.
  46706. * The higher the faster.
  46707. */
  46708. get touchAngularSensibility(): number;
  46709. set touchAngularSensibility(value: number);
  46710. /**
  46711. * Defines the touch sensibility for move.
  46712. * The higher the faster.
  46713. */
  46714. get touchMoveSensibility(): number;
  46715. set touchMoveSensibility(value: number);
  46716. /**
  46717. * Instantiates a new touch camera.
  46718. * This represents a FPS type of camera controlled by touch.
  46719. * This is like a universal camera minus the Gamepad controls.
  46720. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46721. * @param name Define the name of the camera in the scene
  46722. * @param position Define the start position of the camera in the scene
  46723. * @param scene Define the scene the camera belongs to
  46724. */
  46725. constructor(name: string, position: Vector3, scene: Scene);
  46726. /**
  46727. * Gets the current object class name.
  46728. * @return the class name
  46729. */
  46730. getClassName(): string;
  46731. /** @hidden */
  46732. _setupInputs(): void;
  46733. }
  46734. }
  46735. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  46736. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46737. import { Scene } from "babylonjs/scene";
  46738. import { Vector3 } from "babylonjs/Maths/math.vector";
  46739. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46740. import { Axis } from "babylonjs/Maths/math.axis";
  46741. /**
  46742. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  46743. * being tilted forward or back and left or right.
  46744. */
  46745. export class DeviceOrientationCamera extends FreeCamera {
  46746. private _initialQuaternion;
  46747. private _quaternionCache;
  46748. private _tmpDragQuaternion;
  46749. private _disablePointerInputWhenUsingDeviceOrientation;
  46750. /**
  46751. * Creates a new device orientation camera
  46752. * @param name The name of the camera
  46753. * @param position The start position camera
  46754. * @param scene The scene the camera belongs to
  46755. */
  46756. constructor(name: string, position: Vector3, scene: Scene);
  46757. /**
  46758. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  46759. */
  46760. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  46761. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  46762. private _dragFactor;
  46763. /**
  46764. * Enabled turning on the y axis when the orientation sensor is active
  46765. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  46766. */
  46767. enableHorizontalDragging(dragFactor?: number): void;
  46768. /**
  46769. * Gets the current instance class name ("DeviceOrientationCamera").
  46770. * This helps avoiding instanceof at run time.
  46771. * @returns the class name
  46772. */
  46773. getClassName(): string;
  46774. /**
  46775. * @hidden
  46776. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  46777. */
  46778. _checkInputs(): void;
  46779. /**
  46780. * Reset the camera to its default orientation on the specified axis only.
  46781. * @param axis The axis to reset
  46782. */
  46783. resetToCurrentRotation(axis?: Axis): void;
  46784. }
  46785. }
  46786. declare module "babylonjs/Gamepads/xboxGamepad" {
  46787. import { Observable } from "babylonjs/Misc/observable";
  46788. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46789. /**
  46790. * Defines supported buttons for XBox360 compatible gamepads
  46791. */
  46792. export enum Xbox360Button {
  46793. /** A */
  46794. A = 0,
  46795. /** B */
  46796. B = 1,
  46797. /** X */
  46798. X = 2,
  46799. /** Y */
  46800. Y = 3,
  46801. /** Left button */
  46802. LB = 4,
  46803. /** Right button */
  46804. RB = 5,
  46805. /** Back */
  46806. Back = 8,
  46807. /** Start */
  46808. Start = 9,
  46809. /** Left stick */
  46810. LeftStick = 10,
  46811. /** Right stick */
  46812. RightStick = 11
  46813. }
  46814. /** Defines values for XBox360 DPad */
  46815. export enum Xbox360Dpad {
  46816. /** Up */
  46817. Up = 12,
  46818. /** Down */
  46819. Down = 13,
  46820. /** Left */
  46821. Left = 14,
  46822. /** Right */
  46823. Right = 15
  46824. }
  46825. /**
  46826. * Defines a XBox360 gamepad
  46827. */
  46828. export class Xbox360Pad extends Gamepad {
  46829. private _leftTrigger;
  46830. private _rightTrigger;
  46831. private _onlefttriggerchanged;
  46832. private _onrighttriggerchanged;
  46833. private _onbuttondown;
  46834. private _onbuttonup;
  46835. private _ondpaddown;
  46836. private _ondpadup;
  46837. /** Observable raised when a button is pressed */
  46838. onButtonDownObservable: Observable<Xbox360Button>;
  46839. /** Observable raised when a button is released */
  46840. onButtonUpObservable: Observable<Xbox360Button>;
  46841. /** Observable raised when a pad is pressed */
  46842. onPadDownObservable: Observable<Xbox360Dpad>;
  46843. /** Observable raised when a pad is released */
  46844. onPadUpObservable: Observable<Xbox360Dpad>;
  46845. private _buttonA;
  46846. private _buttonB;
  46847. private _buttonX;
  46848. private _buttonY;
  46849. private _buttonBack;
  46850. private _buttonStart;
  46851. private _buttonLB;
  46852. private _buttonRB;
  46853. private _buttonLeftStick;
  46854. private _buttonRightStick;
  46855. private _dPadUp;
  46856. private _dPadDown;
  46857. private _dPadLeft;
  46858. private _dPadRight;
  46859. private _isXboxOnePad;
  46860. /**
  46861. * Creates a new XBox360 gamepad object
  46862. * @param id defines the id of this gamepad
  46863. * @param index defines its index
  46864. * @param gamepad defines the internal HTML gamepad object
  46865. * @param xboxOne defines if it is a XBox One gamepad
  46866. */
  46867. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  46868. /**
  46869. * Defines the callback to call when left trigger is pressed
  46870. * @param callback defines the callback to use
  46871. */
  46872. onlefttriggerchanged(callback: (value: number) => void): void;
  46873. /**
  46874. * Defines the callback to call when right trigger is pressed
  46875. * @param callback defines the callback to use
  46876. */
  46877. onrighttriggerchanged(callback: (value: number) => void): void;
  46878. /**
  46879. * Gets the left trigger value
  46880. */
  46881. get leftTrigger(): number;
  46882. /**
  46883. * Sets the left trigger value
  46884. */
  46885. set leftTrigger(newValue: number);
  46886. /**
  46887. * Gets the right trigger value
  46888. */
  46889. get rightTrigger(): number;
  46890. /**
  46891. * Sets the right trigger value
  46892. */
  46893. set rightTrigger(newValue: number);
  46894. /**
  46895. * Defines the callback to call when a button is pressed
  46896. * @param callback defines the callback to use
  46897. */
  46898. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  46899. /**
  46900. * Defines the callback to call when a button is released
  46901. * @param callback defines the callback to use
  46902. */
  46903. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  46904. /**
  46905. * Defines the callback to call when a pad is pressed
  46906. * @param callback defines the callback to use
  46907. */
  46908. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  46909. /**
  46910. * Defines the callback to call when a pad is released
  46911. * @param callback defines the callback to use
  46912. */
  46913. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  46914. private _setButtonValue;
  46915. private _setDPadValue;
  46916. /**
  46917. * Gets the value of the `A` button
  46918. */
  46919. get buttonA(): number;
  46920. /**
  46921. * Sets the value of the `A` button
  46922. */
  46923. set buttonA(value: number);
  46924. /**
  46925. * Gets the value of the `B` button
  46926. */
  46927. get buttonB(): number;
  46928. /**
  46929. * Sets the value of the `B` button
  46930. */
  46931. set buttonB(value: number);
  46932. /**
  46933. * Gets the value of the `X` button
  46934. */
  46935. get buttonX(): number;
  46936. /**
  46937. * Sets the value of the `X` button
  46938. */
  46939. set buttonX(value: number);
  46940. /**
  46941. * Gets the value of the `Y` button
  46942. */
  46943. get buttonY(): number;
  46944. /**
  46945. * Sets the value of the `Y` button
  46946. */
  46947. set buttonY(value: number);
  46948. /**
  46949. * Gets the value of the `Start` button
  46950. */
  46951. get buttonStart(): number;
  46952. /**
  46953. * Sets the value of the `Start` button
  46954. */
  46955. set buttonStart(value: number);
  46956. /**
  46957. * Gets the value of the `Back` button
  46958. */
  46959. get buttonBack(): number;
  46960. /**
  46961. * Sets the value of the `Back` button
  46962. */
  46963. set buttonBack(value: number);
  46964. /**
  46965. * Gets the value of the `Left` button
  46966. */
  46967. get buttonLB(): number;
  46968. /**
  46969. * Sets the value of the `Left` button
  46970. */
  46971. set buttonLB(value: number);
  46972. /**
  46973. * Gets the value of the `Right` button
  46974. */
  46975. get buttonRB(): number;
  46976. /**
  46977. * Sets the value of the `Right` button
  46978. */
  46979. set buttonRB(value: number);
  46980. /**
  46981. * Gets the value of the Left joystick
  46982. */
  46983. get buttonLeftStick(): number;
  46984. /**
  46985. * Sets the value of the Left joystick
  46986. */
  46987. set buttonLeftStick(value: number);
  46988. /**
  46989. * Gets the value of the Right joystick
  46990. */
  46991. get buttonRightStick(): number;
  46992. /**
  46993. * Sets the value of the Right joystick
  46994. */
  46995. set buttonRightStick(value: number);
  46996. /**
  46997. * Gets the value of D-pad up
  46998. */
  46999. get dPadUp(): number;
  47000. /**
  47001. * Sets the value of D-pad up
  47002. */
  47003. set dPadUp(value: number);
  47004. /**
  47005. * Gets the value of D-pad down
  47006. */
  47007. get dPadDown(): number;
  47008. /**
  47009. * Sets the value of D-pad down
  47010. */
  47011. set dPadDown(value: number);
  47012. /**
  47013. * Gets the value of D-pad left
  47014. */
  47015. get dPadLeft(): number;
  47016. /**
  47017. * Sets the value of D-pad left
  47018. */
  47019. set dPadLeft(value: number);
  47020. /**
  47021. * Gets the value of D-pad right
  47022. */
  47023. get dPadRight(): number;
  47024. /**
  47025. * Sets the value of D-pad right
  47026. */
  47027. set dPadRight(value: number);
  47028. /**
  47029. * Force the gamepad to synchronize with device values
  47030. */
  47031. update(): void;
  47032. /**
  47033. * Disposes the gamepad
  47034. */
  47035. dispose(): void;
  47036. }
  47037. }
  47038. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47039. import { Observable } from "babylonjs/Misc/observable";
  47040. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47041. /**
  47042. * Defines supported buttons for DualShock compatible gamepads
  47043. */
  47044. export enum DualShockButton {
  47045. /** Cross */
  47046. Cross = 0,
  47047. /** Circle */
  47048. Circle = 1,
  47049. /** Square */
  47050. Square = 2,
  47051. /** Triangle */
  47052. Triangle = 3,
  47053. /** L1 */
  47054. L1 = 4,
  47055. /** R1 */
  47056. R1 = 5,
  47057. /** Share */
  47058. Share = 8,
  47059. /** Options */
  47060. Options = 9,
  47061. /** Left stick */
  47062. LeftStick = 10,
  47063. /** Right stick */
  47064. RightStick = 11
  47065. }
  47066. /** Defines values for DualShock DPad */
  47067. export enum DualShockDpad {
  47068. /** Up */
  47069. Up = 12,
  47070. /** Down */
  47071. Down = 13,
  47072. /** Left */
  47073. Left = 14,
  47074. /** Right */
  47075. Right = 15
  47076. }
  47077. /**
  47078. * Defines a DualShock gamepad
  47079. */
  47080. export class DualShockPad extends Gamepad {
  47081. private _leftTrigger;
  47082. private _rightTrigger;
  47083. private _onlefttriggerchanged;
  47084. private _onrighttriggerchanged;
  47085. private _onbuttondown;
  47086. private _onbuttonup;
  47087. private _ondpaddown;
  47088. private _ondpadup;
  47089. /** Observable raised when a button is pressed */
  47090. onButtonDownObservable: Observable<DualShockButton>;
  47091. /** Observable raised when a button is released */
  47092. onButtonUpObservable: Observable<DualShockButton>;
  47093. /** Observable raised when a pad is pressed */
  47094. onPadDownObservable: Observable<DualShockDpad>;
  47095. /** Observable raised when a pad is released */
  47096. onPadUpObservable: Observable<DualShockDpad>;
  47097. private _buttonCross;
  47098. private _buttonCircle;
  47099. private _buttonSquare;
  47100. private _buttonTriangle;
  47101. private _buttonShare;
  47102. private _buttonOptions;
  47103. private _buttonL1;
  47104. private _buttonR1;
  47105. private _buttonLeftStick;
  47106. private _buttonRightStick;
  47107. private _dPadUp;
  47108. private _dPadDown;
  47109. private _dPadLeft;
  47110. private _dPadRight;
  47111. /**
  47112. * Creates a new DualShock gamepad object
  47113. * @param id defines the id of this gamepad
  47114. * @param index defines its index
  47115. * @param gamepad defines the internal HTML gamepad object
  47116. */
  47117. constructor(id: string, index: number, gamepad: any);
  47118. /**
  47119. * Defines the callback to call when left trigger is pressed
  47120. * @param callback defines the callback to use
  47121. */
  47122. onlefttriggerchanged(callback: (value: number) => void): void;
  47123. /**
  47124. * Defines the callback to call when right trigger is pressed
  47125. * @param callback defines the callback to use
  47126. */
  47127. onrighttriggerchanged(callback: (value: number) => void): void;
  47128. /**
  47129. * Gets the left trigger value
  47130. */
  47131. get leftTrigger(): number;
  47132. /**
  47133. * Sets the left trigger value
  47134. */
  47135. set leftTrigger(newValue: number);
  47136. /**
  47137. * Gets the right trigger value
  47138. */
  47139. get rightTrigger(): number;
  47140. /**
  47141. * Sets the right trigger value
  47142. */
  47143. set rightTrigger(newValue: number);
  47144. /**
  47145. * Defines the callback to call when a button is pressed
  47146. * @param callback defines the callback to use
  47147. */
  47148. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47149. /**
  47150. * Defines the callback to call when a button is released
  47151. * @param callback defines the callback to use
  47152. */
  47153. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47154. /**
  47155. * Defines the callback to call when a pad is pressed
  47156. * @param callback defines the callback to use
  47157. */
  47158. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47159. /**
  47160. * Defines the callback to call when a pad is released
  47161. * @param callback defines the callback to use
  47162. */
  47163. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47164. private _setButtonValue;
  47165. private _setDPadValue;
  47166. /**
  47167. * Gets the value of the `Cross` button
  47168. */
  47169. get buttonCross(): number;
  47170. /**
  47171. * Sets the value of the `Cross` button
  47172. */
  47173. set buttonCross(value: number);
  47174. /**
  47175. * Gets the value of the `Circle` button
  47176. */
  47177. get buttonCircle(): number;
  47178. /**
  47179. * Sets the value of the `Circle` button
  47180. */
  47181. set buttonCircle(value: number);
  47182. /**
  47183. * Gets the value of the `Square` button
  47184. */
  47185. get buttonSquare(): number;
  47186. /**
  47187. * Sets the value of the `Square` button
  47188. */
  47189. set buttonSquare(value: number);
  47190. /**
  47191. * Gets the value of the `Triangle` button
  47192. */
  47193. get buttonTriangle(): number;
  47194. /**
  47195. * Sets the value of the `Triangle` button
  47196. */
  47197. set buttonTriangle(value: number);
  47198. /**
  47199. * Gets the value of the `Options` button
  47200. */
  47201. get buttonOptions(): number;
  47202. /**
  47203. * Sets the value of the `Options` button
  47204. */
  47205. set buttonOptions(value: number);
  47206. /**
  47207. * Gets the value of the `Share` button
  47208. */
  47209. get buttonShare(): number;
  47210. /**
  47211. * Sets the value of the `Share` button
  47212. */
  47213. set buttonShare(value: number);
  47214. /**
  47215. * Gets the value of the `L1` button
  47216. */
  47217. get buttonL1(): number;
  47218. /**
  47219. * Sets the value of the `L1` button
  47220. */
  47221. set buttonL1(value: number);
  47222. /**
  47223. * Gets the value of the `R1` button
  47224. */
  47225. get buttonR1(): number;
  47226. /**
  47227. * Sets the value of the `R1` button
  47228. */
  47229. set buttonR1(value: number);
  47230. /**
  47231. * Gets the value of the Left joystick
  47232. */
  47233. get buttonLeftStick(): number;
  47234. /**
  47235. * Sets the value of the Left joystick
  47236. */
  47237. set buttonLeftStick(value: number);
  47238. /**
  47239. * Gets the value of the Right joystick
  47240. */
  47241. get buttonRightStick(): number;
  47242. /**
  47243. * Sets the value of the Right joystick
  47244. */
  47245. set buttonRightStick(value: number);
  47246. /**
  47247. * Gets the value of D-pad up
  47248. */
  47249. get dPadUp(): number;
  47250. /**
  47251. * Sets the value of D-pad up
  47252. */
  47253. set dPadUp(value: number);
  47254. /**
  47255. * Gets the value of D-pad down
  47256. */
  47257. get dPadDown(): number;
  47258. /**
  47259. * Sets the value of D-pad down
  47260. */
  47261. set dPadDown(value: number);
  47262. /**
  47263. * Gets the value of D-pad left
  47264. */
  47265. get dPadLeft(): number;
  47266. /**
  47267. * Sets the value of D-pad left
  47268. */
  47269. set dPadLeft(value: number);
  47270. /**
  47271. * Gets the value of D-pad right
  47272. */
  47273. get dPadRight(): number;
  47274. /**
  47275. * Sets the value of D-pad right
  47276. */
  47277. set dPadRight(value: number);
  47278. /**
  47279. * Force the gamepad to synchronize with device values
  47280. */
  47281. update(): void;
  47282. /**
  47283. * Disposes the gamepad
  47284. */
  47285. dispose(): void;
  47286. }
  47287. }
  47288. declare module "babylonjs/Gamepads/gamepadManager" {
  47289. import { Observable } from "babylonjs/Misc/observable";
  47290. import { Nullable } from "babylonjs/types";
  47291. import { Scene } from "babylonjs/scene";
  47292. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47293. /**
  47294. * Manager for handling gamepads
  47295. */
  47296. export class GamepadManager {
  47297. private _scene?;
  47298. private _babylonGamepads;
  47299. private _oneGamepadConnected;
  47300. /** @hidden */
  47301. _isMonitoring: boolean;
  47302. private _gamepadEventSupported;
  47303. private _gamepadSupport?;
  47304. /**
  47305. * observable to be triggered when the gamepad controller has been connected
  47306. */
  47307. onGamepadConnectedObservable: Observable<Gamepad>;
  47308. /**
  47309. * observable to be triggered when the gamepad controller has been disconnected
  47310. */
  47311. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47312. private _onGamepadConnectedEvent;
  47313. private _onGamepadDisconnectedEvent;
  47314. /**
  47315. * Initializes the gamepad manager
  47316. * @param _scene BabylonJS scene
  47317. */
  47318. constructor(_scene?: Scene | undefined);
  47319. /**
  47320. * The gamepads in the game pad manager
  47321. */
  47322. get gamepads(): Gamepad[];
  47323. /**
  47324. * Get the gamepad controllers based on type
  47325. * @param type The type of gamepad controller
  47326. * @returns Nullable gamepad
  47327. */
  47328. getGamepadByType(type?: number): Nullable<Gamepad>;
  47329. /**
  47330. * Disposes the gamepad manager
  47331. */
  47332. dispose(): void;
  47333. private _addNewGamepad;
  47334. private _startMonitoringGamepads;
  47335. private _stopMonitoringGamepads;
  47336. /** @hidden */
  47337. _checkGamepadsStatus(): void;
  47338. private _updateGamepadObjects;
  47339. }
  47340. }
  47341. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47342. import { Nullable } from "babylonjs/types";
  47343. import { Scene } from "babylonjs/scene";
  47344. import { ISceneComponent } from "babylonjs/sceneComponent";
  47345. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47346. module "babylonjs/scene" {
  47347. interface Scene {
  47348. /** @hidden */
  47349. _gamepadManager: Nullable<GamepadManager>;
  47350. /**
  47351. * Gets the gamepad manager associated with the scene
  47352. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47353. */
  47354. gamepadManager: GamepadManager;
  47355. }
  47356. }
  47357. module "babylonjs/Cameras/freeCameraInputsManager" {
  47358. /**
  47359. * Interface representing a free camera inputs manager
  47360. */
  47361. interface FreeCameraInputsManager {
  47362. /**
  47363. * Adds gamepad input support to the FreeCameraInputsManager.
  47364. * @returns the FreeCameraInputsManager
  47365. */
  47366. addGamepad(): FreeCameraInputsManager;
  47367. }
  47368. }
  47369. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47370. /**
  47371. * Interface representing an arc rotate camera inputs manager
  47372. */
  47373. interface ArcRotateCameraInputsManager {
  47374. /**
  47375. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47376. * @returns the camera inputs manager
  47377. */
  47378. addGamepad(): ArcRotateCameraInputsManager;
  47379. }
  47380. }
  47381. /**
  47382. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47383. */
  47384. export class GamepadSystemSceneComponent implements ISceneComponent {
  47385. /**
  47386. * The component name helpfull to identify the component in the list of scene components.
  47387. */
  47388. readonly name: string;
  47389. /**
  47390. * The scene the component belongs to.
  47391. */
  47392. scene: Scene;
  47393. /**
  47394. * Creates a new instance of the component for the given scene
  47395. * @param scene Defines the scene to register the component in
  47396. */
  47397. constructor(scene: Scene);
  47398. /**
  47399. * Registers the component in a given scene
  47400. */
  47401. register(): void;
  47402. /**
  47403. * Rebuilds the elements related to this component in case of
  47404. * context lost for instance.
  47405. */
  47406. rebuild(): void;
  47407. /**
  47408. * Disposes the component and the associated ressources
  47409. */
  47410. dispose(): void;
  47411. private _beforeCameraUpdate;
  47412. }
  47413. }
  47414. declare module "babylonjs/Cameras/universalCamera" {
  47415. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47416. import { Scene } from "babylonjs/scene";
  47417. import { Vector3 } from "babylonjs/Maths/math.vector";
  47418. import "babylonjs/Gamepads/gamepadSceneComponent";
  47419. /**
  47420. * 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,
  47421. * which still works and will still be found in many Playgrounds.
  47422. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47423. */
  47424. export class UniversalCamera extends TouchCamera {
  47425. /**
  47426. * Defines the gamepad rotation sensiblity.
  47427. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47428. */
  47429. get gamepadAngularSensibility(): number;
  47430. set gamepadAngularSensibility(value: number);
  47431. /**
  47432. * Defines the gamepad move sensiblity.
  47433. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47434. */
  47435. get gamepadMoveSensibility(): number;
  47436. set gamepadMoveSensibility(value: number);
  47437. /**
  47438. * 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,
  47439. * which still works and will still be found in many Playgrounds.
  47440. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47441. * @param name Define the name of the camera in the scene
  47442. * @param position Define the start position of the camera in the scene
  47443. * @param scene Define the scene the camera belongs to
  47444. */
  47445. constructor(name: string, position: Vector3, scene: Scene);
  47446. /**
  47447. * Gets the current object class name.
  47448. * @return the class name
  47449. */
  47450. getClassName(): string;
  47451. }
  47452. }
  47453. declare module "babylonjs/Cameras/gamepadCamera" {
  47454. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47455. import { Scene } from "babylonjs/scene";
  47456. import { Vector3 } from "babylonjs/Maths/math.vector";
  47457. /**
  47458. * This represents a FPS type of camera. This is only here for back compat purpose.
  47459. * Please use the UniversalCamera instead as both are identical.
  47460. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47461. */
  47462. export class GamepadCamera extends UniversalCamera {
  47463. /**
  47464. * Instantiates a new Gamepad Camera
  47465. * This represents a FPS type of camera. This is only here for back compat purpose.
  47466. * Please use the UniversalCamera instead as both are identical.
  47467. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47468. * @param name Define the name of the camera in the scene
  47469. * @param position Define the start position of the camera in the scene
  47470. * @param scene Define the scene the camera belongs to
  47471. */
  47472. constructor(name: string, position: Vector3, scene: Scene);
  47473. /**
  47474. * Gets the current object class name.
  47475. * @return the class name
  47476. */
  47477. getClassName(): string;
  47478. }
  47479. }
  47480. declare module "babylonjs/Shaders/pass.fragment" {
  47481. /** @hidden */
  47482. export var passPixelShader: {
  47483. name: string;
  47484. shader: string;
  47485. };
  47486. }
  47487. declare module "babylonjs/Shaders/passCube.fragment" {
  47488. /** @hidden */
  47489. export var passCubePixelShader: {
  47490. name: string;
  47491. shader: string;
  47492. };
  47493. }
  47494. declare module "babylonjs/PostProcesses/passPostProcess" {
  47495. import { Nullable } from "babylonjs/types";
  47496. import { Camera } from "babylonjs/Cameras/camera";
  47497. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47498. import { Engine } from "babylonjs/Engines/engine";
  47499. import "babylonjs/Shaders/pass.fragment";
  47500. import "babylonjs/Shaders/passCube.fragment";
  47501. /**
  47502. * PassPostProcess which produces an output the same as it's input
  47503. */
  47504. export class PassPostProcess extends PostProcess {
  47505. /**
  47506. * Creates the PassPostProcess
  47507. * @param name The name of the effect.
  47508. * @param options The required width/height ratio to downsize to before computing the render pass.
  47509. * @param camera The camera to apply the render pass to.
  47510. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47511. * @param engine The engine which the post process will be applied. (default: current engine)
  47512. * @param reusable If the post process can be reused on the same frame. (default: false)
  47513. * @param textureType The type of texture to be used when performing the post processing.
  47514. * @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)
  47515. */
  47516. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47517. }
  47518. /**
  47519. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47520. */
  47521. export class PassCubePostProcess extends PostProcess {
  47522. private _face;
  47523. /**
  47524. * Gets or sets the cube face to display.
  47525. * * 0 is +X
  47526. * * 1 is -X
  47527. * * 2 is +Y
  47528. * * 3 is -Y
  47529. * * 4 is +Z
  47530. * * 5 is -Z
  47531. */
  47532. get face(): number;
  47533. set face(value: number);
  47534. /**
  47535. * Creates the PassCubePostProcess
  47536. * @param name The name of the effect.
  47537. * @param options The required width/height ratio to downsize to before computing the render pass.
  47538. * @param camera The camera to apply the render pass to.
  47539. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47540. * @param engine The engine which the post process will be applied. (default: current engine)
  47541. * @param reusable If the post process can be reused on the same frame. (default: false)
  47542. * @param textureType The type of texture to be used when performing the post processing.
  47543. * @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)
  47544. */
  47545. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47546. }
  47547. }
  47548. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47549. /** @hidden */
  47550. export var anaglyphPixelShader: {
  47551. name: string;
  47552. shader: string;
  47553. };
  47554. }
  47555. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47556. import { Engine } from "babylonjs/Engines/engine";
  47557. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47558. import { Camera } from "babylonjs/Cameras/camera";
  47559. import "babylonjs/Shaders/anaglyph.fragment";
  47560. /**
  47561. * Postprocess used to generate anaglyphic rendering
  47562. */
  47563. export class AnaglyphPostProcess extends PostProcess {
  47564. private _passedProcess;
  47565. /**
  47566. * Creates a new AnaglyphPostProcess
  47567. * @param name defines postprocess name
  47568. * @param options defines creation options or target ratio scale
  47569. * @param rigCameras defines cameras using this postprocess
  47570. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47571. * @param engine defines hosting engine
  47572. * @param reusable defines if the postprocess will be reused multiple times per frame
  47573. */
  47574. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47575. }
  47576. }
  47577. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47578. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47579. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47580. import { Scene } from "babylonjs/scene";
  47581. import { Vector3 } from "babylonjs/Maths/math.vector";
  47582. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47583. /**
  47584. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47585. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47586. */
  47587. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47588. /**
  47589. * Creates a new AnaglyphArcRotateCamera
  47590. * @param name defines camera name
  47591. * @param alpha defines alpha angle (in radians)
  47592. * @param beta defines beta angle (in radians)
  47593. * @param radius defines radius
  47594. * @param target defines camera target
  47595. * @param interaxialDistance defines distance between each color axis
  47596. * @param scene defines the hosting scene
  47597. */
  47598. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47599. /**
  47600. * Gets camera class name
  47601. * @returns AnaglyphArcRotateCamera
  47602. */
  47603. getClassName(): string;
  47604. }
  47605. }
  47606. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47607. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47608. import { Scene } from "babylonjs/scene";
  47609. import { Vector3 } from "babylonjs/Maths/math.vector";
  47610. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47611. /**
  47612. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47613. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47614. */
  47615. export class AnaglyphFreeCamera extends FreeCamera {
  47616. /**
  47617. * Creates a new AnaglyphFreeCamera
  47618. * @param name defines camera name
  47619. * @param position defines initial position
  47620. * @param interaxialDistance defines distance between each color axis
  47621. * @param scene defines the hosting scene
  47622. */
  47623. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47624. /**
  47625. * Gets camera class name
  47626. * @returns AnaglyphFreeCamera
  47627. */
  47628. getClassName(): string;
  47629. }
  47630. }
  47631. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47632. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47633. import { Scene } from "babylonjs/scene";
  47634. import { Vector3 } from "babylonjs/Maths/math.vector";
  47635. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47636. /**
  47637. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47638. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47639. */
  47640. export class AnaglyphGamepadCamera extends GamepadCamera {
  47641. /**
  47642. * Creates a new AnaglyphGamepadCamera
  47643. * @param name defines camera name
  47644. * @param position defines initial position
  47645. * @param interaxialDistance defines distance between each color axis
  47646. * @param scene defines the hosting scene
  47647. */
  47648. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47649. /**
  47650. * Gets camera class name
  47651. * @returns AnaglyphGamepadCamera
  47652. */
  47653. getClassName(): string;
  47654. }
  47655. }
  47656. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  47657. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47658. import { Scene } from "babylonjs/scene";
  47659. import { Vector3 } from "babylonjs/Maths/math.vector";
  47660. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47661. /**
  47662. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  47663. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47664. */
  47665. export class AnaglyphUniversalCamera extends UniversalCamera {
  47666. /**
  47667. * Creates a new AnaglyphUniversalCamera
  47668. * @param name defines camera name
  47669. * @param position defines initial position
  47670. * @param interaxialDistance defines distance between each color axis
  47671. * @param scene defines the hosting scene
  47672. */
  47673. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47674. /**
  47675. * Gets camera class name
  47676. * @returns AnaglyphUniversalCamera
  47677. */
  47678. getClassName(): string;
  47679. }
  47680. }
  47681. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  47682. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  47683. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47684. import { Scene } from "babylonjs/scene";
  47685. import { Vector3 } from "babylonjs/Maths/math.vector";
  47686. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47687. /**
  47688. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  47689. * @see https://doc.babylonjs.com/features/cameras
  47690. */
  47691. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  47692. /**
  47693. * Creates a new StereoscopicArcRotateCamera
  47694. * @param name defines camera name
  47695. * @param alpha defines alpha angle (in radians)
  47696. * @param beta defines beta angle (in radians)
  47697. * @param radius defines radius
  47698. * @param target defines camera target
  47699. * @param interaxialDistance defines distance between each color axis
  47700. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47701. * @param scene defines the hosting scene
  47702. */
  47703. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47704. /**
  47705. * Gets camera class name
  47706. * @returns StereoscopicArcRotateCamera
  47707. */
  47708. getClassName(): string;
  47709. }
  47710. }
  47711. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  47712. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47713. import { Scene } from "babylonjs/scene";
  47714. import { Vector3 } from "babylonjs/Maths/math.vector";
  47715. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47716. /**
  47717. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  47718. * @see https://doc.babylonjs.com/features/cameras
  47719. */
  47720. export class StereoscopicFreeCamera extends FreeCamera {
  47721. /**
  47722. * Creates a new StereoscopicFreeCamera
  47723. * @param name defines camera name
  47724. * @param position defines initial position
  47725. * @param interaxialDistance defines distance between each color axis
  47726. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47727. * @param scene defines the hosting scene
  47728. */
  47729. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47730. /**
  47731. * Gets camera class name
  47732. * @returns StereoscopicFreeCamera
  47733. */
  47734. getClassName(): string;
  47735. }
  47736. }
  47737. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  47738. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47739. import { Scene } from "babylonjs/scene";
  47740. import { Vector3 } from "babylonjs/Maths/math.vector";
  47741. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47742. /**
  47743. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  47744. * @see https://doc.babylonjs.com/features/cameras
  47745. */
  47746. export class StereoscopicGamepadCamera extends GamepadCamera {
  47747. /**
  47748. * Creates a new StereoscopicGamepadCamera
  47749. * @param name defines camera name
  47750. * @param position defines initial position
  47751. * @param interaxialDistance defines distance between each color axis
  47752. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47753. * @param scene defines the hosting scene
  47754. */
  47755. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47756. /**
  47757. * Gets camera class name
  47758. * @returns StereoscopicGamepadCamera
  47759. */
  47760. getClassName(): string;
  47761. }
  47762. }
  47763. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  47764. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47765. import { Scene } from "babylonjs/scene";
  47766. import { Vector3 } from "babylonjs/Maths/math.vector";
  47767. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47768. /**
  47769. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  47770. * @see https://doc.babylonjs.com/features/cameras
  47771. */
  47772. export class StereoscopicUniversalCamera extends UniversalCamera {
  47773. /**
  47774. * Creates a new StereoscopicUniversalCamera
  47775. * @param name defines camera name
  47776. * @param position defines initial position
  47777. * @param interaxialDistance defines distance between each color axis
  47778. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47779. * @param scene defines the hosting scene
  47780. */
  47781. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47782. /**
  47783. * Gets camera class name
  47784. * @returns StereoscopicUniversalCamera
  47785. */
  47786. getClassName(): string;
  47787. }
  47788. }
  47789. declare module "babylonjs/Cameras/Stereoscopic/index" {
  47790. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  47791. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  47792. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  47793. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  47794. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  47795. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  47796. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  47797. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  47798. }
  47799. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  47800. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47801. import { Scene } from "babylonjs/scene";
  47802. import { Vector3 } from "babylonjs/Maths/math.vector";
  47803. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47804. /**
  47805. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  47806. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47807. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47808. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47809. */
  47810. export class VirtualJoysticksCamera extends FreeCamera {
  47811. /**
  47812. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  47813. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47814. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47815. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47816. * @param name Define the name of the camera in the scene
  47817. * @param position Define the start position of the camera in the scene
  47818. * @param scene Define the scene the camera belongs to
  47819. */
  47820. constructor(name: string, position: Vector3, scene: Scene);
  47821. /**
  47822. * Gets the current object class name.
  47823. * @return the class name
  47824. */
  47825. getClassName(): string;
  47826. }
  47827. }
  47828. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  47829. import { Matrix } from "babylonjs/Maths/math.vector";
  47830. /**
  47831. * This represents all the required metrics to create a VR camera.
  47832. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  47833. */
  47834. export class VRCameraMetrics {
  47835. /**
  47836. * Define the horizontal resolution off the screen.
  47837. */
  47838. hResolution: number;
  47839. /**
  47840. * Define the vertical resolution off the screen.
  47841. */
  47842. vResolution: number;
  47843. /**
  47844. * Define the horizontal screen size.
  47845. */
  47846. hScreenSize: number;
  47847. /**
  47848. * Define the vertical screen size.
  47849. */
  47850. vScreenSize: number;
  47851. /**
  47852. * Define the vertical screen center position.
  47853. */
  47854. vScreenCenter: number;
  47855. /**
  47856. * Define the distance of the eyes to the screen.
  47857. */
  47858. eyeToScreenDistance: number;
  47859. /**
  47860. * Define the distance between both lenses
  47861. */
  47862. lensSeparationDistance: number;
  47863. /**
  47864. * Define the distance between both viewer's eyes.
  47865. */
  47866. interpupillaryDistance: number;
  47867. /**
  47868. * Define the distortion factor of the VR postprocess.
  47869. * Please, touch with care.
  47870. */
  47871. distortionK: number[];
  47872. /**
  47873. * Define the chromatic aberration correction factors for the VR post process.
  47874. */
  47875. chromaAbCorrection: number[];
  47876. /**
  47877. * Define the scale factor of the post process.
  47878. * The smaller the better but the slower.
  47879. */
  47880. postProcessScaleFactor: number;
  47881. /**
  47882. * Define an offset for the lens center.
  47883. */
  47884. lensCenterOffset: number;
  47885. /**
  47886. * Define if the current vr camera should compensate the distortion of the lense or not.
  47887. */
  47888. compensateDistortion: boolean;
  47889. /**
  47890. * Defines if multiview should be enabled when rendering (Default: false)
  47891. */
  47892. multiviewEnabled: boolean;
  47893. /**
  47894. * Gets the rendering aspect ratio based on the provided resolutions.
  47895. */
  47896. get aspectRatio(): number;
  47897. /**
  47898. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  47899. */
  47900. get aspectRatioFov(): number;
  47901. /**
  47902. * @hidden
  47903. */
  47904. get leftHMatrix(): Matrix;
  47905. /**
  47906. * @hidden
  47907. */
  47908. get rightHMatrix(): Matrix;
  47909. /**
  47910. * @hidden
  47911. */
  47912. get leftPreViewMatrix(): Matrix;
  47913. /**
  47914. * @hidden
  47915. */
  47916. get rightPreViewMatrix(): Matrix;
  47917. /**
  47918. * Get the default VRMetrics based on the most generic setup.
  47919. * @returns the default vr metrics
  47920. */
  47921. static GetDefault(): VRCameraMetrics;
  47922. }
  47923. }
  47924. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  47925. /** @hidden */
  47926. export var vrDistortionCorrectionPixelShader: {
  47927. name: string;
  47928. shader: string;
  47929. };
  47930. }
  47931. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  47932. import { Camera } from "babylonjs/Cameras/camera";
  47933. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47934. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47935. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  47936. /**
  47937. * VRDistortionCorrectionPostProcess used for mobile VR
  47938. */
  47939. export class VRDistortionCorrectionPostProcess extends PostProcess {
  47940. private _isRightEye;
  47941. private _distortionFactors;
  47942. private _postProcessScaleFactor;
  47943. private _lensCenterOffset;
  47944. private _scaleIn;
  47945. private _scaleFactor;
  47946. private _lensCenter;
  47947. /**
  47948. * Initializes the VRDistortionCorrectionPostProcess
  47949. * @param name The name of the effect.
  47950. * @param camera The camera to apply the render pass to.
  47951. * @param isRightEye If this is for the right eye distortion
  47952. * @param vrMetrics All the required metrics for the VR camera
  47953. */
  47954. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  47955. }
  47956. }
  47957. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  47958. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  47959. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47960. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47961. import { Scene } from "babylonjs/scene";
  47962. import { Vector3 } from "babylonjs/Maths/math.vector";
  47963. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47964. import "babylonjs/Cameras/RigModes/vrRigMode";
  47965. /**
  47966. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  47967. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47968. */
  47969. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  47970. /**
  47971. * Creates a new VRDeviceOrientationArcRotateCamera
  47972. * @param name defines camera name
  47973. * @param alpha defines the camera rotation along the logitudinal axis
  47974. * @param beta defines the camera rotation along the latitudinal axis
  47975. * @param radius defines the camera distance from its target
  47976. * @param target defines the camera target
  47977. * @param scene defines the scene the camera belongs to
  47978. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47979. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47980. */
  47981. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47982. /**
  47983. * Gets camera class name
  47984. * @returns VRDeviceOrientationArcRotateCamera
  47985. */
  47986. getClassName(): string;
  47987. }
  47988. }
  47989. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  47990. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47991. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47992. import { Scene } from "babylonjs/scene";
  47993. import { Vector3 } from "babylonjs/Maths/math.vector";
  47994. import "babylonjs/Cameras/RigModes/vrRigMode";
  47995. /**
  47996. * Camera used to simulate VR rendering (based on FreeCamera)
  47997. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47998. */
  47999. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48000. /**
  48001. * Creates a new VRDeviceOrientationFreeCamera
  48002. * @param name defines camera name
  48003. * @param position defines the start position of the camera
  48004. * @param scene defines the scene the camera belongs to
  48005. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48006. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48007. */
  48008. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48009. /**
  48010. * Gets camera class name
  48011. * @returns VRDeviceOrientationFreeCamera
  48012. */
  48013. getClassName(): string;
  48014. }
  48015. }
  48016. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48017. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48018. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48019. import { Scene } from "babylonjs/scene";
  48020. import { Vector3 } from "babylonjs/Maths/math.vector";
  48021. import "babylonjs/Gamepads/gamepadSceneComponent";
  48022. /**
  48023. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48024. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48025. */
  48026. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48027. /**
  48028. * Creates a new VRDeviceOrientationGamepadCamera
  48029. * @param name defines camera name
  48030. * @param position defines the start position of the camera
  48031. * @param scene defines the scene the camera belongs to
  48032. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48033. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48034. */
  48035. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48036. /**
  48037. * Gets camera class name
  48038. * @returns VRDeviceOrientationGamepadCamera
  48039. */
  48040. getClassName(): string;
  48041. }
  48042. }
  48043. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48044. import { Scene } from "babylonjs/scene";
  48045. import { Texture } from "babylonjs/Materials/Textures/texture";
  48046. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48047. /**
  48048. * A class extending Texture allowing drawing on a texture
  48049. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48050. */
  48051. export class DynamicTexture extends Texture {
  48052. private _generateMipMaps;
  48053. private _canvas;
  48054. private _context;
  48055. /**
  48056. * Creates a DynamicTexture
  48057. * @param name defines the name of the texture
  48058. * @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
  48059. * @param scene defines the scene where you want the texture
  48060. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48061. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48062. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48063. */
  48064. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48065. /**
  48066. * Get the current class name of the texture useful for serialization or dynamic coding.
  48067. * @returns "DynamicTexture"
  48068. */
  48069. getClassName(): string;
  48070. /**
  48071. * Gets the current state of canRescale
  48072. */
  48073. get canRescale(): boolean;
  48074. private _recreate;
  48075. /**
  48076. * Scales the texture
  48077. * @param ratio the scale factor to apply to both width and height
  48078. */
  48079. scale(ratio: number): void;
  48080. /**
  48081. * Resizes the texture
  48082. * @param width the new width
  48083. * @param height the new height
  48084. */
  48085. scaleTo(width: number, height: number): void;
  48086. /**
  48087. * Gets the context of the canvas used by the texture
  48088. * @returns the canvas context of the dynamic texture
  48089. */
  48090. getContext(): CanvasRenderingContext2D;
  48091. /**
  48092. * Clears the texture
  48093. */
  48094. clear(): void;
  48095. /**
  48096. * Updates the texture
  48097. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48098. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48099. */
  48100. update(invertY?: boolean, premulAlpha?: boolean): void;
  48101. /**
  48102. * Draws text onto the texture
  48103. * @param text defines the text to be drawn
  48104. * @param x defines the placement of the text from the left
  48105. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48106. * @param font defines the font to be used with font-style, font-size, font-name
  48107. * @param color defines the color used for the text
  48108. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48109. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48110. * @param update defines whether texture is immediately update (default is true)
  48111. */
  48112. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48113. /**
  48114. * Clones the texture
  48115. * @returns the clone of the texture.
  48116. */
  48117. clone(): DynamicTexture;
  48118. /**
  48119. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48120. * @returns a serialized dynamic texture object
  48121. */
  48122. serialize(): any;
  48123. private _IsCanvasElement;
  48124. /** @hidden */
  48125. _rebuild(): void;
  48126. }
  48127. }
  48128. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48129. import { Scene } from "babylonjs/scene";
  48130. import { Color3 } from "babylonjs/Maths/math.color";
  48131. import { Mesh } from "babylonjs/Meshes/mesh";
  48132. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48133. import { Nullable } from "babylonjs/types";
  48134. /**
  48135. * Class containing static functions to help procedurally build meshes
  48136. */
  48137. export class GroundBuilder {
  48138. /**
  48139. * Creates a ground mesh
  48140. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48141. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48143. * @param name defines the name of the mesh
  48144. * @param options defines the options used to create the mesh
  48145. * @param scene defines the hosting scene
  48146. * @returns the ground mesh
  48147. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48148. */
  48149. static CreateGround(name: string, options: {
  48150. width?: number;
  48151. height?: number;
  48152. subdivisions?: number;
  48153. subdivisionsX?: number;
  48154. subdivisionsY?: number;
  48155. updatable?: boolean;
  48156. }, scene: any): Mesh;
  48157. /**
  48158. * Creates a tiled ground mesh
  48159. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48160. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48161. * * 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
  48162. * * 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
  48163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48164. * @param name defines the name of the mesh
  48165. * @param options defines the options used to create the mesh
  48166. * @param scene defines the hosting scene
  48167. * @returns the tiled ground mesh
  48168. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48169. */
  48170. static CreateTiledGround(name: string, options: {
  48171. xmin: number;
  48172. zmin: number;
  48173. xmax: number;
  48174. zmax: number;
  48175. subdivisions?: {
  48176. w: number;
  48177. h: number;
  48178. };
  48179. precision?: {
  48180. w: number;
  48181. h: number;
  48182. };
  48183. updatable?: boolean;
  48184. }, scene?: Nullable<Scene>): Mesh;
  48185. /**
  48186. * Creates a ground mesh from a height map
  48187. * * The parameter `url` sets the URL of the height map image resource.
  48188. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48189. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48190. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48191. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48192. * * 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.
  48193. * * 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).
  48194. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48196. * @param name defines the name of the mesh
  48197. * @param url defines the url to the height map
  48198. * @param options defines the options used to create the mesh
  48199. * @param scene defines the hosting scene
  48200. * @returns the ground mesh
  48201. * @see https://doc.babylonjs.com/babylon101/height_map
  48202. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48203. */
  48204. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48205. width?: number;
  48206. height?: number;
  48207. subdivisions?: number;
  48208. minHeight?: number;
  48209. maxHeight?: number;
  48210. colorFilter?: Color3;
  48211. alphaFilter?: number;
  48212. updatable?: boolean;
  48213. onReady?: (mesh: GroundMesh) => void;
  48214. }, scene?: Nullable<Scene>): GroundMesh;
  48215. }
  48216. }
  48217. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48218. import { Vector4 } from "babylonjs/Maths/math.vector";
  48219. import { Mesh } from "babylonjs/Meshes/mesh";
  48220. /**
  48221. * Class containing static functions to help procedurally build meshes
  48222. */
  48223. export class TorusBuilder {
  48224. /**
  48225. * Creates a torus mesh
  48226. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48227. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48228. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48232. * @param name defines the name of the mesh
  48233. * @param options defines the options used to create the mesh
  48234. * @param scene defines the hosting scene
  48235. * @returns the torus mesh
  48236. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48237. */
  48238. static CreateTorus(name: string, options: {
  48239. diameter?: number;
  48240. thickness?: number;
  48241. tessellation?: number;
  48242. updatable?: boolean;
  48243. sideOrientation?: number;
  48244. frontUVs?: Vector4;
  48245. backUVs?: Vector4;
  48246. }, scene: any): Mesh;
  48247. }
  48248. }
  48249. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48250. import { Vector4 } from "babylonjs/Maths/math.vector";
  48251. import { Color4 } from "babylonjs/Maths/math.color";
  48252. import { Mesh } from "babylonjs/Meshes/mesh";
  48253. /**
  48254. * Class containing static functions to help procedurally build meshes
  48255. */
  48256. export class CylinderBuilder {
  48257. /**
  48258. * Creates a cylinder or a cone mesh
  48259. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48260. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48261. * * 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.
  48262. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48263. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48264. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48265. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48266. * * 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).
  48267. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48268. * * 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).
  48269. * * 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
  48270. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48271. * * 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
  48272. * * 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.
  48273. * * If `enclose` is false, a ring surface is one element.
  48274. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48275. * * 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
  48276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48277. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48279. * @param name defines the name of the mesh
  48280. * @param options defines the options used to create the mesh
  48281. * @param scene defines the hosting scene
  48282. * @returns the cylinder mesh
  48283. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48284. */
  48285. static CreateCylinder(name: string, options: {
  48286. height?: number;
  48287. diameterTop?: number;
  48288. diameterBottom?: number;
  48289. diameter?: number;
  48290. tessellation?: number;
  48291. subdivisions?: number;
  48292. arc?: number;
  48293. faceColors?: Color4[];
  48294. faceUV?: Vector4[];
  48295. updatable?: boolean;
  48296. hasRings?: boolean;
  48297. enclose?: boolean;
  48298. cap?: number;
  48299. sideOrientation?: number;
  48300. frontUVs?: Vector4;
  48301. backUVs?: Vector4;
  48302. }, scene: any): Mesh;
  48303. }
  48304. }
  48305. declare module "babylonjs/XR/webXRTypes" {
  48306. import { Nullable } from "babylonjs/types";
  48307. import { IDisposable } from "babylonjs/scene";
  48308. /**
  48309. * States of the webXR experience
  48310. */
  48311. export enum WebXRState {
  48312. /**
  48313. * Transitioning to being in XR mode
  48314. */
  48315. ENTERING_XR = 0,
  48316. /**
  48317. * Transitioning to non XR mode
  48318. */
  48319. EXITING_XR = 1,
  48320. /**
  48321. * In XR mode and presenting
  48322. */
  48323. IN_XR = 2,
  48324. /**
  48325. * Not entered XR mode
  48326. */
  48327. NOT_IN_XR = 3
  48328. }
  48329. /**
  48330. * Abstraction of the XR render target
  48331. */
  48332. export interface WebXRRenderTarget extends IDisposable {
  48333. /**
  48334. * xrpresent context of the canvas which can be used to display/mirror xr content
  48335. */
  48336. canvasContext: WebGLRenderingContext;
  48337. /**
  48338. * xr layer for the canvas
  48339. */
  48340. xrLayer: Nullable<XRWebGLLayer>;
  48341. /**
  48342. * Initializes the xr layer for the session
  48343. * @param xrSession xr session
  48344. * @returns a promise that will resolve once the XR Layer has been created
  48345. */
  48346. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48347. }
  48348. }
  48349. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48350. import { Nullable } from "babylonjs/types";
  48351. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48352. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48353. import { Observable } from "babylonjs/Misc/observable";
  48354. /**
  48355. * COnfiguration object for WebXR output canvas
  48356. */
  48357. export class WebXRManagedOutputCanvasOptions {
  48358. /**
  48359. * An optional canvas in case you wish to create it yourself and provide it here.
  48360. * If not provided, a new canvas will be created
  48361. */
  48362. canvasElement?: HTMLCanvasElement;
  48363. /**
  48364. * Options for this XR Layer output
  48365. */
  48366. canvasOptions?: XRWebGLLayerOptions;
  48367. /**
  48368. * CSS styling for a newly created canvas (if not provided)
  48369. */
  48370. newCanvasCssStyle?: string;
  48371. /**
  48372. * Get the default values of the configuration object
  48373. * @returns default values of this configuration object
  48374. */
  48375. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  48376. }
  48377. /**
  48378. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48379. */
  48380. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48381. private _options;
  48382. private _canvas;
  48383. private _engine;
  48384. private _originalCanvasSize;
  48385. /**
  48386. * Rendering context of the canvas which can be used to display/mirror xr content
  48387. */
  48388. canvasContext: WebGLRenderingContext;
  48389. /**
  48390. * xr layer for the canvas
  48391. */
  48392. xrLayer: Nullable<XRWebGLLayer>;
  48393. /**
  48394. * Obseervers registered here will be triggered when the xr layer was initialized
  48395. */
  48396. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48397. /**
  48398. * Initializes the canvas to be added/removed upon entering/exiting xr
  48399. * @param _xrSessionManager The XR Session manager
  48400. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48401. */
  48402. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48403. /**
  48404. * Disposes of the object
  48405. */
  48406. dispose(): void;
  48407. /**
  48408. * Initializes the xr layer for the session
  48409. * @param xrSession xr session
  48410. * @returns a promise that will resolve once the XR Layer has been created
  48411. */
  48412. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48413. private _addCanvas;
  48414. private _removeCanvas;
  48415. private _setCanvasSize;
  48416. private _setManagedOutputCanvas;
  48417. }
  48418. }
  48419. declare module "babylonjs/XR/webXRSessionManager" {
  48420. import { Observable } from "babylonjs/Misc/observable";
  48421. import { Nullable } from "babylonjs/types";
  48422. import { IDisposable, Scene } from "babylonjs/scene";
  48423. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48424. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48425. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48426. /**
  48427. * Manages an XRSession to work with Babylon's engine
  48428. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48429. */
  48430. export class WebXRSessionManager implements IDisposable {
  48431. /** The scene which the session should be created for */
  48432. scene: Scene;
  48433. private _referenceSpace;
  48434. private _rttProvider;
  48435. private _sessionEnded;
  48436. private _xrNavigator;
  48437. private baseLayer;
  48438. /**
  48439. * The base reference space from which the session started. good if you want to reset your
  48440. * reference space
  48441. */
  48442. baseReferenceSpace: XRReferenceSpace;
  48443. /**
  48444. * Current XR frame
  48445. */
  48446. currentFrame: Nullable<XRFrame>;
  48447. /** WebXR timestamp updated every frame */
  48448. currentTimestamp: number;
  48449. /**
  48450. * Used just in case of a failure to initialize an immersive session.
  48451. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48452. */
  48453. defaultHeightCompensation: number;
  48454. /**
  48455. * Fires every time a new xrFrame arrives which can be used to update the camera
  48456. */
  48457. onXRFrameObservable: Observable<XRFrame>;
  48458. /**
  48459. * Fires when the reference space changed
  48460. */
  48461. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48462. /**
  48463. * Fires when the xr session is ended either by the device or manually done
  48464. */
  48465. onXRSessionEnded: Observable<any>;
  48466. /**
  48467. * Fires when the xr session is ended either by the device or manually done
  48468. */
  48469. onXRSessionInit: Observable<XRSession>;
  48470. /**
  48471. * Underlying xr session
  48472. */
  48473. session: XRSession;
  48474. /**
  48475. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48476. * or get the offset the player is currently at.
  48477. */
  48478. viewerReferenceSpace: XRReferenceSpace;
  48479. /**
  48480. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48481. * @param scene The scene which the session should be created for
  48482. */
  48483. constructor(
  48484. /** The scene which the session should be created for */
  48485. scene: Scene);
  48486. /**
  48487. * The current reference space used in this session. This reference space can constantly change!
  48488. * It is mainly used to offset the camera's position.
  48489. */
  48490. get referenceSpace(): XRReferenceSpace;
  48491. /**
  48492. * Set a new reference space and triggers the observable
  48493. */
  48494. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48495. /**
  48496. * Disposes of the session manager
  48497. */
  48498. dispose(): void;
  48499. /**
  48500. * Stops the xrSession and restores the render loop
  48501. * @returns Promise which resolves after it exits XR
  48502. */
  48503. exitXRAsync(): Promise<void>;
  48504. /**
  48505. * Gets the correct render target texture to be rendered this frame for this eye
  48506. * @param eye the eye for which to get the render target
  48507. * @returns the render target for the specified eye
  48508. */
  48509. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48510. /**
  48511. * Creates a WebXRRenderTarget object for the XR session
  48512. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48513. * @param options optional options to provide when creating a new render target
  48514. * @returns a WebXR render target to which the session can render
  48515. */
  48516. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48517. /**
  48518. * Initializes the manager
  48519. * After initialization enterXR can be called to start an XR session
  48520. * @returns Promise which resolves after it is initialized
  48521. */
  48522. initializeAsync(): Promise<void>;
  48523. /**
  48524. * Initializes an xr session
  48525. * @param xrSessionMode mode to initialize
  48526. * @param xrSessionInit defines optional and required values to pass to the session builder
  48527. * @returns a promise which will resolve once the session has been initialized
  48528. */
  48529. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48530. /**
  48531. * Checks if a session would be supported for the creation options specified
  48532. * @param sessionMode session mode to check if supported eg. immersive-vr
  48533. * @returns A Promise that resolves to true if supported and false if not
  48534. */
  48535. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48536. /**
  48537. * Resets the reference space to the one started the session
  48538. */
  48539. resetReferenceSpace(): void;
  48540. /**
  48541. * Starts rendering to the xr layer
  48542. */
  48543. runXRRenderLoop(): void;
  48544. /**
  48545. * Sets the reference space on the xr session
  48546. * @param referenceSpaceType space to set
  48547. * @returns a promise that will resolve once the reference space has been set
  48548. */
  48549. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48550. /**
  48551. * Updates the render state of the session
  48552. * @param state state to set
  48553. * @returns a promise that resolves once the render state has been updated
  48554. */
  48555. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48556. /**
  48557. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48558. * @param sessionMode defines the session to test
  48559. * @returns a promise with boolean as final value
  48560. */
  48561. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48562. private _createRenderTargetTexture;
  48563. }
  48564. }
  48565. declare module "babylonjs/XR/webXRCamera" {
  48566. import { Scene } from "babylonjs/scene";
  48567. import { Camera } from "babylonjs/Cameras/camera";
  48568. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48569. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48570. /**
  48571. * WebXR Camera which holds the views for the xrSession
  48572. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48573. */
  48574. export class WebXRCamera extends FreeCamera {
  48575. private _xrSessionManager;
  48576. private _firstFrame;
  48577. private _referenceQuaternion;
  48578. private _referencedPosition;
  48579. private _xrInvPositionCache;
  48580. private _xrInvQuaternionCache;
  48581. /**
  48582. * Should position compensation execute on first frame.
  48583. * This is used when copying the position from a native (non XR) camera
  48584. */
  48585. compensateOnFirstFrame: boolean;
  48586. /**
  48587. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48588. * @param name the name of the camera
  48589. * @param scene the scene to add the camera to
  48590. * @param _xrSessionManager a constructed xr session manager
  48591. */
  48592. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48593. /**
  48594. * Return the user's height, unrelated to the current ground.
  48595. * This will be the y position of this camera, when ground level is 0.
  48596. */
  48597. get realWorldHeight(): number;
  48598. /** @hidden */
  48599. _updateForDualEyeDebugging(): void;
  48600. /**
  48601. * Sets this camera's transformation based on a non-vr camera
  48602. * @param otherCamera the non-vr camera to copy the transformation from
  48603. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48604. */
  48605. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48606. /**
  48607. * Gets the current instance class name ("WebXRCamera").
  48608. * @returns the class name
  48609. */
  48610. getClassName(): string;
  48611. private _rotate180;
  48612. private _updateFromXRSession;
  48613. private _updateNumberOfRigCameras;
  48614. private _updateReferenceSpace;
  48615. private _updateReferenceSpaceOffset;
  48616. }
  48617. }
  48618. declare module "babylonjs/XR/webXRFeaturesManager" {
  48619. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48620. import { IDisposable } from "babylonjs/scene";
  48621. /**
  48622. * Defining the interface required for a (webxr) feature
  48623. */
  48624. export interface IWebXRFeature extends IDisposable {
  48625. /**
  48626. * Is this feature attached
  48627. */
  48628. attached: boolean;
  48629. /**
  48630. * Should auto-attach be disabled?
  48631. */
  48632. disableAutoAttach: boolean;
  48633. /**
  48634. * Attach the feature to the session
  48635. * Will usually be called by the features manager
  48636. *
  48637. * @param force should attachment be forced (even when already attached)
  48638. * @returns true if successful.
  48639. */
  48640. attach(force?: boolean): boolean;
  48641. /**
  48642. * Detach the feature from the session
  48643. * Will usually be called by the features manager
  48644. *
  48645. * @returns true if successful.
  48646. */
  48647. detach(): boolean;
  48648. /**
  48649. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48650. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48651. *
  48652. * @returns whether or not the feature is compatible in this environment
  48653. */
  48654. isCompatible(): boolean;
  48655. /**
  48656. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  48657. */
  48658. xrNativeFeatureName?: string;
  48659. }
  48660. /**
  48661. * A list of the currently available features without referencing them
  48662. */
  48663. export class WebXRFeatureName {
  48664. /**
  48665. * The name of the anchor system feature
  48666. */
  48667. static ANCHOR_SYSTEM: string;
  48668. /**
  48669. * The name of the background remover feature
  48670. */
  48671. static BACKGROUND_REMOVER: string;
  48672. /**
  48673. * The name of the hit test feature
  48674. */
  48675. static HIT_TEST: string;
  48676. /**
  48677. * physics impostors for xr controllers feature
  48678. */
  48679. static PHYSICS_CONTROLLERS: string;
  48680. /**
  48681. * The name of the plane detection feature
  48682. */
  48683. static PLANE_DETECTION: string;
  48684. /**
  48685. * The name of the pointer selection feature
  48686. */
  48687. static POINTER_SELECTION: string;
  48688. /**
  48689. * The name of the teleportation feature
  48690. */
  48691. static TELEPORTATION: string;
  48692. }
  48693. /**
  48694. * Defining the constructor of a feature. Used to register the modules.
  48695. */
  48696. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  48697. /**
  48698. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48699. * It is mainly used in AR sessions.
  48700. *
  48701. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48702. */
  48703. export class WebXRFeaturesManager implements IDisposable {
  48704. private _xrSessionManager;
  48705. private static readonly _AvailableFeatures;
  48706. private _features;
  48707. /**
  48708. * constructs a new features manages.
  48709. *
  48710. * @param _xrSessionManager an instance of WebXRSessionManager
  48711. */
  48712. constructor(_xrSessionManager: WebXRSessionManager);
  48713. /**
  48714. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48715. * Mainly used internally.
  48716. *
  48717. * @param featureName the name of the feature to register
  48718. * @param constructorFunction the function used to construct the module
  48719. * @param version the (babylon) version of the module
  48720. * @param stable is that a stable version of this module
  48721. */
  48722. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48723. /**
  48724. * Returns a constructor of a specific feature.
  48725. *
  48726. * @param featureName the name of the feature to construct
  48727. * @param version the version of the feature to load
  48728. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48729. * @param options optional options provided to the module.
  48730. * @returns a function that, when called, will return a new instance of this feature
  48731. */
  48732. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  48733. /**
  48734. * Can be used to return the list of features currently registered
  48735. *
  48736. * @returns an Array of available features
  48737. */
  48738. static GetAvailableFeatures(): string[];
  48739. /**
  48740. * Gets the versions available for a specific feature
  48741. * @param featureName the name of the feature
  48742. * @returns an array with the available versions
  48743. */
  48744. static GetAvailableVersions(featureName: string): string[];
  48745. /**
  48746. * Return the latest unstable version of this feature
  48747. * @param featureName the name of the feature to search
  48748. * @returns the version number. if not found will return -1
  48749. */
  48750. static GetLatestVersionOfFeature(featureName: string): number;
  48751. /**
  48752. * Return the latest stable version of this feature
  48753. * @param featureName the name of the feature to search
  48754. * @returns the version number. if not found will return -1
  48755. */
  48756. static GetStableVersionOfFeature(featureName: string): number;
  48757. /**
  48758. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  48759. * Can be used during a session to start a feature
  48760. * @param featureName the name of feature to attach
  48761. */
  48762. attachFeature(featureName: string): void;
  48763. /**
  48764. * Can be used inside a session or when the session ends to detach a specific feature
  48765. * @param featureName the name of the feature to detach
  48766. */
  48767. detachFeature(featureName: string): void;
  48768. /**
  48769. * Used to disable an already-enabled feature
  48770. * The feature will be disposed and will be recreated once enabled.
  48771. * @param featureName the feature to disable
  48772. * @returns true if disable was successful
  48773. */
  48774. disableFeature(featureName: string | {
  48775. Name: string;
  48776. }): boolean;
  48777. /**
  48778. * dispose this features manager
  48779. */
  48780. dispose(): void;
  48781. /**
  48782. * 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.
  48783. * 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.
  48784. *
  48785. * @param featureName the name of the feature to load or the class of the feature
  48786. * @param version optional version to load. if not provided the latest version will be enabled
  48787. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  48788. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  48789. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  48790. * @returns a new constructed feature or throws an error if feature not found.
  48791. */
  48792. enableFeature(featureName: string | {
  48793. Name: string;
  48794. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  48795. /**
  48796. * get the implementation of an enabled feature.
  48797. * @param featureName the name of the feature to load
  48798. * @returns the feature class, if found
  48799. */
  48800. getEnabledFeature(featureName: string): IWebXRFeature;
  48801. /**
  48802. * Get the list of enabled features
  48803. * @returns an array of enabled features
  48804. */
  48805. getEnabledFeatures(): string[];
  48806. /**
  48807. * This function will exten the session creation configuration object with enabled features.
  48808. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  48809. * according to the defined "required" variable, provided during enableFeature call
  48810. * @param xrSessionInit the xr Session init object to extend
  48811. *
  48812. * @returns an extended XRSessionInit object
  48813. */
  48814. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  48815. }
  48816. }
  48817. declare module "babylonjs/XR/webXRExperienceHelper" {
  48818. import { Observable } from "babylonjs/Misc/observable";
  48819. import { IDisposable, Scene } from "babylonjs/scene";
  48820. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48821. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48822. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48823. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  48824. /**
  48825. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  48826. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  48827. */
  48828. export class WebXRExperienceHelper implements IDisposable {
  48829. private scene;
  48830. private _nonVRCamera;
  48831. private _originalSceneAutoClear;
  48832. private _supported;
  48833. /**
  48834. * Camera used to render xr content
  48835. */
  48836. camera: WebXRCamera;
  48837. /** A features manager for this xr session */
  48838. featuresManager: WebXRFeaturesManager;
  48839. /**
  48840. * Observers registered here will be triggered after the camera's initial transformation is set
  48841. * This can be used to set a different ground level or an extra rotation.
  48842. *
  48843. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  48844. * to the position set after this observable is done executing.
  48845. */
  48846. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  48847. /**
  48848. * Fires when the state of the experience helper has changed
  48849. */
  48850. onStateChangedObservable: Observable<WebXRState>;
  48851. /** Session manager used to keep track of xr session */
  48852. sessionManager: WebXRSessionManager;
  48853. /**
  48854. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  48855. */
  48856. state: WebXRState;
  48857. /**
  48858. * Creates a WebXRExperienceHelper
  48859. * @param scene The scene the helper should be created in
  48860. */
  48861. private constructor();
  48862. /**
  48863. * Creates the experience helper
  48864. * @param scene the scene to attach the experience helper to
  48865. * @returns a promise for the experience helper
  48866. */
  48867. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  48868. /**
  48869. * Disposes of the experience helper
  48870. */
  48871. dispose(): void;
  48872. /**
  48873. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  48874. * @param sessionMode options for the XR session
  48875. * @param referenceSpaceType frame of reference of the XR session
  48876. * @param renderTarget the output canvas that will be used to enter XR mode
  48877. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  48878. * @returns promise that resolves after xr mode has entered
  48879. */
  48880. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  48881. /**
  48882. * Exits XR mode and returns the scene to its original state
  48883. * @returns promise that resolves after xr mode has exited
  48884. */
  48885. exitXRAsync(): Promise<void>;
  48886. private _nonXRToXRCamera;
  48887. private _setState;
  48888. }
  48889. }
  48890. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  48891. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48892. import { Observable } from "babylonjs/Misc/observable";
  48893. import { IDisposable } from "babylonjs/scene";
  48894. /**
  48895. * X-Y values for axes in WebXR
  48896. */
  48897. export interface IWebXRMotionControllerAxesValue {
  48898. /**
  48899. * The value of the x axis
  48900. */
  48901. x: number;
  48902. /**
  48903. * The value of the y-axis
  48904. */
  48905. y: number;
  48906. }
  48907. /**
  48908. * changed / previous values for the values of this component
  48909. */
  48910. export interface IWebXRMotionControllerComponentChangesValues<T> {
  48911. /**
  48912. * current (this frame) value
  48913. */
  48914. current: T;
  48915. /**
  48916. * previous (last change) value
  48917. */
  48918. previous: T;
  48919. }
  48920. /**
  48921. * Represents changes in the component between current frame and last values recorded
  48922. */
  48923. export interface IWebXRMotionControllerComponentChanges {
  48924. /**
  48925. * will be populated with previous and current values if axes changed
  48926. */
  48927. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  48928. /**
  48929. * will be populated with previous and current values if pressed changed
  48930. */
  48931. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48932. /**
  48933. * will be populated with previous and current values if touched changed
  48934. */
  48935. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48936. /**
  48937. * will be populated with previous and current values if value changed
  48938. */
  48939. value?: IWebXRMotionControllerComponentChangesValues<number>;
  48940. }
  48941. /**
  48942. * This class represents a single component (for example button or thumbstick) of a motion controller
  48943. */
  48944. export class WebXRControllerComponent implements IDisposable {
  48945. /**
  48946. * the id of this component
  48947. */
  48948. id: string;
  48949. /**
  48950. * the type of the component
  48951. */
  48952. type: MotionControllerComponentType;
  48953. private _buttonIndex;
  48954. private _axesIndices;
  48955. private _axes;
  48956. private _changes;
  48957. private _currentValue;
  48958. private _hasChanges;
  48959. private _pressed;
  48960. private _touched;
  48961. /**
  48962. * button component type
  48963. */
  48964. static BUTTON_TYPE: MotionControllerComponentType;
  48965. /**
  48966. * squeeze component type
  48967. */
  48968. static SQUEEZE_TYPE: MotionControllerComponentType;
  48969. /**
  48970. * Thumbstick component type
  48971. */
  48972. static THUMBSTICK_TYPE: MotionControllerComponentType;
  48973. /**
  48974. * Touchpad component type
  48975. */
  48976. static TOUCHPAD_TYPE: MotionControllerComponentType;
  48977. /**
  48978. * trigger component type
  48979. */
  48980. static TRIGGER_TYPE: MotionControllerComponentType;
  48981. /**
  48982. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  48983. * the axes data changes
  48984. */
  48985. onAxisValueChangedObservable: Observable<{
  48986. x: number;
  48987. y: number;
  48988. }>;
  48989. /**
  48990. * Observers registered here will be triggered when the state of a button changes
  48991. * State change is either pressed / touched / value
  48992. */
  48993. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  48994. /**
  48995. * Creates a new component for a motion controller.
  48996. * It is created by the motion controller itself
  48997. *
  48998. * @param id the id of this component
  48999. * @param type the type of the component
  49000. * @param _buttonIndex index in the buttons array of the gamepad
  49001. * @param _axesIndices indices of the values in the axes array of the gamepad
  49002. */
  49003. constructor(
  49004. /**
  49005. * the id of this component
  49006. */
  49007. id: string,
  49008. /**
  49009. * the type of the component
  49010. */
  49011. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49012. /**
  49013. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49014. */
  49015. get axes(): IWebXRMotionControllerAxesValue;
  49016. /**
  49017. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49018. */
  49019. get changes(): IWebXRMotionControllerComponentChanges;
  49020. /**
  49021. * Return whether or not the component changed the last frame
  49022. */
  49023. get hasChanges(): boolean;
  49024. /**
  49025. * is the button currently pressed
  49026. */
  49027. get pressed(): boolean;
  49028. /**
  49029. * is the button currently touched
  49030. */
  49031. get touched(): boolean;
  49032. /**
  49033. * Get the current value of this component
  49034. */
  49035. get value(): number;
  49036. /**
  49037. * Dispose this component
  49038. */
  49039. dispose(): void;
  49040. /**
  49041. * Are there axes correlating to this component
  49042. * @return true is axes data is available
  49043. */
  49044. isAxes(): boolean;
  49045. /**
  49046. * Is this component a button (hence - pressable)
  49047. * @returns true if can be pressed
  49048. */
  49049. isButton(): boolean;
  49050. /**
  49051. * update this component using the gamepad object it is in. Called on every frame
  49052. * @param nativeController the native gamepad controller object
  49053. */
  49054. update(nativeController: IMinimalMotionControllerObject): void;
  49055. }
  49056. }
  49057. declare module "babylonjs/Loading/sceneLoader" {
  49058. import { Observable } from "babylonjs/Misc/observable";
  49059. import { Nullable } from "babylonjs/types";
  49060. import { Scene } from "babylonjs/scene";
  49061. import { Engine } from "babylonjs/Engines/engine";
  49062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49063. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49064. import { AssetContainer } from "babylonjs/assetContainer";
  49065. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49066. import { Skeleton } from "babylonjs/Bones/skeleton";
  49067. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49068. import { WebRequest } from "babylonjs/Misc/webRequest";
  49069. /**
  49070. * Interface used to represent data loading progression
  49071. */
  49072. export interface ISceneLoaderProgressEvent {
  49073. /**
  49074. * Defines if data length to load can be evaluated
  49075. */
  49076. readonly lengthComputable: boolean;
  49077. /**
  49078. * Defines the loaded data length
  49079. */
  49080. readonly loaded: number;
  49081. /**
  49082. * Defines the data length to load
  49083. */
  49084. readonly total: number;
  49085. }
  49086. /**
  49087. * Interface used by SceneLoader plugins to define supported file extensions
  49088. */
  49089. export interface ISceneLoaderPluginExtensions {
  49090. /**
  49091. * Defines the list of supported extensions
  49092. */
  49093. [extension: string]: {
  49094. isBinary: boolean;
  49095. };
  49096. }
  49097. /**
  49098. * Interface used by SceneLoader plugin factory
  49099. */
  49100. export interface ISceneLoaderPluginFactory {
  49101. /**
  49102. * Defines the name of the factory
  49103. */
  49104. name: string;
  49105. /**
  49106. * Function called to create a new plugin
  49107. * @return the new plugin
  49108. */
  49109. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49110. /**
  49111. * The callback that returns true if the data can be directly loaded.
  49112. * @param data string containing the file data
  49113. * @returns if the data can be loaded directly
  49114. */
  49115. canDirectLoad?(data: string): boolean;
  49116. }
  49117. /**
  49118. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49119. */
  49120. export interface ISceneLoaderPluginBase {
  49121. /**
  49122. * The friendly name of this plugin.
  49123. */
  49124. name: string;
  49125. /**
  49126. * The file extensions supported by this plugin.
  49127. */
  49128. extensions: string | ISceneLoaderPluginExtensions;
  49129. /**
  49130. * The callback called when loading from a url.
  49131. * @param scene scene loading this url
  49132. * @param url url to load
  49133. * @param onSuccess callback called when the file successfully loads
  49134. * @param onProgress callback called while file is loading (if the server supports this mode)
  49135. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49136. * @param onError callback called when the file fails to load
  49137. * @returns a file request object
  49138. */
  49139. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49140. /**
  49141. * The callback called when loading from a file object.
  49142. * @param scene scene loading this file
  49143. * @param file defines the file to load
  49144. * @param onSuccess defines the callback to call when data is loaded
  49145. * @param onProgress defines the callback to call during loading process
  49146. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49147. * @param onError defines the callback to call when an error occurs
  49148. * @returns a file request object
  49149. */
  49150. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49151. /**
  49152. * The callback that returns true if the data can be directly loaded.
  49153. * @param data string containing the file data
  49154. * @returns if the data can be loaded directly
  49155. */
  49156. canDirectLoad?(data: string): boolean;
  49157. /**
  49158. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49159. * @param scene scene loading this data
  49160. * @param data string containing the data
  49161. * @returns data to pass to the plugin
  49162. */
  49163. directLoad?(scene: Scene, data: string): any;
  49164. /**
  49165. * The callback that allows custom handling of the root url based on the response url.
  49166. * @param rootUrl the original root url
  49167. * @param responseURL the response url if available
  49168. * @returns the new root url
  49169. */
  49170. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49171. }
  49172. /**
  49173. * Interface used to define a SceneLoader plugin
  49174. */
  49175. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49176. /**
  49177. * Import meshes into a scene.
  49178. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49179. * @param scene The scene to import into
  49180. * @param data The data to import
  49181. * @param rootUrl The root url for scene and resources
  49182. * @param meshes The meshes array to import into
  49183. * @param particleSystems The particle systems array to import into
  49184. * @param skeletons The skeletons array to import into
  49185. * @param onError The callback when import fails
  49186. * @returns True if successful or false otherwise
  49187. */
  49188. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49189. /**
  49190. * Load into a scene.
  49191. * @param scene The scene to load into
  49192. * @param data The data to import
  49193. * @param rootUrl The root url for scene and resources
  49194. * @param onError The callback when import fails
  49195. * @returns True if successful or false otherwise
  49196. */
  49197. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49198. /**
  49199. * Load into an asset container.
  49200. * @param scene The scene to load into
  49201. * @param data The data to import
  49202. * @param rootUrl The root url for scene and resources
  49203. * @param onError The callback when import fails
  49204. * @returns The loaded asset container
  49205. */
  49206. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49207. }
  49208. /**
  49209. * Interface used to define an async SceneLoader plugin
  49210. */
  49211. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49212. /**
  49213. * Import meshes into a scene.
  49214. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49215. * @param scene The scene to import into
  49216. * @param data The data to import
  49217. * @param rootUrl The root url for scene and resources
  49218. * @param onProgress The callback when the load progresses
  49219. * @param fileName Defines the name of the file to load
  49220. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49221. */
  49222. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49223. meshes: AbstractMesh[];
  49224. particleSystems: IParticleSystem[];
  49225. skeletons: Skeleton[];
  49226. animationGroups: AnimationGroup[];
  49227. }>;
  49228. /**
  49229. * Load into a scene.
  49230. * @param scene The scene to load into
  49231. * @param data The data to import
  49232. * @param rootUrl The root url for scene and resources
  49233. * @param onProgress The callback when the load progresses
  49234. * @param fileName Defines the name of the file to load
  49235. * @returns Nothing
  49236. */
  49237. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49238. /**
  49239. * Load into an asset container.
  49240. * @param scene The scene to load into
  49241. * @param data The data to import
  49242. * @param rootUrl The root url for scene and resources
  49243. * @param onProgress The callback when the load progresses
  49244. * @param fileName Defines the name of the file to load
  49245. * @returns The loaded asset container
  49246. */
  49247. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49248. }
  49249. /**
  49250. * Mode that determines how to handle old animation groups before loading new ones.
  49251. */
  49252. export enum SceneLoaderAnimationGroupLoadingMode {
  49253. /**
  49254. * Reset all old animations to initial state then dispose them.
  49255. */
  49256. Clean = 0,
  49257. /**
  49258. * Stop all old animations.
  49259. */
  49260. Stop = 1,
  49261. /**
  49262. * Restart old animations from first frame.
  49263. */
  49264. Sync = 2,
  49265. /**
  49266. * Old animations remains untouched.
  49267. */
  49268. NoSync = 3
  49269. }
  49270. /**
  49271. * Defines a plugin registered by the SceneLoader
  49272. */
  49273. interface IRegisteredPlugin {
  49274. /**
  49275. * Defines the plugin to use
  49276. */
  49277. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49278. /**
  49279. * Defines if the plugin supports binary data
  49280. */
  49281. isBinary: boolean;
  49282. }
  49283. /**
  49284. * Class used to load scene from various file formats using registered plugins
  49285. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49286. */
  49287. export class SceneLoader {
  49288. /**
  49289. * No logging while loading
  49290. */
  49291. static readonly NO_LOGGING: number;
  49292. /**
  49293. * Minimal logging while loading
  49294. */
  49295. static readonly MINIMAL_LOGGING: number;
  49296. /**
  49297. * Summary logging while loading
  49298. */
  49299. static readonly SUMMARY_LOGGING: number;
  49300. /**
  49301. * Detailled logging while loading
  49302. */
  49303. static readonly DETAILED_LOGGING: number;
  49304. /**
  49305. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49306. */
  49307. static get ForceFullSceneLoadingForIncremental(): boolean;
  49308. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49309. /**
  49310. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49311. */
  49312. static get ShowLoadingScreen(): boolean;
  49313. static set ShowLoadingScreen(value: boolean);
  49314. /**
  49315. * Defines the current logging level (while loading the scene)
  49316. * @ignorenaming
  49317. */
  49318. static get loggingLevel(): number;
  49319. static set loggingLevel(value: number);
  49320. /**
  49321. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49322. */
  49323. static get CleanBoneMatrixWeights(): boolean;
  49324. static set CleanBoneMatrixWeights(value: boolean);
  49325. /**
  49326. * Event raised when a plugin is used to load a scene
  49327. */
  49328. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49329. private static _registeredPlugins;
  49330. private static _showingLoadingScreen;
  49331. /**
  49332. * Gets the default plugin (used to load Babylon files)
  49333. * @returns the .babylon plugin
  49334. */
  49335. static GetDefaultPlugin(): IRegisteredPlugin;
  49336. private static _GetPluginForExtension;
  49337. private static _GetPluginForDirectLoad;
  49338. private static _GetPluginForFilename;
  49339. private static _GetDirectLoad;
  49340. private static _LoadData;
  49341. private static _GetFileInfo;
  49342. /**
  49343. * Gets a plugin that can load the given extension
  49344. * @param extension defines the extension to load
  49345. * @returns a plugin or null if none works
  49346. */
  49347. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49348. /**
  49349. * Gets a boolean indicating that the given extension can be loaded
  49350. * @param extension defines the extension to load
  49351. * @returns true if the extension is supported
  49352. */
  49353. static IsPluginForExtensionAvailable(extension: string): boolean;
  49354. /**
  49355. * Adds a new plugin to the list of registered plugins
  49356. * @param plugin defines the plugin to add
  49357. */
  49358. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49359. /**
  49360. * Import meshes into a scene
  49361. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49362. * @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)
  49363. * @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)
  49364. * @param scene the instance of BABYLON.Scene to append to
  49365. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49366. * @param onProgress a callback with a progress event for each file being loaded
  49367. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49368. * @param pluginExtension the extension used to determine the plugin
  49369. * @returns The loaded plugin
  49370. */
  49371. 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>;
  49372. /**
  49373. * Import meshes into a scene
  49374. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49375. * @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)
  49376. * @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)
  49377. * @param scene the instance of BABYLON.Scene to append to
  49378. * @param onProgress a callback with a progress event for each file being loaded
  49379. * @param pluginExtension the extension used to determine the plugin
  49380. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49381. */
  49382. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49383. meshes: AbstractMesh[];
  49384. particleSystems: IParticleSystem[];
  49385. skeletons: Skeleton[];
  49386. animationGroups: AnimationGroup[];
  49387. }>;
  49388. /**
  49389. * Load a scene
  49390. * @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)
  49391. * @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)
  49392. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49393. * @param onSuccess a callback with the scene when import succeeds
  49394. * @param onProgress a callback with a progress event for each file being loaded
  49395. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49396. * @param pluginExtension the extension used to determine the plugin
  49397. * @returns The loaded plugin
  49398. */
  49399. 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>;
  49400. /**
  49401. * Load a scene
  49402. * @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)
  49403. * @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)
  49404. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49405. * @param onProgress a callback with a progress event for each file being loaded
  49406. * @param pluginExtension the extension used to determine the plugin
  49407. * @returns The loaded scene
  49408. */
  49409. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49410. /**
  49411. * Append a scene
  49412. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  49413. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  49414. * @param scene is the instance of BABYLON.Scene to append to
  49415. * @param onSuccess a callback with the scene when import succeeds
  49416. * @param onProgress a callback with a progress event for each file being loaded
  49417. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49418. * @param pluginExtension the extension used to determine the plugin
  49419. * @returns The loaded plugin
  49420. */
  49421. 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>;
  49422. /**
  49423. * Append a scene
  49424. * @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)
  49425. * @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)
  49426. * @param scene is the instance of BABYLON.Scene to append to
  49427. * @param onProgress a callback with a progress event for each file being loaded
  49428. * @param pluginExtension the extension used to determine the plugin
  49429. * @returns The given scene
  49430. */
  49431. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49432. /**
  49433. * Load a scene into an asset container
  49434. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  49435. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  49436. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49437. * @param onSuccess a callback with the scene when import succeeds
  49438. * @param onProgress a callback with a progress event for each file being loaded
  49439. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49440. * @param pluginExtension the extension used to determine the plugin
  49441. * @returns The loaded plugin
  49442. */
  49443. 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>;
  49444. /**
  49445. * Load a scene into an asset container
  49446. * @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)
  49447. * @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)
  49448. * @param scene is the instance of Scene to append to
  49449. * @param onProgress a callback with a progress event for each file being loaded
  49450. * @param pluginExtension the extension used to determine the plugin
  49451. * @returns The loaded asset container
  49452. */
  49453. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49454. /**
  49455. * Import animations from a file into a scene
  49456. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  49457. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  49458. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49459. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49460. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49461. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49462. * @param onSuccess a callback with the scene when import succeeds
  49463. * @param onProgress a callback with a progress event for each file being loaded
  49464. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49465. * @param pluginExtension the extension used to determine the plugin
  49466. */
  49467. 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;
  49468. /**
  49469. * Import animations from a file into a scene
  49470. * @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)
  49471. * @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)
  49472. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49473. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49474. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49475. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49476. * @param onSuccess a callback with the scene when import succeeds
  49477. * @param onProgress a callback with a progress event for each file being loaded
  49478. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49479. * @param pluginExtension the extension used to determine the plugin
  49480. * @returns the updated scene with imported animations
  49481. */
  49482. 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>;
  49483. }
  49484. }
  49485. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49486. import { IDisposable, Scene } from "babylonjs/scene";
  49487. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49488. import { Observable } from "babylonjs/Misc/observable";
  49489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49490. import { Nullable } from "babylonjs/types";
  49491. /**
  49492. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49493. */
  49494. export type MotionControllerHandedness = "none" | "left" | "right";
  49495. /**
  49496. * The type of components available in motion controllers.
  49497. * This is not the name of the component.
  49498. */
  49499. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49500. /**
  49501. * The state of a controller component
  49502. */
  49503. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49504. /**
  49505. * The schema of motion controller layout.
  49506. * No object will be initialized using this interface
  49507. * This is used just to define the profile.
  49508. */
  49509. export interface IMotionControllerLayout {
  49510. /**
  49511. * Path to load the assets. Usually relative to the base path
  49512. */
  49513. assetPath: string;
  49514. /**
  49515. * Available components (unsorted)
  49516. */
  49517. components: {
  49518. /**
  49519. * A map of component Ids
  49520. */
  49521. [componentId: string]: {
  49522. /**
  49523. * The type of input the component outputs
  49524. */
  49525. type: MotionControllerComponentType;
  49526. /**
  49527. * The indices of this component in the gamepad object
  49528. */
  49529. gamepadIndices: {
  49530. /**
  49531. * Index of button
  49532. */
  49533. button?: number;
  49534. /**
  49535. * If available, index of x-axis
  49536. */
  49537. xAxis?: number;
  49538. /**
  49539. * If available, index of y-axis
  49540. */
  49541. yAxis?: number;
  49542. };
  49543. /**
  49544. * The mesh's root node name
  49545. */
  49546. rootNodeName: string;
  49547. /**
  49548. * Animation definitions for this model
  49549. */
  49550. visualResponses: {
  49551. [stateKey: string]: {
  49552. /**
  49553. * What property will be animated
  49554. */
  49555. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49556. /**
  49557. * What states influence this visual response
  49558. */
  49559. states: MotionControllerComponentStateType[];
  49560. /**
  49561. * Type of animation - movement or visibility
  49562. */
  49563. valueNodeProperty: "transform" | "visibility";
  49564. /**
  49565. * Base node name to move. Its position will be calculated according to the min and max nodes
  49566. */
  49567. valueNodeName?: string;
  49568. /**
  49569. * Minimum movement node
  49570. */
  49571. minNodeName?: string;
  49572. /**
  49573. * Max movement node
  49574. */
  49575. maxNodeName?: string;
  49576. };
  49577. };
  49578. /**
  49579. * If touch enabled, what is the name of node to display user feedback
  49580. */
  49581. touchPointNodeName?: string;
  49582. };
  49583. };
  49584. /**
  49585. * Is it xr standard mapping or not
  49586. */
  49587. gamepadMapping: "" | "xr-standard";
  49588. /**
  49589. * Base root node of this entire model
  49590. */
  49591. rootNodeName: string;
  49592. /**
  49593. * Defines the main button component id
  49594. */
  49595. selectComponentId: string;
  49596. }
  49597. /**
  49598. * A definition for the layout map in the input profile
  49599. */
  49600. export interface IMotionControllerLayoutMap {
  49601. /**
  49602. * Layouts with handedness type as a key
  49603. */
  49604. [handedness: string]: IMotionControllerLayout;
  49605. }
  49606. /**
  49607. * The XR Input profile schema
  49608. * Profiles can be found here:
  49609. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49610. */
  49611. export interface IMotionControllerProfile {
  49612. /**
  49613. * fallback profiles for this profileId
  49614. */
  49615. fallbackProfileIds: string[];
  49616. /**
  49617. * The layout map, with handedness as key
  49618. */
  49619. layouts: IMotionControllerLayoutMap;
  49620. /**
  49621. * The id of this profile
  49622. * correlates to the profile(s) in the xrInput.profiles array
  49623. */
  49624. profileId: string;
  49625. }
  49626. /**
  49627. * A helper-interface for the 3 meshes needed for controller button animation
  49628. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  49629. */
  49630. export interface IMotionControllerButtonMeshMap {
  49631. /**
  49632. * the mesh that defines the pressed value mesh position.
  49633. * This is used to find the max-position of this button
  49634. */
  49635. pressedMesh: AbstractMesh;
  49636. /**
  49637. * the mesh that defines the unpressed value mesh position.
  49638. * This is used to find the min (or initial) position of this button
  49639. */
  49640. unpressedMesh: AbstractMesh;
  49641. /**
  49642. * The mesh that will be changed when value changes
  49643. */
  49644. valueMesh: AbstractMesh;
  49645. }
  49646. /**
  49647. * A helper-interface for the 3 meshes needed for controller axis animation.
  49648. * This will be expanded when touchpad animations are fully supported
  49649. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  49650. */
  49651. export interface IMotionControllerMeshMap {
  49652. /**
  49653. * the mesh that defines the maximum value mesh position.
  49654. */
  49655. maxMesh?: AbstractMesh;
  49656. /**
  49657. * the mesh that defines the minimum value mesh position.
  49658. */
  49659. minMesh?: AbstractMesh;
  49660. /**
  49661. * The mesh that will be changed when axis value changes
  49662. */
  49663. valueMesh: AbstractMesh;
  49664. }
  49665. /**
  49666. * The elements needed for change-detection of the gamepad objects in motion controllers
  49667. */
  49668. export interface IMinimalMotionControllerObject {
  49669. /**
  49670. * Available axes of this controller
  49671. */
  49672. axes: number[];
  49673. /**
  49674. * An array of available buttons
  49675. */
  49676. buttons: Array<{
  49677. /**
  49678. * Value of the button/trigger
  49679. */
  49680. value: number;
  49681. /**
  49682. * If the button/trigger is currently touched
  49683. */
  49684. touched: boolean;
  49685. /**
  49686. * If the button/trigger is currently pressed
  49687. */
  49688. pressed: boolean;
  49689. }>;
  49690. /**
  49691. * EXPERIMENTAL haptic support.
  49692. */
  49693. hapticActuators?: Array<{
  49694. pulse: (value: number, duration: number) => Promise<boolean>;
  49695. }>;
  49696. }
  49697. /**
  49698. * An Abstract Motion controller
  49699. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49700. * Each component has an observable to check for changes in value and state
  49701. */
  49702. export abstract class WebXRAbstractMotionController implements IDisposable {
  49703. protected scene: Scene;
  49704. protected layout: IMotionControllerLayout;
  49705. /**
  49706. * The gamepad object correlating to this controller
  49707. */
  49708. gamepadObject: IMinimalMotionControllerObject;
  49709. /**
  49710. * handedness (left/right/none) of this controller
  49711. */
  49712. handedness: MotionControllerHandedness;
  49713. private _initComponent;
  49714. private _modelReady;
  49715. /**
  49716. * A map of components (WebXRControllerComponent) in this motion controller
  49717. * Components have a ComponentType and can also have both button and axis definitions
  49718. */
  49719. readonly components: {
  49720. [id: string]: WebXRControllerComponent;
  49721. };
  49722. /**
  49723. * Disable the model's animation. Can be set at any time.
  49724. */
  49725. disableAnimation: boolean;
  49726. /**
  49727. * Observers registered here will be triggered when the model of this controller is done loading
  49728. */
  49729. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49730. /**
  49731. * The profile id of this motion controller
  49732. */
  49733. abstract profileId: string;
  49734. /**
  49735. * The root mesh of the model. It is null if the model was not yet initialized
  49736. */
  49737. rootMesh: Nullable<AbstractMesh>;
  49738. /**
  49739. * constructs a new abstract motion controller
  49740. * @param scene the scene to which the model of the controller will be added
  49741. * @param layout The profile layout to load
  49742. * @param gamepadObject The gamepad object correlating to this controller
  49743. * @param handedness handedness (left/right/none) of this controller
  49744. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  49745. */
  49746. constructor(scene: Scene, layout: IMotionControllerLayout,
  49747. /**
  49748. * The gamepad object correlating to this controller
  49749. */
  49750. gamepadObject: IMinimalMotionControllerObject,
  49751. /**
  49752. * handedness (left/right/none) of this controller
  49753. */
  49754. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  49755. /**
  49756. * Dispose this controller, the model mesh and all its components
  49757. */
  49758. dispose(): void;
  49759. /**
  49760. * Returns all components of specific type
  49761. * @param type the type to search for
  49762. * @return an array of components with this type
  49763. */
  49764. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  49765. /**
  49766. * get a component based an its component id as defined in layout.components
  49767. * @param id the id of the component
  49768. * @returns the component correlates to the id or undefined if not found
  49769. */
  49770. getComponent(id: string): WebXRControllerComponent;
  49771. /**
  49772. * Get the list of components available in this motion controller
  49773. * @returns an array of strings correlating to available components
  49774. */
  49775. getComponentIds(): string[];
  49776. /**
  49777. * Get the first component of specific type
  49778. * @param type type of component to find
  49779. * @return a controller component or null if not found
  49780. */
  49781. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  49782. /**
  49783. * Get the main (Select) component of this controller as defined in the layout
  49784. * @returns the main component of this controller
  49785. */
  49786. getMainComponent(): WebXRControllerComponent;
  49787. /**
  49788. * Loads the model correlating to this controller
  49789. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  49790. * @returns A promise fulfilled with the result of the model loading
  49791. */
  49792. loadModel(): Promise<boolean>;
  49793. /**
  49794. * Update this model using the current XRFrame
  49795. * @param xrFrame the current xr frame to use and update the model
  49796. */
  49797. updateFromXRFrame(xrFrame: XRFrame): void;
  49798. /**
  49799. * Backwards compatibility due to a deeply-integrated typo
  49800. */
  49801. get handness(): XREye;
  49802. /**
  49803. * Pulse (vibrate) this controller
  49804. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  49805. * Consecutive calls to this function will cancel the last pulse call
  49806. *
  49807. * @param value the strength of the pulse in 0.0...1.0 range
  49808. * @param duration Duration of the pulse in milliseconds
  49809. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  49810. * @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
  49811. */
  49812. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  49813. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49814. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49815. /**
  49816. * Moves the axis on the controller mesh based on its current state
  49817. * @param axis the index of the axis
  49818. * @param axisValue the value of the axis which determines the meshes new position
  49819. * @hidden
  49820. */
  49821. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  49822. /**
  49823. * Update the model itself with the current frame data
  49824. * @param xrFrame the frame to use for updating the model mesh
  49825. */
  49826. protected updateModel(xrFrame: XRFrame): void;
  49827. /**
  49828. * Get the filename and path for this controller's model
  49829. * @returns a map of filename and path
  49830. */
  49831. protected abstract _getFilenameAndPath(): {
  49832. filename: string;
  49833. path: string;
  49834. };
  49835. /**
  49836. * This function is called before the mesh is loaded. It checks for loading constraints.
  49837. * For example, this function can check if the GLB loader is available
  49838. * If this function returns false, the generic controller will be loaded instead
  49839. * @returns Is the client ready to load the mesh
  49840. */
  49841. protected abstract _getModelLoadingConstraints(): boolean;
  49842. /**
  49843. * This function will be called after the model was successfully loaded and can be used
  49844. * for mesh transformations before it is available for the user
  49845. * @param meshes the loaded meshes
  49846. */
  49847. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  49848. /**
  49849. * Set the root mesh for this controller. Important for the WebXR controller class
  49850. * @param meshes the loaded meshes
  49851. */
  49852. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  49853. /**
  49854. * A function executed each frame that updates the mesh (if needed)
  49855. * @param xrFrame the current xrFrame
  49856. */
  49857. protected abstract _updateModel(xrFrame: XRFrame): void;
  49858. private _getGenericFilenameAndPath;
  49859. private _getGenericParentMesh;
  49860. }
  49861. }
  49862. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  49863. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49865. import { Scene } from "babylonjs/scene";
  49866. /**
  49867. * A generic trigger-only motion controller for WebXR
  49868. */
  49869. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  49870. /**
  49871. * Static version of the profile id of this controller
  49872. */
  49873. static ProfileId: string;
  49874. profileId: string;
  49875. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  49876. protected _getFilenameAndPath(): {
  49877. filename: string;
  49878. path: string;
  49879. };
  49880. protected _getModelLoadingConstraints(): boolean;
  49881. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  49882. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49883. protected _updateModel(): void;
  49884. }
  49885. }
  49886. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  49887. import { Vector4 } from "babylonjs/Maths/math.vector";
  49888. import { Mesh } from "babylonjs/Meshes/mesh";
  49889. import { Scene } from "babylonjs/scene";
  49890. import { Nullable } from "babylonjs/types";
  49891. /**
  49892. * Class containing static functions to help procedurally build meshes
  49893. */
  49894. export class SphereBuilder {
  49895. /**
  49896. * Creates a sphere mesh
  49897. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49898. * * 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`)
  49899. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49900. * * 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
  49901. * * 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)
  49902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49903. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49905. * @param name defines the name of the mesh
  49906. * @param options defines the options used to create the mesh
  49907. * @param scene defines the hosting scene
  49908. * @returns the sphere mesh
  49909. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49910. */
  49911. static CreateSphere(name: string, options: {
  49912. segments?: number;
  49913. diameter?: number;
  49914. diameterX?: number;
  49915. diameterY?: number;
  49916. diameterZ?: number;
  49917. arc?: number;
  49918. slice?: number;
  49919. sideOrientation?: number;
  49920. frontUVs?: Vector4;
  49921. backUVs?: Vector4;
  49922. updatable?: boolean;
  49923. }, scene?: Nullable<Scene>): Mesh;
  49924. }
  49925. }
  49926. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  49927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49928. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49929. import { Scene } from "babylonjs/scene";
  49930. /**
  49931. * A profiled motion controller has its profile loaded from an online repository.
  49932. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  49933. */
  49934. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  49935. private _repositoryUrl;
  49936. private _buttonMeshMapping;
  49937. private _touchDots;
  49938. /**
  49939. * The profile ID of this controller. Will be populated when the controller initializes.
  49940. */
  49941. profileId: string;
  49942. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  49943. dispose(): void;
  49944. protected _getFilenameAndPath(): {
  49945. filename: string;
  49946. path: string;
  49947. };
  49948. protected _getModelLoadingConstraints(): boolean;
  49949. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  49950. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49951. protected _updateModel(_xrFrame: XRFrame): void;
  49952. }
  49953. }
  49954. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  49955. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49956. import { Scene } from "babylonjs/scene";
  49957. /**
  49958. * A construction function type to create a new controller based on an xrInput object
  49959. */
  49960. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  49961. /**
  49962. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  49963. *
  49964. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  49965. * it should be replaced with auto-loaded controllers.
  49966. *
  49967. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  49968. */
  49969. export class WebXRMotionControllerManager {
  49970. private static _AvailableControllers;
  49971. private static _Fallbacks;
  49972. private static _ProfileLoadingPromises;
  49973. private static _ProfilesList;
  49974. /**
  49975. * The base URL of the online controller repository. Can be changed at any time.
  49976. */
  49977. static BaseRepositoryUrl: string;
  49978. /**
  49979. * Which repository gets priority - local or online
  49980. */
  49981. static PrioritizeOnlineRepository: boolean;
  49982. /**
  49983. * Use the online repository, or use only locally-defined controllers
  49984. */
  49985. static UseOnlineRepository: boolean;
  49986. /**
  49987. * Clear the cache used for profile loading and reload when requested again
  49988. */
  49989. static ClearProfilesCache(): void;
  49990. /**
  49991. * Register the default fallbacks.
  49992. * This function is called automatically when this file is imported.
  49993. */
  49994. static DefaultFallbacks(): void;
  49995. /**
  49996. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  49997. * @param profileId the profile to which a fallback needs to be found
  49998. * @return an array with corresponding fallback profiles
  49999. */
  50000. static FindFallbackWithProfileId(profileId: string): string[];
  50001. /**
  50002. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50003. * The order of search:
  50004. *
  50005. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50006. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50007. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50008. * 4) return the generic trigger controller if none were found
  50009. *
  50010. * @param xrInput the xrInput to which a new controller is initialized
  50011. * @param scene the scene to which the model will be added
  50012. * @param forceProfile force a certain profile for this controller
  50013. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50014. */
  50015. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50016. /**
  50017. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50018. *
  50019. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50020. *
  50021. * @param type the profile type to register
  50022. * @param constructFunction the function to be called when loading this profile
  50023. */
  50024. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50025. /**
  50026. * Register a fallback to a specific profile.
  50027. * @param profileId the profileId that will receive the fallbacks
  50028. * @param fallbacks A list of fallback profiles
  50029. */
  50030. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50031. /**
  50032. * Will update the list of profiles available in the repository
  50033. * @return a promise that resolves to a map of profiles available online
  50034. */
  50035. static UpdateProfilesList(): Promise<{
  50036. [profile: string]: string;
  50037. }>;
  50038. private static _LoadProfileFromRepository;
  50039. private static _LoadProfilesFromAvailableControllers;
  50040. }
  50041. }
  50042. declare module "babylonjs/XR/webXRInputSource" {
  50043. import { Observable } from "babylonjs/Misc/observable";
  50044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50045. import { Ray } from "babylonjs/Culling/ray";
  50046. import { Scene } from "babylonjs/scene";
  50047. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50048. /**
  50049. * Configuration options for the WebXR controller creation
  50050. */
  50051. export interface IWebXRControllerOptions {
  50052. /**
  50053. * Should the controller mesh be animated when a user interacts with it
  50054. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50055. */
  50056. disableMotionControllerAnimation?: boolean;
  50057. /**
  50058. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50059. */
  50060. doNotLoadControllerMesh?: boolean;
  50061. /**
  50062. * Force a specific controller type for this controller.
  50063. * This can be used when creating your own profile or when testing different controllers
  50064. */
  50065. forceControllerProfile?: string;
  50066. /**
  50067. * Defines a rendering group ID for meshes that will be loaded.
  50068. * This is for the default controllers only.
  50069. */
  50070. renderingGroupId?: number;
  50071. }
  50072. /**
  50073. * Represents an XR controller
  50074. */
  50075. export class WebXRInputSource {
  50076. private _scene;
  50077. /** The underlying input source for the controller */
  50078. inputSource: XRInputSource;
  50079. private _options;
  50080. private _tmpVector;
  50081. private _uniqueId;
  50082. /**
  50083. * 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
  50084. */
  50085. grip?: AbstractMesh;
  50086. /**
  50087. * If available, this is the gamepad object related to this controller.
  50088. * Using this object it is possible to get click events and trackpad changes of the
  50089. * webxr controller that is currently being used.
  50090. */
  50091. motionController?: WebXRAbstractMotionController;
  50092. /**
  50093. * Event that fires when the controller is removed/disposed.
  50094. * The object provided as event data is this controller, after associated assets were disposed.
  50095. * uniqueId is still available.
  50096. */
  50097. onDisposeObservable: Observable<WebXRInputSource>;
  50098. /**
  50099. * Will be triggered when the mesh associated with the motion controller is done loading.
  50100. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50101. * A shortened version of controller -> motion controller -> on mesh loaded.
  50102. */
  50103. onMeshLoadedObservable: Observable<AbstractMesh>;
  50104. /**
  50105. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50106. */
  50107. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50108. /**
  50109. * Pointer which can be used to select objects or attach a visible laser to
  50110. */
  50111. pointer: AbstractMesh;
  50112. /**
  50113. * Creates the input source object
  50114. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50115. * @param _scene the scene which the controller should be associated to
  50116. * @param inputSource the underlying input source for the controller
  50117. * @param _options options for this controller creation
  50118. */
  50119. constructor(_scene: Scene,
  50120. /** The underlying input source for the controller */
  50121. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50122. /**
  50123. * Get this controllers unique id
  50124. */
  50125. get uniqueId(): string;
  50126. /**
  50127. * Disposes of the object
  50128. */
  50129. dispose(): void;
  50130. /**
  50131. * Gets a world space ray coming from the pointer or grip
  50132. * @param result the resulting ray
  50133. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50134. */
  50135. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50136. /**
  50137. * Updates the controller pose based on the given XRFrame
  50138. * @param xrFrame xr frame to update the pose with
  50139. * @param referenceSpace reference space to use
  50140. */
  50141. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50142. }
  50143. }
  50144. declare module "babylonjs/XR/webXRInput" {
  50145. import { Observable } from "babylonjs/Misc/observable";
  50146. import { IDisposable } from "babylonjs/scene";
  50147. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50148. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50149. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50150. /**
  50151. * The schema for initialization options of the XR Input class
  50152. */
  50153. export interface IWebXRInputOptions {
  50154. /**
  50155. * If set to true no model will be automatically loaded
  50156. */
  50157. doNotLoadControllerMeshes?: boolean;
  50158. /**
  50159. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50160. * If not found, the xr input profile data will be used.
  50161. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50162. */
  50163. forceInputProfile?: string;
  50164. /**
  50165. * Do not send a request to the controller repository to load the profile.
  50166. *
  50167. * Instead, use the controllers available in babylon itself.
  50168. */
  50169. disableOnlineControllerRepository?: boolean;
  50170. /**
  50171. * A custom URL for the controllers repository
  50172. */
  50173. customControllersRepositoryURL?: string;
  50174. /**
  50175. * Should the controller model's components not move according to the user input
  50176. */
  50177. disableControllerAnimation?: boolean;
  50178. /**
  50179. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50180. */
  50181. controllerOptions?: IWebXRControllerOptions;
  50182. }
  50183. /**
  50184. * XR input used to track XR inputs such as controllers/rays
  50185. */
  50186. export class WebXRInput implements IDisposable {
  50187. /**
  50188. * the xr session manager for this session
  50189. */
  50190. xrSessionManager: WebXRSessionManager;
  50191. /**
  50192. * the WebXR camera for this session. Mainly used for teleportation
  50193. */
  50194. xrCamera: WebXRCamera;
  50195. private readonly options;
  50196. /**
  50197. * XR controllers being tracked
  50198. */
  50199. controllers: Array<WebXRInputSource>;
  50200. private _frameObserver;
  50201. private _sessionEndedObserver;
  50202. private _sessionInitObserver;
  50203. /**
  50204. * Event when a controller has been connected/added
  50205. */
  50206. onControllerAddedObservable: Observable<WebXRInputSource>;
  50207. /**
  50208. * Event when a controller has been removed/disconnected
  50209. */
  50210. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50211. /**
  50212. * Initializes the WebXRInput
  50213. * @param xrSessionManager the xr session manager for this session
  50214. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50215. * @param options = initialization options for this xr input
  50216. */
  50217. constructor(
  50218. /**
  50219. * the xr session manager for this session
  50220. */
  50221. xrSessionManager: WebXRSessionManager,
  50222. /**
  50223. * the WebXR camera for this session. Mainly used for teleportation
  50224. */
  50225. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50226. private _onInputSourcesChange;
  50227. private _addAndRemoveControllers;
  50228. /**
  50229. * Disposes of the object
  50230. */
  50231. dispose(): void;
  50232. }
  50233. }
  50234. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50235. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50236. import { Observable, EventState } from "babylonjs/Misc/observable";
  50237. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50238. /**
  50239. * This is the base class for all WebXR features.
  50240. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50241. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50242. */
  50243. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50244. protected _xrSessionManager: WebXRSessionManager;
  50245. private _attached;
  50246. private _removeOnDetach;
  50247. /**
  50248. * Should auto-attach be disabled?
  50249. */
  50250. disableAutoAttach: boolean;
  50251. /**
  50252. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50253. */
  50254. xrNativeFeatureName: string;
  50255. /**
  50256. * Construct a new (abstract) WebXR feature
  50257. * @param _xrSessionManager the xr session manager for this feature
  50258. */
  50259. constructor(_xrSessionManager: WebXRSessionManager);
  50260. /**
  50261. * Is this feature attached
  50262. */
  50263. get attached(): boolean;
  50264. /**
  50265. * attach this feature
  50266. *
  50267. * @param force should attachment be forced (even when already attached)
  50268. * @returns true if successful, false is failed or already attached
  50269. */
  50270. attach(force?: boolean): boolean;
  50271. /**
  50272. * detach this feature.
  50273. *
  50274. * @returns true if successful, false if failed or already detached
  50275. */
  50276. detach(): boolean;
  50277. /**
  50278. * Dispose this feature and all of the resources attached
  50279. */
  50280. dispose(): void;
  50281. /**
  50282. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50283. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50284. *
  50285. * @returns whether or not the feature is compatible in this environment
  50286. */
  50287. isCompatible(): boolean;
  50288. /**
  50289. * This is used to register callbacks that will automatically be removed when detach is called.
  50290. * @param observable the observable to which the observer will be attached
  50291. * @param callback the callback to register
  50292. */
  50293. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50294. /**
  50295. * Code in this function will be executed on each xrFrame received from the browser.
  50296. * This function will not execute after the feature is detached.
  50297. * @param _xrFrame the current frame
  50298. */
  50299. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50300. }
  50301. }
  50302. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50303. import { IDisposable, Scene } from "babylonjs/scene";
  50304. import { Nullable } from "babylonjs/types";
  50305. import { Observable } from "babylonjs/Misc/observable";
  50306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50307. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50308. import { Camera } from "babylonjs/Cameras/camera";
  50309. /**
  50310. * Renders a layer on top of an existing scene
  50311. */
  50312. export class UtilityLayerRenderer implements IDisposable {
  50313. /** the original scene that will be rendered on top of */
  50314. originalScene: Scene;
  50315. private _pointerCaptures;
  50316. private _lastPointerEvents;
  50317. private static _DefaultUtilityLayer;
  50318. private static _DefaultKeepDepthUtilityLayer;
  50319. private _sharedGizmoLight;
  50320. private _renderCamera;
  50321. /**
  50322. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50323. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50324. * @returns the camera that is used when rendering the utility layer
  50325. */
  50326. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50327. /**
  50328. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50329. * @param cam the camera that should be used when rendering the utility layer
  50330. */
  50331. setRenderCamera(cam: Nullable<Camera>): void;
  50332. /**
  50333. * @hidden
  50334. * Light which used by gizmos to get light shading
  50335. */
  50336. _getSharedGizmoLight(): HemisphericLight;
  50337. /**
  50338. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50339. */
  50340. pickUtilitySceneFirst: boolean;
  50341. /**
  50342. * 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)
  50343. */
  50344. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50345. /**
  50346. * 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)
  50347. */
  50348. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50349. /**
  50350. * The scene that is rendered on top of the original scene
  50351. */
  50352. utilityLayerScene: Scene;
  50353. /**
  50354. * If the utility layer should automatically be rendered on top of existing scene
  50355. */
  50356. shouldRender: boolean;
  50357. /**
  50358. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50359. */
  50360. onlyCheckPointerDownEvents: boolean;
  50361. /**
  50362. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50363. */
  50364. processAllEvents: boolean;
  50365. /**
  50366. * Observable raised when the pointer move from the utility layer scene to the main scene
  50367. */
  50368. onPointerOutObservable: Observable<number>;
  50369. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50370. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50371. private _afterRenderObserver;
  50372. private _sceneDisposeObserver;
  50373. private _originalPointerObserver;
  50374. /**
  50375. * Instantiates a UtilityLayerRenderer
  50376. * @param originalScene the original scene that will be rendered on top of
  50377. * @param handleEvents boolean indicating if the utility layer should handle events
  50378. */
  50379. constructor(
  50380. /** the original scene that will be rendered on top of */
  50381. originalScene: Scene, handleEvents?: boolean);
  50382. private _notifyObservers;
  50383. /**
  50384. * Renders the utility layers scene on top of the original scene
  50385. */
  50386. render(): void;
  50387. /**
  50388. * Disposes of the renderer
  50389. */
  50390. dispose(): void;
  50391. private _updateCamera;
  50392. }
  50393. }
  50394. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50395. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50397. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50398. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50399. import { Scene } from "babylonjs/scene";
  50400. import { Nullable } from "babylonjs/types";
  50401. import { Color3 } from "babylonjs/Maths/math.color";
  50402. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50403. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50404. /**
  50405. * Options interface for the pointer selection module
  50406. */
  50407. export interface IWebXRControllerPointerSelectionOptions {
  50408. /**
  50409. * if provided, this scene will be used to render meshes.
  50410. */
  50411. customUtilityLayerScene?: Scene;
  50412. /**
  50413. * 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)
  50414. * If not disabled, the last picked point will be used to execute a pointer up event
  50415. * If disabled, pointer up event will be triggered right after the pointer down event.
  50416. * Used in screen and gaze target ray mode only
  50417. */
  50418. disablePointerUpOnTouchOut: boolean;
  50419. /**
  50420. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50421. */
  50422. forceGazeMode: boolean;
  50423. /**
  50424. * 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
  50425. * to start a new countdown to the pointer down event.
  50426. * Defaults to 1.
  50427. */
  50428. gazeModePointerMovedFactor?: number;
  50429. /**
  50430. * Different button type to use instead of the main component
  50431. */
  50432. overrideButtonId?: string;
  50433. /**
  50434. * use this rendering group id for the meshes (optional)
  50435. */
  50436. renderingGroupId?: number;
  50437. /**
  50438. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50439. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50440. * 3000 means 3 seconds between pointing at something and selecting it
  50441. */
  50442. timeToSelect?: number;
  50443. /**
  50444. * Should meshes created here be added to a utility layer or the main scene
  50445. */
  50446. useUtilityLayer?: boolean;
  50447. /**
  50448. * Optional WebXR camera to be used for gaze selection
  50449. */
  50450. gazeCamera?: WebXRCamera;
  50451. /**
  50452. * the xr input to use with this pointer selection
  50453. */
  50454. xrInput: WebXRInput;
  50455. }
  50456. /**
  50457. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50458. */
  50459. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50460. private readonly _options;
  50461. private static _idCounter;
  50462. private _attachController;
  50463. private _controllers;
  50464. private _scene;
  50465. private _tmpVectorForPickCompare;
  50466. /**
  50467. * The module's name
  50468. */
  50469. static readonly Name: string;
  50470. /**
  50471. * The (Babylon) version of this module.
  50472. * This is an integer representing the implementation version.
  50473. * This number does not correspond to the WebXR specs version
  50474. */
  50475. static readonly Version: number;
  50476. /**
  50477. * Disable lighting on the laser pointer (so it will always be visible)
  50478. */
  50479. disablePointerLighting: boolean;
  50480. /**
  50481. * Disable lighting on the selection mesh (so it will always be visible)
  50482. */
  50483. disableSelectionMeshLighting: boolean;
  50484. /**
  50485. * Should the laser pointer be displayed
  50486. */
  50487. displayLaserPointer: boolean;
  50488. /**
  50489. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50490. */
  50491. displaySelectionMesh: boolean;
  50492. /**
  50493. * This color will be set to the laser pointer when selection is triggered
  50494. */
  50495. laserPointerPickedColor: Color3;
  50496. /**
  50497. * Default color of the laser pointer
  50498. */
  50499. laserPointerDefaultColor: Color3;
  50500. /**
  50501. * default color of the selection ring
  50502. */
  50503. selectionMeshDefaultColor: Color3;
  50504. /**
  50505. * This color will be applied to the selection ring when selection is triggered
  50506. */
  50507. selectionMeshPickedColor: Color3;
  50508. /**
  50509. * Optional filter to be used for ray selection. This predicate shares behavior with
  50510. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50511. */
  50512. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50513. /**
  50514. * constructs a new background remover module
  50515. * @param _xrSessionManager the session manager for this module
  50516. * @param _options read-only options to be used in this module
  50517. */
  50518. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50519. /**
  50520. * attach this feature
  50521. * Will usually be called by the features manager
  50522. *
  50523. * @returns true if successful.
  50524. */
  50525. attach(): boolean;
  50526. /**
  50527. * detach this feature.
  50528. * Will usually be called by the features manager
  50529. *
  50530. * @returns true if successful.
  50531. */
  50532. detach(): boolean;
  50533. /**
  50534. * Will get the mesh under a specific pointer.
  50535. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50536. * @param controllerId the controllerId to check
  50537. * @returns The mesh under pointer or null if no mesh is under the pointer
  50538. */
  50539. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50540. /**
  50541. * Get the xr controller that correlates to the pointer id in the pointer event
  50542. *
  50543. * @param id the pointer id to search for
  50544. * @returns the controller that correlates to this id or null if not found
  50545. */
  50546. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50547. protected _onXRFrame(_xrFrame: XRFrame): void;
  50548. private _attachGazeMode;
  50549. private _attachScreenRayMode;
  50550. private _attachTrackedPointerRayMode;
  50551. private _convertNormalToDirectionOfRay;
  50552. private _detachController;
  50553. private _generateNewMeshPair;
  50554. private _pickingMoved;
  50555. private _updatePointerDistance;
  50556. /** @hidden */
  50557. get lasterPointerDefaultColor(): Color3;
  50558. }
  50559. }
  50560. declare module "babylonjs/XR/webXREnterExitUI" {
  50561. import { Nullable } from "babylonjs/types";
  50562. import { Observable } from "babylonjs/Misc/observable";
  50563. import { IDisposable, Scene } from "babylonjs/scene";
  50564. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50565. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50566. /**
  50567. * Button which can be used to enter a different mode of XR
  50568. */
  50569. export class WebXREnterExitUIButton {
  50570. /** button element */
  50571. element: HTMLElement;
  50572. /** XR initialization options for the button */
  50573. sessionMode: XRSessionMode;
  50574. /** Reference space type */
  50575. referenceSpaceType: XRReferenceSpaceType;
  50576. /**
  50577. * Creates a WebXREnterExitUIButton
  50578. * @param element button element
  50579. * @param sessionMode XR initialization session mode
  50580. * @param referenceSpaceType the type of reference space to be used
  50581. */
  50582. constructor(
  50583. /** button element */
  50584. element: HTMLElement,
  50585. /** XR initialization options for the button */
  50586. sessionMode: XRSessionMode,
  50587. /** Reference space type */
  50588. referenceSpaceType: XRReferenceSpaceType);
  50589. /**
  50590. * Extendable function which can be used to update the button's visuals when the state changes
  50591. * @param activeButton the current active button in the UI
  50592. */
  50593. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50594. }
  50595. /**
  50596. * Options to create the webXR UI
  50597. */
  50598. export class WebXREnterExitUIOptions {
  50599. /**
  50600. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50601. */
  50602. customButtons?: Array<WebXREnterExitUIButton>;
  50603. /**
  50604. * A reference space type to use when creating the default button.
  50605. * Default is local-floor
  50606. */
  50607. referenceSpaceType?: XRReferenceSpaceType;
  50608. /**
  50609. * Context to enter xr with
  50610. */
  50611. renderTarget?: Nullable<WebXRRenderTarget>;
  50612. /**
  50613. * A session mode to use when creating the default button.
  50614. * Default is immersive-vr
  50615. */
  50616. sessionMode?: XRSessionMode;
  50617. /**
  50618. * A list of optional features to init the session with
  50619. */
  50620. optionalFeatures?: string[];
  50621. /**
  50622. * A list of optional features to init the session with
  50623. */
  50624. requiredFeatures?: string[];
  50625. }
  50626. /**
  50627. * UI to allow the user to enter/exit XR mode
  50628. */
  50629. export class WebXREnterExitUI implements IDisposable {
  50630. private scene;
  50631. /** version of the options passed to this UI */
  50632. options: WebXREnterExitUIOptions;
  50633. private _activeButton;
  50634. private _buttons;
  50635. private _overlay;
  50636. /**
  50637. * Fired every time the active button is changed.
  50638. *
  50639. * When xr is entered via a button that launches xr that button will be the callback parameter
  50640. *
  50641. * When exiting xr the callback parameter will be null)
  50642. */
  50643. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  50644. /**
  50645. *
  50646. * @param scene babylon scene object to use
  50647. * @param options (read-only) version of the options passed to this UI
  50648. */
  50649. private constructor();
  50650. /**
  50651. * Creates UI to allow the user to enter/exit XR mode
  50652. * @param scene the scene to add the ui to
  50653. * @param helper the xr experience helper to enter/exit xr with
  50654. * @param options options to configure the UI
  50655. * @returns the created ui
  50656. */
  50657. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  50658. /**
  50659. * Disposes of the XR UI component
  50660. */
  50661. dispose(): void;
  50662. private _updateButtons;
  50663. }
  50664. }
  50665. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  50666. import { Vector3 } from "babylonjs/Maths/math.vector";
  50667. import { Color4 } from "babylonjs/Maths/math.color";
  50668. import { Nullable } from "babylonjs/types";
  50669. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50670. import { Scene } from "babylonjs/scene";
  50671. /**
  50672. * Class containing static functions to help procedurally build meshes
  50673. */
  50674. export class LinesBuilder {
  50675. /**
  50676. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50677. * * 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
  50678. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50679. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50680. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50681. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50682. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50683. * * 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
  50684. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50686. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50687. * @param name defines the name of the new line system
  50688. * @param options defines the options used to create the line system
  50689. * @param scene defines the hosting scene
  50690. * @returns a new line system mesh
  50691. */
  50692. static CreateLineSystem(name: string, options: {
  50693. lines: Vector3[][];
  50694. updatable?: boolean;
  50695. instance?: Nullable<LinesMesh>;
  50696. colors?: Nullable<Color4[][]>;
  50697. useVertexAlpha?: boolean;
  50698. }, scene: Nullable<Scene>): LinesMesh;
  50699. /**
  50700. * Creates a line mesh
  50701. * 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
  50702. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50703. * * The parameter `points` is an array successive Vector3
  50704. * * 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
  50705. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50706. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50707. * * When updating an instance, remember that only point positions can change, not the number of points
  50708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50709. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50710. * @param name defines the name of the new line system
  50711. * @param options defines the options used to create the line system
  50712. * @param scene defines the hosting scene
  50713. * @returns a new line mesh
  50714. */
  50715. static CreateLines(name: string, options: {
  50716. points: Vector3[];
  50717. updatable?: boolean;
  50718. instance?: Nullable<LinesMesh>;
  50719. colors?: Color4[];
  50720. useVertexAlpha?: boolean;
  50721. }, scene?: Nullable<Scene>): LinesMesh;
  50722. /**
  50723. * Creates a dashed line mesh
  50724. * * 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
  50725. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50726. * * The parameter `points` is an array successive Vector3
  50727. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50728. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50729. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50730. * * 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
  50731. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50732. * * When updating an instance, remember that only point positions can change, not the number of points
  50733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50734. * @param name defines the name of the mesh
  50735. * @param options defines the options used to create the mesh
  50736. * @param scene defines the hosting scene
  50737. * @returns the dashed line mesh
  50738. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50739. */
  50740. static CreateDashedLines(name: string, options: {
  50741. points: Vector3[];
  50742. dashSize?: number;
  50743. gapSize?: number;
  50744. dashNb?: number;
  50745. updatable?: boolean;
  50746. instance?: LinesMesh;
  50747. useVertexAlpha?: boolean;
  50748. }, scene?: Nullable<Scene>): LinesMesh;
  50749. }
  50750. }
  50751. declare module "babylonjs/Misc/timer" {
  50752. import { Observable, Observer } from "babylonjs/Misc/observable";
  50753. import { Nullable } from "babylonjs/types";
  50754. import { IDisposable } from "babylonjs/scene";
  50755. /**
  50756. * Construction options for a timer
  50757. */
  50758. export interface ITimerOptions<T> {
  50759. /**
  50760. * Time-to-end
  50761. */
  50762. timeout: number;
  50763. /**
  50764. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  50765. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  50766. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  50767. */
  50768. contextObservable: Observable<T>;
  50769. /**
  50770. * Optional parameters when adding an observer to the observable
  50771. */
  50772. observableParameters?: {
  50773. mask?: number;
  50774. insertFirst?: boolean;
  50775. scope?: any;
  50776. };
  50777. /**
  50778. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  50779. */
  50780. breakCondition?: (data?: ITimerData<T>) => boolean;
  50781. /**
  50782. * Will be triggered when the time condition has met
  50783. */
  50784. onEnded?: (data: ITimerData<any>) => void;
  50785. /**
  50786. * Will be triggered when the break condition has met (prematurely ended)
  50787. */
  50788. onAborted?: (data: ITimerData<any>) => void;
  50789. /**
  50790. * Optional function to execute on each tick (or count)
  50791. */
  50792. onTick?: (data: ITimerData<any>) => void;
  50793. }
  50794. /**
  50795. * An interface defining the data sent by the timer
  50796. */
  50797. export interface ITimerData<T> {
  50798. /**
  50799. * When did it start
  50800. */
  50801. startTime: number;
  50802. /**
  50803. * Time now
  50804. */
  50805. currentTime: number;
  50806. /**
  50807. * Time passed since started
  50808. */
  50809. deltaTime: number;
  50810. /**
  50811. * How much is completed, in [0.0...1.0].
  50812. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  50813. */
  50814. completeRate: number;
  50815. /**
  50816. * What the registered observable sent in the last count
  50817. */
  50818. payload: T;
  50819. }
  50820. /**
  50821. * The current state of the timer
  50822. */
  50823. export enum TimerState {
  50824. /**
  50825. * Timer initialized, not yet started
  50826. */
  50827. INIT = 0,
  50828. /**
  50829. * Timer started and counting
  50830. */
  50831. STARTED = 1,
  50832. /**
  50833. * Timer ended (whether aborted or time reached)
  50834. */
  50835. ENDED = 2
  50836. }
  50837. /**
  50838. * A simple version of the timer. Will take options and start the timer immediately after calling it
  50839. *
  50840. * @param options options with which to initialize this timer
  50841. */
  50842. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  50843. /**
  50844. * An advanced implementation of a timer class
  50845. */
  50846. export class AdvancedTimer<T = any> implements IDisposable {
  50847. /**
  50848. * Will notify each time the timer calculates the remaining time
  50849. */
  50850. onEachCountObservable: Observable<ITimerData<T>>;
  50851. /**
  50852. * Will trigger when the timer was aborted due to the break condition
  50853. */
  50854. onTimerAbortedObservable: Observable<ITimerData<T>>;
  50855. /**
  50856. * Will trigger when the timer ended successfully
  50857. */
  50858. onTimerEndedObservable: Observable<ITimerData<T>>;
  50859. /**
  50860. * Will trigger when the timer state has changed
  50861. */
  50862. onStateChangedObservable: Observable<TimerState>;
  50863. private _observer;
  50864. private _contextObservable;
  50865. private _observableParameters;
  50866. private _startTime;
  50867. private _timer;
  50868. private _state;
  50869. private _breakCondition;
  50870. private _timeToEnd;
  50871. private _breakOnNextTick;
  50872. /**
  50873. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  50874. * @param options construction options for this advanced timer
  50875. */
  50876. constructor(options: ITimerOptions<T>);
  50877. /**
  50878. * set a breaking condition for this timer. Default is to never break during count
  50879. * @param predicate the new break condition. Returns true to break, false otherwise
  50880. */
  50881. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  50882. /**
  50883. * Reset ALL associated observables in this advanced timer
  50884. */
  50885. clearObservables(): void;
  50886. /**
  50887. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  50888. *
  50889. * @param timeToEnd how much time to measure until timer ended
  50890. */
  50891. start(timeToEnd?: number): void;
  50892. /**
  50893. * Will force a stop on the next tick.
  50894. */
  50895. stop(): void;
  50896. /**
  50897. * Dispose this timer, clearing all resources
  50898. */
  50899. dispose(): void;
  50900. private _setState;
  50901. private _tick;
  50902. private _stop;
  50903. }
  50904. }
  50905. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  50906. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50907. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50908. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50910. import { Vector3 } from "babylonjs/Maths/math.vector";
  50911. import { Material } from "babylonjs/Materials/material";
  50912. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50913. import { Scene } from "babylonjs/scene";
  50914. /**
  50915. * The options container for the teleportation module
  50916. */
  50917. export interface IWebXRTeleportationOptions {
  50918. /**
  50919. * if provided, this scene will be used to render meshes.
  50920. */
  50921. customUtilityLayerScene?: Scene;
  50922. /**
  50923. * Values to configure the default target mesh
  50924. */
  50925. defaultTargetMeshOptions?: {
  50926. /**
  50927. * Fill color of the teleportation area
  50928. */
  50929. teleportationFillColor?: string;
  50930. /**
  50931. * Border color for the teleportation area
  50932. */
  50933. teleportationBorderColor?: string;
  50934. /**
  50935. * Disable the mesh's animation sequence
  50936. */
  50937. disableAnimation?: boolean;
  50938. /**
  50939. * Disable lighting on the material or the ring and arrow
  50940. */
  50941. disableLighting?: boolean;
  50942. /**
  50943. * Override the default material of the torus and arrow
  50944. */
  50945. torusArrowMaterial?: Material;
  50946. };
  50947. /**
  50948. * A list of meshes to use as floor meshes.
  50949. * Meshes can be added and removed after initializing the feature using the
  50950. * addFloorMesh and removeFloorMesh functions
  50951. * If empty, rotation will still work
  50952. */
  50953. floorMeshes?: AbstractMesh[];
  50954. /**
  50955. * use this rendering group id for the meshes (optional)
  50956. */
  50957. renderingGroupId?: number;
  50958. /**
  50959. * Should teleportation move only to snap points
  50960. */
  50961. snapPointsOnly?: boolean;
  50962. /**
  50963. * An array of points to which the teleportation will snap to.
  50964. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  50965. */
  50966. snapPositions?: Vector3[];
  50967. /**
  50968. * How close should the teleportation ray be in order to snap to position.
  50969. * Default to 0.8 units (meters)
  50970. */
  50971. snapToPositionRadius?: number;
  50972. /**
  50973. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  50974. * If you want to support rotation, make sure your mesh has a direction indicator.
  50975. *
  50976. * When left untouched, the default mesh will be initialized.
  50977. */
  50978. teleportationTargetMesh?: AbstractMesh;
  50979. /**
  50980. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  50981. */
  50982. timeToTeleport?: number;
  50983. /**
  50984. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  50985. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  50986. */
  50987. useMainComponentOnly?: boolean;
  50988. /**
  50989. * Should meshes created here be added to a utility layer or the main scene
  50990. */
  50991. useUtilityLayer?: boolean;
  50992. /**
  50993. * Babylon XR Input class for controller
  50994. */
  50995. xrInput: WebXRInput;
  50996. }
  50997. /**
  50998. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  50999. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51000. * the input of the attached controllers.
  51001. */
  51002. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51003. private _options;
  51004. private _controllers;
  51005. private _currentTeleportationControllerId;
  51006. private _floorMeshes;
  51007. private _quadraticBezierCurve;
  51008. private _selectionFeature;
  51009. private _snapToPositions;
  51010. private _snappedToPoint;
  51011. private _teleportationRingMaterial?;
  51012. private _tmpRay;
  51013. private _tmpVector;
  51014. /**
  51015. * The module's name
  51016. */
  51017. static readonly Name: string;
  51018. /**
  51019. * The (Babylon) version of this module.
  51020. * This is an integer representing the implementation version.
  51021. * This number does not correspond to the webxr specs version
  51022. */
  51023. static readonly Version: number;
  51024. /**
  51025. * Is movement backwards enabled
  51026. */
  51027. backwardsMovementEnabled: boolean;
  51028. /**
  51029. * Distance to travel when moving backwards
  51030. */
  51031. backwardsTeleportationDistance: number;
  51032. /**
  51033. * The distance from the user to the inspection point in the direction of the controller
  51034. * A higher number will allow the user to move further
  51035. * defaults to 5 (meters, in xr units)
  51036. */
  51037. parabolicCheckRadius: number;
  51038. /**
  51039. * Should the module support parabolic ray on top of direct ray
  51040. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51041. * Very helpful when moving between floors / different heights
  51042. */
  51043. parabolicRayEnabled: boolean;
  51044. /**
  51045. * How much rotation should be applied when rotating right and left
  51046. */
  51047. rotationAngle: number;
  51048. /**
  51049. * Is rotation enabled when moving forward?
  51050. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51051. */
  51052. rotationEnabled: boolean;
  51053. /**
  51054. * constructs a new anchor system
  51055. * @param _xrSessionManager an instance of WebXRSessionManager
  51056. * @param _options configuration object for this feature
  51057. */
  51058. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51059. /**
  51060. * Get the snapPointsOnly flag
  51061. */
  51062. get snapPointsOnly(): boolean;
  51063. /**
  51064. * Sets the snapPointsOnly flag
  51065. * @param snapToPoints should teleportation be exclusively to snap points
  51066. */
  51067. set snapPointsOnly(snapToPoints: boolean);
  51068. /**
  51069. * Add a new mesh to the floor meshes array
  51070. * @param mesh the mesh to use as floor mesh
  51071. */
  51072. addFloorMesh(mesh: AbstractMesh): void;
  51073. /**
  51074. * Add a new snap-to point to fix teleportation to this position
  51075. * @param newSnapPoint The new Snap-To point
  51076. */
  51077. addSnapPoint(newSnapPoint: Vector3): void;
  51078. attach(): boolean;
  51079. detach(): boolean;
  51080. dispose(): void;
  51081. /**
  51082. * Remove a mesh from the floor meshes array
  51083. * @param mesh the mesh to remove
  51084. */
  51085. removeFloorMesh(mesh: AbstractMesh): void;
  51086. /**
  51087. * Remove a mesh from the floor meshes array using its name
  51088. * @param name the mesh name to remove
  51089. */
  51090. removeFloorMeshByName(name: string): void;
  51091. /**
  51092. * 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
  51093. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51094. * @returns was the point found and removed or not
  51095. */
  51096. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51097. /**
  51098. * This function sets a selection feature that will be disabled when
  51099. * the forward ray is shown and will be reattached when hidden.
  51100. * This is used to remove the selection rays when moving.
  51101. * @param selectionFeature the feature to disable when forward movement is enabled
  51102. */
  51103. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  51104. protected _onXRFrame(_xrFrame: XRFrame): void;
  51105. private _attachController;
  51106. private _createDefaultTargetMesh;
  51107. private _detachController;
  51108. private _findClosestSnapPointWithRadius;
  51109. private _setTargetMeshPosition;
  51110. private _setTargetMeshVisibility;
  51111. private _showParabolicPath;
  51112. private _teleportForward;
  51113. }
  51114. }
  51115. declare module "babylonjs/XR/webXRDefaultExperience" {
  51116. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51117. import { Scene } from "babylonjs/scene";
  51118. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51119. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51120. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51121. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51123. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51124. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51125. /**
  51126. * Options for the default xr helper
  51127. */
  51128. export class WebXRDefaultExperienceOptions {
  51129. /**
  51130. * Enable or disable default UI to enter XR
  51131. */
  51132. disableDefaultUI?: boolean;
  51133. /**
  51134. * Should teleportation not initialize. defaults to false.
  51135. */
  51136. disableTeleportation?: boolean;
  51137. /**
  51138. * Floor meshes that will be used for teleport
  51139. */
  51140. floorMeshes?: Array<AbstractMesh>;
  51141. /**
  51142. * If set to true, the first frame will not be used to reset position
  51143. * The first frame is mainly used when copying transformation from the old camera
  51144. * Mainly used in AR
  51145. */
  51146. ignoreNativeCameraTransformation?: boolean;
  51147. /**
  51148. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51149. */
  51150. inputOptions?: IWebXRInputOptions;
  51151. /**
  51152. * optional configuration for the output canvas
  51153. */
  51154. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51155. /**
  51156. * optional UI options. This can be used among other to change session mode and reference space type
  51157. */
  51158. uiOptions?: WebXREnterExitUIOptions;
  51159. /**
  51160. * When loading teleportation and pointer select, use stable versions instead of latest.
  51161. */
  51162. useStablePlugins?: boolean;
  51163. /**
  51164. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51165. */
  51166. renderingGroupId?: number;
  51167. /**
  51168. * A list of optional features to init the session with
  51169. * If set to true, all features we support will be added
  51170. */
  51171. optionalFeatures?: boolean | string[];
  51172. }
  51173. /**
  51174. * Default experience which provides a similar setup to the previous webVRExperience
  51175. */
  51176. export class WebXRDefaultExperience {
  51177. /**
  51178. * Base experience
  51179. */
  51180. baseExperience: WebXRExperienceHelper;
  51181. /**
  51182. * Enables ui for entering/exiting xr
  51183. */
  51184. enterExitUI: WebXREnterExitUI;
  51185. /**
  51186. * Input experience extension
  51187. */
  51188. input: WebXRInput;
  51189. /**
  51190. * Enables laser pointer and selection
  51191. */
  51192. pointerSelection: WebXRControllerPointerSelection;
  51193. /**
  51194. * Default target xr should render to
  51195. */
  51196. renderTarget: WebXRRenderTarget;
  51197. /**
  51198. * Enables teleportation
  51199. */
  51200. teleportation: WebXRMotionControllerTeleportation;
  51201. private constructor();
  51202. /**
  51203. * Creates the default xr experience
  51204. * @param scene scene
  51205. * @param options options for basic configuration
  51206. * @returns resulting WebXRDefaultExperience
  51207. */
  51208. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51209. /**
  51210. * DIsposes of the experience helper
  51211. */
  51212. dispose(): void;
  51213. }
  51214. }
  51215. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51216. import { Observable } from "babylonjs/Misc/observable";
  51217. import { Nullable } from "babylonjs/types";
  51218. import { Camera } from "babylonjs/Cameras/camera";
  51219. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51220. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51221. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51222. import { Scene } from "babylonjs/scene";
  51223. import { Vector3 } from "babylonjs/Maths/math.vector";
  51224. import { Color3 } from "babylonjs/Maths/math.color";
  51225. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51227. import { Mesh } from "babylonjs/Meshes/mesh";
  51228. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51229. import { EasingFunction } from "babylonjs/Animations/easing";
  51230. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51231. import "babylonjs/Meshes/Builders/groundBuilder";
  51232. import "babylonjs/Meshes/Builders/torusBuilder";
  51233. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51234. import "babylonjs/Gamepads/gamepadSceneComponent";
  51235. import "babylonjs/Animations/animatable";
  51236. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51237. /**
  51238. * Options to modify the vr teleportation behavior.
  51239. */
  51240. export interface VRTeleportationOptions {
  51241. /**
  51242. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51243. */
  51244. floorMeshName?: string;
  51245. /**
  51246. * A list of meshes to be used as the teleportation floor. (default: empty)
  51247. */
  51248. floorMeshes?: Mesh[];
  51249. /**
  51250. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51251. */
  51252. teleportationMode?: number;
  51253. /**
  51254. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51255. */
  51256. teleportationTime?: number;
  51257. /**
  51258. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51259. */
  51260. teleportationSpeed?: number;
  51261. /**
  51262. * The easing function used in the animation or null for Linear. (default CircleEase)
  51263. */
  51264. easingFunction?: EasingFunction;
  51265. }
  51266. /**
  51267. * Options to modify the vr experience helper's behavior.
  51268. */
  51269. export interface VRExperienceHelperOptions extends WebVROptions {
  51270. /**
  51271. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51272. */
  51273. createDeviceOrientationCamera?: boolean;
  51274. /**
  51275. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51276. */
  51277. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51278. /**
  51279. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51280. */
  51281. laserToggle?: boolean;
  51282. /**
  51283. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51284. */
  51285. floorMeshes?: Mesh[];
  51286. /**
  51287. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51288. */
  51289. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51290. /**
  51291. * Defines if WebXR should be used instead of WebVR (if available)
  51292. */
  51293. useXR?: boolean;
  51294. }
  51295. /**
  51296. * Event containing information after VR has been entered
  51297. */
  51298. export class OnAfterEnteringVRObservableEvent {
  51299. /**
  51300. * If entering vr was successful
  51301. */
  51302. success: boolean;
  51303. }
  51304. /**
  51305. * Helps to quickly add VR support to an existing scene.
  51306. * See https://doc.babylonjs.com/how_to/webvr_helper
  51307. */
  51308. export class VRExperienceHelper {
  51309. /** Options to modify the vr experience helper's behavior. */
  51310. webVROptions: VRExperienceHelperOptions;
  51311. private _scene;
  51312. private _position;
  51313. private _btnVR;
  51314. private _btnVRDisplayed;
  51315. private _webVRsupported;
  51316. private _webVRready;
  51317. private _webVRrequesting;
  51318. private _webVRpresenting;
  51319. private _hasEnteredVR;
  51320. private _fullscreenVRpresenting;
  51321. private _inputElement;
  51322. private _webVRCamera;
  51323. private _vrDeviceOrientationCamera;
  51324. private _deviceOrientationCamera;
  51325. private _existingCamera;
  51326. private _onKeyDown;
  51327. private _onVrDisplayPresentChange;
  51328. private _onVRDisplayChanged;
  51329. private _onVRRequestPresentStart;
  51330. private _onVRRequestPresentComplete;
  51331. /**
  51332. * 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)
  51333. */
  51334. enableGazeEvenWhenNoPointerLock: boolean;
  51335. /**
  51336. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51337. */
  51338. exitVROnDoubleTap: boolean;
  51339. /**
  51340. * Observable raised right before entering VR.
  51341. */
  51342. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51343. /**
  51344. * Observable raised when entering VR has completed.
  51345. */
  51346. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51347. /**
  51348. * Observable raised when exiting VR.
  51349. */
  51350. onExitingVRObservable: Observable<VRExperienceHelper>;
  51351. /**
  51352. * Observable raised when controller mesh is loaded.
  51353. */
  51354. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51355. /** Return this.onEnteringVRObservable
  51356. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51357. */
  51358. get onEnteringVR(): Observable<VRExperienceHelper>;
  51359. /** Return this.onExitingVRObservable
  51360. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51361. */
  51362. get onExitingVR(): Observable<VRExperienceHelper>;
  51363. /** Return this.onControllerMeshLoadedObservable
  51364. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51365. */
  51366. get onControllerMeshLoaded(): Observable<WebVRController>;
  51367. private _rayLength;
  51368. private _useCustomVRButton;
  51369. private _teleportationRequested;
  51370. private _teleportActive;
  51371. private _floorMeshName;
  51372. private _floorMeshesCollection;
  51373. private _teleportationMode;
  51374. private _teleportationTime;
  51375. private _teleportationSpeed;
  51376. private _teleportationEasing;
  51377. private _rotationAllowed;
  51378. private _teleportBackwardsVector;
  51379. private _teleportationTarget;
  51380. private _isDefaultTeleportationTarget;
  51381. private _postProcessMove;
  51382. private _teleportationFillColor;
  51383. private _teleportationBorderColor;
  51384. private _rotationAngle;
  51385. private _haloCenter;
  51386. private _cameraGazer;
  51387. private _padSensibilityUp;
  51388. private _padSensibilityDown;
  51389. private _leftController;
  51390. private _rightController;
  51391. private _gazeColor;
  51392. private _laserColor;
  51393. private _pickedLaserColor;
  51394. private _pickedGazeColor;
  51395. /**
  51396. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51397. */
  51398. onNewMeshSelected: Observable<AbstractMesh>;
  51399. /**
  51400. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51401. * This observable will provide the mesh and the controller used to select the mesh
  51402. */
  51403. onMeshSelectedWithController: Observable<{
  51404. mesh: AbstractMesh;
  51405. controller: WebVRController;
  51406. }>;
  51407. /**
  51408. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51409. */
  51410. onNewMeshPicked: Observable<PickingInfo>;
  51411. private _circleEase;
  51412. /**
  51413. * Observable raised before camera teleportation
  51414. */
  51415. onBeforeCameraTeleport: Observable<Vector3>;
  51416. /**
  51417. * Observable raised after camera teleportation
  51418. */
  51419. onAfterCameraTeleport: Observable<Vector3>;
  51420. /**
  51421. * Observable raised when current selected mesh gets unselected
  51422. */
  51423. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51424. private _raySelectionPredicate;
  51425. /**
  51426. * To be optionaly changed by user to define custom ray selection
  51427. */
  51428. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51429. /**
  51430. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51431. */
  51432. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51433. /**
  51434. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51435. */
  51436. teleportationEnabled: boolean;
  51437. private _defaultHeight;
  51438. private _teleportationInitialized;
  51439. private _interactionsEnabled;
  51440. private _interactionsRequested;
  51441. private _displayGaze;
  51442. private _displayLaserPointer;
  51443. /**
  51444. * The mesh used to display where the user is going to teleport.
  51445. */
  51446. get teleportationTarget(): Mesh;
  51447. /**
  51448. * Sets the mesh to be used to display where the user is going to teleport.
  51449. */
  51450. set teleportationTarget(value: Mesh);
  51451. /**
  51452. * 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
  51453. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51454. * See https://doc.babylonjs.com/resources/baking_transformations
  51455. */
  51456. get gazeTrackerMesh(): Mesh;
  51457. set gazeTrackerMesh(value: Mesh);
  51458. /**
  51459. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51460. */
  51461. updateGazeTrackerScale: boolean;
  51462. /**
  51463. * If the gaze trackers color should be updated when selecting meshes
  51464. */
  51465. updateGazeTrackerColor: boolean;
  51466. /**
  51467. * If the controller laser color should be updated when selecting meshes
  51468. */
  51469. updateControllerLaserColor: boolean;
  51470. /**
  51471. * The gaze tracking mesh corresponding to the left controller
  51472. */
  51473. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51474. /**
  51475. * The gaze tracking mesh corresponding to the right controller
  51476. */
  51477. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51478. /**
  51479. * If the ray of the gaze should be displayed.
  51480. */
  51481. get displayGaze(): boolean;
  51482. /**
  51483. * Sets if the ray of the gaze should be displayed.
  51484. */
  51485. set displayGaze(value: boolean);
  51486. /**
  51487. * If the ray of the LaserPointer should be displayed.
  51488. */
  51489. get displayLaserPointer(): boolean;
  51490. /**
  51491. * Sets if the ray of the LaserPointer should be displayed.
  51492. */
  51493. set displayLaserPointer(value: boolean);
  51494. /**
  51495. * The deviceOrientationCamera used as the camera when not in VR.
  51496. */
  51497. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51498. /**
  51499. * Based on the current WebVR support, returns the current VR camera used.
  51500. */
  51501. get currentVRCamera(): Nullable<Camera>;
  51502. /**
  51503. * The webVRCamera which is used when in VR.
  51504. */
  51505. get webVRCamera(): WebVRFreeCamera;
  51506. /**
  51507. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51508. */
  51509. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51510. /**
  51511. * The html button that is used to trigger entering into VR.
  51512. */
  51513. get vrButton(): Nullable<HTMLButtonElement>;
  51514. private get _teleportationRequestInitiated();
  51515. /**
  51516. * Defines whether or not Pointer lock should be requested when switching to
  51517. * full screen.
  51518. */
  51519. requestPointerLockOnFullScreen: boolean;
  51520. /**
  51521. * If asking to force XR, this will be populated with the default xr experience
  51522. */
  51523. xr: WebXRDefaultExperience;
  51524. /**
  51525. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51526. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51527. */
  51528. xrTestDone: boolean;
  51529. /**
  51530. * Instantiates a VRExperienceHelper.
  51531. * Helps to quickly add VR support to an existing scene.
  51532. * @param scene The scene the VRExperienceHelper belongs to.
  51533. * @param webVROptions Options to modify the vr experience helper's behavior.
  51534. */
  51535. constructor(scene: Scene,
  51536. /** Options to modify the vr experience helper's behavior. */
  51537. webVROptions?: VRExperienceHelperOptions);
  51538. private completeVRInit;
  51539. private _onDefaultMeshLoaded;
  51540. private _onResize;
  51541. private _onFullscreenChange;
  51542. /**
  51543. * Gets a value indicating if we are currently in VR mode.
  51544. */
  51545. get isInVRMode(): boolean;
  51546. private onVrDisplayPresentChange;
  51547. private onVRDisplayChanged;
  51548. private moveButtonToBottomRight;
  51549. private displayVRButton;
  51550. private updateButtonVisibility;
  51551. private _cachedAngularSensibility;
  51552. /**
  51553. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51554. * Otherwise, will use the fullscreen API.
  51555. */
  51556. enterVR(): void;
  51557. /**
  51558. * Attempt to exit VR, or fullscreen.
  51559. */
  51560. exitVR(): void;
  51561. /**
  51562. * The position of the vr experience helper.
  51563. */
  51564. get position(): Vector3;
  51565. /**
  51566. * Sets the position of the vr experience helper.
  51567. */
  51568. set position(value: Vector3);
  51569. /**
  51570. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51571. */
  51572. enableInteractions(): void;
  51573. private get _noControllerIsActive();
  51574. private beforeRender;
  51575. private _isTeleportationFloor;
  51576. /**
  51577. * Adds a floor mesh to be used for teleportation.
  51578. * @param floorMesh the mesh to be used for teleportation.
  51579. */
  51580. addFloorMesh(floorMesh: Mesh): void;
  51581. /**
  51582. * Removes a floor mesh from being used for teleportation.
  51583. * @param floorMesh the mesh to be removed.
  51584. */
  51585. removeFloorMesh(floorMesh: Mesh): void;
  51586. /**
  51587. * Enables interactions and teleportation using the VR controllers and gaze.
  51588. * @param vrTeleportationOptions options to modify teleportation behavior.
  51589. */
  51590. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51591. private _onNewGamepadConnected;
  51592. private _tryEnableInteractionOnController;
  51593. private _onNewGamepadDisconnected;
  51594. private _enableInteractionOnController;
  51595. private _checkTeleportWithRay;
  51596. private _checkRotate;
  51597. private _checkTeleportBackwards;
  51598. private _enableTeleportationOnController;
  51599. private _createTeleportationCircles;
  51600. private _displayTeleportationTarget;
  51601. private _hideTeleportationTarget;
  51602. private _rotateCamera;
  51603. private _moveTeleportationSelectorTo;
  51604. private _workingVector;
  51605. private _workingQuaternion;
  51606. private _workingMatrix;
  51607. /**
  51608. * Time Constant Teleportation Mode
  51609. */
  51610. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  51611. /**
  51612. * Speed Constant Teleportation Mode
  51613. */
  51614. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  51615. /**
  51616. * Teleports the users feet to the desired location
  51617. * @param location The location where the user's feet should be placed
  51618. */
  51619. teleportCamera(location: Vector3): void;
  51620. private _convertNormalToDirectionOfRay;
  51621. private _castRayAndSelectObject;
  51622. private _notifySelectedMeshUnselected;
  51623. /**
  51624. * Permanently set new colors for the laser pointer
  51625. * @param color the new laser color
  51626. * @param pickedColor the new laser color when picked mesh detected
  51627. */
  51628. setLaserColor(color: Color3, pickedColor?: Color3): void;
  51629. /**
  51630. * Set lighting enabled / disabled on the laser pointer of both controllers
  51631. * @param enabled should the lighting be enabled on the laser pointer
  51632. */
  51633. setLaserLightingState(enabled?: boolean): void;
  51634. /**
  51635. * Permanently set new colors for the gaze pointer
  51636. * @param color the new gaze color
  51637. * @param pickedColor the new gaze color when picked mesh detected
  51638. */
  51639. setGazeColor(color: Color3, pickedColor?: Color3): void;
  51640. /**
  51641. * Sets the color of the laser ray from the vr controllers.
  51642. * @param color new color for the ray.
  51643. */
  51644. changeLaserColor(color: Color3): void;
  51645. /**
  51646. * Sets the color of the ray from the vr headsets gaze.
  51647. * @param color new color for the ray.
  51648. */
  51649. changeGazeColor(color: Color3): void;
  51650. /**
  51651. * Exits VR and disposes of the vr experience helper
  51652. */
  51653. dispose(): void;
  51654. /**
  51655. * Gets the name of the VRExperienceHelper class
  51656. * @returns "VRExperienceHelper"
  51657. */
  51658. getClassName(): string;
  51659. }
  51660. }
  51661. declare module "babylonjs/Cameras/VR/index" {
  51662. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  51663. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  51664. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51665. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  51666. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  51667. export * from "babylonjs/Cameras/VR/webVRCamera";
  51668. }
  51669. declare module "babylonjs/Cameras/RigModes/index" {
  51670. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51671. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51672. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  51673. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  51674. }
  51675. declare module "babylonjs/Cameras/index" {
  51676. export * from "babylonjs/Cameras/Inputs/index";
  51677. export * from "babylonjs/Cameras/cameraInputsManager";
  51678. export * from "babylonjs/Cameras/camera";
  51679. export * from "babylonjs/Cameras/targetCamera";
  51680. export * from "babylonjs/Cameras/freeCamera";
  51681. export * from "babylonjs/Cameras/freeCameraInputsManager";
  51682. export * from "babylonjs/Cameras/touchCamera";
  51683. export * from "babylonjs/Cameras/arcRotateCamera";
  51684. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51685. export * from "babylonjs/Cameras/deviceOrientationCamera";
  51686. export * from "babylonjs/Cameras/flyCamera";
  51687. export * from "babylonjs/Cameras/flyCameraInputsManager";
  51688. export * from "babylonjs/Cameras/followCamera";
  51689. export * from "babylonjs/Cameras/followCameraInputsManager";
  51690. export * from "babylonjs/Cameras/gamepadCamera";
  51691. export * from "babylonjs/Cameras/Stereoscopic/index";
  51692. export * from "babylonjs/Cameras/universalCamera";
  51693. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  51694. export * from "babylonjs/Cameras/VR/index";
  51695. export * from "babylonjs/Cameras/RigModes/index";
  51696. }
  51697. declare module "babylonjs/Collisions/index" {
  51698. export * from "babylonjs/Collisions/collider";
  51699. export * from "babylonjs/Collisions/collisionCoordinator";
  51700. export * from "babylonjs/Collisions/pickingInfo";
  51701. export * from "babylonjs/Collisions/intersectionInfo";
  51702. export * from "babylonjs/Collisions/meshCollisionData";
  51703. }
  51704. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51705. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51706. import { Vector3 } from "babylonjs/Maths/math.vector";
  51707. import { Ray } from "babylonjs/Culling/ray";
  51708. import { Plane } from "babylonjs/Maths/math.plane";
  51709. /**
  51710. * Contains an array of blocks representing the octree
  51711. */
  51712. export interface IOctreeContainer<T> {
  51713. /**
  51714. * Blocks within the octree
  51715. */
  51716. blocks: Array<OctreeBlock<T>>;
  51717. }
  51718. /**
  51719. * Class used to store a cell in an octree
  51720. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51721. */
  51722. export class OctreeBlock<T> {
  51723. /**
  51724. * Gets the content of the current block
  51725. */
  51726. entries: T[];
  51727. /**
  51728. * Gets the list of block children
  51729. */
  51730. blocks: Array<OctreeBlock<T>>;
  51731. private _depth;
  51732. private _maxDepth;
  51733. private _capacity;
  51734. private _minPoint;
  51735. private _maxPoint;
  51736. private _boundingVectors;
  51737. private _creationFunc;
  51738. /**
  51739. * Creates a new block
  51740. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  51741. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  51742. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51743. * @param depth defines the current depth of this block in the octree
  51744. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  51745. * @param creationFunc defines a callback to call when an element is added to the block
  51746. */
  51747. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  51748. /**
  51749. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51750. */
  51751. get capacity(): number;
  51752. /**
  51753. * Gets the minimum vector (in world space) of the block's bounding box
  51754. */
  51755. get minPoint(): Vector3;
  51756. /**
  51757. * Gets the maximum vector (in world space) of the block's bounding box
  51758. */
  51759. get maxPoint(): Vector3;
  51760. /**
  51761. * Add a new element to this block
  51762. * @param entry defines the element to add
  51763. */
  51764. addEntry(entry: T): void;
  51765. /**
  51766. * Remove an element from this block
  51767. * @param entry defines the element to remove
  51768. */
  51769. removeEntry(entry: T): void;
  51770. /**
  51771. * Add an array of elements to this block
  51772. * @param entries defines the array of elements to add
  51773. */
  51774. addEntries(entries: T[]): void;
  51775. /**
  51776. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  51777. * @param frustumPlanes defines the frustum planes to test
  51778. * @param selection defines the array to store current content if selection is positive
  51779. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51780. */
  51781. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51782. /**
  51783. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  51784. * @param sphereCenter defines the bounding sphere center
  51785. * @param sphereRadius defines the bounding sphere radius
  51786. * @param selection defines the array to store current content if selection is positive
  51787. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51788. */
  51789. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51790. /**
  51791. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  51792. * @param ray defines the ray to test with
  51793. * @param selection defines the array to store current content if selection is positive
  51794. */
  51795. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  51796. /**
  51797. * Subdivide the content into child blocks (this block will then be empty)
  51798. */
  51799. createInnerBlocks(): void;
  51800. /**
  51801. * @hidden
  51802. */
  51803. 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;
  51804. }
  51805. }
  51806. declare module "babylonjs/Culling/Octrees/octree" {
  51807. import { SmartArray } from "babylonjs/Misc/smartArray";
  51808. import { Vector3 } from "babylonjs/Maths/math.vector";
  51809. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51811. import { Ray } from "babylonjs/Culling/ray";
  51812. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  51813. import { Plane } from "babylonjs/Maths/math.plane";
  51814. /**
  51815. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  51816. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51817. */
  51818. export class Octree<T> {
  51819. /** 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.) */
  51820. maxDepth: number;
  51821. /**
  51822. * Blocks within the octree containing objects
  51823. */
  51824. blocks: Array<OctreeBlock<T>>;
  51825. /**
  51826. * Content stored in the octree
  51827. */
  51828. dynamicContent: T[];
  51829. private _maxBlockCapacity;
  51830. private _selectionContent;
  51831. private _creationFunc;
  51832. /**
  51833. * Creates a octree
  51834. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51835. * @param creationFunc function to be used to instatiate the octree
  51836. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  51837. * @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.)
  51838. */
  51839. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  51840. /** 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.) */
  51841. maxDepth?: number);
  51842. /**
  51843. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  51844. * @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);
  51845. * @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);
  51846. * @param entries meshes to be added to the octree blocks
  51847. */
  51848. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  51849. /**
  51850. * Adds a mesh to the octree
  51851. * @param entry Mesh to add to the octree
  51852. */
  51853. addMesh(entry: T): void;
  51854. /**
  51855. * Remove an element from the octree
  51856. * @param entry defines the element to remove
  51857. */
  51858. removeMesh(entry: T): void;
  51859. /**
  51860. * Selects an array of meshes within the frustum
  51861. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  51862. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  51863. * @returns array of meshes within the frustum
  51864. */
  51865. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  51866. /**
  51867. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  51868. * @param sphereCenter defines the bounding sphere center
  51869. * @param sphereRadius defines the bounding sphere radius
  51870. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51871. * @returns an array of objects that intersect the sphere
  51872. */
  51873. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  51874. /**
  51875. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  51876. * @param ray defines the ray to test with
  51877. * @returns array of intersected objects
  51878. */
  51879. intersectsRay(ray: Ray): SmartArray<T>;
  51880. /**
  51881. * Adds a mesh into the octree block if it intersects the block
  51882. */
  51883. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  51884. /**
  51885. * Adds a submesh into the octree block if it intersects the block
  51886. */
  51887. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  51888. }
  51889. }
  51890. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  51891. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  51892. import { Scene } from "babylonjs/scene";
  51893. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51894. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51895. import { Ray } from "babylonjs/Culling/ray";
  51896. import { Octree } from "babylonjs/Culling/Octrees/octree";
  51897. import { Collider } from "babylonjs/Collisions/collider";
  51898. module "babylonjs/scene" {
  51899. interface Scene {
  51900. /**
  51901. * @hidden
  51902. * Backing Filed
  51903. */
  51904. _selectionOctree: Octree<AbstractMesh>;
  51905. /**
  51906. * Gets the octree used to boost mesh selection (picking)
  51907. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51908. */
  51909. selectionOctree: Octree<AbstractMesh>;
  51910. /**
  51911. * Creates or updates the octree used to boost selection (picking)
  51912. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51913. * @param maxCapacity defines the maximum capacity per leaf
  51914. * @param maxDepth defines the maximum depth of the octree
  51915. * @returns an octree of AbstractMesh
  51916. */
  51917. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  51918. }
  51919. }
  51920. module "babylonjs/Meshes/abstractMesh" {
  51921. interface AbstractMesh {
  51922. /**
  51923. * @hidden
  51924. * Backing Field
  51925. */
  51926. _submeshesOctree: Octree<SubMesh>;
  51927. /**
  51928. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  51929. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  51930. * @param maxCapacity defines the maximum size of each block (64 by default)
  51931. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  51932. * @returns the new octree
  51933. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  51934. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51935. */
  51936. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  51937. }
  51938. }
  51939. /**
  51940. * Defines the octree scene component responsible to manage any octrees
  51941. * in a given scene.
  51942. */
  51943. export class OctreeSceneComponent {
  51944. /**
  51945. * The component name help to identify the component in the list of scene components.
  51946. */
  51947. readonly name: string;
  51948. /**
  51949. * The scene the component belongs to.
  51950. */
  51951. scene: Scene;
  51952. /**
  51953. * Indicates if the meshes have been checked to make sure they are isEnabled()
  51954. */
  51955. readonly checksIsEnabled: boolean;
  51956. /**
  51957. * Creates a new instance of the component for the given scene
  51958. * @param scene Defines the scene to register the component in
  51959. */
  51960. constructor(scene: Scene);
  51961. /**
  51962. * Registers the component in a given scene
  51963. */
  51964. register(): void;
  51965. /**
  51966. * Return the list of active meshes
  51967. * @returns the list of active meshes
  51968. */
  51969. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  51970. /**
  51971. * Return the list of active sub meshes
  51972. * @param mesh The mesh to get the candidates sub meshes from
  51973. * @returns the list of active sub meshes
  51974. */
  51975. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  51976. private _tempRay;
  51977. /**
  51978. * Return the list of sub meshes intersecting with a given local ray
  51979. * @param mesh defines the mesh to find the submesh for
  51980. * @param localRay defines the ray in local space
  51981. * @returns the list of intersecting sub meshes
  51982. */
  51983. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  51984. /**
  51985. * Return the list of sub meshes colliding with a collider
  51986. * @param mesh defines the mesh to find the submesh for
  51987. * @param collider defines the collider to evaluate the collision against
  51988. * @returns the list of colliding sub meshes
  51989. */
  51990. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  51991. /**
  51992. * Rebuilds the elements related to this component in case of
  51993. * context lost for instance.
  51994. */
  51995. rebuild(): void;
  51996. /**
  51997. * Disposes the component and the associated ressources.
  51998. */
  51999. dispose(): void;
  52000. }
  52001. }
  52002. declare module "babylonjs/Culling/Octrees/index" {
  52003. export * from "babylonjs/Culling/Octrees/octree";
  52004. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52005. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52006. }
  52007. declare module "babylonjs/Culling/index" {
  52008. export * from "babylonjs/Culling/boundingBox";
  52009. export * from "babylonjs/Culling/boundingInfo";
  52010. export * from "babylonjs/Culling/boundingSphere";
  52011. export * from "babylonjs/Culling/Octrees/index";
  52012. export * from "babylonjs/Culling/ray";
  52013. }
  52014. declare module "babylonjs/Gizmos/gizmo" {
  52015. import { Nullable } from "babylonjs/types";
  52016. import { IDisposable } from "babylonjs/scene";
  52017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52018. import { Mesh } from "babylonjs/Meshes/mesh";
  52019. import { Node } from "babylonjs/node";
  52020. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52021. /**
  52022. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52023. */
  52024. export class Gizmo implements IDisposable {
  52025. /** The utility layer the gizmo will be added to */
  52026. gizmoLayer: UtilityLayerRenderer;
  52027. /**
  52028. * The root mesh of the gizmo
  52029. */
  52030. _rootMesh: Mesh;
  52031. private _attachedMesh;
  52032. private _attachedNode;
  52033. /**
  52034. * Ratio for the scale of the gizmo (Default: 1)
  52035. */
  52036. scaleRatio: number;
  52037. /**
  52038. * If a custom mesh has been set (Default: false)
  52039. */
  52040. protected _customMeshSet: boolean;
  52041. /**
  52042. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52043. * * When set, interactions will be enabled
  52044. */
  52045. get attachedMesh(): Nullable<AbstractMesh>;
  52046. set attachedMesh(value: Nullable<AbstractMesh>);
  52047. /**
  52048. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52049. * * When set, interactions will be enabled
  52050. */
  52051. get attachedNode(): Nullable<Node>;
  52052. set attachedNode(value: Nullable<Node>);
  52053. /**
  52054. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52055. * @param mesh The mesh to replace the default mesh of the gizmo
  52056. */
  52057. setCustomMesh(mesh: Mesh): void;
  52058. /**
  52059. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52060. */
  52061. updateGizmoRotationToMatchAttachedMesh: boolean;
  52062. /**
  52063. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52064. */
  52065. updateGizmoPositionToMatchAttachedMesh: boolean;
  52066. /**
  52067. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52068. */
  52069. updateScale: boolean;
  52070. protected _interactionsEnabled: boolean;
  52071. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52072. private _beforeRenderObserver;
  52073. private _tempVector;
  52074. /**
  52075. * Creates a gizmo
  52076. * @param gizmoLayer The utility layer the gizmo will be added to
  52077. */
  52078. constructor(
  52079. /** The utility layer the gizmo will be added to */
  52080. gizmoLayer?: UtilityLayerRenderer);
  52081. /**
  52082. * Updates the gizmo to match the attached mesh's position/rotation
  52083. */
  52084. protected _update(): void;
  52085. /**
  52086. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52087. * @param value Node, TransformNode or mesh
  52088. */
  52089. protected _matrixChanged(): void;
  52090. /**
  52091. * Disposes of the gizmo
  52092. */
  52093. dispose(): void;
  52094. }
  52095. }
  52096. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52097. import { Observable } from "babylonjs/Misc/observable";
  52098. import { Nullable } from "babylonjs/types";
  52099. import { Vector3 } from "babylonjs/Maths/math.vector";
  52100. import { Color3 } from "babylonjs/Maths/math.color";
  52101. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52102. import { Node } from "babylonjs/node";
  52103. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52104. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52105. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52106. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52107. import { Scene } from "babylonjs/scene";
  52108. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52109. /**
  52110. * Single plane drag gizmo
  52111. */
  52112. export class PlaneDragGizmo extends Gizmo {
  52113. /**
  52114. * Drag behavior responsible for the gizmos dragging interactions
  52115. */
  52116. dragBehavior: PointerDragBehavior;
  52117. private _pointerObserver;
  52118. /**
  52119. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52120. */
  52121. snapDistance: number;
  52122. /**
  52123. * Event that fires each time the gizmo snaps to a new location.
  52124. * * snapDistance is the the change in distance
  52125. */
  52126. onSnapObservable: Observable<{
  52127. snapDistance: number;
  52128. }>;
  52129. private _plane;
  52130. private _coloredMaterial;
  52131. private _hoverMaterial;
  52132. private _isEnabled;
  52133. private _parent;
  52134. /** @hidden */
  52135. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52136. /** @hidden */
  52137. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52138. /**
  52139. * Creates a PlaneDragGizmo
  52140. * @param gizmoLayer The utility layer the gizmo will be added to
  52141. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52142. * @param color The color of the gizmo
  52143. */
  52144. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52145. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52146. /**
  52147. * If the gizmo is enabled
  52148. */
  52149. set isEnabled(value: boolean);
  52150. get isEnabled(): boolean;
  52151. /**
  52152. * Disposes of the gizmo
  52153. */
  52154. dispose(): void;
  52155. }
  52156. }
  52157. declare module "babylonjs/Gizmos/positionGizmo" {
  52158. import { Observable } from "babylonjs/Misc/observable";
  52159. import { Nullable } from "babylonjs/types";
  52160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52161. import { Node } from "babylonjs/node";
  52162. import { Mesh } from "babylonjs/Meshes/mesh";
  52163. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52164. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52165. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52166. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52167. /**
  52168. * Gizmo that enables dragging a mesh along 3 axis
  52169. */
  52170. export class PositionGizmo extends Gizmo {
  52171. /**
  52172. * Internal gizmo used for interactions on the x axis
  52173. */
  52174. xGizmo: AxisDragGizmo;
  52175. /**
  52176. * Internal gizmo used for interactions on the y axis
  52177. */
  52178. yGizmo: AxisDragGizmo;
  52179. /**
  52180. * Internal gizmo used for interactions on the z axis
  52181. */
  52182. zGizmo: AxisDragGizmo;
  52183. /**
  52184. * Internal gizmo used for interactions on the yz plane
  52185. */
  52186. xPlaneGizmo: PlaneDragGizmo;
  52187. /**
  52188. * Internal gizmo used for interactions on the xz plane
  52189. */
  52190. yPlaneGizmo: PlaneDragGizmo;
  52191. /**
  52192. * Internal gizmo used for interactions on the xy plane
  52193. */
  52194. zPlaneGizmo: PlaneDragGizmo;
  52195. /**
  52196. * private variables
  52197. */
  52198. private _meshAttached;
  52199. private _nodeAttached;
  52200. private _updateGizmoRotationToMatchAttachedMesh;
  52201. private _snapDistance;
  52202. private _scaleRatio;
  52203. /** Fires an event when any of it's sub gizmos are dragged */
  52204. onDragStartObservable: Observable<unknown>;
  52205. /** Fires an event when any of it's sub gizmos are released from dragging */
  52206. onDragEndObservable: Observable<unknown>;
  52207. /**
  52208. * If set to true, planar drag is enabled
  52209. */
  52210. private _planarGizmoEnabled;
  52211. get attachedMesh(): Nullable<AbstractMesh>;
  52212. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52213. get attachedNode(): Nullable<Node>;
  52214. set attachedNode(node: Nullable<Node>);
  52215. /**
  52216. * Creates a PositionGizmo
  52217. * @param gizmoLayer The utility layer the gizmo will be added to
  52218. @param thickness display gizmo axis thickness
  52219. */
  52220. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52221. /**
  52222. * If the planar drag gizmo is enabled
  52223. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52224. */
  52225. set planarGizmoEnabled(value: boolean);
  52226. get planarGizmoEnabled(): boolean;
  52227. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52228. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52229. /**
  52230. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52231. */
  52232. set snapDistance(value: number);
  52233. get snapDistance(): number;
  52234. /**
  52235. * Ratio for the scale of the gizmo (Default: 1)
  52236. */
  52237. set scaleRatio(value: number);
  52238. get scaleRatio(): number;
  52239. /**
  52240. * Disposes of the gizmo
  52241. */
  52242. dispose(): void;
  52243. /**
  52244. * CustomMeshes are not supported by this gizmo
  52245. * @param mesh The mesh to replace the default mesh of the gizmo
  52246. */
  52247. setCustomMesh(mesh: Mesh): void;
  52248. }
  52249. }
  52250. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52251. import { Observable } from "babylonjs/Misc/observable";
  52252. import { Nullable } from "babylonjs/types";
  52253. import { Vector3 } from "babylonjs/Maths/math.vector";
  52254. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52255. import { Node } from "babylonjs/node";
  52256. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52257. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52258. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52259. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52260. import { Scene } from "babylonjs/scene";
  52261. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52262. import { Color3 } from "babylonjs/Maths/math.color";
  52263. /**
  52264. * Single axis drag gizmo
  52265. */
  52266. export class AxisDragGizmo extends Gizmo {
  52267. /**
  52268. * Drag behavior responsible for the gizmos dragging interactions
  52269. */
  52270. dragBehavior: PointerDragBehavior;
  52271. private _pointerObserver;
  52272. /**
  52273. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52274. */
  52275. snapDistance: number;
  52276. /**
  52277. * Event that fires each time the gizmo snaps to a new location.
  52278. * * snapDistance is the the change in distance
  52279. */
  52280. onSnapObservable: Observable<{
  52281. snapDistance: number;
  52282. }>;
  52283. private _isEnabled;
  52284. private _parent;
  52285. private _arrow;
  52286. private _coloredMaterial;
  52287. private _hoverMaterial;
  52288. /** @hidden */
  52289. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52290. /** @hidden */
  52291. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52292. /**
  52293. * Creates an AxisDragGizmo
  52294. * @param gizmoLayer The utility layer the gizmo will be added to
  52295. * @param dragAxis The axis which the gizmo will be able to drag on
  52296. * @param color The color of the gizmo
  52297. * @param thickness display gizmo axis thickness
  52298. */
  52299. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52300. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52301. /**
  52302. * If the gizmo is enabled
  52303. */
  52304. set isEnabled(value: boolean);
  52305. get isEnabled(): boolean;
  52306. /**
  52307. * Disposes of the gizmo
  52308. */
  52309. dispose(): void;
  52310. }
  52311. }
  52312. declare module "babylonjs/Debug/axesViewer" {
  52313. import { Vector3 } from "babylonjs/Maths/math.vector";
  52314. import { Nullable } from "babylonjs/types";
  52315. import { Scene } from "babylonjs/scene";
  52316. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52317. /**
  52318. * The Axes viewer will show 3 axes in a specific point in space
  52319. */
  52320. export class AxesViewer {
  52321. private _xAxis;
  52322. private _yAxis;
  52323. private _zAxis;
  52324. private _scaleLinesFactor;
  52325. private _instanced;
  52326. /**
  52327. * Gets the hosting scene
  52328. */
  52329. scene: Scene;
  52330. /**
  52331. * Gets or sets a number used to scale line length
  52332. */
  52333. scaleLines: number;
  52334. /** Gets the node hierarchy used to render x-axis */
  52335. get xAxis(): TransformNode;
  52336. /** Gets the node hierarchy used to render y-axis */
  52337. get yAxis(): TransformNode;
  52338. /** Gets the node hierarchy used to render z-axis */
  52339. get zAxis(): TransformNode;
  52340. /**
  52341. * Creates a new AxesViewer
  52342. * @param scene defines the hosting scene
  52343. * @param scaleLines defines a number used to scale line length (1 by default)
  52344. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52345. * @param xAxis defines the node hierarchy used to render the x-axis
  52346. * @param yAxis defines the node hierarchy used to render the y-axis
  52347. * @param zAxis defines the node hierarchy used to render the z-axis
  52348. */
  52349. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52350. /**
  52351. * Force the viewer to update
  52352. * @param position defines the position of the viewer
  52353. * @param xaxis defines the x axis of the viewer
  52354. * @param yaxis defines the y axis of the viewer
  52355. * @param zaxis defines the z axis of the viewer
  52356. */
  52357. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52358. /**
  52359. * Creates an instance of this axes viewer.
  52360. * @returns a new axes viewer with instanced meshes
  52361. */
  52362. createInstance(): AxesViewer;
  52363. /** Releases resources */
  52364. dispose(): void;
  52365. private static _SetRenderingGroupId;
  52366. }
  52367. }
  52368. declare module "babylonjs/Debug/boneAxesViewer" {
  52369. import { Nullable } from "babylonjs/types";
  52370. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52371. import { Vector3 } from "babylonjs/Maths/math.vector";
  52372. import { Mesh } from "babylonjs/Meshes/mesh";
  52373. import { Bone } from "babylonjs/Bones/bone";
  52374. import { Scene } from "babylonjs/scene";
  52375. /**
  52376. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52377. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52378. */
  52379. export class BoneAxesViewer extends AxesViewer {
  52380. /**
  52381. * Gets or sets the target mesh where to display the axes viewer
  52382. */
  52383. mesh: Nullable<Mesh>;
  52384. /**
  52385. * Gets or sets the target bone where to display the axes viewer
  52386. */
  52387. bone: Nullable<Bone>;
  52388. /** Gets current position */
  52389. pos: Vector3;
  52390. /** Gets direction of X axis */
  52391. xaxis: Vector3;
  52392. /** Gets direction of Y axis */
  52393. yaxis: Vector3;
  52394. /** Gets direction of Z axis */
  52395. zaxis: Vector3;
  52396. /**
  52397. * Creates a new BoneAxesViewer
  52398. * @param scene defines the hosting scene
  52399. * @param bone defines the target bone
  52400. * @param mesh defines the target mesh
  52401. * @param scaleLines defines a scaling factor for line length (1 by default)
  52402. */
  52403. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52404. /**
  52405. * Force the viewer to update
  52406. */
  52407. update(): void;
  52408. /** Releases resources */
  52409. dispose(): void;
  52410. }
  52411. }
  52412. declare module "babylonjs/Debug/debugLayer" {
  52413. import { Scene } from "babylonjs/scene";
  52414. /**
  52415. * Interface used to define scene explorer extensibility option
  52416. */
  52417. export interface IExplorerExtensibilityOption {
  52418. /**
  52419. * Define the option label
  52420. */
  52421. label: string;
  52422. /**
  52423. * Defines the action to execute on click
  52424. */
  52425. action: (entity: any) => void;
  52426. }
  52427. /**
  52428. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52429. */
  52430. export interface IExplorerExtensibilityGroup {
  52431. /**
  52432. * Defines a predicate to test if a given type mut be extended
  52433. */
  52434. predicate: (entity: any) => boolean;
  52435. /**
  52436. * Gets the list of options added to a type
  52437. */
  52438. entries: IExplorerExtensibilityOption[];
  52439. }
  52440. /**
  52441. * Interface used to define the options to use to create the Inspector
  52442. */
  52443. export interface IInspectorOptions {
  52444. /**
  52445. * Display in overlay mode (default: false)
  52446. */
  52447. overlay?: boolean;
  52448. /**
  52449. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52450. */
  52451. globalRoot?: HTMLElement;
  52452. /**
  52453. * Display the Scene explorer
  52454. */
  52455. showExplorer?: boolean;
  52456. /**
  52457. * Display the property inspector
  52458. */
  52459. showInspector?: boolean;
  52460. /**
  52461. * Display in embed mode (both panes on the right)
  52462. */
  52463. embedMode?: boolean;
  52464. /**
  52465. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52466. */
  52467. handleResize?: boolean;
  52468. /**
  52469. * Allow the panes to popup (default: true)
  52470. */
  52471. enablePopup?: boolean;
  52472. /**
  52473. * Allow the panes to be closed by users (default: true)
  52474. */
  52475. enableClose?: boolean;
  52476. /**
  52477. * Optional list of extensibility entries
  52478. */
  52479. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52480. /**
  52481. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52482. */
  52483. inspectorURL?: string;
  52484. /**
  52485. * Optional initial tab (default to DebugLayerTab.Properties)
  52486. */
  52487. initialTab?: DebugLayerTab;
  52488. }
  52489. module "babylonjs/scene" {
  52490. interface Scene {
  52491. /**
  52492. * @hidden
  52493. * Backing field
  52494. */
  52495. _debugLayer: DebugLayer;
  52496. /**
  52497. * Gets the debug layer (aka Inspector) associated with the scene
  52498. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52499. */
  52500. debugLayer: DebugLayer;
  52501. }
  52502. }
  52503. /**
  52504. * Enum of inspector action tab
  52505. */
  52506. export enum DebugLayerTab {
  52507. /**
  52508. * Properties tag (default)
  52509. */
  52510. Properties = 0,
  52511. /**
  52512. * Debug tab
  52513. */
  52514. Debug = 1,
  52515. /**
  52516. * Statistics tab
  52517. */
  52518. Statistics = 2,
  52519. /**
  52520. * Tools tab
  52521. */
  52522. Tools = 3,
  52523. /**
  52524. * Settings tab
  52525. */
  52526. Settings = 4
  52527. }
  52528. /**
  52529. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52530. * what is happening in your scene
  52531. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52532. */
  52533. export class DebugLayer {
  52534. /**
  52535. * Define the url to get the inspector script from.
  52536. * By default it uses the babylonjs CDN.
  52537. * @ignoreNaming
  52538. */
  52539. static InspectorURL: string;
  52540. private _scene;
  52541. private BJSINSPECTOR;
  52542. private _onPropertyChangedObservable?;
  52543. /**
  52544. * Observable triggered when a property is changed through the inspector.
  52545. */
  52546. get onPropertyChangedObservable(): any;
  52547. /**
  52548. * Instantiates a new debug layer.
  52549. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52550. * what is happening in your scene
  52551. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52552. * @param scene Defines the scene to inspect
  52553. */
  52554. constructor(scene: Scene);
  52555. /** Creates the inspector window. */
  52556. private _createInspector;
  52557. /**
  52558. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52559. * @param entity defines the entity to select
  52560. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52561. */
  52562. select(entity: any, lineContainerTitles?: string | string[]): void;
  52563. /** Get the inspector from bundle or global */
  52564. private _getGlobalInspector;
  52565. /**
  52566. * Get if the inspector is visible or not.
  52567. * @returns true if visible otherwise, false
  52568. */
  52569. isVisible(): boolean;
  52570. /**
  52571. * Hide the inspector and close its window.
  52572. */
  52573. hide(): void;
  52574. /**
  52575. * Update the scene in the inspector
  52576. */
  52577. setAsActiveScene(): void;
  52578. /**
  52579. * Launch the debugLayer.
  52580. * @param config Define the configuration of the inspector
  52581. * @return a promise fulfilled when the debug layer is visible
  52582. */
  52583. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52584. }
  52585. }
  52586. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52587. import { Nullable } from "babylonjs/types";
  52588. import { Scene } from "babylonjs/scene";
  52589. import { Vector4 } from "babylonjs/Maths/math.vector";
  52590. import { Color4 } from "babylonjs/Maths/math.color";
  52591. import { Mesh } from "babylonjs/Meshes/mesh";
  52592. /**
  52593. * Class containing static functions to help procedurally build meshes
  52594. */
  52595. export class BoxBuilder {
  52596. /**
  52597. * Creates a box mesh
  52598. * * The parameter `size` sets the size (float) of each box side (default 1)
  52599. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52600. * * 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)
  52601. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52605. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52606. * @param name defines the name of the mesh
  52607. * @param options defines the options used to create the mesh
  52608. * @param scene defines the hosting scene
  52609. * @returns the box mesh
  52610. */
  52611. static CreateBox(name: string, options: {
  52612. size?: number;
  52613. width?: number;
  52614. height?: number;
  52615. depth?: number;
  52616. faceUV?: Vector4[];
  52617. faceColors?: Color4[];
  52618. sideOrientation?: number;
  52619. frontUVs?: Vector4;
  52620. backUVs?: Vector4;
  52621. wrap?: boolean;
  52622. topBaseAt?: number;
  52623. bottomBaseAt?: number;
  52624. updatable?: boolean;
  52625. }, scene?: Nullable<Scene>): Mesh;
  52626. }
  52627. }
  52628. declare module "babylonjs/Debug/physicsViewer" {
  52629. import { Nullable } from "babylonjs/types";
  52630. import { Scene } from "babylonjs/scene";
  52631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52632. import { Mesh } from "babylonjs/Meshes/mesh";
  52633. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52634. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52635. /**
  52636. * Used to show the physics impostor around the specific mesh
  52637. */
  52638. export class PhysicsViewer {
  52639. /** @hidden */
  52640. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  52641. /** @hidden */
  52642. protected _meshes: Array<Nullable<AbstractMesh>>;
  52643. /** @hidden */
  52644. protected _scene: Nullable<Scene>;
  52645. /** @hidden */
  52646. protected _numMeshes: number;
  52647. /** @hidden */
  52648. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  52649. private _renderFunction;
  52650. private _utilityLayer;
  52651. private _debugBoxMesh;
  52652. private _debugSphereMesh;
  52653. private _debugCylinderMesh;
  52654. private _debugMaterial;
  52655. private _debugMeshMeshes;
  52656. /**
  52657. * Creates a new PhysicsViewer
  52658. * @param scene defines the hosting scene
  52659. */
  52660. constructor(scene: Scene);
  52661. /** @hidden */
  52662. protected _updateDebugMeshes(): void;
  52663. /**
  52664. * Renders a specified physic impostor
  52665. * @param impostor defines the impostor to render
  52666. * @param targetMesh defines the mesh represented by the impostor
  52667. * @returns the new debug mesh used to render the impostor
  52668. */
  52669. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  52670. /**
  52671. * Hides a specified physic impostor
  52672. * @param impostor defines the impostor to hide
  52673. */
  52674. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  52675. private _getDebugMaterial;
  52676. private _getDebugBoxMesh;
  52677. private _getDebugSphereMesh;
  52678. private _getDebugCylinderMesh;
  52679. private _getDebugMeshMesh;
  52680. private _getDebugMesh;
  52681. /** Releases all resources */
  52682. dispose(): void;
  52683. }
  52684. }
  52685. declare module "babylonjs/Debug/rayHelper" {
  52686. import { Nullable } from "babylonjs/types";
  52687. import { Ray } from "babylonjs/Culling/ray";
  52688. import { Vector3 } from "babylonjs/Maths/math.vector";
  52689. import { Color3 } from "babylonjs/Maths/math.color";
  52690. import { Scene } from "babylonjs/scene";
  52691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52692. import "babylonjs/Meshes/Builders/linesBuilder";
  52693. /**
  52694. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52695. * in order to better appreciate the issue one might have.
  52696. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52697. */
  52698. export class RayHelper {
  52699. /**
  52700. * Defines the ray we are currently tryin to visualize.
  52701. */
  52702. ray: Nullable<Ray>;
  52703. private _renderPoints;
  52704. private _renderLine;
  52705. private _renderFunction;
  52706. private _scene;
  52707. private _updateToMeshFunction;
  52708. private _attachedToMesh;
  52709. private _meshSpaceDirection;
  52710. private _meshSpaceOrigin;
  52711. /**
  52712. * Helper function to create a colored helper in a scene in one line.
  52713. * @param ray Defines the ray we are currently tryin to visualize
  52714. * @param scene Defines the scene the ray is used in
  52715. * @param color Defines the color we want to see the ray in
  52716. * @returns The newly created ray helper.
  52717. */
  52718. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  52719. /**
  52720. * Instantiate a new ray helper.
  52721. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52722. * in order to better appreciate the issue one might have.
  52723. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52724. * @param ray Defines the ray we are currently tryin to visualize
  52725. */
  52726. constructor(ray: Ray);
  52727. /**
  52728. * Shows the ray we are willing to debug.
  52729. * @param scene Defines the scene the ray needs to be rendered in
  52730. * @param color Defines the color the ray needs to be rendered in
  52731. */
  52732. show(scene: Scene, color?: Color3): void;
  52733. /**
  52734. * Hides the ray we are debugging.
  52735. */
  52736. hide(): void;
  52737. private _render;
  52738. /**
  52739. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  52740. * @param mesh Defines the mesh we want the helper attached to
  52741. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  52742. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  52743. * @param length Defines the length of the ray
  52744. */
  52745. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  52746. /**
  52747. * Detach the ray helper from the mesh it has previously been attached to.
  52748. */
  52749. detachFromMesh(): void;
  52750. private _updateToMesh;
  52751. /**
  52752. * Dispose the helper and release its associated resources.
  52753. */
  52754. dispose(): void;
  52755. }
  52756. }
  52757. declare module "babylonjs/Debug/skeletonViewer" {
  52758. import { Color3 } from "babylonjs/Maths/math.color";
  52759. import { Scene } from "babylonjs/scene";
  52760. import { Nullable } from "babylonjs/types";
  52761. import { Skeleton } from "babylonjs/Bones/skeleton";
  52762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52763. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52764. /**
  52765. * Class used to render a debug view of a given skeleton
  52766. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  52767. */
  52768. export class SkeletonViewer {
  52769. /** defines the skeleton to render */
  52770. skeleton: Skeleton;
  52771. /** defines the mesh attached to the skeleton */
  52772. mesh: AbstractMesh;
  52773. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52774. autoUpdateBonesMatrices: boolean;
  52775. /** defines the rendering group id to use with the viewer */
  52776. renderingGroupId: number;
  52777. /** Gets or sets the color used to render the skeleton */
  52778. color: Color3;
  52779. private _scene;
  52780. private _debugLines;
  52781. private _debugMesh;
  52782. private _isEnabled;
  52783. private _renderFunction;
  52784. private _utilityLayer;
  52785. /**
  52786. * Returns the mesh used to render the bones
  52787. */
  52788. get debugMesh(): Nullable<LinesMesh>;
  52789. /**
  52790. * Creates a new SkeletonViewer
  52791. * @param skeleton defines the skeleton to render
  52792. * @param mesh defines the mesh attached to the skeleton
  52793. * @param scene defines the hosting scene
  52794. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  52795. * @param renderingGroupId defines the rendering group id to use with the viewer
  52796. */
  52797. constructor(
  52798. /** defines the skeleton to render */
  52799. skeleton: Skeleton,
  52800. /** defines the mesh attached to the skeleton */
  52801. mesh: AbstractMesh, scene: Scene,
  52802. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52803. autoUpdateBonesMatrices?: boolean,
  52804. /** defines the rendering group id to use with the viewer */
  52805. renderingGroupId?: number);
  52806. /** Gets or sets a boolean indicating if the viewer is enabled */
  52807. set isEnabled(value: boolean);
  52808. get isEnabled(): boolean;
  52809. private _getBonePosition;
  52810. private _getLinesForBonesWithLength;
  52811. private _getLinesForBonesNoLength;
  52812. /** Update the viewer to sync with current skeleton state */
  52813. update(): void;
  52814. /** Release associated resources */
  52815. dispose(): void;
  52816. }
  52817. }
  52818. declare module "babylonjs/Debug/index" {
  52819. export * from "babylonjs/Debug/axesViewer";
  52820. export * from "babylonjs/Debug/boneAxesViewer";
  52821. export * from "babylonjs/Debug/debugLayer";
  52822. export * from "babylonjs/Debug/physicsViewer";
  52823. export * from "babylonjs/Debug/rayHelper";
  52824. export * from "babylonjs/Debug/skeletonViewer";
  52825. }
  52826. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  52827. /**
  52828. * Enum for Device Types
  52829. */
  52830. export enum DeviceType {
  52831. /** Generic */
  52832. Generic = 0,
  52833. /** Keyboard */
  52834. Keyboard = 1,
  52835. /** Mouse */
  52836. Mouse = 2,
  52837. /** Touch Pointers */
  52838. Touch = 3,
  52839. /** PS4 Dual Shock */
  52840. DualShock = 4,
  52841. /** Xbox */
  52842. Xbox = 5,
  52843. /** Switch Controller */
  52844. Switch = 6
  52845. }
  52846. /**
  52847. * Enum for All Pointers (Touch/Mouse)
  52848. */
  52849. export enum PointerInput {
  52850. /** Horizontal Axis */
  52851. Horizontal = 0,
  52852. /** Vertical Axis */
  52853. Vertical = 1,
  52854. /** Left Click or Touch */
  52855. LeftClick = 2,
  52856. /** Middle Click */
  52857. MiddleClick = 3,
  52858. /** Right Click */
  52859. RightClick = 4,
  52860. /** Browser Back */
  52861. BrowserBack = 5,
  52862. /** Browser Forward */
  52863. BrowserForward = 6
  52864. }
  52865. /**
  52866. * Enum for Dual Shock Gamepad
  52867. */
  52868. export enum DualShockInput {
  52869. /** Cross */
  52870. Cross = 0,
  52871. /** Circle */
  52872. Circle = 1,
  52873. /** Square */
  52874. Square = 2,
  52875. /** Triangle */
  52876. Triangle = 3,
  52877. /** L1 */
  52878. L1 = 4,
  52879. /** R1 */
  52880. R1 = 5,
  52881. /** L2 */
  52882. L2 = 6,
  52883. /** R2 */
  52884. R2 = 7,
  52885. /** Share */
  52886. Share = 8,
  52887. /** Options */
  52888. Options = 9,
  52889. /** L3 */
  52890. L3 = 10,
  52891. /** R3 */
  52892. R3 = 11,
  52893. /** DPadUp */
  52894. DPadUp = 12,
  52895. /** DPadDown */
  52896. DPadDown = 13,
  52897. /** DPadLeft */
  52898. DPadLeft = 14,
  52899. /** DRight */
  52900. DPadRight = 15,
  52901. /** Home */
  52902. Home = 16,
  52903. /** TouchPad */
  52904. TouchPad = 17,
  52905. /** LStickXAxis */
  52906. LStickXAxis = 18,
  52907. /** LStickYAxis */
  52908. LStickYAxis = 19,
  52909. /** RStickXAxis */
  52910. RStickXAxis = 20,
  52911. /** RStickYAxis */
  52912. RStickYAxis = 21
  52913. }
  52914. /**
  52915. * Enum for Xbox Gamepad
  52916. */
  52917. export enum XboxInput {
  52918. /** A */
  52919. A = 0,
  52920. /** B */
  52921. B = 1,
  52922. /** X */
  52923. X = 2,
  52924. /** Y */
  52925. Y = 3,
  52926. /** LB */
  52927. LB = 4,
  52928. /** RB */
  52929. RB = 5,
  52930. /** LT */
  52931. LT = 6,
  52932. /** RT */
  52933. RT = 7,
  52934. /** Back */
  52935. Back = 8,
  52936. /** Start */
  52937. Start = 9,
  52938. /** LS */
  52939. LS = 10,
  52940. /** RS */
  52941. RS = 11,
  52942. /** DPadUp */
  52943. DPadUp = 12,
  52944. /** DPadDown */
  52945. DPadDown = 13,
  52946. /** DPadLeft */
  52947. DPadLeft = 14,
  52948. /** DRight */
  52949. DPadRight = 15,
  52950. /** Home */
  52951. Home = 16,
  52952. /** LStickXAxis */
  52953. LStickXAxis = 17,
  52954. /** LStickYAxis */
  52955. LStickYAxis = 18,
  52956. /** RStickXAxis */
  52957. RStickXAxis = 19,
  52958. /** RStickYAxis */
  52959. RStickYAxis = 20
  52960. }
  52961. /**
  52962. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  52963. */
  52964. export enum SwitchInput {
  52965. /** B */
  52966. B = 0,
  52967. /** A */
  52968. A = 1,
  52969. /** Y */
  52970. Y = 2,
  52971. /** X */
  52972. X = 3,
  52973. /** L */
  52974. L = 4,
  52975. /** R */
  52976. R = 5,
  52977. /** ZL */
  52978. ZL = 6,
  52979. /** ZR */
  52980. ZR = 7,
  52981. /** Minus */
  52982. Minus = 8,
  52983. /** Plus */
  52984. Plus = 9,
  52985. /** LS */
  52986. LS = 10,
  52987. /** RS */
  52988. RS = 11,
  52989. /** DPadUp */
  52990. DPadUp = 12,
  52991. /** DPadDown */
  52992. DPadDown = 13,
  52993. /** DPadLeft */
  52994. DPadLeft = 14,
  52995. /** DRight */
  52996. DPadRight = 15,
  52997. /** Home */
  52998. Home = 16,
  52999. /** Capture */
  53000. Capture = 17,
  53001. /** LStickXAxis */
  53002. LStickXAxis = 18,
  53003. /** LStickYAxis */
  53004. LStickYAxis = 19,
  53005. /** RStickXAxis */
  53006. RStickXAxis = 20,
  53007. /** RStickYAxis */
  53008. RStickYAxis = 21
  53009. }
  53010. }
  53011. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53012. import { Engine } from "babylonjs/Engines/engine";
  53013. import { IDisposable } from "babylonjs/scene";
  53014. import { Nullable } from "babylonjs/types";
  53015. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53016. /**
  53017. * This class will take all inputs from Keyboard, Pointer, and
  53018. * any Gamepads and provide a polling system that all devices
  53019. * will use. This class assumes that there will only be one
  53020. * pointer device and one keyboard.
  53021. */
  53022. export class DeviceInputSystem implements IDisposable {
  53023. /**
  53024. * Callback to be triggered when a device is connected
  53025. */
  53026. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53027. /**
  53028. * Callback to be triggered when a device is disconnected
  53029. */
  53030. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53031. /**
  53032. * Callback to be triggered when event driven input is updated
  53033. */
  53034. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53035. private _inputs;
  53036. private _gamepads;
  53037. private _keyboardActive;
  53038. private _pointerActive;
  53039. private _elementToAttachTo;
  53040. private _keyboardDownEvent;
  53041. private _keyboardUpEvent;
  53042. private _pointerMoveEvent;
  53043. private _pointerDownEvent;
  53044. private _pointerUpEvent;
  53045. private _gamepadConnectedEvent;
  53046. private _gamepadDisconnectedEvent;
  53047. private static _MAX_KEYCODES;
  53048. private static _MAX_POINTER_INPUTS;
  53049. private constructor();
  53050. /**
  53051. * Creates a new DeviceInputSystem instance
  53052. * @param engine Engine to pull input element from
  53053. * @returns The new instance
  53054. */
  53055. static Create(engine: Engine): DeviceInputSystem;
  53056. /**
  53057. * Checks for current device input value, given an id and input index
  53058. * @param deviceName Id of connected device
  53059. * @param inputIndex Index of device input
  53060. * @returns Current value of input
  53061. */
  53062. /**
  53063. * Checks for current device input value, given an id and input index
  53064. * @param deviceType Enum specifiying device type
  53065. * @param deviceSlot "Slot" or index that device is referenced in
  53066. * @param inputIndex Id of input to be checked
  53067. * @returns Current value of input
  53068. */
  53069. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  53070. /**
  53071. * Dispose of all the eventlisteners
  53072. */
  53073. dispose(): void;
  53074. /**
  53075. * Add device and inputs to device array
  53076. * @param deviceType Enum specifiying device type
  53077. * @param deviceSlot "Slot" or index that device is referenced in
  53078. * @param numberOfInputs Number of input entries to create for given device
  53079. */
  53080. private _registerDevice;
  53081. /**
  53082. * Given a specific device name, remove that device from the device map
  53083. * @param deviceType Enum specifiying device type
  53084. * @param deviceSlot "Slot" or index that device is referenced in
  53085. */
  53086. private _unregisterDevice;
  53087. /**
  53088. * Handle all actions that come from keyboard interaction
  53089. */
  53090. private _handleKeyActions;
  53091. /**
  53092. * Handle all actions that come from pointer interaction
  53093. */
  53094. private _handlePointerActions;
  53095. /**
  53096. * Handle all actions that come from gamepad interaction
  53097. */
  53098. private _handleGamepadActions;
  53099. /**
  53100. * Update all non-event based devices with each frame
  53101. * @param deviceType Enum specifiying device type
  53102. * @param deviceSlot "Slot" or index that device is referenced in
  53103. * @param inputIndex Id of input to be checked
  53104. */
  53105. private _updateDevice;
  53106. /**
  53107. * Gets DeviceType from the device name
  53108. * @param deviceName Name of Device from DeviceInputSystem
  53109. * @returns DeviceType enum value
  53110. */
  53111. private _getGamepadDeviceType;
  53112. }
  53113. }
  53114. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53115. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53116. /**
  53117. * Type to handle enforcement of inputs
  53118. */
  53119. 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;
  53120. }
  53121. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53122. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53123. import { Engine } from "babylonjs/Engines/engine";
  53124. import { IDisposable } from "babylonjs/scene";
  53125. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53126. import { Nullable } from "babylonjs/types";
  53127. import { Observable } from "babylonjs/Misc/observable";
  53128. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53129. /**
  53130. * Class that handles all input for a specific device
  53131. */
  53132. export class DeviceSource<T extends DeviceType> {
  53133. /** Type of device */
  53134. readonly deviceType: DeviceType;
  53135. /** "Slot" or index that device is referenced in */
  53136. readonly deviceSlot: number;
  53137. /**
  53138. * Observable to handle device input changes per device
  53139. */
  53140. readonly onInputChangedObservable: Observable<{
  53141. inputIndex: DeviceInput<T>;
  53142. previousState: Nullable<number>;
  53143. currentState: Nullable<number>;
  53144. }>;
  53145. private readonly _deviceInputSystem;
  53146. /**
  53147. * Default Constructor
  53148. * @param deviceInputSystem Reference to DeviceInputSystem
  53149. * @param deviceType Type of device
  53150. * @param deviceSlot "Slot" or index that device is referenced in
  53151. */
  53152. constructor(deviceInputSystem: DeviceInputSystem,
  53153. /** Type of device */
  53154. deviceType: DeviceType,
  53155. /** "Slot" or index that device is referenced in */
  53156. deviceSlot?: number);
  53157. /**
  53158. * Get input for specific input
  53159. * @param inputIndex index of specific input on device
  53160. * @returns Input value from DeviceInputSystem
  53161. */
  53162. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  53163. }
  53164. /**
  53165. * Class to keep track of devices
  53166. */
  53167. export class DeviceSourceManager implements IDisposable {
  53168. /**
  53169. * Observable to be triggered when before a device is connected
  53170. */
  53171. readonly onBeforeDeviceConnectedObservable: Observable<{
  53172. deviceType: DeviceType;
  53173. deviceSlot: number;
  53174. }>;
  53175. /**
  53176. * Observable to be triggered when before a device is disconnected
  53177. */
  53178. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53179. deviceType: DeviceType;
  53180. deviceSlot: number;
  53181. }>;
  53182. /**
  53183. * Observable to be triggered when after a device is connected
  53184. */
  53185. readonly onAfterDeviceConnectedObservable: Observable<{
  53186. deviceType: DeviceType;
  53187. deviceSlot: number;
  53188. }>;
  53189. /**
  53190. * Observable to be triggered when after a device is disconnected
  53191. */
  53192. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53193. deviceType: DeviceType;
  53194. deviceSlot: number;
  53195. }>;
  53196. private readonly _devices;
  53197. private readonly _firstDevice;
  53198. private readonly _deviceInputSystem;
  53199. /**
  53200. * Default Constructor
  53201. * @param engine engine to pull input element from
  53202. */
  53203. constructor(engine: Engine);
  53204. /**
  53205. * Gets a DeviceSource, given a type and slot
  53206. * @param deviceType Enum specifying device type
  53207. * @param deviceSlot "Slot" or index that device is referenced in
  53208. * @returns DeviceSource object
  53209. */
  53210. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53211. /**
  53212. * Gets an array of DeviceSource objects for a given device type
  53213. * @param deviceType Enum specifying device type
  53214. * @returns Array of DeviceSource objects
  53215. */
  53216. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53217. /**
  53218. * Dispose of DeviceInputSystem and other parts
  53219. */
  53220. dispose(): void;
  53221. /**
  53222. * Function to add device name to device list
  53223. * @param deviceType Enum specifying device type
  53224. * @param deviceSlot "Slot" or index that device is referenced in
  53225. */
  53226. private _addDevice;
  53227. /**
  53228. * Function to remove device name to device list
  53229. * @param deviceType Enum specifying device type
  53230. * @param deviceSlot "Slot" or index that device is referenced in
  53231. */
  53232. private _removeDevice;
  53233. /**
  53234. * Updates array storing first connected device of each type
  53235. * @param type Type of Device
  53236. */
  53237. private _updateFirstDevices;
  53238. }
  53239. }
  53240. declare module "babylonjs/DeviceInput/index" {
  53241. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53242. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53243. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53244. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53245. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53246. }
  53247. declare module "babylonjs/Engines/nullEngine" {
  53248. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53249. import { Engine } from "babylonjs/Engines/engine";
  53250. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53251. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53252. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53253. import { Effect } from "babylonjs/Materials/effect";
  53254. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53255. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53256. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53257. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53258. /**
  53259. * Options to create the null engine
  53260. */
  53261. export class NullEngineOptions {
  53262. /**
  53263. * Render width (Default: 512)
  53264. */
  53265. renderWidth: number;
  53266. /**
  53267. * Render height (Default: 256)
  53268. */
  53269. renderHeight: number;
  53270. /**
  53271. * Texture size (Default: 512)
  53272. */
  53273. textureSize: number;
  53274. /**
  53275. * If delta time between frames should be constant
  53276. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53277. */
  53278. deterministicLockstep: boolean;
  53279. /**
  53280. * Maximum about of steps between frames (Default: 4)
  53281. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53282. */
  53283. lockstepMaxSteps: number;
  53284. /**
  53285. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  53286. */
  53287. useHighPrecisionMatrix?: boolean;
  53288. }
  53289. /**
  53290. * The null engine class provides support for headless version of babylon.js.
  53291. * This can be used in server side scenario or for testing purposes
  53292. */
  53293. export class NullEngine extends Engine {
  53294. private _options;
  53295. /**
  53296. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  53297. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53298. * @returns true if engine is in deterministic lock step mode
  53299. */
  53300. isDeterministicLockStep(): boolean;
  53301. /**
  53302. * Gets the max steps when engine is running in deterministic lock step
  53303. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53304. * @returns the max steps
  53305. */
  53306. getLockstepMaxSteps(): number;
  53307. /**
  53308. * Gets the current hardware scaling level.
  53309. * By default the hardware scaling level is computed from the window device ratio.
  53310. * 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.
  53311. * @returns a number indicating the current hardware scaling level
  53312. */
  53313. getHardwareScalingLevel(): number;
  53314. constructor(options?: NullEngineOptions);
  53315. /**
  53316. * Creates a vertex buffer
  53317. * @param vertices the data for the vertex buffer
  53318. * @returns the new WebGL static buffer
  53319. */
  53320. createVertexBuffer(vertices: FloatArray): DataBuffer;
  53321. /**
  53322. * Creates a new index buffer
  53323. * @param indices defines the content of the index buffer
  53324. * @param updatable defines if the index buffer must be updatable
  53325. * @returns a new webGL buffer
  53326. */
  53327. createIndexBuffer(indices: IndicesArray): DataBuffer;
  53328. /**
  53329. * Clear the current render buffer or the current render target (if any is set up)
  53330. * @param color defines the color to use
  53331. * @param backBuffer defines if the back buffer must be cleared
  53332. * @param depth defines if the depth buffer must be cleared
  53333. * @param stencil defines if the stencil buffer must be cleared
  53334. */
  53335. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53336. /**
  53337. * Gets the current render width
  53338. * @param useScreen defines if screen size must be used (or the current render target if any)
  53339. * @returns a number defining the current render width
  53340. */
  53341. getRenderWidth(useScreen?: boolean): number;
  53342. /**
  53343. * Gets the current render height
  53344. * @param useScreen defines if screen size must be used (or the current render target if any)
  53345. * @returns a number defining the current render height
  53346. */
  53347. getRenderHeight(useScreen?: boolean): number;
  53348. /**
  53349. * Set the WebGL's viewport
  53350. * @param viewport defines the viewport element to be used
  53351. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  53352. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  53353. */
  53354. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  53355. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  53356. /**
  53357. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  53358. * @param pipelineContext defines the pipeline context to use
  53359. * @param uniformsNames defines the list of uniform names
  53360. * @returns an array of webGL uniform locations
  53361. */
  53362. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  53363. /**
  53364. * Gets the lsit of active attributes for a given webGL program
  53365. * @param pipelineContext defines the pipeline context to use
  53366. * @param attributesNames defines the list of attribute names to get
  53367. * @returns an array of indices indicating the offset of each attribute
  53368. */
  53369. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53370. /**
  53371. * Binds an effect to the webGL context
  53372. * @param effect defines the effect to bind
  53373. */
  53374. bindSamplers(effect: Effect): void;
  53375. /**
  53376. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  53377. * @param effect defines the effect to activate
  53378. */
  53379. enableEffect(effect: Effect): void;
  53380. /**
  53381. * Set various states to the webGL context
  53382. * @param culling defines backface culling state
  53383. * @param zOffset defines the value to apply to zOffset (0 by default)
  53384. * @param force defines if states must be applied even if cache is up to date
  53385. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  53386. */
  53387. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53388. /**
  53389. * Set the value of an uniform to an array of int32
  53390. * @param uniform defines the webGL uniform location where to store the value
  53391. * @param array defines the array of int32 to store
  53392. */
  53393. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53394. /**
  53395. * Set the value of an uniform to an array of int32 (stored as vec2)
  53396. * @param uniform defines the webGL uniform location where to store the value
  53397. * @param array defines the array of int32 to store
  53398. */
  53399. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53400. /**
  53401. * Set the value of an uniform to an array of int32 (stored as vec3)
  53402. * @param uniform defines the webGL uniform location where to store the value
  53403. * @param array defines the array of int32 to store
  53404. */
  53405. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53406. /**
  53407. * Set the value of an uniform to an array of int32 (stored as vec4)
  53408. * @param uniform defines the webGL uniform location where to store the value
  53409. * @param array defines the array of int32 to store
  53410. */
  53411. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53412. /**
  53413. * Set the value of an uniform to an array of float32
  53414. * @param uniform defines the webGL uniform location where to store the value
  53415. * @param array defines the array of float32 to store
  53416. */
  53417. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53418. /**
  53419. * Set the value of an uniform to an array of float32 (stored as vec2)
  53420. * @param uniform defines the webGL uniform location where to store the value
  53421. * @param array defines the array of float32 to store
  53422. */
  53423. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53424. /**
  53425. * Set the value of an uniform to an array of float32 (stored as vec3)
  53426. * @param uniform defines the webGL uniform location where to store the value
  53427. * @param array defines the array of float32 to store
  53428. */
  53429. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53430. /**
  53431. * Set the value of an uniform to an array of float32 (stored as vec4)
  53432. * @param uniform defines the webGL uniform location where to store the value
  53433. * @param array defines the array of float32 to store
  53434. */
  53435. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53436. /**
  53437. * Set the value of an uniform to an array of number
  53438. * @param uniform defines the webGL uniform location where to store the value
  53439. * @param array defines the array of number to store
  53440. */
  53441. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53442. /**
  53443. * Set the value of an uniform to an array of number (stored as vec2)
  53444. * @param uniform defines the webGL uniform location where to store the value
  53445. * @param array defines the array of number to store
  53446. */
  53447. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53448. /**
  53449. * Set the value of an uniform to an array of number (stored as vec3)
  53450. * @param uniform defines the webGL uniform location where to store the value
  53451. * @param array defines the array of number to store
  53452. */
  53453. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53454. /**
  53455. * Set the value of an uniform to an array of number (stored as vec4)
  53456. * @param uniform defines the webGL uniform location where to store the value
  53457. * @param array defines the array of number to store
  53458. */
  53459. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53460. /**
  53461. * Set the value of an uniform to an array of float32 (stored as matrices)
  53462. * @param uniform defines the webGL uniform location where to store the value
  53463. * @param matrices defines the array of float32 to store
  53464. */
  53465. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53466. /**
  53467. * Set the value of an uniform to a matrix (3x3)
  53468. * @param uniform defines the webGL uniform location where to store the value
  53469. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  53470. */
  53471. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53472. /**
  53473. * Set the value of an uniform to a matrix (2x2)
  53474. * @param uniform defines the webGL uniform location where to store the value
  53475. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  53476. */
  53477. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53478. /**
  53479. * Set the value of an uniform to a number (float)
  53480. * @param uniform defines the webGL uniform location where to store the value
  53481. * @param value defines the float number to store
  53482. */
  53483. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53484. /**
  53485. * Set the value of an uniform to a vec2
  53486. * @param uniform defines the webGL uniform location where to store the value
  53487. * @param x defines the 1st component of the value
  53488. * @param y defines the 2nd component of the value
  53489. */
  53490. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53491. /**
  53492. * Set the value of an uniform to a vec3
  53493. * @param uniform defines the webGL uniform location where to store the value
  53494. * @param x defines the 1st component of the value
  53495. * @param y defines the 2nd component of the value
  53496. * @param z defines the 3rd component of the value
  53497. */
  53498. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53499. /**
  53500. * Set the value of an uniform to a boolean
  53501. * @param uniform defines the webGL uniform location where to store the value
  53502. * @param bool defines the boolean to store
  53503. */
  53504. setBool(uniform: WebGLUniformLocation, bool: number): void;
  53505. /**
  53506. * Set the value of an uniform to a vec4
  53507. * @param uniform defines the webGL uniform location where to store the value
  53508. * @param x defines the 1st component of the value
  53509. * @param y defines the 2nd component of the value
  53510. * @param z defines the 3rd component of the value
  53511. * @param w defines the 4th component of the value
  53512. */
  53513. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53514. /**
  53515. * Sets the current alpha mode
  53516. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  53517. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53518. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53519. */
  53520. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53521. /**
  53522. * Bind webGl buffers directly to the webGL context
  53523. * @param vertexBuffers defines the vertex buffer to bind
  53524. * @param indexBuffer defines the index buffer to bind
  53525. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  53526. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  53527. * @param effect defines the effect associated with the vertex buffer
  53528. */
  53529. bindBuffers(vertexBuffers: {
  53530. [key: string]: VertexBuffer;
  53531. }, indexBuffer: DataBuffer, effect: Effect): void;
  53532. /**
  53533. * Force the entire cache to be cleared
  53534. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  53535. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  53536. */
  53537. wipeCaches(bruteForce?: boolean): void;
  53538. /**
  53539. * Send a draw order
  53540. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  53541. * @param indexStart defines the starting index
  53542. * @param indexCount defines the number of index to draw
  53543. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53544. */
  53545. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  53546. /**
  53547. * Draw a list of indexed primitives
  53548. * @param fillMode defines the primitive to use
  53549. * @param indexStart defines the starting index
  53550. * @param indexCount defines the number of index to draw
  53551. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53552. */
  53553. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53554. /**
  53555. * Draw a list of unindexed primitives
  53556. * @param fillMode defines the primitive to use
  53557. * @param verticesStart defines the index of first vertex to draw
  53558. * @param verticesCount defines the count of vertices to draw
  53559. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53560. */
  53561. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53562. /** @hidden */
  53563. _createTexture(): WebGLTexture;
  53564. /** @hidden */
  53565. _releaseTexture(texture: InternalTexture): void;
  53566. /**
  53567. * Usually called from Texture.ts.
  53568. * Passed information to create a WebGLTexture
  53569. * @param urlArg defines a value which contains one of the following:
  53570. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53571. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53572. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53573. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53574. * @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)
  53575. * @param scene needed for loading to the correct scene
  53576. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53577. * @param onLoad optional callback to be called upon successful completion
  53578. * @param onError optional callback to be called upon failure
  53579. * @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
  53580. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53581. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53582. * @param forcedExtension defines the extension to use to pick the right loader
  53583. * @param mimeType defines an optional mime type
  53584. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53585. */
  53586. 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;
  53587. /**
  53588. * Creates a new render target texture
  53589. * @param size defines the size of the texture
  53590. * @param options defines the options used to create the texture
  53591. * @returns a new render target texture stored in an InternalTexture
  53592. */
  53593. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  53594. /**
  53595. * Update the sampling mode of a given texture
  53596. * @param samplingMode defines the required sampling mode
  53597. * @param texture defines the texture to update
  53598. */
  53599. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53600. /**
  53601. * Binds the frame buffer to the specified texture.
  53602. * @param texture The texture to render to or null for the default canvas
  53603. * @param faceIndex The face of the texture to render to in case of cube texture
  53604. * @param requiredWidth The width of the target to render to
  53605. * @param requiredHeight The height of the target to render to
  53606. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  53607. * @param lodLevel defines le lod level to bind to the frame buffer
  53608. */
  53609. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53610. /**
  53611. * Unbind the current render target texture from the webGL context
  53612. * @param texture defines the render target texture to unbind
  53613. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53614. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53615. */
  53616. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53617. /**
  53618. * Creates a dynamic vertex buffer
  53619. * @param vertices the data for the dynamic vertex buffer
  53620. * @returns the new WebGL dynamic buffer
  53621. */
  53622. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  53623. /**
  53624. * Update the content of a dynamic texture
  53625. * @param texture defines the texture to update
  53626. * @param canvas defines the canvas containing the source
  53627. * @param invertY defines if data must be stored with Y axis inverted
  53628. * @param premulAlpha defines if alpha is stored as premultiplied
  53629. * @param format defines the format of the data
  53630. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  53631. */
  53632. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  53633. /**
  53634. * Gets a boolean indicating if all created effects are ready
  53635. * @returns true if all effects are ready
  53636. */
  53637. areAllEffectsReady(): boolean;
  53638. /**
  53639. * @hidden
  53640. * Get the current error code of the webGL context
  53641. * @returns the error code
  53642. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  53643. */
  53644. getError(): number;
  53645. /** @hidden */
  53646. _getUnpackAlignement(): number;
  53647. /** @hidden */
  53648. _unpackFlipY(value: boolean): void;
  53649. /**
  53650. * Update a dynamic index buffer
  53651. * @param indexBuffer defines the target index buffer
  53652. * @param indices defines the data to update
  53653. * @param offset defines the offset in the target index buffer where update should start
  53654. */
  53655. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  53656. /**
  53657. * Updates a dynamic vertex buffer.
  53658. * @param vertexBuffer the vertex buffer to update
  53659. * @param vertices the data used to update the vertex buffer
  53660. * @param byteOffset the byte offset of the data (optional)
  53661. * @param byteLength the byte length of the data (optional)
  53662. */
  53663. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  53664. /** @hidden */
  53665. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  53666. /** @hidden */
  53667. _bindTexture(channel: number, texture: InternalTexture): void;
  53668. protected _deleteBuffer(buffer: WebGLBuffer): void;
  53669. /**
  53670. * 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
  53671. */
  53672. releaseEffects(): void;
  53673. displayLoadingUI(): void;
  53674. hideLoadingUI(): void;
  53675. /** @hidden */
  53676. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53677. /** @hidden */
  53678. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53679. /** @hidden */
  53680. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53681. /** @hidden */
  53682. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53683. }
  53684. }
  53685. declare module "babylonjs/Instrumentation/timeToken" {
  53686. import { Nullable } from "babylonjs/types";
  53687. /**
  53688. * @hidden
  53689. **/
  53690. export class _TimeToken {
  53691. _startTimeQuery: Nullable<WebGLQuery>;
  53692. _endTimeQuery: Nullable<WebGLQuery>;
  53693. _timeElapsedQuery: Nullable<WebGLQuery>;
  53694. _timeElapsedQueryEnded: boolean;
  53695. }
  53696. }
  53697. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  53698. import { Nullable, int } from "babylonjs/types";
  53699. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  53700. /** @hidden */
  53701. export class _OcclusionDataStorage {
  53702. /** @hidden */
  53703. occlusionInternalRetryCounter: number;
  53704. /** @hidden */
  53705. isOcclusionQueryInProgress: boolean;
  53706. /** @hidden */
  53707. isOccluded: boolean;
  53708. /** @hidden */
  53709. occlusionRetryCount: number;
  53710. /** @hidden */
  53711. occlusionType: number;
  53712. /** @hidden */
  53713. occlusionQueryAlgorithmType: number;
  53714. }
  53715. module "babylonjs/Engines/engine" {
  53716. interface Engine {
  53717. /**
  53718. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  53719. * @return the new query
  53720. */
  53721. createQuery(): WebGLQuery;
  53722. /**
  53723. * Delete and release a webGL query
  53724. * @param query defines the query to delete
  53725. * @return the current engine
  53726. */
  53727. deleteQuery(query: WebGLQuery): Engine;
  53728. /**
  53729. * Check if a given query has resolved and got its value
  53730. * @param query defines the query to check
  53731. * @returns true if the query got its value
  53732. */
  53733. isQueryResultAvailable(query: WebGLQuery): boolean;
  53734. /**
  53735. * Gets the value of a given query
  53736. * @param query defines the query to check
  53737. * @returns the value of the query
  53738. */
  53739. getQueryResult(query: WebGLQuery): number;
  53740. /**
  53741. * Initiates an occlusion query
  53742. * @param algorithmType defines the algorithm to use
  53743. * @param query defines the query to use
  53744. * @returns the current engine
  53745. * @see https://doc.babylonjs.com/features/occlusionquery
  53746. */
  53747. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  53748. /**
  53749. * Ends an occlusion query
  53750. * @see https://doc.babylonjs.com/features/occlusionquery
  53751. * @param algorithmType defines the algorithm to use
  53752. * @returns the current engine
  53753. */
  53754. endOcclusionQuery(algorithmType: number): Engine;
  53755. /**
  53756. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  53757. * Please note that only one query can be issued at a time
  53758. * @returns a time token used to track the time span
  53759. */
  53760. startTimeQuery(): Nullable<_TimeToken>;
  53761. /**
  53762. * Ends a time query
  53763. * @param token defines the token used to measure the time span
  53764. * @returns the time spent (in ns)
  53765. */
  53766. endTimeQuery(token: _TimeToken): int;
  53767. /** @hidden */
  53768. _currentNonTimestampToken: Nullable<_TimeToken>;
  53769. /** @hidden */
  53770. _createTimeQuery(): WebGLQuery;
  53771. /** @hidden */
  53772. _deleteTimeQuery(query: WebGLQuery): void;
  53773. /** @hidden */
  53774. _getGlAlgorithmType(algorithmType: number): number;
  53775. /** @hidden */
  53776. _getTimeQueryResult(query: WebGLQuery): any;
  53777. /** @hidden */
  53778. _getTimeQueryAvailability(query: WebGLQuery): any;
  53779. }
  53780. }
  53781. module "babylonjs/Meshes/abstractMesh" {
  53782. interface AbstractMesh {
  53783. /**
  53784. * Backing filed
  53785. * @hidden
  53786. */
  53787. __occlusionDataStorage: _OcclusionDataStorage;
  53788. /**
  53789. * Access property
  53790. * @hidden
  53791. */
  53792. _occlusionDataStorage: _OcclusionDataStorage;
  53793. /**
  53794. * 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.
  53795. * The default value is -1 which means don't break the query and wait till the result
  53796. * @see https://doc.babylonjs.com/features/occlusionquery
  53797. */
  53798. occlusionRetryCount: number;
  53799. /**
  53800. * 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:
  53801. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  53802. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  53803. * * 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.
  53804. * @see https://doc.babylonjs.com/features/occlusionquery
  53805. */
  53806. occlusionType: number;
  53807. /**
  53808. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  53809. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  53810. * * 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.
  53811. * @see https://doc.babylonjs.com/features/occlusionquery
  53812. */
  53813. occlusionQueryAlgorithmType: number;
  53814. /**
  53815. * 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
  53816. * @see https://doc.babylonjs.com/features/occlusionquery
  53817. */
  53818. isOccluded: boolean;
  53819. /**
  53820. * Flag to check the progress status of the query
  53821. * @see https://doc.babylonjs.com/features/occlusionquery
  53822. */
  53823. isOcclusionQueryInProgress: boolean;
  53824. }
  53825. }
  53826. }
  53827. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  53828. import { Nullable } from "babylonjs/types";
  53829. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53830. /** @hidden */
  53831. export var _forceTransformFeedbackToBundle: boolean;
  53832. module "babylonjs/Engines/engine" {
  53833. interface Engine {
  53834. /**
  53835. * Creates a webGL transform feedback object
  53836. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  53837. * @returns the webGL transform feedback object
  53838. */
  53839. createTransformFeedback(): WebGLTransformFeedback;
  53840. /**
  53841. * Delete a webGL transform feedback object
  53842. * @param value defines the webGL transform feedback object to delete
  53843. */
  53844. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  53845. /**
  53846. * Bind a webGL transform feedback object to the webgl context
  53847. * @param value defines the webGL transform feedback object to bind
  53848. */
  53849. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  53850. /**
  53851. * Begins a transform feedback operation
  53852. * @param usePoints defines if points or triangles must be used
  53853. */
  53854. beginTransformFeedback(usePoints: boolean): void;
  53855. /**
  53856. * Ends a transform feedback operation
  53857. */
  53858. endTransformFeedback(): void;
  53859. /**
  53860. * Specify the varyings to use with transform feedback
  53861. * @param program defines the associated webGL program
  53862. * @param value defines the list of strings representing the varying names
  53863. */
  53864. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  53865. /**
  53866. * Bind a webGL buffer for a transform feedback operation
  53867. * @param value defines the webGL buffer to bind
  53868. */
  53869. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  53870. }
  53871. }
  53872. }
  53873. declare module "babylonjs/Engines/Extensions/engine.views" {
  53874. import { Camera } from "babylonjs/Cameras/camera";
  53875. import { Nullable } from "babylonjs/types";
  53876. /**
  53877. * Class used to define an additional view for the engine
  53878. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53879. */
  53880. export class EngineView {
  53881. /** Defines the canvas where to render the view */
  53882. target: HTMLCanvasElement;
  53883. /** Defines an optional camera used to render the view (will use active camera else) */
  53884. camera?: Camera;
  53885. }
  53886. module "babylonjs/Engines/engine" {
  53887. interface Engine {
  53888. /**
  53889. * Gets or sets the HTML element to use for attaching events
  53890. */
  53891. inputElement: Nullable<HTMLElement>;
  53892. /**
  53893. * Gets the current engine view
  53894. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53895. */
  53896. activeView: Nullable<EngineView>;
  53897. /** Gets or sets the list of views */
  53898. views: EngineView[];
  53899. /**
  53900. * Register a new child canvas
  53901. * @param canvas defines the canvas to register
  53902. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  53903. * @returns the associated view
  53904. */
  53905. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  53906. /**
  53907. * Remove a registered child canvas
  53908. * @param canvas defines the canvas to remove
  53909. * @returns the current engine
  53910. */
  53911. unRegisterView(canvas: HTMLCanvasElement): Engine;
  53912. }
  53913. }
  53914. }
  53915. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  53916. import { Nullable } from "babylonjs/types";
  53917. module "babylonjs/Engines/engine" {
  53918. interface Engine {
  53919. /** @hidden */
  53920. _excludedCompressedTextures: string[];
  53921. /** @hidden */
  53922. _textureFormatInUse: string;
  53923. /**
  53924. * Gets the list of texture formats supported
  53925. */
  53926. readonly texturesSupported: Array<string>;
  53927. /**
  53928. * Gets the texture format in use
  53929. */
  53930. readonly textureFormatInUse: Nullable<string>;
  53931. /**
  53932. * Set the compressed texture extensions or file names to skip.
  53933. *
  53934. * @param skippedFiles defines the list of those texture files you want to skip
  53935. * Example: [".dds", ".env", "myfile.png"]
  53936. */
  53937. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  53938. /**
  53939. * Set the compressed texture format to use, based on the formats you have, and the formats
  53940. * supported by the hardware / browser.
  53941. *
  53942. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  53943. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  53944. * to API arguments needed to compressed textures. This puts the burden on the container
  53945. * generator to house the arcane code for determining these for current & future formats.
  53946. *
  53947. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53948. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53949. *
  53950. * Note: The result of this call is not taken into account when a texture is base64.
  53951. *
  53952. * @param formatsAvailable defines the list of those format families you have created
  53953. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  53954. *
  53955. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  53956. * @returns The extension selected.
  53957. */
  53958. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  53959. }
  53960. }
  53961. }
  53962. declare module "babylonjs/Engines/Extensions/index" {
  53963. export * from "babylonjs/Engines/Extensions/engine.alpha";
  53964. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  53965. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  53966. export * from "babylonjs/Engines/Extensions/engine.multiview";
  53967. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  53968. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  53969. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  53970. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  53971. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  53972. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  53973. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53974. export * from "babylonjs/Engines/Extensions/engine.webVR";
  53975. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  53976. export * from "babylonjs/Engines/Extensions/engine.views";
  53977. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  53978. import "babylonjs/Engines/Extensions/engine.textureSelector";
  53979. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  53980. }
  53981. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  53982. import { Nullable } from "babylonjs/types";
  53983. /**
  53984. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  53985. */
  53986. export interface CubeMapInfo {
  53987. /**
  53988. * The pixel array for the front face.
  53989. * This is stored in format, left to right, up to down format.
  53990. */
  53991. front: Nullable<ArrayBufferView>;
  53992. /**
  53993. * The pixel array for the back face.
  53994. * This is stored in format, left to right, up to down format.
  53995. */
  53996. back: Nullable<ArrayBufferView>;
  53997. /**
  53998. * The pixel array for the left face.
  53999. * This is stored in format, left to right, up to down format.
  54000. */
  54001. left: Nullable<ArrayBufferView>;
  54002. /**
  54003. * The pixel array for the right face.
  54004. * This is stored in format, left to right, up to down format.
  54005. */
  54006. right: Nullable<ArrayBufferView>;
  54007. /**
  54008. * The pixel array for the up face.
  54009. * This is stored in format, left to right, up to down format.
  54010. */
  54011. up: Nullable<ArrayBufferView>;
  54012. /**
  54013. * The pixel array for the down face.
  54014. * This is stored in format, left to right, up to down format.
  54015. */
  54016. down: Nullable<ArrayBufferView>;
  54017. /**
  54018. * The size of the cubemap stored.
  54019. *
  54020. * Each faces will be size * size pixels.
  54021. */
  54022. size: number;
  54023. /**
  54024. * The format of the texture.
  54025. *
  54026. * RGBA, RGB.
  54027. */
  54028. format: number;
  54029. /**
  54030. * The type of the texture data.
  54031. *
  54032. * UNSIGNED_INT, FLOAT.
  54033. */
  54034. type: number;
  54035. /**
  54036. * Specifies whether the texture is in gamma space.
  54037. */
  54038. gammaSpace: boolean;
  54039. }
  54040. /**
  54041. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54042. */
  54043. export class PanoramaToCubeMapTools {
  54044. private static FACE_LEFT;
  54045. private static FACE_RIGHT;
  54046. private static FACE_FRONT;
  54047. private static FACE_BACK;
  54048. private static FACE_DOWN;
  54049. private static FACE_UP;
  54050. /**
  54051. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54052. *
  54053. * @param float32Array The source data.
  54054. * @param inputWidth The width of the input panorama.
  54055. * @param inputHeight The height of the input panorama.
  54056. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54057. * @return The cubemap data
  54058. */
  54059. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54060. private static CreateCubemapTexture;
  54061. private static CalcProjectionSpherical;
  54062. }
  54063. }
  54064. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54065. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54066. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54067. import { Nullable } from "babylonjs/types";
  54068. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54069. /**
  54070. * Helper class dealing with the extraction of spherical polynomial dataArray
  54071. * from a cube map.
  54072. */
  54073. export class CubeMapToSphericalPolynomialTools {
  54074. private static FileFaces;
  54075. /**
  54076. * Converts a texture to the according Spherical Polynomial data.
  54077. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54078. *
  54079. * @param texture The texture to extract the information from.
  54080. * @return The Spherical Polynomial data.
  54081. */
  54082. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54083. /**
  54084. * Converts a cubemap to the according Spherical Polynomial data.
  54085. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54086. *
  54087. * @param cubeInfo The Cube map to extract the information from.
  54088. * @return The Spherical Polynomial data.
  54089. */
  54090. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54091. }
  54092. }
  54093. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54094. import { Nullable } from "babylonjs/types";
  54095. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54096. module "babylonjs/Materials/Textures/baseTexture" {
  54097. interface BaseTexture {
  54098. /**
  54099. * Get the polynomial representation of the texture data.
  54100. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54101. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54102. */
  54103. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54104. }
  54105. }
  54106. }
  54107. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54108. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54109. /** @hidden */
  54110. export var rgbdEncodePixelShader: {
  54111. name: string;
  54112. shader: string;
  54113. };
  54114. }
  54115. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54116. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54117. /** @hidden */
  54118. export var rgbdDecodePixelShader: {
  54119. name: string;
  54120. shader: string;
  54121. };
  54122. }
  54123. declare module "babylonjs/Misc/environmentTextureTools" {
  54124. import { Nullable } from "babylonjs/types";
  54125. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54126. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54128. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54129. import "babylonjs/Engines/Extensions/engine.readTexture";
  54130. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54131. import "babylonjs/Shaders/rgbdEncode.fragment";
  54132. import "babylonjs/Shaders/rgbdDecode.fragment";
  54133. /**
  54134. * Raw texture data and descriptor sufficient for WebGL texture upload
  54135. */
  54136. export interface EnvironmentTextureInfo {
  54137. /**
  54138. * Version of the environment map
  54139. */
  54140. version: number;
  54141. /**
  54142. * Width of image
  54143. */
  54144. width: number;
  54145. /**
  54146. * Irradiance information stored in the file.
  54147. */
  54148. irradiance: any;
  54149. /**
  54150. * Specular information stored in the file.
  54151. */
  54152. specular: any;
  54153. }
  54154. /**
  54155. * Defines One Image in the file. It requires only the position in the file
  54156. * as well as the length.
  54157. */
  54158. interface BufferImageData {
  54159. /**
  54160. * Length of the image data.
  54161. */
  54162. length: number;
  54163. /**
  54164. * Position of the data from the null terminator delimiting the end of the JSON.
  54165. */
  54166. position: number;
  54167. }
  54168. /**
  54169. * Defines the specular data enclosed in the file.
  54170. * This corresponds to the version 1 of the data.
  54171. */
  54172. export interface EnvironmentTextureSpecularInfoV1 {
  54173. /**
  54174. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54175. */
  54176. specularDataPosition?: number;
  54177. /**
  54178. * This contains all the images data needed to reconstruct the cubemap.
  54179. */
  54180. mipmaps: Array<BufferImageData>;
  54181. /**
  54182. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54183. */
  54184. lodGenerationScale: number;
  54185. }
  54186. /**
  54187. * Sets of helpers addressing the serialization and deserialization of environment texture
  54188. * stored in a BabylonJS env file.
  54189. * Those files are usually stored as .env files.
  54190. */
  54191. export class EnvironmentTextureTools {
  54192. /**
  54193. * Magic number identifying the env file.
  54194. */
  54195. private static _MagicBytes;
  54196. /**
  54197. * Gets the environment info from an env file.
  54198. * @param data The array buffer containing the .env bytes.
  54199. * @returns the environment file info (the json header) if successfully parsed.
  54200. */
  54201. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54202. /**
  54203. * Creates an environment texture from a loaded cube texture.
  54204. * @param texture defines the cube texture to convert in env file
  54205. * @return a promise containing the environment data if succesfull.
  54206. */
  54207. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54208. /**
  54209. * Creates a JSON representation of the spherical data.
  54210. * @param texture defines the texture containing the polynomials
  54211. * @return the JSON representation of the spherical info
  54212. */
  54213. private static _CreateEnvTextureIrradiance;
  54214. /**
  54215. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54216. * @param data the image data
  54217. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54218. * @return the views described by info providing access to the underlying buffer
  54219. */
  54220. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54221. /**
  54222. * Uploads the texture info contained in the env file to the GPU.
  54223. * @param texture defines the internal texture to upload to
  54224. * @param data defines the data to load
  54225. * @param info defines the texture info retrieved through the GetEnvInfo method
  54226. * @returns a promise
  54227. */
  54228. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54229. private static _OnImageReadyAsync;
  54230. /**
  54231. * Uploads the levels of image data to the GPU.
  54232. * @param texture defines the internal texture to upload to
  54233. * @param imageData defines the array buffer views of image data [mipmap][face]
  54234. * @returns a promise
  54235. */
  54236. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54237. /**
  54238. * Uploads spherical polynomials information to the texture.
  54239. * @param texture defines the texture we are trying to upload the information to
  54240. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54241. */
  54242. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54243. /** @hidden */
  54244. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54245. }
  54246. }
  54247. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54248. /**
  54249. * Class used to inline functions in shader code
  54250. */
  54251. export class ShaderCodeInliner {
  54252. private static readonly _RegexpFindFunctionNameAndType;
  54253. private _sourceCode;
  54254. private _functionDescr;
  54255. private _numMaxIterations;
  54256. /** Gets or sets the token used to mark the functions to inline */
  54257. inlineToken: string;
  54258. /** Gets or sets the debug mode */
  54259. debug: boolean;
  54260. /** Gets the code after the inlining process */
  54261. get code(): string;
  54262. /**
  54263. * Initializes the inliner
  54264. * @param sourceCode shader code source to inline
  54265. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  54266. */
  54267. constructor(sourceCode: string, numMaxIterations?: number);
  54268. /**
  54269. * Start the processing of the shader code
  54270. */
  54271. processCode(): void;
  54272. private _collectFunctions;
  54273. private _processInlining;
  54274. private _extractBetweenMarkers;
  54275. private _skipWhitespaces;
  54276. private _removeComments;
  54277. private _replaceFunctionCallsByCode;
  54278. private _findBackward;
  54279. private _escapeRegExp;
  54280. private _replaceNames;
  54281. }
  54282. }
  54283. declare module "babylonjs/Engines/nativeEngine" {
  54284. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  54285. import { Engine } from "babylonjs/Engines/engine";
  54286. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54287. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54288. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54289. import { Effect } from "babylonjs/Materials/effect";
  54290. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54291. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  54292. import { IColor4Like } from "babylonjs/Maths/math.like";
  54293. import { Scene } from "babylonjs/scene";
  54294. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  54295. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  54296. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54297. /**
  54298. * Container for accessors for natively-stored mesh data buffers.
  54299. */
  54300. class NativeDataBuffer extends DataBuffer {
  54301. /**
  54302. * Accessor value used to identify/retrieve a natively-stored index buffer.
  54303. */
  54304. nativeIndexBuffer?: any;
  54305. /**
  54306. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  54307. */
  54308. nativeVertexBuffer?: any;
  54309. }
  54310. /** @hidden */
  54311. class NativeTexture extends InternalTexture {
  54312. getInternalTexture(): InternalTexture;
  54313. getViewCount(): number;
  54314. }
  54315. /** @hidden */
  54316. export class NativeEngine extends Engine {
  54317. private readonly _native;
  54318. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  54319. private readonly INVALID_HANDLE;
  54320. getHardwareScalingLevel(): number;
  54321. constructor();
  54322. dispose(): void;
  54323. /**
  54324. * Can be used to override the current requestAnimationFrame requester.
  54325. * @hidden
  54326. */
  54327. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  54328. /**
  54329. * Override default engine behavior.
  54330. * @param color
  54331. * @param backBuffer
  54332. * @param depth
  54333. * @param stencil
  54334. */
  54335. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  54336. /**
  54337. * Gets host document
  54338. * @returns the host document object
  54339. */
  54340. getHostDocument(): Nullable<Document>;
  54341. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54342. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  54343. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  54344. recordVertexArrayObject(vertexBuffers: {
  54345. [key: string]: VertexBuffer;
  54346. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  54347. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54348. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54349. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54350. /**
  54351. * Draw a list of indexed primitives
  54352. * @param fillMode defines the primitive to use
  54353. * @param indexStart defines the starting index
  54354. * @param indexCount defines the number of index to draw
  54355. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54356. */
  54357. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54358. /**
  54359. * Draw a list of unindexed primitives
  54360. * @param fillMode defines the primitive to use
  54361. * @param verticesStart defines the index of first vertex to draw
  54362. * @param verticesCount defines the count of vertices to draw
  54363. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54364. */
  54365. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54366. createPipelineContext(): IPipelineContext;
  54367. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  54368. /** @hidden */
  54369. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  54370. /** @hidden */
  54371. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  54372. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54373. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54374. protected _setProgram(program: WebGLProgram): void;
  54375. _releaseEffect(effect: Effect): void;
  54376. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  54377. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  54378. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  54379. bindSamplers(effect: Effect): void;
  54380. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  54381. getRenderWidth(useScreen?: boolean): number;
  54382. getRenderHeight(useScreen?: boolean): number;
  54383. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  54384. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54385. /**
  54386. * Set the z offset to apply to current rendering
  54387. * @param value defines the offset to apply
  54388. */
  54389. setZOffset(value: number): void;
  54390. /**
  54391. * Gets the current value of the zOffset
  54392. * @returns the current zOffset state
  54393. */
  54394. getZOffset(): number;
  54395. /**
  54396. * Enable or disable depth buffering
  54397. * @param enable defines the state to set
  54398. */
  54399. setDepthBuffer(enable: boolean): void;
  54400. /**
  54401. * Gets a boolean indicating if depth writing is enabled
  54402. * @returns the current depth writing state
  54403. */
  54404. getDepthWrite(): boolean;
  54405. /**
  54406. * Enable or disable depth writing
  54407. * @param enable defines the state to set
  54408. */
  54409. setDepthWrite(enable: boolean): void;
  54410. /**
  54411. * Enable or disable color writing
  54412. * @param enable defines the state to set
  54413. */
  54414. setColorWrite(enable: boolean): void;
  54415. /**
  54416. * Gets a boolean indicating if color writing is enabled
  54417. * @returns the current color writing state
  54418. */
  54419. getColorWrite(): boolean;
  54420. /**
  54421. * Sets alpha constants used by some alpha blending modes
  54422. * @param r defines the red component
  54423. * @param g defines the green component
  54424. * @param b defines the blue component
  54425. * @param a defines the alpha component
  54426. */
  54427. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  54428. /**
  54429. * Sets the current alpha mode
  54430. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  54431. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54432. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54433. */
  54434. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54435. /**
  54436. * Gets the current alpha mode
  54437. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54438. * @returns the current alpha mode
  54439. */
  54440. getAlphaMode(): number;
  54441. setInt(uniform: WebGLUniformLocation, int: number): void;
  54442. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  54443. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  54444. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  54445. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  54446. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  54447. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  54448. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  54449. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  54450. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  54451. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  54452. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  54453. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  54454. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  54455. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54456. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54457. setFloat(uniform: WebGLUniformLocation, value: number): void;
  54458. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  54459. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  54460. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  54461. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  54462. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  54463. wipeCaches(bruteForce?: boolean): void;
  54464. _createTexture(): WebGLTexture;
  54465. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  54466. /**
  54467. * Usually called from Texture.ts.
  54468. * Passed information to create a WebGLTexture
  54469. * @param url defines a value which contains one of the following:
  54470. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54471. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54472. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54473. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54474. * @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)
  54475. * @param scene needed for loading to the correct scene
  54476. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54477. * @param onLoad optional callback to be called upon successful completion
  54478. * @param onError optional callback to be called upon failure
  54479. * @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
  54480. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54481. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54482. * @param forcedExtension defines the extension to use to pick the right loader
  54483. * @param mimeType defines an optional mime type
  54484. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54485. */
  54486. 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;
  54487. /**
  54488. * Creates a cube texture
  54489. * @param rootUrl defines the url where the files to load is located
  54490. * @param scene defines the current scene
  54491. * @param files defines the list of files to load (1 per face)
  54492. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  54493. * @param onLoad defines an optional callback raised when the texture is loaded
  54494. * @param onError defines an optional callback raised if there is an issue to load the texture
  54495. * @param format defines the format of the data
  54496. * @param forcedExtension defines the extension to use to pick the right loader
  54497. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  54498. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54499. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54500. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  54501. * @returns the cube texture as an InternalTexture
  54502. */
  54503. 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;
  54504. private _getSamplingFilter;
  54505. private static _GetNativeTextureFormat;
  54506. createRenderTargetTexture(size: number | {
  54507. width: number;
  54508. height: number;
  54509. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  54510. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54511. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54512. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54513. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  54514. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  54515. /**
  54516. * Updates a dynamic vertex buffer.
  54517. * @param vertexBuffer the vertex buffer to update
  54518. * @param data the data used to update the vertex buffer
  54519. * @param byteOffset the byte offset of the data (optional)
  54520. * @param byteLength the byte length of the data (optional)
  54521. */
  54522. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  54523. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  54524. private _updateAnisotropicLevel;
  54525. private _getAddressMode;
  54526. /** @hidden */
  54527. _bindTexture(channel: number, texture: InternalTexture): void;
  54528. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  54529. releaseEffects(): void;
  54530. /** @hidden */
  54531. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54532. /** @hidden */
  54533. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54534. /** @hidden */
  54535. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54536. /** @hidden */
  54537. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54538. }
  54539. }
  54540. declare module "babylonjs/Engines/index" {
  54541. export * from "babylonjs/Engines/constants";
  54542. export * from "babylonjs/Engines/engineCapabilities";
  54543. export * from "babylonjs/Engines/instancingAttributeInfo";
  54544. export * from "babylonjs/Engines/thinEngine";
  54545. export * from "babylonjs/Engines/engine";
  54546. export * from "babylonjs/Engines/engineStore";
  54547. export * from "babylonjs/Engines/nullEngine";
  54548. export * from "babylonjs/Engines/Extensions/index";
  54549. export * from "babylonjs/Engines/IPipelineContext";
  54550. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  54551. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  54552. export * from "babylonjs/Engines/nativeEngine";
  54553. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  54554. export * from "babylonjs/Engines/performanceConfigurator";
  54555. }
  54556. declare module "babylonjs/Events/clipboardEvents" {
  54557. /**
  54558. * Gather the list of clipboard event types as constants.
  54559. */
  54560. export class ClipboardEventTypes {
  54561. /**
  54562. * The clipboard event is fired when a copy command is active (pressed).
  54563. */
  54564. static readonly COPY: number;
  54565. /**
  54566. * The clipboard event is fired when a cut command is active (pressed).
  54567. */
  54568. static readonly CUT: number;
  54569. /**
  54570. * The clipboard event is fired when a paste command is active (pressed).
  54571. */
  54572. static readonly PASTE: number;
  54573. }
  54574. /**
  54575. * This class is used to store clipboard related info for the onClipboardObservable event.
  54576. */
  54577. export class ClipboardInfo {
  54578. /**
  54579. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54580. */
  54581. type: number;
  54582. /**
  54583. * Defines the related dom event
  54584. */
  54585. event: ClipboardEvent;
  54586. /**
  54587. *Creates an instance of ClipboardInfo.
  54588. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  54589. * @param event Defines the related dom event
  54590. */
  54591. constructor(
  54592. /**
  54593. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54594. */
  54595. type: number,
  54596. /**
  54597. * Defines the related dom event
  54598. */
  54599. event: ClipboardEvent);
  54600. /**
  54601. * Get the clipboard event's type from the keycode.
  54602. * @param keyCode Defines the keyCode for the current keyboard event.
  54603. * @return {number}
  54604. */
  54605. static GetTypeFromCharacter(keyCode: number): number;
  54606. }
  54607. }
  54608. declare module "babylonjs/Events/index" {
  54609. export * from "babylonjs/Events/keyboardEvents";
  54610. export * from "babylonjs/Events/pointerEvents";
  54611. export * from "babylonjs/Events/clipboardEvents";
  54612. }
  54613. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  54614. import { Scene } from "babylonjs/scene";
  54615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54616. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54617. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54618. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54619. /**
  54620. * Google Daydream controller
  54621. */
  54622. export class DaydreamController extends WebVRController {
  54623. /**
  54624. * Base Url for the controller model.
  54625. */
  54626. static MODEL_BASE_URL: string;
  54627. /**
  54628. * File name for the controller model.
  54629. */
  54630. static MODEL_FILENAME: string;
  54631. /**
  54632. * Gamepad Id prefix used to identify Daydream Controller.
  54633. */
  54634. static readonly GAMEPAD_ID_PREFIX: string;
  54635. /**
  54636. * Creates a new DaydreamController from a gamepad
  54637. * @param vrGamepad the gamepad that the controller should be created from
  54638. */
  54639. constructor(vrGamepad: any);
  54640. /**
  54641. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54642. * @param scene scene in which to add meshes
  54643. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54644. */
  54645. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54646. /**
  54647. * Called once for each button that changed state since the last frame
  54648. * @param buttonIdx Which button index changed
  54649. * @param state New state of the button
  54650. * @param changes Which properties on the state changed since last frame
  54651. */
  54652. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54653. }
  54654. }
  54655. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  54656. import { Scene } from "babylonjs/scene";
  54657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54658. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54659. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54660. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54661. /**
  54662. * Gear VR Controller
  54663. */
  54664. export class GearVRController extends WebVRController {
  54665. /**
  54666. * Base Url for the controller model.
  54667. */
  54668. static MODEL_BASE_URL: string;
  54669. /**
  54670. * File name for the controller model.
  54671. */
  54672. static MODEL_FILENAME: string;
  54673. /**
  54674. * Gamepad Id prefix used to identify this controller.
  54675. */
  54676. static readonly GAMEPAD_ID_PREFIX: string;
  54677. private readonly _buttonIndexToObservableNameMap;
  54678. /**
  54679. * Creates a new GearVRController from a gamepad
  54680. * @param vrGamepad the gamepad that the controller should be created from
  54681. */
  54682. constructor(vrGamepad: any);
  54683. /**
  54684. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54685. * @param scene scene in which to add meshes
  54686. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54687. */
  54688. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54689. /**
  54690. * Called once for each button that changed state since the last frame
  54691. * @param buttonIdx Which button index changed
  54692. * @param state New state of the button
  54693. * @param changes Which properties on the state changed since last frame
  54694. */
  54695. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54696. }
  54697. }
  54698. declare module "babylonjs/Gamepads/Controllers/genericController" {
  54699. import { Scene } from "babylonjs/scene";
  54700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54701. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54702. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54703. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54704. /**
  54705. * Generic Controller
  54706. */
  54707. export class GenericController extends WebVRController {
  54708. /**
  54709. * Base Url for the controller model.
  54710. */
  54711. static readonly MODEL_BASE_URL: string;
  54712. /**
  54713. * File name for the controller model.
  54714. */
  54715. static readonly MODEL_FILENAME: string;
  54716. /**
  54717. * Creates a new GenericController from a gamepad
  54718. * @param vrGamepad the gamepad that the controller should be created from
  54719. */
  54720. constructor(vrGamepad: any);
  54721. /**
  54722. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54723. * @param scene scene in which to add meshes
  54724. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54725. */
  54726. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54727. /**
  54728. * Called once for each button that changed state since the last frame
  54729. * @param buttonIdx Which button index changed
  54730. * @param state New state of the button
  54731. * @param changes Which properties on the state changed since last frame
  54732. */
  54733. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54734. }
  54735. }
  54736. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  54737. import { Observable } from "babylonjs/Misc/observable";
  54738. import { Scene } from "babylonjs/scene";
  54739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54740. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54741. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54742. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54743. /**
  54744. * Oculus Touch Controller
  54745. */
  54746. export class OculusTouchController extends WebVRController {
  54747. /**
  54748. * Base Url for the controller model.
  54749. */
  54750. static MODEL_BASE_URL: string;
  54751. /**
  54752. * File name for the left controller model.
  54753. */
  54754. static MODEL_LEFT_FILENAME: string;
  54755. /**
  54756. * File name for the right controller model.
  54757. */
  54758. static MODEL_RIGHT_FILENAME: string;
  54759. /**
  54760. * Base Url for the Quest controller model.
  54761. */
  54762. static QUEST_MODEL_BASE_URL: string;
  54763. /**
  54764. * @hidden
  54765. * If the controllers are running on a device that needs the updated Quest controller models
  54766. */
  54767. static _IsQuest: boolean;
  54768. /**
  54769. * Fired when the secondary trigger on this controller is modified
  54770. */
  54771. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  54772. /**
  54773. * Fired when the thumb rest on this controller is modified
  54774. */
  54775. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  54776. /**
  54777. * Creates a new OculusTouchController from a gamepad
  54778. * @param vrGamepad the gamepad that the controller should be created from
  54779. */
  54780. constructor(vrGamepad: any);
  54781. /**
  54782. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54783. * @param scene scene in which to add meshes
  54784. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54785. */
  54786. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54787. /**
  54788. * Fired when the A button on this controller is modified
  54789. */
  54790. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54791. /**
  54792. * Fired when the B button on this controller is modified
  54793. */
  54794. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54795. /**
  54796. * Fired when the X button on this controller is modified
  54797. */
  54798. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54799. /**
  54800. * Fired when the Y button on this controller is modified
  54801. */
  54802. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54803. /**
  54804. * Called once for each button that changed state since the last frame
  54805. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  54806. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  54807. * 2) secondary trigger (same)
  54808. * 3) A (right) X (left), touch, pressed = value
  54809. * 4) B / Y
  54810. * 5) thumb rest
  54811. * @param buttonIdx Which button index changed
  54812. * @param state New state of the button
  54813. * @param changes Which properties on the state changed since last frame
  54814. */
  54815. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54816. }
  54817. }
  54818. declare module "babylonjs/Gamepads/Controllers/viveController" {
  54819. import { Scene } from "babylonjs/scene";
  54820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54821. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54822. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54823. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54824. import { Observable } from "babylonjs/Misc/observable";
  54825. /**
  54826. * Vive Controller
  54827. */
  54828. export class ViveController extends WebVRController {
  54829. /**
  54830. * Base Url for the controller model.
  54831. */
  54832. static MODEL_BASE_URL: string;
  54833. /**
  54834. * File name for the controller model.
  54835. */
  54836. static MODEL_FILENAME: string;
  54837. /**
  54838. * Creates a new ViveController from a gamepad
  54839. * @param vrGamepad the gamepad that the controller should be created from
  54840. */
  54841. constructor(vrGamepad: any);
  54842. /**
  54843. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54844. * @param scene scene in which to add meshes
  54845. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54846. */
  54847. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54848. /**
  54849. * Fired when the left button on this controller is modified
  54850. */
  54851. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54852. /**
  54853. * Fired when the right button on this controller is modified
  54854. */
  54855. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54856. /**
  54857. * Fired when the menu button on this controller is modified
  54858. */
  54859. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54860. /**
  54861. * Called once for each button that changed state since the last frame
  54862. * Vive mapping:
  54863. * 0: touchpad
  54864. * 1: trigger
  54865. * 2: left AND right buttons
  54866. * 3: menu button
  54867. * @param buttonIdx Which button index changed
  54868. * @param state New state of the button
  54869. * @param changes Which properties on the state changed since last frame
  54870. */
  54871. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54872. }
  54873. }
  54874. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  54875. import { Observable } from "babylonjs/Misc/observable";
  54876. import { Scene } from "babylonjs/scene";
  54877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54878. import { Ray } from "babylonjs/Culling/ray";
  54879. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54880. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54881. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54882. /**
  54883. * Defines the WindowsMotionController object that the state of the windows motion controller
  54884. */
  54885. export class WindowsMotionController extends WebVRController {
  54886. /**
  54887. * The base url used to load the left and right controller models
  54888. */
  54889. static MODEL_BASE_URL: string;
  54890. /**
  54891. * The name of the left controller model file
  54892. */
  54893. static MODEL_LEFT_FILENAME: string;
  54894. /**
  54895. * The name of the right controller model file
  54896. */
  54897. static MODEL_RIGHT_FILENAME: string;
  54898. /**
  54899. * The controller name prefix for this controller type
  54900. */
  54901. static readonly GAMEPAD_ID_PREFIX: string;
  54902. /**
  54903. * The controller id pattern for this controller type
  54904. */
  54905. private static readonly GAMEPAD_ID_PATTERN;
  54906. private _loadedMeshInfo;
  54907. protected readonly _mapping: {
  54908. buttons: string[];
  54909. buttonMeshNames: {
  54910. trigger: string;
  54911. menu: string;
  54912. grip: string;
  54913. thumbstick: string;
  54914. trackpad: string;
  54915. };
  54916. buttonObservableNames: {
  54917. trigger: string;
  54918. menu: string;
  54919. grip: string;
  54920. thumbstick: string;
  54921. trackpad: string;
  54922. };
  54923. axisMeshNames: string[];
  54924. pointingPoseMeshName: string;
  54925. };
  54926. /**
  54927. * Fired when the trackpad on this controller is clicked
  54928. */
  54929. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54930. /**
  54931. * Fired when the trackpad on this controller is modified
  54932. */
  54933. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54934. /**
  54935. * The current x and y values of this controller's trackpad
  54936. */
  54937. trackpad: StickValues;
  54938. /**
  54939. * Creates a new WindowsMotionController from a gamepad
  54940. * @param vrGamepad the gamepad that the controller should be created from
  54941. */
  54942. constructor(vrGamepad: any);
  54943. /**
  54944. * Fired when the trigger on this controller is modified
  54945. */
  54946. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54947. /**
  54948. * Fired when the menu button on this controller is modified
  54949. */
  54950. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54951. /**
  54952. * Fired when the grip button on this controller is modified
  54953. */
  54954. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54955. /**
  54956. * Fired when the thumbstick button on this controller is modified
  54957. */
  54958. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54959. /**
  54960. * Fired when the touchpad button on this controller is modified
  54961. */
  54962. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54963. /**
  54964. * Fired when the touchpad values on this controller are modified
  54965. */
  54966. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  54967. protected _updateTrackpad(): void;
  54968. /**
  54969. * Called once per frame by the engine.
  54970. */
  54971. update(): void;
  54972. /**
  54973. * Called once for each button that changed state since the last frame
  54974. * @param buttonIdx Which button index changed
  54975. * @param state New state of the button
  54976. * @param changes Which properties on the state changed since last frame
  54977. */
  54978. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54979. /**
  54980. * Moves the buttons on the controller mesh based on their current state
  54981. * @param buttonName the name of the button to move
  54982. * @param buttonValue the value of the button which determines the buttons new position
  54983. */
  54984. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  54985. /**
  54986. * Moves the axis on the controller mesh based on its current state
  54987. * @param axis the index of the axis
  54988. * @param axisValue the value of the axis which determines the meshes new position
  54989. * @hidden
  54990. */
  54991. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  54992. /**
  54993. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54994. * @param scene scene in which to add meshes
  54995. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54996. */
  54997. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  54998. /**
  54999. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55000. * can be transformed by button presses and axes values, based on this._mapping.
  55001. *
  55002. * @param scene scene in which the meshes exist
  55003. * @param meshes list of meshes that make up the controller model to process
  55004. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55005. */
  55006. private processModel;
  55007. private createMeshInfo;
  55008. /**
  55009. * Gets the ray of the controller in the direction the controller is pointing
  55010. * @param length the length the resulting ray should be
  55011. * @returns a ray in the direction the controller is pointing
  55012. */
  55013. getForwardRay(length?: number): Ray;
  55014. /**
  55015. * Disposes of the controller
  55016. */
  55017. dispose(): void;
  55018. }
  55019. /**
  55020. * This class represents a new windows motion controller in XR.
  55021. */
  55022. export class XRWindowsMotionController extends WindowsMotionController {
  55023. /**
  55024. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55025. */
  55026. protected readonly _mapping: {
  55027. buttons: string[];
  55028. buttonMeshNames: {
  55029. trigger: string;
  55030. menu: string;
  55031. grip: string;
  55032. thumbstick: string;
  55033. trackpad: string;
  55034. };
  55035. buttonObservableNames: {
  55036. trigger: string;
  55037. menu: string;
  55038. grip: string;
  55039. thumbstick: string;
  55040. trackpad: string;
  55041. };
  55042. axisMeshNames: string[];
  55043. pointingPoseMeshName: string;
  55044. };
  55045. /**
  55046. * Construct a new XR-Based windows motion controller
  55047. *
  55048. * @param gamepadInfo the gamepad object from the browser
  55049. */
  55050. constructor(gamepadInfo: any);
  55051. /**
  55052. * holds the thumbstick values (X,Y)
  55053. */
  55054. thumbstickValues: StickValues;
  55055. /**
  55056. * Fired when the thumbstick on this controller is clicked
  55057. */
  55058. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55059. /**
  55060. * Fired when the thumbstick on this controller is modified
  55061. */
  55062. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55063. /**
  55064. * Fired when the touchpad button on this controller is modified
  55065. */
  55066. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55067. /**
  55068. * Fired when the touchpad values on this controller are modified
  55069. */
  55070. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55071. /**
  55072. * Fired when the thumbstick button on this controller is modified
  55073. * here to prevent breaking changes
  55074. */
  55075. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55076. /**
  55077. * updating the thumbstick(!) and not the trackpad.
  55078. * This is named this way due to the difference between WebVR and XR and to avoid
  55079. * changing the parent class.
  55080. */
  55081. protected _updateTrackpad(): void;
  55082. /**
  55083. * Disposes the class with joy
  55084. */
  55085. dispose(): void;
  55086. }
  55087. }
  55088. declare module "babylonjs/Gamepads/Controllers/index" {
  55089. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55090. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55091. export * from "babylonjs/Gamepads/Controllers/genericController";
  55092. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55093. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55094. export * from "babylonjs/Gamepads/Controllers/viveController";
  55095. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55096. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55097. }
  55098. declare module "babylonjs/Gamepads/index" {
  55099. export * from "babylonjs/Gamepads/Controllers/index";
  55100. export * from "babylonjs/Gamepads/gamepad";
  55101. export * from "babylonjs/Gamepads/gamepadManager";
  55102. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55103. export * from "babylonjs/Gamepads/xboxGamepad";
  55104. export * from "babylonjs/Gamepads/dualShockGamepad";
  55105. }
  55106. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55107. import { Scene } from "babylonjs/scene";
  55108. import { Vector4 } from "babylonjs/Maths/math.vector";
  55109. import { Color4 } from "babylonjs/Maths/math.color";
  55110. import { Mesh } from "babylonjs/Meshes/mesh";
  55111. import { Nullable } from "babylonjs/types";
  55112. /**
  55113. * Class containing static functions to help procedurally build meshes
  55114. */
  55115. export class PolyhedronBuilder {
  55116. /**
  55117. * Creates a polyhedron mesh
  55118. * * 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
  55119. * * The parameter `size` (positive float, default 1) sets the polygon size
  55120. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55121. * * 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`
  55122. * * 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
  55123. * * 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)`)
  55124. * * 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
  55125. * * 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
  55126. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55127. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55129. * @param name defines the name of the mesh
  55130. * @param options defines the options used to create the mesh
  55131. * @param scene defines the hosting scene
  55132. * @returns the polyhedron mesh
  55133. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55134. */
  55135. static CreatePolyhedron(name: string, options: {
  55136. type?: number;
  55137. size?: number;
  55138. sizeX?: number;
  55139. sizeY?: number;
  55140. sizeZ?: number;
  55141. custom?: any;
  55142. faceUV?: Vector4[];
  55143. faceColors?: Color4[];
  55144. flat?: boolean;
  55145. updatable?: boolean;
  55146. sideOrientation?: number;
  55147. frontUVs?: Vector4;
  55148. backUVs?: Vector4;
  55149. }, scene?: Nullable<Scene>): Mesh;
  55150. }
  55151. }
  55152. declare module "babylonjs/Gizmos/scaleGizmo" {
  55153. import { Observable } from "babylonjs/Misc/observable";
  55154. import { Nullable } from "babylonjs/types";
  55155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55156. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55157. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55158. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55159. import { Node } from "babylonjs/node";
  55160. /**
  55161. * Gizmo that enables scaling a mesh along 3 axis
  55162. */
  55163. export class ScaleGizmo extends Gizmo {
  55164. /**
  55165. * Internal gizmo used for interactions on the x axis
  55166. */
  55167. xGizmo: AxisScaleGizmo;
  55168. /**
  55169. * Internal gizmo used for interactions on the y axis
  55170. */
  55171. yGizmo: AxisScaleGizmo;
  55172. /**
  55173. * Internal gizmo used for interactions on the z axis
  55174. */
  55175. zGizmo: AxisScaleGizmo;
  55176. /**
  55177. * Internal gizmo used to scale all axis equally
  55178. */
  55179. uniformScaleGizmo: AxisScaleGizmo;
  55180. private _meshAttached;
  55181. private _nodeAttached;
  55182. private _updateGizmoRotationToMatchAttachedMesh;
  55183. private _snapDistance;
  55184. private _scaleRatio;
  55185. private _uniformScalingMesh;
  55186. private _octahedron;
  55187. private _sensitivity;
  55188. /** Fires an event when any of it's sub gizmos are dragged */
  55189. onDragStartObservable: Observable<unknown>;
  55190. /** Fires an event when any of it's sub gizmos are released from dragging */
  55191. onDragEndObservable: Observable<unknown>;
  55192. get attachedMesh(): Nullable<AbstractMesh>;
  55193. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55194. get attachedNode(): Nullable<Node>;
  55195. set attachedNode(node: Nullable<Node>);
  55196. /**
  55197. * Creates a ScaleGizmo
  55198. * @param gizmoLayer The utility layer the gizmo will be added to
  55199. * @param thickness display gizmo axis thickness
  55200. */
  55201. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55202. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55203. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55204. /**
  55205. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55206. */
  55207. set snapDistance(value: number);
  55208. get snapDistance(): number;
  55209. /**
  55210. * Ratio for the scale of the gizmo (Default: 1)
  55211. */
  55212. set scaleRatio(value: number);
  55213. get scaleRatio(): number;
  55214. /**
  55215. * Sensitivity factor for dragging (Default: 1)
  55216. */
  55217. set sensitivity(value: number);
  55218. get sensitivity(): number;
  55219. /**
  55220. * Disposes of the gizmo
  55221. */
  55222. dispose(): void;
  55223. }
  55224. }
  55225. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55226. import { Observable } from "babylonjs/Misc/observable";
  55227. import { Nullable } from "babylonjs/types";
  55228. import { Vector3 } from "babylonjs/Maths/math.vector";
  55229. import { Node } from "babylonjs/node";
  55230. import { Mesh } from "babylonjs/Meshes/mesh";
  55231. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55232. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55233. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55234. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55235. import { Color3 } from "babylonjs/Maths/math.color";
  55236. /**
  55237. * Single axis scale gizmo
  55238. */
  55239. export class AxisScaleGizmo extends Gizmo {
  55240. /**
  55241. * Drag behavior responsible for the gizmos dragging interactions
  55242. */
  55243. dragBehavior: PointerDragBehavior;
  55244. private _pointerObserver;
  55245. /**
  55246. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55247. */
  55248. snapDistance: number;
  55249. /**
  55250. * Event that fires each time the gizmo snaps to a new location.
  55251. * * snapDistance is the the change in distance
  55252. */
  55253. onSnapObservable: Observable<{
  55254. snapDistance: number;
  55255. }>;
  55256. /**
  55257. * If the scaling operation should be done on all axis (default: false)
  55258. */
  55259. uniformScaling: boolean;
  55260. /**
  55261. * Custom sensitivity value for the drag strength
  55262. */
  55263. sensitivity: number;
  55264. private _isEnabled;
  55265. private _parent;
  55266. private _arrow;
  55267. private _coloredMaterial;
  55268. private _hoverMaterial;
  55269. /**
  55270. * Creates an AxisScaleGizmo
  55271. * @param gizmoLayer The utility layer the gizmo will be added to
  55272. * @param dragAxis The axis which the gizmo will be able to scale on
  55273. * @param color The color of the gizmo
  55274. * @param thickness display gizmo axis thickness
  55275. */
  55276. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  55277. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55278. /**
  55279. * If the gizmo is enabled
  55280. */
  55281. set isEnabled(value: boolean);
  55282. get isEnabled(): boolean;
  55283. /**
  55284. * Disposes of the gizmo
  55285. */
  55286. dispose(): void;
  55287. /**
  55288. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55289. * @param mesh The mesh to replace the default mesh of the gizmo
  55290. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  55291. */
  55292. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  55293. }
  55294. }
  55295. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  55296. import { Observable } from "babylonjs/Misc/observable";
  55297. import { Nullable } from "babylonjs/types";
  55298. import { Vector3 } from "babylonjs/Maths/math.vector";
  55299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55300. import { Mesh } from "babylonjs/Meshes/mesh";
  55301. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55302. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55303. import { Color3 } from "babylonjs/Maths/math.color";
  55304. import "babylonjs/Meshes/Builders/boxBuilder";
  55305. /**
  55306. * Bounding box gizmo
  55307. */
  55308. export class BoundingBoxGizmo extends Gizmo {
  55309. private _lineBoundingBox;
  55310. private _rotateSpheresParent;
  55311. private _scaleBoxesParent;
  55312. private _boundingDimensions;
  55313. private _renderObserver;
  55314. private _pointerObserver;
  55315. private _scaleDragSpeed;
  55316. private _tmpQuaternion;
  55317. private _tmpVector;
  55318. private _tmpRotationMatrix;
  55319. /**
  55320. * 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)
  55321. */
  55322. ignoreChildren: boolean;
  55323. /**
  55324. * 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)
  55325. */
  55326. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  55327. /**
  55328. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  55329. */
  55330. rotationSphereSize: number;
  55331. /**
  55332. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  55333. */
  55334. scaleBoxSize: number;
  55335. /**
  55336. * 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)
  55337. */
  55338. fixedDragMeshScreenSize: boolean;
  55339. /**
  55340. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  55341. */
  55342. fixedDragMeshScreenSizeDistanceFactor: number;
  55343. /**
  55344. * Fired when a rotation sphere or scale box is dragged
  55345. */
  55346. onDragStartObservable: Observable<{}>;
  55347. /**
  55348. * Fired when a scale box is dragged
  55349. */
  55350. onScaleBoxDragObservable: Observable<{}>;
  55351. /**
  55352. * Fired when a scale box drag is ended
  55353. */
  55354. onScaleBoxDragEndObservable: Observable<{}>;
  55355. /**
  55356. * Fired when a rotation sphere is dragged
  55357. */
  55358. onRotationSphereDragObservable: Observable<{}>;
  55359. /**
  55360. * Fired when a rotation sphere drag is ended
  55361. */
  55362. onRotationSphereDragEndObservable: Observable<{}>;
  55363. /**
  55364. * 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)
  55365. */
  55366. scalePivot: Nullable<Vector3>;
  55367. /**
  55368. * Mesh used as a pivot to rotate the attached node
  55369. */
  55370. private _anchorMesh;
  55371. private _existingMeshScale;
  55372. private _dragMesh;
  55373. private pointerDragBehavior;
  55374. private coloredMaterial;
  55375. private hoverColoredMaterial;
  55376. /**
  55377. * Sets the color of the bounding box gizmo
  55378. * @param color the color to set
  55379. */
  55380. setColor(color: Color3): void;
  55381. /**
  55382. * Creates an BoundingBoxGizmo
  55383. * @param gizmoLayer The utility layer the gizmo will be added to
  55384. * @param color The color of the gizmo
  55385. */
  55386. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  55387. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  55388. private _selectNode;
  55389. /**
  55390. * Updates the bounding box information for the Gizmo
  55391. */
  55392. updateBoundingBox(): void;
  55393. private _updateRotationSpheres;
  55394. private _updateScaleBoxes;
  55395. /**
  55396. * Enables rotation on the specified axis and disables rotation on the others
  55397. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  55398. */
  55399. setEnabledRotationAxis(axis: string): void;
  55400. /**
  55401. * Enables/disables scaling
  55402. * @param enable if scaling should be enabled
  55403. * @param homogeneousScaling defines if scaling should only be homogeneous
  55404. */
  55405. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  55406. private _updateDummy;
  55407. /**
  55408. * Enables a pointer drag behavior on the bounding box of the gizmo
  55409. */
  55410. enableDragBehavior(): void;
  55411. /**
  55412. * Disposes of the gizmo
  55413. */
  55414. dispose(): void;
  55415. /**
  55416. * 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)
  55417. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  55418. * @returns the bounding box mesh with the passed in mesh as a child
  55419. */
  55420. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  55421. /**
  55422. * CustomMeshes are not supported by this gizmo
  55423. * @param mesh The mesh to replace the default mesh of the gizmo
  55424. */
  55425. setCustomMesh(mesh: Mesh): void;
  55426. }
  55427. }
  55428. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  55429. import { Observable } from "babylonjs/Misc/observable";
  55430. import { Nullable } from "babylonjs/types";
  55431. import { Vector3 } from "babylonjs/Maths/math.vector";
  55432. import { Color3 } from "babylonjs/Maths/math.color";
  55433. import { Node } from "babylonjs/node";
  55434. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55435. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55436. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55437. import "babylonjs/Meshes/Builders/linesBuilder";
  55438. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55439. /**
  55440. * Single plane rotation gizmo
  55441. */
  55442. export class PlaneRotationGizmo extends Gizmo {
  55443. /**
  55444. * Drag behavior responsible for the gizmos dragging interactions
  55445. */
  55446. dragBehavior: PointerDragBehavior;
  55447. private _pointerObserver;
  55448. /**
  55449. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  55450. */
  55451. snapDistance: number;
  55452. /**
  55453. * Event that fires each time the gizmo snaps to a new location.
  55454. * * snapDistance is the the change in distance
  55455. */
  55456. onSnapObservable: Observable<{
  55457. snapDistance: number;
  55458. }>;
  55459. private _isEnabled;
  55460. private _parent;
  55461. /**
  55462. * Creates a PlaneRotationGizmo
  55463. * @param gizmoLayer The utility layer the gizmo will be added to
  55464. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  55465. * @param color The color of the gizmo
  55466. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55467. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55468. * @param thickness display gizmo axis thickness
  55469. */
  55470. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  55471. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55472. /**
  55473. * If the gizmo is enabled
  55474. */
  55475. set isEnabled(value: boolean);
  55476. get isEnabled(): boolean;
  55477. /**
  55478. * Disposes of the gizmo
  55479. */
  55480. dispose(): void;
  55481. }
  55482. }
  55483. declare module "babylonjs/Gizmos/rotationGizmo" {
  55484. import { Observable } from "babylonjs/Misc/observable";
  55485. import { Nullable } from "babylonjs/types";
  55486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55487. import { Mesh } from "babylonjs/Meshes/mesh";
  55488. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55489. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  55490. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55491. import { Node } from "babylonjs/node";
  55492. /**
  55493. * Gizmo that enables rotating a mesh along 3 axis
  55494. */
  55495. export class RotationGizmo extends Gizmo {
  55496. /**
  55497. * Internal gizmo used for interactions on the x axis
  55498. */
  55499. xGizmo: PlaneRotationGizmo;
  55500. /**
  55501. * Internal gizmo used for interactions on the y axis
  55502. */
  55503. yGizmo: PlaneRotationGizmo;
  55504. /**
  55505. * Internal gizmo used for interactions on the z axis
  55506. */
  55507. zGizmo: PlaneRotationGizmo;
  55508. /** Fires an event when any of it's sub gizmos are dragged */
  55509. onDragStartObservable: Observable<unknown>;
  55510. /** Fires an event when any of it's sub gizmos are released from dragging */
  55511. onDragEndObservable: Observable<unknown>;
  55512. private _meshAttached;
  55513. private _nodeAttached;
  55514. get attachedMesh(): Nullable<AbstractMesh>;
  55515. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55516. get attachedNode(): Nullable<Node>;
  55517. set attachedNode(node: Nullable<Node>);
  55518. /**
  55519. * Creates a RotationGizmo
  55520. * @param gizmoLayer The utility layer the gizmo will be added to
  55521. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55522. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55523. * @param thickness display gizmo axis thickness
  55524. */
  55525. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  55526. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55527. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55528. /**
  55529. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55530. */
  55531. set snapDistance(value: number);
  55532. get snapDistance(): number;
  55533. /**
  55534. * Ratio for the scale of the gizmo (Default: 1)
  55535. */
  55536. set scaleRatio(value: number);
  55537. get scaleRatio(): number;
  55538. /**
  55539. * Disposes of the gizmo
  55540. */
  55541. dispose(): void;
  55542. /**
  55543. * CustomMeshes are not supported by this gizmo
  55544. * @param mesh The mesh to replace the default mesh of the gizmo
  55545. */
  55546. setCustomMesh(mesh: Mesh): void;
  55547. }
  55548. }
  55549. declare module "babylonjs/Gizmos/gizmoManager" {
  55550. import { Observable } from "babylonjs/Misc/observable";
  55551. import { Nullable } from "babylonjs/types";
  55552. import { Scene, IDisposable } from "babylonjs/scene";
  55553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55554. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55555. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  55556. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55557. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55558. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55559. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  55560. /**
  55561. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  55562. */
  55563. export class GizmoManager implements IDisposable {
  55564. private scene;
  55565. /**
  55566. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  55567. */
  55568. gizmos: {
  55569. positionGizmo: Nullable<PositionGizmo>;
  55570. rotationGizmo: Nullable<RotationGizmo>;
  55571. scaleGizmo: Nullable<ScaleGizmo>;
  55572. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  55573. };
  55574. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  55575. clearGizmoOnEmptyPointerEvent: boolean;
  55576. /** Fires an event when the manager is attached to a mesh */
  55577. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  55578. private _gizmosEnabled;
  55579. private _pointerObserver;
  55580. private _attachedMesh;
  55581. private _boundingBoxColor;
  55582. private _defaultUtilityLayer;
  55583. private _defaultKeepDepthUtilityLayer;
  55584. private _thickness;
  55585. /**
  55586. * When bounding box gizmo is enabled, this can be used to track drag/end events
  55587. */
  55588. boundingBoxDragBehavior: SixDofDragBehavior;
  55589. /**
  55590. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  55591. */
  55592. attachableMeshes: Nullable<Array<AbstractMesh>>;
  55593. /**
  55594. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  55595. */
  55596. usePointerToAttachGizmos: boolean;
  55597. /**
  55598. * Utility layer that the bounding box gizmo belongs to
  55599. */
  55600. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  55601. /**
  55602. * Utility layer that all gizmos besides bounding box belong to
  55603. */
  55604. get utilityLayer(): UtilityLayerRenderer;
  55605. /**
  55606. * Instatiates a gizmo manager
  55607. * @param scene the scene to overlay the gizmos on top of
  55608. * @param thickness display gizmo axis thickness
  55609. */
  55610. constructor(scene: Scene, thickness?: number);
  55611. /**
  55612. * Attaches a set of gizmos to the specified mesh
  55613. * @param mesh The mesh the gizmo's should be attached to
  55614. */
  55615. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55616. /**
  55617. * If the position gizmo is enabled
  55618. */
  55619. set positionGizmoEnabled(value: boolean);
  55620. get positionGizmoEnabled(): boolean;
  55621. /**
  55622. * If the rotation gizmo is enabled
  55623. */
  55624. set rotationGizmoEnabled(value: boolean);
  55625. get rotationGizmoEnabled(): boolean;
  55626. /**
  55627. * If the scale gizmo is enabled
  55628. */
  55629. set scaleGizmoEnabled(value: boolean);
  55630. get scaleGizmoEnabled(): boolean;
  55631. /**
  55632. * If the boundingBox gizmo is enabled
  55633. */
  55634. set boundingBoxGizmoEnabled(value: boolean);
  55635. get boundingBoxGizmoEnabled(): boolean;
  55636. /**
  55637. * Disposes of the gizmo manager
  55638. */
  55639. dispose(): void;
  55640. }
  55641. }
  55642. declare module "babylonjs/Lights/directionalLight" {
  55643. import { Camera } from "babylonjs/Cameras/camera";
  55644. import { Scene } from "babylonjs/scene";
  55645. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55647. import { Light } from "babylonjs/Lights/light";
  55648. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55649. import { Effect } from "babylonjs/Materials/effect";
  55650. /**
  55651. * A directional light is defined by a direction (what a surprise!).
  55652. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  55653. * 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.
  55654. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55655. */
  55656. export class DirectionalLight extends ShadowLight {
  55657. private _shadowFrustumSize;
  55658. /**
  55659. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  55660. */
  55661. get shadowFrustumSize(): number;
  55662. /**
  55663. * Specifies a fix frustum size for the shadow generation.
  55664. */
  55665. set shadowFrustumSize(value: number);
  55666. private _shadowOrthoScale;
  55667. /**
  55668. * Gets the shadow projection scale against the optimal computed one.
  55669. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55670. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55671. */
  55672. get shadowOrthoScale(): number;
  55673. /**
  55674. * Sets the shadow projection scale against the optimal computed one.
  55675. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55676. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55677. */
  55678. set shadowOrthoScale(value: number);
  55679. /**
  55680. * Automatically compute the projection matrix to best fit (including all the casters)
  55681. * on each frame.
  55682. */
  55683. autoUpdateExtends: boolean;
  55684. /**
  55685. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  55686. * on each frame. autoUpdateExtends must be set to true for this to work
  55687. */
  55688. autoCalcShadowZBounds: boolean;
  55689. private _orthoLeft;
  55690. private _orthoRight;
  55691. private _orthoTop;
  55692. private _orthoBottom;
  55693. /**
  55694. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  55695. * The directional light is emitted from everywhere in the given direction.
  55696. * It can cast shadows.
  55697. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55698. * @param name The friendly name of the light
  55699. * @param direction The direction of the light
  55700. * @param scene The scene the light belongs to
  55701. */
  55702. constructor(name: string, direction: Vector3, scene: Scene);
  55703. /**
  55704. * Returns the string "DirectionalLight".
  55705. * @return The class name
  55706. */
  55707. getClassName(): string;
  55708. /**
  55709. * Returns the integer 1.
  55710. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55711. */
  55712. getTypeID(): number;
  55713. /**
  55714. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  55715. * Returns the DirectionalLight Shadow projection matrix.
  55716. */
  55717. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55718. /**
  55719. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  55720. * Returns the DirectionalLight Shadow projection matrix.
  55721. */
  55722. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  55723. /**
  55724. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  55725. * Returns the DirectionalLight Shadow projection matrix.
  55726. */
  55727. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55728. protected _buildUniformLayout(): void;
  55729. /**
  55730. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  55731. * @param effect The effect to update
  55732. * @param lightIndex The index of the light in the effect to update
  55733. * @returns The directional light
  55734. */
  55735. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  55736. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  55737. /**
  55738. * Gets the minZ used for shadow according to both the scene and the light.
  55739. *
  55740. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55741. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55742. * @param activeCamera The camera we are returning the min for
  55743. * @returns the depth min z
  55744. */
  55745. getDepthMinZ(activeCamera: Camera): number;
  55746. /**
  55747. * Gets the maxZ used for shadow according to both the scene and the light.
  55748. *
  55749. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55750. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55751. * @param activeCamera The camera we are returning the max for
  55752. * @returns the depth max z
  55753. */
  55754. getDepthMaxZ(activeCamera: Camera): number;
  55755. /**
  55756. * Prepares the list of defines specific to the light type.
  55757. * @param defines the list of defines
  55758. * @param lightIndex defines the index of the light for the effect
  55759. */
  55760. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55761. }
  55762. }
  55763. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  55764. import { Mesh } from "babylonjs/Meshes/mesh";
  55765. /**
  55766. * Class containing static functions to help procedurally build meshes
  55767. */
  55768. export class HemisphereBuilder {
  55769. /**
  55770. * Creates a hemisphere mesh
  55771. * @param name defines the name of the mesh
  55772. * @param options defines the options used to create the mesh
  55773. * @param scene defines the hosting scene
  55774. * @returns the hemisphere mesh
  55775. */
  55776. static CreateHemisphere(name: string, options: {
  55777. segments?: number;
  55778. diameter?: number;
  55779. sideOrientation?: number;
  55780. }, scene: any): Mesh;
  55781. }
  55782. }
  55783. declare module "babylonjs/Lights/spotLight" {
  55784. import { Nullable } from "babylonjs/types";
  55785. import { Scene } from "babylonjs/scene";
  55786. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55788. import { Effect } from "babylonjs/Materials/effect";
  55789. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55790. import { Light } from "babylonjs/Lights/light";
  55791. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55792. /**
  55793. * A spot light is defined by a position, a direction, an angle, and an exponent.
  55794. * These values define a cone of light starting from the position, emitting toward the direction.
  55795. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  55796. * and the exponent defines the speed of the decay of the light with distance (reach).
  55797. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55798. */
  55799. export class SpotLight extends ShadowLight {
  55800. private _angle;
  55801. private _innerAngle;
  55802. private _cosHalfAngle;
  55803. private _lightAngleScale;
  55804. private _lightAngleOffset;
  55805. /**
  55806. * Gets the cone angle of the spot light in Radians.
  55807. */
  55808. get angle(): number;
  55809. /**
  55810. * Sets the cone angle of the spot light in Radians.
  55811. */
  55812. set angle(value: number);
  55813. /**
  55814. * Only used in gltf falloff mode, this defines the angle where
  55815. * the directional falloff will start before cutting at angle which could be seen
  55816. * as outer angle.
  55817. */
  55818. get innerAngle(): number;
  55819. /**
  55820. * Only used in gltf falloff mode, this defines the angle where
  55821. * the directional falloff will start before cutting at angle which could be seen
  55822. * as outer angle.
  55823. */
  55824. set innerAngle(value: number);
  55825. private _shadowAngleScale;
  55826. /**
  55827. * Allows scaling the angle of the light for shadow generation only.
  55828. */
  55829. get shadowAngleScale(): number;
  55830. /**
  55831. * Allows scaling the angle of the light for shadow generation only.
  55832. */
  55833. set shadowAngleScale(value: number);
  55834. /**
  55835. * The light decay speed with the distance from the emission spot.
  55836. */
  55837. exponent: number;
  55838. private _projectionTextureMatrix;
  55839. /**
  55840. * Allows reading the projecton texture
  55841. */
  55842. get projectionTextureMatrix(): Matrix;
  55843. protected _projectionTextureLightNear: number;
  55844. /**
  55845. * Gets the near clip of the Spotlight for texture projection.
  55846. */
  55847. get projectionTextureLightNear(): number;
  55848. /**
  55849. * Sets the near clip of the Spotlight for texture projection.
  55850. */
  55851. set projectionTextureLightNear(value: number);
  55852. protected _projectionTextureLightFar: number;
  55853. /**
  55854. * Gets the far clip of the Spotlight for texture projection.
  55855. */
  55856. get projectionTextureLightFar(): number;
  55857. /**
  55858. * Sets the far clip of the Spotlight for texture projection.
  55859. */
  55860. set projectionTextureLightFar(value: number);
  55861. protected _projectionTextureUpDirection: Vector3;
  55862. /**
  55863. * Gets the Up vector of the Spotlight for texture projection.
  55864. */
  55865. get projectionTextureUpDirection(): Vector3;
  55866. /**
  55867. * Sets the Up vector of the Spotlight for texture projection.
  55868. */
  55869. set projectionTextureUpDirection(value: Vector3);
  55870. private _projectionTexture;
  55871. /**
  55872. * Gets the projection texture of the light.
  55873. */
  55874. get projectionTexture(): Nullable<BaseTexture>;
  55875. /**
  55876. * Sets the projection texture of the light.
  55877. */
  55878. set projectionTexture(value: Nullable<BaseTexture>);
  55879. private _projectionTextureViewLightDirty;
  55880. private _projectionTextureProjectionLightDirty;
  55881. private _projectionTextureDirty;
  55882. private _projectionTextureViewTargetVector;
  55883. private _projectionTextureViewLightMatrix;
  55884. private _projectionTextureProjectionLightMatrix;
  55885. private _projectionTextureScalingMatrix;
  55886. /**
  55887. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  55888. * It can cast shadows.
  55889. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55890. * @param name The light friendly name
  55891. * @param position The position of the spot light in the scene
  55892. * @param direction The direction of the light in the scene
  55893. * @param angle The cone angle of the light in Radians
  55894. * @param exponent The light decay speed with the distance from the emission spot
  55895. * @param scene The scene the lights belongs to
  55896. */
  55897. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  55898. /**
  55899. * Returns the string "SpotLight".
  55900. * @returns the class name
  55901. */
  55902. getClassName(): string;
  55903. /**
  55904. * Returns the integer 2.
  55905. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55906. */
  55907. getTypeID(): number;
  55908. /**
  55909. * Overrides the direction setter to recompute the projection texture view light Matrix.
  55910. */
  55911. protected _setDirection(value: Vector3): void;
  55912. /**
  55913. * Overrides the position setter to recompute the projection texture view light Matrix.
  55914. */
  55915. protected _setPosition(value: Vector3): void;
  55916. /**
  55917. * 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.
  55918. * Returns the SpotLight.
  55919. */
  55920. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55921. protected _computeProjectionTextureViewLightMatrix(): void;
  55922. protected _computeProjectionTextureProjectionLightMatrix(): void;
  55923. /**
  55924. * Main function for light texture projection matrix computing.
  55925. */
  55926. protected _computeProjectionTextureMatrix(): void;
  55927. protected _buildUniformLayout(): void;
  55928. private _computeAngleValues;
  55929. /**
  55930. * Sets the passed Effect "effect" with the Light textures.
  55931. * @param effect The effect to update
  55932. * @param lightIndex The index of the light in the effect to update
  55933. * @returns The light
  55934. */
  55935. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  55936. /**
  55937. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  55938. * @param effect The effect to update
  55939. * @param lightIndex The index of the light in the effect to update
  55940. * @returns The spot light
  55941. */
  55942. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  55943. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55944. /**
  55945. * Disposes the light and the associated resources.
  55946. */
  55947. dispose(): void;
  55948. /**
  55949. * Prepares the list of defines specific to the light type.
  55950. * @param defines the list of defines
  55951. * @param lightIndex defines the index of the light for the effect
  55952. */
  55953. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55954. }
  55955. }
  55956. declare module "babylonjs/Gizmos/lightGizmo" {
  55957. import { Nullable } from "babylonjs/types";
  55958. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55959. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55960. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55961. import { Light } from "babylonjs/Lights/light";
  55962. /**
  55963. * Gizmo that enables viewing a light
  55964. */
  55965. export class LightGizmo extends Gizmo {
  55966. private _lightMesh;
  55967. private _material;
  55968. private _cachedPosition;
  55969. private _cachedForward;
  55970. private _attachedMeshParent;
  55971. /**
  55972. * Creates a LightGizmo
  55973. * @param gizmoLayer The utility layer the gizmo will be added to
  55974. */
  55975. constructor(gizmoLayer?: UtilityLayerRenderer);
  55976. private _light;
  55977. /**
  55978. * The light that the gizmo is attached to
  55979. */
  55980. set light(light: Nullable<Light>);
  55981. get light(): Nullable<Light>;
  55982. /**
  55983. * Gets the material used to render the light gizmo
  55984. */
  55985. get material(): StandardMaterial;
  55986. /**
  55987. * @hidden
  55988. * Updates the gizmo to match the attached mesh's position/rotation
  55989. */
  55990. protected _update(): void;
  55991. private static _Scale;
  55992. /**
  55993. * Creates the lines for a light mesh
  55994. */
  55995. private static _CreateLightLines;
  55996. /**
  55997. * Disposes of the light gizmo
  55998. */
  55999. dispose(): void;
  56000. private static _CreateHemisphericLightMesh;
  56001. private static _CreatePointLightMesh;
  56002. private static _CreateSpotLightMesh;
  56003. private static _CreateDirectionalLightMesh;
  56004. }
  56005. }
  56006. declare module "babylonjs/Gizmos/index" {
  56007. export * from "babylonjs/Gizmos/axisDragGizmo";
  56008. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56009. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56010. export * from "babylonjs/Gizmos/gizmo";
  56011. export * from "babylonjs/Gizmos/gizmoManager";
  56012. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56013. export * from "babylonjs/Gizmos/positionGizmo";
  56014. export * from "babylonjs/Gizmos/rotationGizmo";
  56015. export * from "babylonjs/Gizmos/scaleGizmo";
  56016. export * from "babylonjs/Gizmos/lightGizmo";
  56017. export * from "babylonjs/Gizmos/planeDragGizmo";
  56018. }
  56019. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56020. /** @hidden */
  56021. export var backgroundFragmentDeclaration: {
  56022. name: string;
  56023. shader: string;
  56024. };
  56025. }
  56026. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56027. /** @hidden */
  56028. export var backgroundUboDeclaration: {
  56029. name: string;
  56030. shader: string;
  56031. };
  56032. }
  56033. declare module "babylonjs/Shaders/background.fragment" {
  56034. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56035. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56036. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56037. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56038. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56039. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56040. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56041. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56042. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56043. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56044. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56045. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56046. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56047. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56048. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56049. /** @hidden */
  56050. export var backgroundPixelShader: {
  56051. name: string;
  56052. shader: string;
  56053. };
  56054. }
  56055. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56056. /** @hidden */
  56057. export var backgroundVertexDeclaration: {
  56058. name: string;
  56059. shader: string;
  56060. };
  56061. }
  56062. declare module "babylonjs/Shaders/background.vertex" {
  56063. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56064. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56065. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56066. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56067. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56068. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56069. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56070. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56071. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56072. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56073. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56074. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56075. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56076. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56077. /** @hidden */
  56078. export var backgroundVertexShader: {
  56079. name: string;
  56080. shader: string;
  56081. };
  56082. }
  56083. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56084. import { Nullable, int, float } from "babylonjs/types";
  56085. import { Scene } from "babylonjs/scene";
  56086. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56087. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56089. import { Mesh } from "babylonjs/Meshes/mesh";
  56090. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56091. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56092. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56093. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56094. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56095. import { Color3 } from "babylonjs/Maths/math.color";
  56096. import "babylonjs/Shaders/background.fragment";
  56097. import "babylonjs/Shaders/background.vertex";
  56098. /**
  56099. * Background material used to create an efficient environement around your scene.
  56100. */
  56101. export class BackgroundMaterial extends PushMaterial {
  56102. /**
  56103. * Standard reflectance value at parallel view angle.
  56104. */
  56105. static StandardReflectance0: number;
  56106. /**
  56107. * Standard reflectance value at grazing angle.
  56108. */
  56109. static StandardReflectance90: number;
  56110. protected _primaryColor: Color3;
  56111. /**
  56112. * Key light Color (multiply against the environement texture)
  56113. */
  56114. primaryColor: Color3;
  56115. protected __perceptualColor: Nullable<Color3>;
  56116. /**
  56117. * Experimental Internal Use Only.
  56118. *
  56119. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56120. * This acts as a helper to set the primary color to a more "human friendly" value.
  56121. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56122. * output color as close as possible from the chosen value.
  56123. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56124. * part of lighting setup.)
  56125. */
  56126. get _perceptualColor(): Nullable<Color3>;
  56127. set _perceptualColor(value: Nullable<Color3>);
  56128. protected _primaryColorShadowLevel: float;
  56129. /**
  56130. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56131. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56132. */
  56133. get primaryColorShadowLevel(): float;
  56134. set primaryColorShadowLevel(value: float);
  56135. protected _primaryColorHighlightLevel: float;
  56136. /**
  56137. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56138. * The primary color is used at the level chosen to define what the white area would look.
  56139. */
  56140. get primaryColorHighlightLevel(): float;
  56141. set primaryColorHighlightLevel(value: float);
  56142. protected _reflectionTexture: Nullable<BaseTexture>;
  56143. /**
  56144. * Reflection Texture used in the material.
  56145. * Should be author in a specific way for the best result (refer to the documentation).
  56146. */
  56147. reflectionTexture: Nullable<BaseTexture>;
  56148. protected _reflectionBlur: float;
  56149. /**
  56150. * Reflection Texture level of blur.
  56151. *
  56152. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56153. * texture twice.
  56154. */
  56155. reflectionBlur: float;
  56156. protected _diffuseTexture: Nullable<BaseTexture>;
  56157. /**
  56158. * Diffuse Texture used in the material.
  56159. * Should be author in a specific way for the best result (refer to the documentation).
  56160. */
  56161. diffuseTexture: Nullable<BaseTexture>;
  56162. protected _shadowLights: Nullable<IShadowLight[]>;
  56163. /**
  56164. * Specify the list of lights casting shadow on the material.
  56165. * All scene shadow lights will be included if null.
  56166. */
  56167. shadowLights: Nullable<IShadowLight[]>;
  56168. protected _shadowLevel: float;
  56169. /**
  56170. * Helps adjusting the shadow to a softer level if required.
  56171. * 0 means black shadows and 1 means no shadows.
  56172. */
  56173. shadowLevel: float;
  56174. protected _sceneCenter: Vector3;
  56175. /**
  56176. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  56177. * It is usually zero but might be interesting to modify according to your setup.
  56178. */
  56179. sceneCenter: Vector3;
  56180. protected _opacityFresnel: boolean;
  56181. /**
  56182. * This helps specifying that the material is falling off to the sky box at grazing angle.
  56183. * This helps ensuring a nice transition when the camera goes under the ground.
  56184. */
  56185. opacityFresnel: boolean;
  56186. protected _reflectionFresnel: boolean;
  56187. /**
  56188. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  56189. * This helps adding a mirror texture on the ground.
  56190. */
  56191. reflectionFresnel: boolean;
  56192. protected _reflectionFalloffDistance: number;
  56193. /**
  56194. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  56195. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  56196. */
  56197. reflectionFalloffDistance: number;
  56198. protected _reflectionAmount: number;
  56199. /**
  56200. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  56201. */
  56202. reflectionAmount: number;
  56203. protected _reflectionReflectance0: number;
  56204. /**
  56205. * This specifies the weight of the reflection at grazing angle.
  56206. */
  56207. reflectionReflectance0: number;
  56208. protected _reflectionReflectance90: number;
  56209. /**
  56210. * This specifies the weight of the reflection at a perpendicular point of view.
  56211. */
  56212. reflectionReflectance90: number;
  56213. /**
  56214. * Sets the reflection reflectance fresnel values according to the default standard
  56215. * empirically know to work well :-)
  56216. */
  56217. set reflectionStandardFresnelWeight(value: number);
  56218. protected _useRGBColor: boolean;
  56219. /**
  56220. * Helps to directly use the maps channels instead of their level.
  56221. */
  56222. useRGBColor: boolean;
  56223. protected _enableNoise: boolean;
  56224. /**
  56225. * This helps reducing the banding effect that could occur on the background.
  56226. */
  56227. enableNoise: boolean;
  56228. /**
  56229. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56230. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  56231. * Recommended to be keep at 1.0 except for special cases.
  56232. */
  56233. get fovMultiplier(): number;
  56234. set fovMultiplier(value: number);
  56235. private _fovMultiplier;
  56236. /**
  56237. * Enable the FOV adjustment feature controlled by fovMultiplier.
  56238. */
  56239. useEquirectangularFOV: boolean;
  56240. private _maxSimultaneousLights;
  56241. /**
  56242. * Number of Simultaneous lights allowed on the material.
  56243. */
  56244. maxSimultaneousLights: int;
  56245. private _shadowOnly;
  56246. /**
  56247. * Make the material only render shadows
  56248. */
  56249. shadowOnly: boolean;
  56250. /**
  56251. * Default configuration related to image processing available in the Background Material.
  56252. */
  56253. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56254. /**
  56255. * Keep track of the image processing observer to allow dispose and replace.
  56256. */
  56257. private _imageProcessingObserver;
  56258. /**
  56259. * Attaches a new image processing configuration to the PBR Material.
  56260. * @param configuration (if null the scene configuration will be use)
  56261. */
  56262. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56263. /**
  56264. * Gets the image processing configuration used either in this material.
  56265. */
  56266. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  56267. /**
  56268. * Sets the Default image processing configuration used either in the this material.
  56269. *
  56270. * If sets to null, the scene one is in use.
  56271. */
  56272. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  56273. /**
  56274. * Gets wether the color curves effect is enabled.
  56275. */
  56276. get cameraColorCurvesEnabled(): boolean;
  56277. /**
  56278. * Sets wether the color curves effect is enabled.
  56279. */
  56280. set cameraColorCurvesEnabled(value: boolean);
  56281. /**
  56282. * Gets wether the color grading effect is enabled.
  56283. */
  56284. get cameraColorGradingEnabled(): boolean;
  56285. /**
  56286. * Gets wether the color grading effect is enabled.
  56287. */
  56288. set cameraColorGradingEnabled(value: boolean);
  56289. /**
  56290. * Gets wether tonemapping is enabled or not.
  56291. */
  56292. get cameraToneMappingEnabled(): boolean;
  56293. /**
  56294. * Sets wether tonemapping is enabled or not
  56295. */
  56296. set cameraToneMappingEnabled(value: boolean);
  56297. /**
  56298. * The camera exposure used on this material.
  56299. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56300. * This corresponds to a photographic exposure.
  56301. */
  56302. get cameraExposure(): float;
  56303. /**
  56304. * The camera exposure used on this material.
  56305. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56306. * This corresponds to a photographic exposure.
  56307. */
  56308. set cameraExposure(value: float);
  56309. /**
  56310. * Gets The camera contrast used on this material.
  56311. */
  56312. get cameraContrast(): float;
  56313. /**
  56314. * Sets The camera contrast used on this material.
  56315. */
  56316. set cameraContrast(value: float);
  56317. /**
  56318. * Gets the Color Grading 2D Lookup Texture.
  56319. */
  56320. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56321. /**
  56322. * Sets the Color Grading 2D Lookup Texture.
  56323. */
  56324. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56325. /**
  56326. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56327. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56328. * 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;
  56329. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56330. */
  56331. get cameraColorCurves(): Nullable<ColorCurves>;
  56332. /**
  56333. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56334. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56335. * 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;
  56336. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56337. */
  56338. set cameraColorCurves(value: Nullable<ColorCurves>);
  56339. /**
  56340. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  56341. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  56342. */
  56343. switchToBGR: boolean;
  56344. private _renderTargets;
  56345. private _reflectionControls;
  56346. private _white;
  56347. private _primaryShadowColor;
  56348. private _primaryHighlightColor;
  56349. /**
  56350. * Instantiates a Background Material in the given scene
  56351. * @param name The friendly name of the material
  56352. * @param scene The scene to add the material to
  56353. */
  56354. constructor(name: string, scene: Scene);
  56355. /**
  56356. * Gets a boolean indicating that current material needs to register RTT
  56357. */
  56358. get hasRenderTargetTextures(): boolean;
  56359. /**
  56360. * The entire material has been created in order to prevent overdraw.
  56361. * @returns false
  56362. */
  56363. needAlphaTesting(): boolean;
  56364. /**
  56365. * The entire material has been created in order to prevent overdraw.
  56366. * @returns true if blending is enable
  56367. */
  56368. needAlphaBlending(): boolean;
  56369. /**
  56370. * Checks wether the material is ready to be rendered for a given mesh.
  56371. * @param mesh The mesh to render
  56372. * @param subMesh The submesh to check against
  56373. * @param useInstances Specify wether or not the material is used with instances
  56374. * @returns true if all the dependencies are ready (Textures, Effects...)
  56375. */
  56376. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56377. /**
  56378. * Compute the primary color according to the chosen perceptual color.
  56379. */
  56380. private _computePrimaryColorFromPerceptualColor;
  56381. /**
  56382. * Compute the highlights and shadow colors according to their chosen levels.
  56383. */
  56384. private _computePrimaryColors;
  56385. /**
  56386. * Build the uniform buffer used in the material.
  56387. */
  56388. buildUniformLayout(): void;
  56389. /**
  56390. * Unbind the material.
  56391. */
  56392. unbind(): void;
  56393. /**
  56394. * Bind only the world matrix to the material.
  56395. * @param world The world matrix to bind.
  56396. */
  56397. bindOnlyWorldMatrix(world: Matrix): void;
  56398. /**
  56399. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  56400. * @param world The world matrix to bind.
  56401. * @param subMesh The submesh to bind for.
  56402. */
  56403. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56404. /**
  56405. * Checks to see if a texture is used in the material.
  56406. * @param texture - Base texture to use.
  56407. * @returns - Boolean specifying if a texture is used in the material.
  56408. */
  56409. hasTexture(texture: BaseTexture): boolean;
  56410. /**
  56411. * Dispose the material.
  56412. * @param forceDisposeEffect Force disposal of the associated effect.
  56413. * @param forceDisposeTextures Force disposal of the associated textures.
  56414. */
  56415. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56416. /**
  56417. * Clones the material.
  56418. * @param name The cloned name.
  56419. * @returns The cloned material.
  56420. */
  56421. clone(name: string): BackgroundMaterial;
  56422. /**
  56423. * Serializes the current material to its JSON representation.
  56424. * @returns The JSON representation.
  56425. */
  56426. serialize(): any;
  56427. /**
  56428. * Gets the class name of the material
  56429. * @returns "BackgroundMaterial"
  56430. */
  56431. getClassName(): string;
  56432. /**
  56433. * Parse a JSON input to create back a background material.
  56434. * @param source The JSON data to parse
  56435. * @param scene The scene to create the parsed material in
  56436. * @param rootUrl The root url of the assets the material depends upon
  56437. * @returns the instantiated BackgroundMaterial.
  56438. */
  56439. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  56440. }
  56441. }
  56442. declare module "babylonjs/Helpers/environmentHelper" {
  56443. import { Observable } from "babylonjs/Misc/observable";
  56444. import { Nullable } from "babylonjs/types";
  56445. import { Scene } from "babylonjs/scene";
  56446. import { Vector3 } from "babylonjs/Maths/math.vector";
  56447. import { Color3 } from "babylonjs/Maths/math.color";
  56448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56449. import { Mesh } from "babylonjs/Meshes/mesh";
  56450. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56451. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  56452. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56453. import "babylonjs/Meshes/Builders/planeBuilder";
  56454. import "babylonjs/Meshes/Builders/boxBuilder";
  56455. /**
  56456. * Represents the different options available during the creation of
  56457. * a Environment helper.
  56458. *
  56459. * This can control the default ground, skybox and image processing setup of your scene.
  56460. */
  56461. export interface IEnvironmentHelperOptions {
  56462. /**
  56463. * Specifies whether or not to create a ground.
  56464. * True by default.
  56465. */
  56466. createGround: boolean;
  56467. /**
  56468. * Specifies the ground size.
  56469. * 15 by default.
  56470. */
  56471. groundSize: number;
  56472. /**
  56473. * The texture used on the ground for the main color.
  56474. * Comes from the BabylonJS CDN by default.
  56475. *
  56476. * Remarks: Can be either a texture or a url.
  56477. */
  56478. groundTexture: string | BaseTexture;
  56479. /**
  56480. * The color mixed in the ground texture by default.
  56481. * BabylonJS clearColor by default.
  56482. */
  56483. groundColor: Color3;
  56484. /**
  56485. * Specifies the ground opacity.
  56486. * 1 by default.
  56487. */
  56488. groundOpacity: number;
  56489. /**
  56490. * Enables the ground to receive shadows.
  56491. * True by default.
  56492. */
  56493. enableGroundShadow: boolean;
  56494. /**
  56495. * Helps preventing the shadow to be fully black on the ground.
  56496. * 0.5 by default.
  56497. */
  56498. groundShadowLevel: number;
  56499. /**
  56500. * Creates a mirror texture attach to the ground.
  56501. * false by default.
  56502. */
  56503. enableGroundMirror: boolean;
  56504. /**
  56505. * Specifies the ground mirror size ratio.
  56506. * 0.3 by default as the default kernel is 64.
  56507. */
  56508. groundMirrorSizeRatio: number;
  56509. /**
  56510. * Specifies the ground mirror blur kernel size.
  56511. * 64 by default.
  56512. */
  56513. groundMirrorBlurKernel: number;
  56514. /**
  56515. * Specifies the ground mirror visibility amount.
  56516. * 1 by default
  56517. */
  56518. groundMirrorAmount: number;
  56519. /**
  56520. * Specifies the ground mirror reflectance weight.
  56521. * This uses the standard weight of the background material to setup the fresnel effect
  56522. * of the mirror.
  56523. * 1 by default.
  56524. */
  56525. groundMirrorFresnelWeight: number;
  56526. /**
  56527. * Specifies the ground mirror Falloff distance.
  56528. * This can helps reducing the size of the reflection.
  56529. * 0 by Default.
  56530. */
  56531. groundMirrorFallOffDistance: number;
  56532. /**
  56533. * Specifies the ground mirror texture type.
  56534. * Unsigned Int by Default.
  56535. */
  56536. groundMirrorTextureType: number;
  56537. /**
  56538. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  56539. * the shown objects.
  56540. */
  56541. groundYBias: number;
  56542. /**
  56543. * Specifies whether or not to create a skybox.
  56544. * True by default.
  56545. */
  56546. createSkybox: boolean;
  56547. /**
  56548. * Specifies the skybox size.
  56549. * 20 by default.
  56550. */
  56551. skyboxSize: number;
  56552. /**
  56553. * The texture used on the skybox for the main color.
  56554. * Comes from the BabylonJS CDN by default.
  56555. *
  56556. * Remarks: Can be either a texture or a url.
  56557. */
  56558. skyboxTexture: string | BaseTexture;
  56559. /**
  56560. * The color mixed in the skybox texture by default.
  56561. * BabylonJS clearColor by default.
  56562. */
  56563. skyboxColor: Color3;
  56564. /**
  56565. * The background rotation around the Y axis of the scene.
  56566. * This helps aligning the key lights of your scene with the background.
  56567. * 0 by default.
  56568. */
  56569. backgroundYRotation: number;
  56570. /**
  56571. * Compute automatically the size of the elements to best fit with the scene.
  56572. */
  56573. sizeAuto: boolean;
  56574. /**
  56575. * Default position of the rootMesh if autoSize is not true.
  56576. */
  56577. rootPosition: Vector3;
  56578. /**
  56579. * Sets up the image processing in the scene.
  56580. * true by default.
  56581. */
  56582. setupImageProcessing: boolean;
  56583. /**
  56584. * The texture used as your environment texture in the scene.
  56585. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  56586. *
  56587. * Remarks: Can be either a texture or a url.
  56588. */
  56589. environmentTexture: string | BaseTexture;
  56590. /**
  56591. * The value of the exposure to apply to the scene.
  56592. * 0.6 by default if setupImageProcessing is true.
  56593. */
  56594. cameraExposure: number;
  56595. /**
  56596. * The value of the contrast to apply to the scene.
  56597. * 1.6 by default if setupImageProcessing is true.
  56598. */
  56599. cameraContrast: number;
  56600. /**
  56601. * Specifies whether or not tonemapping should be enabled in the scene.
  56602. * true by default if setupImageProcessing is true.
  56603. */
  56604. toneMappingEnabled: boolean;
  56605. }
  56606. /**
  56607. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  56608. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  56609. * It also helps with the default setup of your imageProcessing configuration.
  56610. */
  56611. export class EnvironmentHelper {
  56612. /**
  56613. * Default ground texture URL.
  56614. */
  56615. private static _groundTextureCDNUrl;
  56616. /**
  56617. * Default skybox texture URL.
  56618. */
  56619. private static _skyboxTextureCDNUrl;
  56620. /**
  56621. * Default environment texture URL.
  56622. */
  56623. private static _environmentTextureCDNUrl;
  56624. /**
  56625. * Creates the default options for the helper.
  56626. */
  56627. private static _getDefaultOptions;
  56628. private _rootMesh;
  56629. /**
  56630. * Gets the root mesh created by the helper.
  56631. */
  56632. get rootMesh(): Mesh;
  56633. private _skybox;
  56634. /**
  56635. * Gets the skybox created by the helper.
  56636. */
  56637. get skybox(): Nullable<Mesh>;
  56638. private _skyboxTexture;
  56639. /**
  56640. * Gets the skybox texture created by the helper.
  56641. */
  56642. get skyboxTexture(): Nullable<BaseTexture>;
  56643. private _skyboxMaterial;
  56644. /**
  56645. * Gets the skybox material created by the helper.
  56646. */
  56647. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  56648. private _ground;
  56649. /**
  56650. * Gets the ground mesh created by the helper.
  56651. */
  56652. get ground(): Nullable<Mesh>;
  56653. private _groundTexture;
  56654. /**
  56655. * Gets the ground texture created by the helper.
  56656. */
  56657. get groundTexture(): Nullable<BaseTexture>;
  56658. private _groundMirror;
  56659. /**
  56660. * Gets the ground mirror created by the helper.
  56661. */
  56662. get groundMirror(): Nullable<MirrorTexture>;
  56663. /**
  56664. * Gets the ground mirror render list to helps pushing the meshes
  56665. * you wish in the ground reflection.
  56666. */
  56667. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  56668. private _groundMaterial;
  56669. /**
  56670. * Gets the ground material created by the helper.
  56671. */
  56672. get groundMaterial(): Nullable<BackgroundMaterial>;
  56673. /**
  56674. * Stores the creation options.
  56675. */
  56676. private readonly _scene;
  56677. private _options;
  56678. /**
  56679. * This observable will be notified with any error during the creation of the environment,
  56680. * mainly texture creation errors.
  56681. */
  56682. onErrorObservable: Observable<{
  56683. message?: string;
  56684. exception?: any;
  56685. }>;
  56686. /**
  56687. * constructor
  56688. * @param options Defines the options we want to customize the helper
  56689. * @param scene The scene to add the material to
  56690. */
  56691. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  56692. /**
  56693. * Updates the background according to the new options
  56694. * @param options
  56695. */
  56696. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  56697. /**
  56698. * Sets the primary color of all the available elements.
  56699. * @param color the main color to affect to the ground and the background
  56700. */
  56701. setMainColor(color: Color3): void;
  56702. /**
  56703. * Setup the image processing according to the specified options.
  56704. */
  56705. private _setupImageProcessing;
  56706. /**
  56707. * Setup the environment texture according to the specified options.
  56708. */
  56709. private _setupEnvironmentTexture;
  56710. /**
  56711. * Setup the background according to the specified options.
  56712. */
  56713. private _setupBackground;
  56714. /**
  56715. * Get the scene sizes according to the setup.
  56716. */
  56717. private _getSceneSize;
  56718. /**
  56719. * Setup the ground according to the specified options.
  56720. */
  56721. private _setupGround;
  56722. /**
  56723. * Setup the ground material according to the specified options.
  56724. */
  56725. private _setupGroundMaterial;
  56726. /**
  56727. * Setup the ground diffuse texture according to the specified options.
  56728. */
  56729. private _setupGroundDiffuseTexture;
  56730. /**
  56731. * Setup the ground mirror texture according to the specified options.
  56732. */
  56733. private _setupGroundMirrorTexture;
  56734. /**
  56735. * Setup the ground to receive the mirror texture.
  56736. */
  56737. private _setupMirrorInGroundMaterial;
  56738. /**
  56739. * Setup the skybox according to the specified options.
  56740. */
  56741. private _setupSkybox;
  56742. /**
  56743. * Setup the skybox material according to the specified options.
  56744. */
  56745. private _setupSkyboxMaterial;
  56746. /**
  56747. * Setup the skybox reflection texture according to the specified options.
  56748. */
  56749. private _setupSkyboxReflectionTexture;
  56750. private _errorHandler;
  56751. /**
  56752. * Dispose all the elements created by the Helper.
  56753. */
  56754. dispose(): void;
  56755. }
  56756. }
  56757. declare module "babylonjs/Helpers/photoDome" {
  56758. import { Observable } from "babylonjs/Misc/observable";
  56759. import { Nullable } from "babylonjs/types";
  56760. import { Scene } from "babylonjs/scene";
  56761. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56762. import { Mesh } from "babylonjs/Meshes/mesh";
  56763. import { Texture } from "babylonjs/Materials/Textures/texture";
  56764. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56765. import "babylonjs/Meshes/Builders/sphereBuilder";
  56766. /**
  56767. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  56768. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  56769. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  56770. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56771. */
  56772. export class PhotoDome extends TransformNode {
  56773. /**
  56774. * Define the image as a Monoscopic panoramic 360 image.
  56775. */
  56776. static readonly MODE_MONOSCOPIC: number;
  56777. /**
  56778. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56779. */
  56780. static readonly MODE_TOPBOTTOM: number;
  56781. /**
  56782. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56783. */
  56784. static readonly MODE_SIDEBYSIDE: number;
  56785. private _useDirectMapping;
  56786. /**
  56787. * The texture being displayed on the sphere
  56788. */
  56789. protected _photoTexture: Texture;
  56790. /**
  56791. * Gets or sets the texture being displayed on the sphere
  56792. */
  56793. get photoTexture(): Texture;
  56794. set photoTexture(value: Texture);
  56795. /**
  56796. * Observable raised when an error occured while loading the 360 image
  56797. */
  56798. onLoadErrorObservable: Observable<string>;
  56799. /**
  56800. * The skybox material
  56801. */
  56802. protected _material: BackgroundMaterial;
  56803. /**
  56804. * The surface used for the skybox
  56805. */
  56806. protected _mesh: Mesh;
  56807. /**
  56808. * Gets the mesh used for the skybox.
  56809. */
  56810. get mesh(): Mesh;
  56811. /**
  56812. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56813. * Also see the options.resolution property.
  56814. */
  56815. get fovMultiplier(): number;
  56816. set fovMultiplier(value: number);
  56817. private _imageMode;
  56818. /**
  56819. * Gets or set the current video mode for the video. It can be:
  56820. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  56821. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56822. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56823. */
  56824. get imageMode(): number;
  56825. set imageMode(value: number);
  56826. /**
  56827. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  56828. * @param name Element's name, child elements will append suffixes for their own names.
  56829. * @param urlsOfPhoto defines the url of the photo to display
  56830. * @param options defines an object containing optional or exposed sub element properties
  56831. * @param onError defines a callback called when an error occured while loading the texture
  56832. */
  56833. constructor(name: string, urlOfPhoto: string, options: {
  56834. resolution?: number;
  56835. size?: number;
  56836. useDirectMapping?: boolean;
  56837. faceForward?: boolean;
  56838. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  56839. private _onBeforeCameraRenderObserver;
  56840. private _changeImageMode;
  56841. /**
  56842. * Releases resources associated with this node.
  56843. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56844. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56845. */
  56846. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56847. }
  56848. }
  56849. declare module "babylonjs/Misc/rgbdTextureTools" {
  56850. import "babylonjs/Shaders/rgbdDecode.fragment";
  56851. import "babylonjs/Engines/Extensions/engine.renderTarget";
  56852. import { Texture } from "babylonjs/Materials/Textures/texture";
  56853. /**
  56854. * Class used to host RGBD texture specific utilities
  56855. */
  56856. export class RGBDTextureTools {
  56857. /**
  56858. * Expand the RGBD Texture from RGBD to Half Float if possible.
  56859. * @param texture the texture to expand.
  56860. */
  56861. static ExpandRGBDTexture(texture: Texture): void;
  56862. }
  56863. }
  56864. declare module "babylonjs/Misc/brdfTextureTools" {
  56865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56866. import { Scene } from "babylonjs/scene";
  56867. /**
  56868. * Class used to host texture specific utilities
  56869. */
  56870. export class BRDFTextureTools {
  56871. /**
  56872. * Prevents texture cache collision
  56873. */
  56874. private static _instanceNumber;
  56875. /**
  56876. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  56877. * @param scene defines the hosting scene
  56878. * @returns the environment BRDF texture
  56879. */
  56880. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  56881. private static _environmentBRDFBase64Texture;
  56882. }
  56883. }
  56884. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  56885. import { Nullable } from "babylonjs/types";
  56886. import { Color3 } from "babylonjs/Maths/math.color";
  56887. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56888. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56889. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56890. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56891. import { Engine } from "babylonjs/Engines/engine";
  56892. import { Scene } from "babylonjs/scene";
  56893. /**
  56894. * @hidden
  56895. */
  56896. export interface IMaterialClearCoatDefines {
  56897. CLEARCOAT: boolean;
  56898. CLEARCOAT_DEFAULTIOR: boolean;
  56899. CLEARCOAT_TEXTURE: boolean;
  56900. CLEARCOAT_TEXTUREDIRECTUV: number;
  56901. CLEARCOAT_BUMP: boolean;
  56902. CLEARCOAT_BUMPDIRECTUV: number;
  56903. CLEARCOAT_TINT: boolean;
  56904. CLEARCOAT_TINT_TEXTURE: boolean;
  56905. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56906. /** @hidden */
  56907. _areTexturesDirty: boolean;
  56908. }
  56909. /**
  56910. * Define the code related to the clear coat parameters of the pbr material.
  56911. */
  56912. export class PBRClearCoatConfiguration {
  56913. /**
  56914. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56915. * The default fits with a polyurethane material.
  56916. */
  56917. private static readonly _DefaultIndexOfRefraction;
  56918. private _isEnabled;
  56919. /**
  56920. * Defines if the clear coat is enabled in the material.
  56921. */
  56922. isEnabled: boolean;
  56923. /**
  56924. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  56925. */
  56926. intensity: number;
  56927. /**
  56928. * Defines the clear coat layer roughness.
  56929. */
  56930. roughness: number;
  56931. private _indexOfRefraction;
  56932. /**
  56933. * Defines the index of refraction of the clear coat.
  56934. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56935. * The default fits with a polyurethane material.
  56936. * Changing the default value is more performance intensive.
  56937. */
  56938. indexOfRefraction: number;
  56939. private _texture;
  56940. /**
  56941. * Stores the clear coat values in a texture.
  56942. */
  56943. texture: Nullable<BaseTexture>;
  56944. private _bumpTexture;
  56945. /**
  56946. * Define the clear coat specific bump texture.
  56947. */
  56948. bumpTexture: Nullable<BaseTexture>;
  56949. private _isTintEnabled;
  56950. /**
  56951. * Defines if the clear coat tint is enabled in the material.
  56952. */
  56953. isTintEnabled: boolean;
  56954. /**
  56955. * Defines the clear coat tint of the material.
  56956. * This is only use if tint is enabled
  56957. */
  56958. tintColor: Color3;
  56959. /**
  56960. * Defines the distance at which the tint color should be found in the
  56961. * clear coat media.
  56962. * This is only use if tint is enabled
  56963. */
  56964. tintColorAtDistance: number;
  56965. /**
  56966. * Defines the clear coat layer thickness.
  56967. * This is only use if tint is enabled
  56968. */
  56969. tintThickness: number;
  56970. private _tintTexture;
  56971. /**
  56972. * Stores the clear tint values in a texture.
  56973. * rgb is tint
  56974. * a is a thickness factor
  56975. */
  56976. tintTexture: Nullable<BaseTexture>;
  56977. /** @hidden */
  56978. private _internalMarkAllSubMeshesAsTexturesDirty;
  56979. /** @hidden */
  56980. _markAllSubMeshesAsTexturesDirty(): void;
  56981. /**
  56982. * Instantiate a new istance of clear coat configuration.
  56983. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56984. */
  56985. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56986. /**
  56987. * Gets wehter the submesh is ready to be used or not.
  56988. * @param defines the list of "defines" to update.
  56989. * @param scene defines the scene the material belongs to.
  56990. * @param engine defines the engine the material belongs to.
  56991. * @param disableBumpMap defines wether the material disables bump or not.
  56992. * @returns - boolean indicating that the submesh is ready or not.
  56993. */
  56994. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  56995. /**
  56996. * Checks to see if a texture is used in the material.
  56997. * @param defines the list of "defines" to update.
  56998. * @param scene defines the scene to the material belongs to.
  56999. */
  57000. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57001. /**
  57002. * Binds the material data.
  57003. * @param uniformBuffer defines the Uniform buffer to fill in.
  57004. * @param scene defines the scene the material belongs to.
  57005. * @param engine defines the engine the material belongs to.
  57006. * @param disableBumpMap defines wether the material disables bump or not.
  57007. * @param isFrozen defines wether the material is frozen or not.
  57008. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57009. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57010. */
  57011. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57012. /**
  57013. * Checks to see if a texture is used in the material.
  57014. * @param texture - Base texture to use.
  57015. * @returns - Boolean specifying if a texture is used in the material.
  57016. */
  57017. hasTexture(texture: BaseTexture): boolean;
  57018. /**
  57019. * Returns an array of the actively used textures.
  57020. * @param activeTextures Array of BaseTextures
  57021. */
  57022. getActiveTextures(activeTextures: BaseTexture[]): void;
  57023. /**
  57024. * Returns the animatable textures.
  57025. * @param animatables Array of animatable textures.
  57026. */
  57027. getAnimatables(animatables: IAnimatable[]): void;
  57028. /**
  57029. * Disposes the resources of the material.
  57030. * @param forceDisposeTextures - Forces the disposal of all textures.
  57031. */
  57032. dispose(forceDisposeTextures?: boolean): void;
  57033. /**
  57034. * Get the current class name of the texture useful for serialization or dynamic coding.
  57035. * @returns "PBRClearCoatConfiguration"
  57036. */
  57037. getClassName(): string;
  57038. /**
  57039. * Add fallbacks to the effect fallbacks list.
  57040. * @param defines defines the Base texture to use.
  57041. * @param fallbacks defines the current fallback list.
  57042. * @param currentRank defines the current fallback rank.
  57043. * @returns the new fallback rank.
  57044. */
  57045. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57046. /**
  57047. * Add the required uniforms to the current list.
  57048. * @param uniforms defines the current uniform list.
  57049. */
  57050. static AddUniforms(uniforms: string[]): void;
  57051. /**
  57052. * Add the required samplers to the current list.
  57053. * @param samplers defines the current sampler list.
  57054. */
  57055. static AddSamplers(samplers: string[]): void;
  57056. /**
  57057. * Add the required uniforms to the current buffer.
  57058. * @param uniformBuffer defines the current uniform buffer.
  57059. */
  57060. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57061. /**
  57062. * Makes a duplicate of the current configuration into another one.
  57063. * @param clearCoatConfiguration define the config where to copy the info
  57064. */
  57065. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57066. /**
  57067. * Serializes this clear coat configuration.
  57068. * @returns - An object with the serialized config.
  57069. */
  57070. serialize(): any;
  57071. /**
  57072. * Parses a anisotropy Configuration from a serialized object.
  57073. * @param source - Serialized object.
  57074. * @param scene Defines the scene we are parsing for
  57075. * @param rootUrl Defines the rootUrl to load from
  57076. */
  57077. parse(source: any, scene: Scene, rootUrl: string): void;
  57078. }
  57079. }
  57080. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57081. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57083. import { Vector2 } from "babylonjs/Maths/math.vector";
  57084. import { Scene } from "babylonjs/scene";
  57085. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57086. import { Nullable } from "babylonjs/types";
  57087. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57088. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57089. /**
  57090. * @hidden
  57091. */
  57092. export interface IMaterialAnisotropicDefines {
  57093. ANISOTROPIC: boolean;
  57094. ANISOTROPIC_TEXTURE: boolean;
  57095. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57096. MAINUV1: boolean;
  57097. _areTexturesDirty: boolean;
  57098. _needUVs: boolean;
  57099. }
  57100. /**
  57101. * Define the code related to the anisotropic parameters of the pbr material.
  57102. */
  57103. export class PBRAnisotropicConfiguration {
  57104. private _isEnabled;
  57105. /**
  57106. * Defines if the anisotropy is enabled in the material.
  57107. */
  57108. isEnabled: boolean;
  57109. /**
  57110. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  57111. */
  57112. intensity: number;
  57113. /**
  57114. * Defines if the effect is along the tangents, bitangents or in between.
  57115. * By default, the effect is "strectching" the highlights along the tangents.
  57116. */
  57117. direction: Vector2;
  57118. private _texture;
  57119. /**
  57120. * Stores the anisotropy values in a texture.
  57121. * rg is direction (like normal from -1 to 1)
  57122. * b is a intensity
  57123. */
  57124. texture: Nullable<BaseTexture>;
  57125. /** @hidden */
  57126. private _internalMarkAllSubMeshesAsTexturesDirty;
  57127. /** @hidden */
  57128. _markAllSubMeshesAsTexturesDirty(): void;
  57129. /**
  57130. * Instantiate a new istance of anisotropy configuration.
  57131. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57132. */
  57133. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57134. /**
  57135. * Specifies that the submesh is ready to be used.
  57136. * @param defines the list of "defines" to update.
  57137. * @param scene defines the scene the material belongs to.
  57138. * @returns - boolean indicating that the submesh is ready or not.
  57139. */
  57140. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  57141. /**
  57142. * Checks to see if a texture is used in the material.
  57143. * @param defines the list of "defines" to update.
  57144. * @param mesh the mesh we are preparing the defines for.
  57145. * @param scene defines the scene the material belongs to.
  57146. */
  57147. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  57148. /**
  57149. * Binds the material data.
  57150. * @param uniformBuffer defines the Uniform buffer to fill in.
  57151. * @param scene defines the scene the material belongs to.
  57152. * @param isFrozen defines wether the material is frozen or not.
  57153. */
  57154. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57155. /**
  57156. * Checks to see if a texture is used in the material.
  57157. * @param texture - Base texture to use.
  57158. * @returns - Boolean specifying if a texture is used in the material.
  57159. */
  57160. hasTexture(texture: BaseTexture): boolean;
  57161. /**
  57162. * Returns an array of the actively used textures.
  57163. * @param activeTextures Array of BaseTextures
  57164. */
  57165. getActiveTextures(activeTextures: BaseTexture[]): void;
  57166. /**
  57167. * Returns the animatable textures.
  57168. * @param animatables Array of animatable textures.
  57169. */
  57170. getAnimatables(animatables: IAnimatable[]): void;
  57171. /**
  57172. * Disposes the resources of the material.
  57173. * @param forceDisposeTextures - Forces the disposal of all textures.
  57174. */
  57175. dispose(forceDisposeTextures?: boolean): void;
  57176. /**
  57177. * Get the current class name of the texture useful for serialization or dynamic coding.
  57178. * @returns "PBRAnisotropicConfiguration"
  57179. */
  57180. getClassName(): string;
  57181. /**
  57182. * Add fallbacks to the effect fallbacks list.
  57183. * @param defines defines the Base texture to use.
  57184. * @param fallbacks defines the current fallback list.
  57185. * @param currentRank defines the current fallback rank.
  57186. * @returns the new fallback rank.
  57187. */
  57188. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57189. /**
  57190. * Add the required uniforms to the current list.
  57191. * @param uniforms defines the current uniform list.
  57192. */
  57193. static AddUniforms(uniforms: string[]): void;
  57194. /**
  57195. * Add the required uniforms to the current buffer.
  57196. * @param uniformBuffer defines the current uniform buffer.
  57197. */
  57198. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57199. /**
  57200. * Add the required samplers to the current list.
  57201. * @param samplers defines the current sampler list.
  57202. */
  57203. static AddSamplers(samplers: string[]): void;
  57204. /**
  57205. * Makes a duplicate of the current configuration into another one.
  57206. * @param anisotropicConfiguration define the config where to copy the info
  57207. */
  57208. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  57209. /**
  57210. * Serializes this anisotropy configuration.
  57211. * @returns - An object with the serialized config.
  57212. */
  57213. serialize(): any;
  57214. /**
  57215. * Parses a anisotropy Configuration from a serialized object.
  57216. * @param source - Serialized object.
  57217. * @param scene Defines the scene we are parsing for
  57218. * @param rootUrl Defines the rootUrl to load from
  57219. */
  57220. parse(source: any, scene: Scene, rootUrl: string): void;
  57221. }
  57222. }
  57223. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  57224. import { Scene } from "babylonjs/scene";
  57225. /**
  57226. * @hidden
  57227. */
  57228. export interface IMaterialBRDFDefines {
  57229. BRDF_V_HEIGHT_CORRELATED: boolean;
  57230. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57231. SPHERICAL_HARMONICS: boolean;
  57232. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57233. /** @hidden */
  57234. _areMiscDirty: boolean;
  57235. }
  57236. /**
  57237. * Define the code related to the BRDF parameters of the pbr material.
  57238. */
  57239. export class PBRBRDFConfiguration {
  57240. /**
  57241. * Default value used for the energy conservation.
  57242. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57243. */
  57244. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  57245. /**
  57246. * Default value used for the Smith Visibility Height Correlated mode.
  57247. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57248. */
  57249. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  57250. /**
  57251. * Default value used for the IBL diffuse part.
  57252. * This can help switching back to the polynomials mode globally which is a tiny bit
  57253. * less GPU intensive at the drawback of a lower quality.
  57254. */
  57255. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  57256. /**
  57257. * Default value used for activating energy conservation for the specular workflow.
  57258. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57259. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57260. */
  57261. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  57262. private _useEnergyConservation;
  57263. /**
  57264. * Defines if the material uses energy conservation.
  57265. */
  57266. useEnergyConservation: boolean;
  57267. private _useSmithVisibilityHeightCorrelated;
  57268. /**
  57269. * LEGACY Mode set to false
  57270. * Defines if the material uses height smith correlated visibility term.
  57271. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  57272. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  57273. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  57274. * Not relying on height correlated will also disable energy conservation.
  57275. */
  57276. useSmithVisibilityHeightCorrelated: boolean;
  57277. private _useSphericalHarmonics;
  57278. /**
  57279. * LEGACY Mode set to false
  57280. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  57281. * diffuse part of the IBL.
  57282. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  57283. * to the ground truth.
  57284. */
  57285. useSphericalHarmonics: boolean;
  57286. private _useSpecularGlossinessInputEnergyConservation;
  57287. /**
  57288. * Defines if the material uses energy conservation, when the specular workflow is active.
  57289. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57290. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57291. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  57292. */
  57293. useSpecularGlossinessInputEnergyConservation: boolean;
  57294. /** @hidden */
  57295. private _internalMarkAllSubMeshesAsMiscDirty;
  57296. /** @hidden */
  57297. _markAllSubMeshesAsMiscDirty(): void;
  57298. /**
  57299. * Instantiate a new istance of clear coat configuration.
  57300. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  57301. */
  57302. constructor(markAllSubMeshesAsMiscDirty: () => void);
  57303. /**
  57304. * Checks to see if a texture is used in the material.
  57305. * @param defines the list of "defines" to update.
  57306. */
  57307. prepareDefines(defines: IMaterialBRDFDefines): void;
  57308. /**
  57309. * Get the current class name of the texture useful for serialization or dynamic coding.
  57310. * @returns "PBRClearCoatConfiguration"
  57311. */
  57312. getClassName(): string;
  57313. /**
  57314. * Makes a duplicate of the current configuration into another one.
  57315. * @param brdfConfiguration define the config where to copy the info
  57316. */
  57317. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  57318. /**
  57319. * Serializes this BRDF configuration.
  57320. * @returns - An object with the serialized config.
  57321. */
  57322. serialize(): any;
  57323. /**
  57324. * Parses a anisotropy Configuration from a serialized object.
  57325. * @param source - Serialized object.
  57326. * @param scene Defines the scene we are parsing for
  57327. * @param rootUrl Defines the rootUrl to load from
  57328. */
  57329. parse(source: any, scene: Scene, rootUrl: string): void;
  57330. }
  57331. }
  57332. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  57333. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57334. import { Color3 } from "babylonjs/Maths/math.color";
  57335. import { Scene } from "babylonjs/scene";
  57336. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57337. import { Nullable } from "babylonjs/types";
  57338. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57339. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57340. /**
  57341. * @hidden
  57342. */
  57343. export interface IMaterialSheenDefines {
  57344. SHEEN: boolean;
  57345. SHEEN_TEXTURE: boolean;
  57346. SHEEN_TEXTUREDIRECTUV: number;
  57347. SHEEN_LINKWITHALBEDO: boolean;
  57348. SHEEN_ROUGHNESS: boolean;
  57349. SHEEN_ALBEDOSCALING: boolean;
  57350. /** @hidden */
  57351. _areTexturesDirty: boolean;
  57352. }
  57353. /**
  57354. * Define the code related to the Sheen parameters of the pbr material.
  57355. */
  57356. export class PBRSheenConfiguration {
  57357. private _isEnabled;
  57358. /**
  57359. * Defines if the material uses sheen.
  57360. */
  57361. isEnabled: boolean;
  57362. private _linkSheenWithAlbedo;
  57363. /**
  57364. * Defines if the sheen is linked to the sheen color.
  57365. */
  57366. linkSheenWithAlbedo: boolean;
  57367. /**
  57368. * Defines the sheen intensity.
  57369. */
  57370. intensity: number;
  57371. /**
  57372. * Defines the sheen color.
  57373. */
  57374. color: Color3;
  57375. private _texture;
  57376. /**
  57377. * Stores the sheen tint values in a texture.
  57378. * rgb is tint
  57379. * a is a intensity or roughness if roughness has been defined
  57380. */
  57381. texture: Nullable<BaseTexture>;
  57382. private _roughness;
  57383. /**
  57384. * Defines the sheen roughness.
  57385. * It is not taken into account if linkSheenWithAlbedo is true.
  57386. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  57387. */
  57388. roughness: Nullable<number>;
  57389. private _albedoScaling;
  57390. /**
  57391. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  57392. * It allows the strength of the sheen effect to not depend on the base color of the material,
  57393. * making it easier to setup and tweak the effect
  57394. */
  57395. albedoScaling: boolean;
  57396. /** @hidden */
  57397. private _internalMarkAllSubMeshesAsTexturesDirty;
  57398. /** @hidden */
  57399. _markAllSubMeshesAsTexturesDirty(): void;
  57400. /**
  57401. * Instantiate a new istance of clear coat configuration.
  57402. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57403. */
  57404. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57405. /**
  57406. * Specifies that the submesh is ready to be used.
  57407. * @param defines the list of "defines" to update.
  57408. * @param scene defines the scene the material belongs to.
  57409. * @returns - boolean indicating that the submesh is ready or not.
  57410. */
  57411. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  57412. /**
  57413. * Checks to see if a texture is used in the material.
  57414. * @param defines the list of "defines" to update.
  57415. * @param scene defines the scene the material belongs to.
  57416. */
  57417. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  57418. /**
  57419. * Binds the material data.
  57420. * @param uniformBuffer defines the Uniform buffer to fill in.
  57421. * @param scene defines the scene the material belongs to.
  57422. * @param isFrozen defines wether the material is frozen or not.
  57423. */
  57424. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57425. /**
  57426. * Checks to see if a texture is used in the material.
  57427. * @param texture - Base texture to use.
  57428. * @returns - Boolean specifying if a texture is used in the material.
  57429. */
  57430. hasTexture(texture: BaseTexture): boolean;
  57431. /**
  57432. * Returns an array of the actively used textures.
  57433. * @param activeTextures Array of BaseTextures
  57434. */
  57435. getActiveTextures(activeTextures: BaseTexture[]): void;
  57436. /**
  57437. * Returns the animatable textures.
  57438. * @param animatables Array of animatable textures.
  57439. */
  57440. getAnimatables(animatables: IAnimatable[]): void;
  57441. /**
  57442. * Disposes the resources of the material.
  57443. * @param forceDisposeTextures - Forces the disposal of all textures.
  57444. */
  57445. dispose(forceDisposeTextures?: boolean): void;
  57446. /**
  57447. * Get the current class name of the texture useful for serialization or dynamic coding.
  57448. * @returns "PBRSheenConfiguration"
  57449. */
  57450. getClassName(): string;
  57451. /**
  57452. * Add fallbacks to the effect fallbacks list.
  57453. * @param defines defines the Base texture to use.
  57454. * @param fallbacks defines the current fallback list.
  57455. * @param currentRank defines the current fallback rank.
  57456. * @returns the new fallback rank.
  57457. */
  57458. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57459. /**
  57460. * Add the required uniforms to the current list.
  57461. * @param uniforms defines the current uniform list.
  57462. */
  57463. static AddUniforms(uniforms: string[]): void;
  57464. /**
  57465. * Add the required uniforms to the current buffer.
  57466. * @param uniformBuffer defines the current uniform buffer.
  57467. */
  57468. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57469. /**
  57470. * Add the required samplers to the current list.
  57471. * @param samplers defines the current sampler list.
  57472. */
  57473. static AddSamplers(samplers: string[]): void;
  57474. /**
  57475. * Makes a duplicate of the current configuration into another one.
  57476. * @param sheenConfiguration define the config where to copy the info
  57477. */
  57478. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  57479. /**
  57480. * Serializes this BRDF configuration.
  57481. * @returns - An object with the serialized config.
  57482. */
  57483. serialize(): any;
  57484. /**
  57485. * Parses a anisotropy Configuration from a serialized object.
  57486. * @param source - Serialized object.
  57487. * @param scene Defines the scene we are parsing for
  57488. * @param rootUrl Defines the rootUrl to load from
  57489. */
  57490. parse(source: any, scene: Scene, rootUrl: string): void;
  57491. }
  57492. }
  57493. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  57494. import { Nullable } from "babylonjs/types";
  57495. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57496. import { Color3 } from "babylonjs/Maths/math.color";
  57497. import { SmartArray } from "babylonjs/Misc/smartArray";
  57498. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57499. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57500. import { Effect } from "babylonjs/Materials/effect";
  57501. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57502. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57503. import { Engine } from "babylonjs/Engines/engine";
  57504. import { Scene } from "babylonjs/scene";
  57505. /**
  57506. * @hidden
  57507. */
  57508. export interface IMaterialSubSurfaceDefines {
  57509. SUBSURFACE: boolean;
  57510. SS_REFRACTION: boolean;
  57511. SS_TRANSLUCENCY: boolean;
  57512. SS_SCATTERING: boolean;
  57513. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57514. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57515. SS_REFRACTIONMAP_3D: boolean;
  57516. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57517. SS_LODINREFRACTIONALPHA: boolean;
  57518. SS_GAMMAREFRACTION: boolean;
  57519. SS_RGBDREFRACTION: boolean;
  57520. SS_LINEARSPECULARREFRACTION: boolean;
  57521. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57522. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57523. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57524. /** @hidden */
  57525. _areTexturesDirty: boolean;
  57526. }
  57527. /**
  57528. * Define the code related to the sub surface parameters of the pbr material.
  57529. */
  57530. export class PBRSubSurfaceConfiguration {
  57531. private _isRefractionEnabled;
  57532. /**
  57533. * Defines if the refraction is enabled in the material.
  57534. */
  57535. isRefractionEnabled: boolean;
  57536. private _isTranslucencyEnabled;
  57537. /**
  57538. * Defines if the translucency is enabled in the material.
  57539. */
  57540. isTranslucencyEnabled: boolean;
  57541. private _isScatteringEnabled;
  57542. /**
  57543. * Defines if the sub surface scattering is enabled in the material.
  57544. */
  57545. isScatteringEnabled: boolean;
  57546. private _scatteringDiffusionProfileIndex;
  57547. /**
  57548. * Diffusion profile for subsurface scattering.
  57549. * Useful for better scattering in the skins or foliages.
  57550. */
  57551. get scatteringDiffusionProfile(): Nullable<Color3>;
  57552. set scatteringDiffusionProfile(c: Nullable<Color3>);
  57553. /**
  57554. * Defines the refraction intensity of the material.
  57555. * The refraction when enabled replaces the Diffuse part of the material.
  57556. * The intensity helps transitionning between diffuse and refraction.
  57557. */
  57558. refractionIntensity: number;
  57559. /**
  57560. * Defines the translucency intensity of the material.
  57561. * When translucency has been enabled, this defines how much of the "translucency"
  57562. * is addded to the diffuse part of the material.
  57563. */
  57564. translucencyIntensity: number;
  57565. /**
  57566. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  57567. */
  57568. useAlbedoToTintRefraction: boolean;
  57569. private _thicknessTexture;
  57570. /**
  57571. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  57572. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  57573. * 0 would mean minimumThickness
  57574. * 1 would mean maximumThickness
  57575. * The other channels might be use as a mask to vary the different effects intensity.
  57576. */
  57577. thicknessTexture: Nullable<BaseTexture>;
  57578. private _refractionTexture;
  57579. /**
  57580. * Defines the texture to use for refraction.
  57581. */
  57582. refractionTexture: Nullable<BaseTexture>;
  57583. private _indexOfRefraction;
  57584. /**
  57585. * Index of refraction of the material base layer.
  57586. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57587. *
  57588. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57589. *
  57590. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57591. */
  57592. indexOfRefraction: number;
  57593. private _volumeIndexOfRefraction;
  57594. /**
  57595. * Index of refraction of the material's volume.
  57596. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57597. *
  57598. * This ONLY impacts refraction. If not provided or given a non-valid value,
  57599. * the volume will use the same IOR as the surface.
  57600. */
  57601. get volumeIndexOfRefraction(): number;
  57602. set volumeIndexOfRefraction(value: number);
  57603. private _invertRefractionY;
  57604. /**
  57605. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57606. */
  57607. invertRefractionY: boolean;
  57608. private _linkRefractionWithTransparency;
  57609. /**
  57610. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57611. * Materials half opaque for instance using refraction could benefit from this control.
  57612. */
  57613. linkRefractionWithTransparency: boolean;
  57614. /**
  57615. * Defines the minimum thickness stored in the thickness map.
  57616. * If no thickness map is defined, this value will be used to simulate thickness.
  57617. */
  57618. minimumThickness: number;
  57619. /**
  57620. * Defines the maximum thickness stored in the thickness map.
  57621. */
  57622. maximumThickness: number;
  57623. /**
  57624. * Defines the volume tint of the material.
  57625. * This is used for both translucency and scattering.
  57626. */
  57627. tintColor: Color3;
  57628. /**
  57629. * Defines the distance at which the tint color should be found in the media.
  57630. * This is used for refraction only.
  57631. */
  57632. tintColorAtDistance: number;
  57633. /**
  57634. * Defines how far each channel transmit through the media.
  57635. * It is defined as a color to simplify it selection.
  57636. */
  57637. diffusionDistance: Color3;
  57638. private _useMaskFromThicknessTexture;
  57639. /**
  57640. * Stores the intensity of the different subsurface effects in the thickness texture.
  57641. * * the green channel is the translucency intensity.
  57642. * * the blue channel is the scattering intensity.
  57643. * * the alpha channel is the refraction intensity.
  57644. */
  57645. useMaskFromThicknessTexture: boolean;
  57646. private _scene;
  57647. /** @hidden */
  57648. private _internalMarkAllSubMeshesAsTexturesDirty;
  57649. private _internalMarkScenePrePassDirty;
  57650. /** @hidden */
  57651. _markAllSubMeshesAsTexturesDirty(): void;
  57652. /** @hidden */
  57653. _markScenePrePassDirty(): void;
  57654. /**
  57655. * Instantiate a new istance of sub surface configuration.
  57656. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57657. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  57658. * @param scene The scene
  57659. */
  57660. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  57661. /**
  57662. * Gets wehter the submesh is ready to be used or not.
  57663. * @param defines the list of "defines" to update.
  57664. * @param scene defines the scene the material belongs to.
  57665. * @returns - boolean indicating that the submesh is ready or not.
  57666. */
  57667. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  57668. /**
  57669. * Checks to see if a texture is used in the material.
  57670. * @param defines the list of "defines" to update.
  57671. * @param scene defines the scene to the material belongs to.
  57672. */
  57673. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  57674. /**
  57675. * Binds the material data.
  57676. * @param uniformBuffer defines the Uniform buffer to fill in.
  57677. * @param scene defines the scene the material belongs to.
  57678. * @param engine defines the engine the material belongs to.
  57679. * @param isFrozen defines whether the material is frozen or not.
  57680. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  57681. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  57682. */
  57683. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  57684. /**
  57685. * Unbinds the material from the mesh.
  57686. * @param activeEffect defines the effect that should be unbound from.
  57687. * @returns true if unbound, otherwise false
  57688. */
  57689. unbind(activeEffect: Effect): boolean;
  57690. /**
  57691. * Returns the texture used for refraction or null if none is used.
  57692. * @param scene defines the scene the material belongs to.
  57693. * @returns - Refraction texture if present. If no refraction texture and refraction
  57694. * is linked with transparency, returns environment texture. Otherwise, returns null.
  57695. */
  57696. private _getRefractionTexture;
  57697. /**
  57698. * Returns true if alpha blending should be disabled.
  57699. */
  57700. get disableAlphaBlending(): boolean;
  57701. /**
  57702. * Fills the list of render target textures.
  57703. * @param renderTargets the list of render targets to update
  57704. */
  57705. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  57706. /**
  57707. * Checks to see if a texture is used in the material.
  57708. * @param texture - Base texture to use.
  57709. * @returns - Boolean specifying if a texture is used in the material.
  57710. */
  57711. hasTexture(texture: BaseTexture): boolean;
  57712. /**
  57713. * Gets a boolean indicating that current material needs to register RTT
  57714. * @returns true if this uses a render target otherwise false.
  57715. */
  57716. hasRenderTargetTextures(): boolean;
  57717. /**
  57718. * Returns an array of the actively used textures.
  57719. * @param activeTextures Array of BaseTextures
  57720. */
  57721. getActiveTextures(activeTextures: BaseTexture[]): void;
  57722. /**
  57723. * Returns the animatable textures.
  57724. * @param animatables Array of animatable textures.
  57725. */
  57726. getAnimatables(animatables: IAnimatable[]): void;
  57727. /**
  57728. * Disposes the resources of the material.
  57729. * @param forceDisposeTextures - Forces the disposal of all textures.
  57730. */
  57731. dispose(forceDisposeTextures?: boolean): void;
  57732. /**
  57733. * Get the current class name of the texture useful for serialization or dynamic coding.
  57734. * @returns "PBRSubSurfaceConfiguration"
  57735. */
  57736. getClassName(): string;
  57737. /**
  57738. * Add fallbacks to the effect fallbacks list.
  57739. * @param defines defines the Base texture to use.
  57740. * @param fallbacks defines the current fallback list.
  57741. * @param currentRank defines the current fallback rank.
  57742. * @returns the new fallback rank.
  57743. */
  57744. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57745. /**
  57746. * Add the required uniforms to the current list.
  57747. * @param uniforms defines the current uniform list.
  57748. */
  57749. static AddUniforms(uniforms: string[]): void;
  57750. /**
  57751. * Add the required samplers to the current list.
  57752. * @param samplers defines the current sampler list.
  57753. */
  57754. static AddSamplers(samplers: string[]): void;
  57755. /**
  57756. * Add the required uniforms to the current buffer.
  57757. * @param uniformBuffer defines the current uniform buffer.
  57758. */
  57759. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57760. /**
  57761. * Makes a duplicate of the current configuration into another one.
  57762. * @param configuration define the config where to copy the info
  57763. */
  57764. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  57765. /**
  57766. * Serializes this Sub Surface configuration.
  57767. * @returns - An object with the serialized config.
  57768. */
  57769. serialize(): any;
  57770. /**
  57771. * Parses a anisotropy Configuration from a serialized object.
  57772. * @param source - Serialized object.
  57773. * @param scene Defines the scene we are parsing for
  57774. * @param rootUrl Defines the rootUrl to load from
  57775. */
  57776. parse(source: any, scene: Scene, rootUrl: string): void;
  57777. }
  57778. }
  57779. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  57780. /** @hidden */
  57781. export var pbrFragmentDeclaration: {
  57782. name: string;
  57783. shader: string;
  57784. };
  57785. }
  57786. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  57787. /** @hidden */
  57788. export var pbrUboDeclaration: {
  57789. name: string;
  57790. shader: string;
  57791. };
  57792. }
  57793. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  57794. /** @hidden */
  57795. export var pbrFragmentExtraDeclaration: {
  57796. name: string;
  57797. shader: string;
  57798. };
  57799. }
  57800. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  57801. /** @hidden */
  57802. export var pbrFragmentSamplersDeclaration: {
  57803. name: string;
  57804. shader: string;
  57805. };
  57806. }
  57807. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  57808. /** @hidden */
  57809. export var importanceSampling: {
  57810. name: string;
  57811. shader: string;
  57812. };
  57813. }
  57814. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  57815. /** @hidden */
  57816. export var pbrHelperFunctions: {
  57817. name: string;
  57818. shader: string;
  57819. };
  57820. }
  57821. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  57822. /** @hidden */
  57823. export var harmonicsFunctions: {
  57824. name: string;
  57825. shader: string;
  57826. };
  57827. }
  57828. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  57829. /** @hidden */
  57830. export var pbrDirectLightingSetupFunctions: {
  57831. name: string;
  57832. shader: string;
  57833. };
  57834. }
  57835. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  57836. /** @hidden */
  57837. export var pbrDirectLightingFalloffFunctions: {
  57838. name: string;
  57839. shader: string;
  57840. };
  57841. }
  57842. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  57843. /** @hidden */
  57844. export var pbrBRDFFunctions: {
  57845. name: string;
  57846. shader: string;
  57847. };
  57848. }
  57849. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  57850. /** @hidden */
  57851. export var hdrFilteringFunctions: {
  57852. name: string;
  57853. shader: string;
  57854. };
  57855. }
  57856. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  57857. /** @hidden */
  57858. export var pbrDirectLightingFunctions: {
  57859. name: string;
  57860. shader: string;
  57861. };
  57862. }
  57863. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  57864. /** @hidden */
  57865. export var pbrIBLFunctions: {
  57866. name: string;
  57867. shader: string;
  57868. };
  57869. }
  57870. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  57871. /** @hidden */
  57872. export var pbrBlockAlbedoOpacity: {
  57873. name: string;
  57874. shader: string;
  57875. };
  57876. }
  57877. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  57878. /** @hidden */
  57879. export var pbrBlockReflectivity: {
  57880. name: string;
  57881. shader: string;
  57882. };
  57883. }
  57884. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  57885. /** @hidden */
  57886. export var pbrBlockAmbientOcclusion: {
  57887. name: string;
  57888. shader: string;
  57889. };
  57890. }
  57891. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  57892. /** @hidden */
  57893. export var pbrBlockAlphaFresnel: {
  57894. name: string;
  57895. shader: string;
  57896. };
  57897. }
  57898. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  57899. /** @hidden */
  57900. export var pbrBlockAnisotropic: {
  57901. name: string;
  57902. shader: string;
  57903. };
  57904. }
  57905. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  57906. /** @hidden */
  57907. export var pbrBlockReflection: {
  57908. name: string;
  57909. shader: string;
  57910. };
  57911. }
  57912. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  57913. /** @hidden */
  57914. export var pbrBlockSheen: {
  57915. name: string;
  57916. shader: string;
  57917. };
  57918. }
  57919. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  57920. /** @hidden */
  57921. export var pbrBlockClearcoat: {
  57922. name: string;
  57923. shader: string;
  57924. };
  57925. }
  57926. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  57927. /** @hidden */
  57928. export var pbrBlockSubSurface: {
  57929. name: string;
  57930. shader: string;
  57931. };
  57932. }
  57933. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  57934. /** @hidden */
  57935. export var pbrBlockNormalGeometric: {
  57936. name: string;
  57937. shader: string;
  57938. };
  57939. }
  57940. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  57941. /** @hidden */
  57942. export var pbrBlockNormalFinal: {
  57943. name: string;
  57944. shader: string;
  57945. };
  57946. }
  57947. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  57948. /** @hidden */
  57949. export var pbrBlockLightmapInit: {
  57950. name: string;
  57951. shader: string;
  57952. };
  57953. }
  57954. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  57955. /** @hidden */
  57956. export var pbrBlockGeometryInfo: {
  57957. name: string;
  57958. shader: string;
  57959. };
  57960. }
  57961. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  57962. /** @hidden */
  57963. export var pbrBlockReflectance0: {
  57964. name: string;
  57965. shader: string;
  57966. };
  57967. }
  57968. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  57969. /** @hidden */
  57970. export var pbrBlockReflectance: {
  57971. name: string;
  57972. shader: string;
  57973. };
  57974. }
  57975. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  57976. /** @hidden */
  57977. export var pbrBlockDirectLighting: {
  57978. name: string;
  57979. shader: string;
  57980. };
  57981. }
  57982. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  57983. /** @hidden */
  57984. export var pbrBlockFinalLitComponents: {
  57985. name: string;
  57986. shader: string;
  57987. };
  57988. }
  57989. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  57990. /** @hidden */
  57991. export var pbrBlockFinalUnlitComponents: {
  57992. name: string;
  57993. shader: string;
  57994. };
  57995. }
  57996. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  57997. /** @hidden */
  57998. export var pbrBlockFinalColorComposition: {
  57999. name: string;
  58000. shader: string;
  58001. };
  58002. }
  58003. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58004. /** @hidden */
  58005. export var pbrBlockImageProcessing: {
  58006. name: string;
  58007. shader: string;
  58008. };
  58009. }
  58010. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58011. /** @hidden */
  58012. export var pbrDebug: {
  58013. name: string;
  58014. shader: string;
  58015. };
  58016. }
  58017. declare module "babylonjs/Shaders/pbr.fragment" {
  58018. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58019. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58020. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58021. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58022. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58023. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58024. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58025. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58026. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58027. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58028. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58029. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58030. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58031. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58032. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58033. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58034. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58035. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58036. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58037. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58038. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58039. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58040. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58041. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58042. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58043. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58044. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58045. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58046. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58047. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58048. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58049. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58050. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58051. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58052. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58053. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58054. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58055. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58056. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58057. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58058. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58059. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58060. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58061. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58062. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58063. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58064. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58065. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58066. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58067. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58068. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58069. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58070. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58071. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58072. /** @hidden */
  58073. export var pbrPixelShader: {
  58074. name: string;
  58075. shader: string;
  58076. };
  58077. }
  58078. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58079. /** @hidden */
  58080. export var pbrVertexDeclaration: {
  58081. name: string;
  58082. shader: string;
  58083. };
  58084. }
  58085. declare module "babylonjs/Shaders/pbr.vertex" {
  58086. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58087. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58088. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58089. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58090. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58091. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58092. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  58093. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  58094. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  58095. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58096. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58097. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58098. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58099. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58100. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58101. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58102. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58103. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  58104. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58105. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  58106. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58107. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  58108. /** @hidden */
  58109. export var pbrVertexShader: {
  58110. name: string;
  58111. shader: string;
  58112. };
  58113. }
  58114. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  58115. import { Nullable } from "babylonjs/types";
  58116. import { Scene } from "babylonjs/scene";
  58117. import { Matrix } from "babylonjs/Maths/math.vector";
  58118. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58120. import { Mesh } from "babylonjs/Meshes/mesh";
  58121. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  58122. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  58123. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  58124. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  58125. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  58126. import { Color3 } from "babylonjs/Maths/math.color";
  58127. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  58128. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  58129. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  58130. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  58131. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58132. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58133. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58134. import "babylonjs/Shaders/pbr.fragment";
  58135. import "babylonjs/Shaders/pbr.vertex";
  58136. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  58137. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  58138. /**
  58139. * Manages the defines for the PBR Material.
  58140. * @hidden
  58141. */
  58142. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  58143. PBR: boolean;
  58144. NUM_SAMPLES: string;
  58145. REALTIME_FILTERING: boolean;
  58146. MAINUV1: boolean;
  58147. MAINUV2: boolean;
  58148. UV1: boolean;
  58149. UV2: boolean;
  58150. ALBEDO: boolean;
  58151. GAMMAALBEDO: boolean;
  58152. ALBEDODIRECTUV: number;
  58153. VERTEXCOLOR: boolean;
  58154. DETAIL: boolean;
  58155. DETAILDIRECTUV: number;
  58156. DETAIL_NORMALBLENDMETHOD: number;
  58157. AMBIENT: boolean;
  58158. AMBIENTDIRECTUV: number;
  58159. AMBIENTINGRAYSCALE: boolean;
  58160. OPACITY: boolean;
  58161. VERTEXALPHA: boolean;
  58162. OPACITYDIRECTUV: number;
  58163. OPACITYRGB: boolean;
  58164. ALPHATEST: boolean;
  58165. DEPTHPREPASS: boolean;
  58166. ALPHABLEND: boolean;
  58167. ALPHAFROMALBEDO: boolean;
  58168. ALPHATESTVALUE: string;
  58169. SPECULAROVERALPHA: boolean;
  58170. RADIANCEOVERALPHA: boolean;
  58171. ALPHAFRESNEL: boolean;
  58172. LINEARALPHAFRESNEL: boolean;
  58173. PREMULTIPLYALPHA: boolean;
  58174. EMISSIVE: boolean;
  58175. EMISSIVEDIRECTUV: number;
  58176. REFLECTIVITY: boolean;
  58177. REFLECTIVITYDIRECTUV: number;
  58178. SPECULARTERM: boolean;
  58179. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  58180. MICROSURFACEAUTOMATIC: boolean;
  58181. LODBASEDMICROSFURACE: boolean;
  58182. MICROSURFACEMAP: boolean;
  58183. MICROSURFACEMAPDIRECTUV: number;
  58184. METALLICWORKFLOW: boolean;
  58185. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  58186. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  58187. METALLNESSSTOREINMETALMAPBLUE: boolean;
  58188. AOSTOREINMETALMAPRED: boolean;
  58189. METALLIC_REFLECTANCE: boolean;
  58190. METALLIC_REFLECTANCEDIRECTUV: number;
  58191. ENVIRONMENTBRDF: boolean;
  58192. ENVIRONMENTBRDF_RGBD: boolean;
  58193. NORMAL: boolean;
  58194. TANGENT: boolean;
  58195. BUMP: boolean;
  58196. BUMPDIRECTUV: number;
  58197. OBJECTSPACE_NORMALMAP: boolean;
  58198. PARALLAX: boolean;
  58199. PARALLAXOCCLUSION: boolean;
  58200. NORMALXYSCALE: boolean;
  58201. LIGHTMAP: boolean;
  58202. LIGHTMAPDIRECTUV: number;
  58203. USELIGHTMAPASSHADOWMAP: boolean;
  58204. GAMMALIGHTMAP: boolean;
  58205. RGBDLIGHTMAP: boolean;
  58206. REFLECTION: boolean;
  58207. REFLECTIONMAP_3D: boolean;
  58208. REFLECTIONMAP_SPHERICAL: boolean;
  58209. REFLECTIONMAP_PLANAR: boolean;
  58210. REFLECTIONMAP_CUBIC: boolean;
  58211. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  58212. REFLECTIONMAP_PROJECTION: boolean;
  58213. REFLECTIONMAP_SKYBOX: boolean;
  58214. REFLECTIONMAP_EXPLICIT: boolean;
  58215. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  58216. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  58217. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  58218. INVERTCUBICMAP: boolean;
  58219. USESPHERICALFROMREFLECTIONMAP: boolean;
  58220. USEIRRADIANCEMAP: boolean;
  58221. SPHERICAL_HARMONICS: boolean;
  58222. USESPHERICALINVERTEX: boolean;
  58223. REFLECTIONMAP_OPPOSITEZ: boolean;
  58224. LODINREFLECTIONALPHA: boolean;
  58225. GAMMAREFLECTION: boolean;
  58226. RGBDREFLECTION: boolean;
  58227. LINEARSPECULARREFLECTION: boolean;
  58228. RADIANCEOCCLUSION: boolean;
  58229. HORIZONOCCLUSION: boolean;
  58230. INSTANCES: boolean;
  58231. THIN_INSTANCES: boolean;
  58232. PREPASS: boolean;
  58233. SCENE_MRT_COUNT: number;
  58234. NUM_BONE_INFLUENCERS: number;
  58235. BonesPerMesh: number;
  58236. BONETEXTURE: boolean;
  58237. NONUNIFORMSCALING: boolean;
  58238. MORPHTARGETS: boolean;
  58239. MORPHTARGETS_NORMAL: boolean;
  58240. MORPHTARGETS_TANGENT: boolean;
  58241. MORPHTARGETS_UV: boolean;
  58242. NUM_MORPH_INFLUENCERS: number;
  58243. IMAGEPROCESSING: boolean;
  58244. VIGNETTE: boolean;
  58245. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58246. VIGNETTEBLENDMODEOPAQUE: boolean;
  58247. TONEMAPPING: boolean;
  58248. TONEMAPPING_ACES: boolean;
  58249. CONTRAST: boolean;
  58250. COLORCURVES: boolean;
  58251. COLORGRADING: boolean;
  58252. COLORGRADING3D: boolean;
  58253. SAMPLER3DGREENDEPTH: boolean;
  58254. SAMPLER3DBGRMAP: boolean;
  58255. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58256. EXPOSURE: boolean;
  58257. MULTIVIEW: boolean;
  58258. USEPHYSICALLIGHTFALLOFF: boolean;
  58259. USEGLTFLIGHTFALLOFF: boolean;
  58260. TWOSIDEDLIGHTING: boolean;
  58261. SHADOWFLOAT: boolean;
  58262. CLIPPLANE: boolean;
  58263. CLIPPLANE2: boolean;
  58264. CLIPPLANE3: boolean;
  58265. CLIPPLANE4: boolean;
  58266. CLIPPLANE5: boolean;
  58267. CLIPPLANE6: boolean;
  58268. POINTSIZE: boolean;
  58269. FOG: boolean;
  58270. LOGARITHMICDEPTH: boolean;
  58271. FORCENORMALFORWARD: boolean;
  58272. SPECULARAA: boolean;
  58273. CLEARCOAT: boolean;
  58274. CLEARCOAT_DEFAULTIOR: boolean;
  58275. CLEARCOAT_TEXTURE: boolean;
  58276. CLEARCOAT_TEXTUREDIRECTUV: number;
  58277. CLEARCOAT_BUMP: boolean;
  58278. CLEARCOAT_BUMPDIRECTUV: number;
  58279. CLEARCOAT_TINT: boolean;
  58280. CLEARCOAT_TINT_TEXTURE: boolean;
  58281. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  58282. ANISOTROPIC: boolean;
  58283. ANISOTROPIC_TEXTURE: boolean;
  58284. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58285. BRDF_V_HEIGHT_CORRELATED: boolean;
  58286. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58287. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58288. SHEEN: boolean;
  58289. SHEEN_TEXTURE: boolean;
  58290. SHEEN_TEXTUREDIRECTUV: number;
  58291. SHEEN_LINKWITHALBEDO: boolean;
  58292. SHEEN_ROUGHNESS: boolean;
  58293. SHEEN_ALBEDOSCALING: boolean;
  58294. SUBSURFACE: boolean;
  58295. SS_REFRACTION: boolean;
  58296. SS_TRANSLUCENCY: boolean;
  58297. SS_SCATTERING: boolean;
  58298. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58299. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58300. SS_REFRACTIONMAP_3D: boolean;
  58301. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58302. SS_LODINREFRACTIONALPHA: boolean;
  58303. SS_GAMMAREFRACTION: boolean;
  58304. SS_RGBDREFRACTION: boolean;
  58305. SS_LINEARSPECULARREFRACTION: boolean;
  58306. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58307. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58308. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58309. UNLIT: boolean;
  58310. DEBUGMODE: number;
  58311. /**
  58312. * Initializes the PBR Material defines.
  58313. */
  58314. constructor();
  58315. /**
  58316. * Resets the PBR Material defines.
  58317. */
  58318. reset(): void;
  58319. }
  58320. /**
  58321. * The Physically based material base class of BJS.
  58322. *
  58323. * This offers the main features of a standard PBR material.
  58324. * For more information, please refer to the documentation :
  58325. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58326. */
  58327. export abstract class PBRBaseMaterial extends PushMaterial {
  58328. /**
  58329. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58330. */
  58331. static readonly PBRMATERIAL_OPAQUE: number;
  58332. /**
  58333. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58334. */
  58335. static readonly PBRMATERIAL_ALPHATEST: number;
  58336. /**
  58337. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58338. */
  58339. static readonly PBRMATERIAL_ALPHABLEND: number;
  58340. /**
  58341. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58342. * They are also discarded below the alpha cutoff threshold to improve performances.
  58343. */
  58344. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58345. /**
  58346. * Defines the default value of how much AO map is occluding the analytical lights
  58347. * (point spot...).
  58348. */
  58349. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58350. /**
  58351. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  58352. */
  58353. static readonly LIGHTFALLOFF_PHYSICAL: number;
  58354. /**
  58355. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  58356. * to enhance interoperability with other engines.
  58357. */
  58358. static readonly LIGHTFALLOFF_GLTF: number;
  58359. /**
  58360. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  58361. * to enhance interoperability with other materials.
  58362. */
  58363. static readonly LIGHTFALLOFF_STANDARD: number;
  58364. /**
  58365. * Intensity of the direct lights e.g. the four lights available in your scene.
  58366. * This impacts both the direct diffuse and specular highlights.
  58367. */
  58368. protected _directIntensity: number;
  58369. /**
  58370. * Intensity of the emissive part of the material.
  58371. * This helps controlling the emissive effect without modifying the emissive color.
  58372. */
  58373. protected _emissiveIntensity: number;
  58374. /**
  58375. * Intensity of the environment e.g. how much the environment will light the object
  58376. * either through harmonics for rough material or through the refelction for shiny ones.
  58377. */
  58378. protected _environmentIntensity: number;
  58379. /**
  58380. * This is a special control allowing the reduction of the specular highlights coming from the
  58381. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58382. */
  58383. protected _specularIntensity: number;
  58384. /**
  58385. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  58386. */
  58387. private _lightingInfos;
  58388. /**
  58389. * Debug Control allowing disabling the bump map on this material.
  58390. */
  58391. protected _disableBumpMap: boolean;
  58392. /**
  58393. * AKA Diffuse Texture in standard nomenclature.
  58394. */
  58395. protected _albedoTexture: Nullable<BaseTexture>;
  58396. /**
  58397. * AKA Occlusion Texture in other nomenclature.
  58398. */
  58399. protected _ambientTexture: Nullable<BaseTexture>;
  58400. /**
  58401. * AKA Occlusion Texture Intensity in other nomenclature.
  58402. */
  58403. protected _ambientTextureStrength: number;
  58404. /**
  58405. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58406. * 1 means it completely occludes it
  58407. * 0 mean it has no impact
  58408. */
  58409. protected _ambientTextureImpactOnAnalyticalLights: number;
  58410. /**
  58411. * Stores the alpha values in a texture.
  58412. */
  58413. protected _opacityTexture: Nullable<BaseTexture>;
  58414. /**
  58415. * Stores the reflection values in a texture.
  58416. */
  58417. protected _reflectionTexture: Nullable<BaseTexture>;
  58418. /**
  58419. * Stores the emissive values in a texture.
  58420. */
  58421. protected _emissiveTexture: Nullable<BaseTexture>;
  58422. /**
  58423. * AKA Specular texture in other nomenclature.
  58424. */
  58425. protected _reflectivityTexture: Nullable<BaseTexture>;
  58426. /**
  58427. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58428. */
  58429. protected _metallicTexture: Nullable<BaseTexture>;
  58430. /**
  58431. * Specifies the metallic scalar of the metallic/roughness workflow.
  58432. * Can also be used to scale the metalness values of the metallic texture.
  58433. */
  58434. protected _metallic: Nullable<number>;
  58435. /**
  58436. * Specifies the roughness scalar of the metallic/roughness workflow.
  58437. * Can also be used to scale the roughness values of the metallic texture.
  58438. */
  58439. protected _roughness: Nullable<number>;
  58440. /**
  58441. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58442. * By default the indexOfrefraction is used to compute F0;
  58443. *
  58444. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58445. *
  58446. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58447. * F90 = metallicReflectanceColor;
  58448. */
  58449. protected _metallicF0Factor: number;
  58450. /**
  58451. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58452. * By default the F90 is always 1;
  58453. *
  58454. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58455. *
  58456. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58457. * F90 = metallicReflectanceColor;
  58458. */
  58459. protected _metallicReflectanceColor: Color3;
  58460. /**
  58461. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58462. * This is multiply against the scalar values defined in the material.
  58463. */
  58464. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  58465. /**
  58466. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58467. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58468. */
  58469. protected _microSurfaceTexture: Nullable<BaseTexture>;
  58470. /**
  58471. * Stores surface normal data used to displace a mesh in a texture.
  58472. */
  58473. protected _bumpTexture: Nullable<BaseTexture>;
  58474. /**
  58475. * Stores the pre-calculated light information of a mesh in a texture.
  58476. */
  58477. protected _lightmapTexture: Nullable<BaseTexture>;
  58478. /**
  58479. * The color of a material in ambient lighting.
  58480. */
  58481. protected _ambientColor: Color3;
  58482. /**
  58483. * AKA Diffuse Color in other nomenclature.
  58484. */
  58485. protected _albedoColor: Color3;
  58486. /**
  58487. * AKA Specular Color in other nomenclature.
  58488. */
  58489. protected _reflectivityColor: Color3;
  58490. /**
  58491. * The color applied when light is reflected from a material.
  58492. */
  58493. protected _reflectionColor: Color3;
  58494. /**
  58495. * The color applied when light is emitted from a material.
  58496. */
  58497. protected _emissiveColor: Color3;
  58498. /**
  58499. * AKA Glossiness in other nomenclature.
  58500. */
  58501. protected _microSurface: number;
  58502. /**
  58503. * Specifies that the material will use the light map as a show map.
  58504. */
  58505. protected _useLightmapAsShadowmap: boolean;
  58506. /**
  58507. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58508. * makes the reflect vector face the model (under horizon).
  58509. */
  58510. protected _useHorizonOcclusion: boolean;
  58511. /**
  58512. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58513. * too much the area relying on ambient texture to define their ambient occlusion.
  58514. */
  58515. protected _useRadianceOcclusion: boolean;
  58516. /**
  58517. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58518. */
  58519. protected _useAlphaFromAlbedoTexture: boolean;
  58520. /**
  58521. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  58522. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58523. */
  58524. protected _useSpecularOverAlpha: boolean;
  58525. /**
  58526. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58527. */
  58528. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58529. /**
  58530. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58531. */
  58532. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  58533. /**
  58534. * Specifies if the metallic texture contains the roughness information in its green channel.
  58535. */
  58536. protected _useRoughnessFromMetallicTextureGreen: boolean;
  58537. /**
  58538. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58539. */
  58540. protected _useMetallnessFromMetallicTextureBlue: boolean;
  58541. /**
  58542. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58543. */
  58544. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  58545. /**
  58546. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58547. */
  58548. protected _useAmbientInGrayScale: boolean;
  58549. /**
  58550. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58551. * The material will try to infer what glossiness each pixel should be.
  58552. */
  58553. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  58554. /**
  58555. * Defines the falloff type used in this material.
  58556. * It by default is Physical.
  58557. */
  58558. protected _lightFalloff: number;
  58559. /**
  58560. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58561. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58562. */
  58563. protected _useRadianceOverAlpha: boolean;
  58564. /**
  58565. * Allows using an object space normal map (instead of tangent space).
  58566. */
  58567. protected _useObjectSpaceNormalMap: boolean;
  58568. /**
  58569. * Allows using the bump map in parallax mode.
  58570. */
  58571. protected _useParallax: boolean;
  58572. /**
  58573. * Allows using the bump map in parallax occlusion mode.
  58574. */
  58575. protected _useParallaxOcclusion: boolean;
  58576. /**
  58577. * Controls the scale bias of the parallax mode.
  58578. */
  58579. protected _parallaxScaleBias: number;
  58580. /**
  58581. * If sets to true, disables all the lights affecting the material.
  58582. */
  58583. protected _disableLighting: boolean;
  58584. /**
  58585. * Number of Simultaneous lights allowed on the material.
  58586. */
  58587. protected _maxSimultaneousLights: number;
  58588. /**
  58589. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  58590. */
  58591. protected _invertNormalMapX: boolean;
  58592. /**
  58593. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  58594. */
  58595. protected _invertNormalMapY: boolean;
  58596. /**
  58597. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58598. */
  58599. protected _twoSidedLighting: boolean;
  58600. /**
  58601. * Defines the alpha limits in alpha test mode.
  58602. */
  58603. protected _alphaCutOff: number;
  58604. /**
  58605. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58606. */
  58607. protected _forceAlphaTest: boolean;
  58608. /**
  58609. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58610. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58611. */
  58612. protected _useAlphaFresnel: boolean;
  58613. /**
  58614. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58615. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58616. */
  58617. protected _useLinearAlphaFresnel: boolean;
  58618. /**
  58619. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  58620. * from cos thetav and roughness:
  58621. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  58622. */
  58623. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  58624. /**
  58625. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58626. */
  58627. protected _forceIrradianceInFragment: boolean;
  58628. private _realTimeFiltering;
  58629. /**
  58630. * Enables realtime filtering on the texture.
  58631. */
  58632. get realTimeFiltering(): boolean;
  58633. set realTimeFiltering(b: boolean);
  58634. private _realTimeFilteringQuality;
  58635. /**
  58636. * Quality switch for realtime filtering
  58637. */
  58638. get realTimeFilteringQuality(): number;
  58639. set realTimeFilteringQuality(n: number);
  58640. /**
  58641. * Can this material render to several textures at once
  58642. */
  58643. get canRenderToMRT(): boolean;
  58644. /**
  58645. * Force normal to face away from face.
  58646. */
  58647. protected _forceNormalForward: boolean;
  58648. /**
  58649. * Enables specular anti aliasing in the PBR shader.
  58650. * It will both interacts on the Geometry for analytical and IBL lighting.
  58651. * It also prefilter the roughness map based on the bump values.
  58652. */
  58653. protected _enableSpecularAntiAliasing: boolean;
  58654. /**
  58655. * Default configuration related to image processing available in the PBR Material.
  58656. */
  58657. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58658. /**
  58659. * Keep track of the image processing observer to allow dispose and replace.
  58660. */
  58661. private _imageProcessingObserver;
  58662. /**
  58663. * Attaches a new image processing configuration to the PBR Material.
  58664. * @param configuration
  58665. */
  58666. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58667. /**
  58668. * Stores the available render targets.
  58669. */
  58670. private _renderTargets;
  58671. /**
  58672. * Sets the global ambient color for the material used in lighting calculations.
  58673. */
  58674. private _globalAmbientColor;
  58675. /**
  58676. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  58677. */
  58678. private _useLogarithmicDepth;
  58679. /**
  58680. * If set to true, no lighting calculations will be applied.
  58681. */
  58682. private _unlit;
  58683. private _debugMode;
  58684. /**
  58685. * @hidden
  58686. * This is reserved for the inspector.
  58687. * Defines the material debug mode.
  58688. * It helps seeing only some components of the material while troubleshooting.
  58689. */
  58690. debugMode: number;
  58691. /**
  58692. * @hidden
  58693. * This is reserved for the inspector.
  58694. * Specify from where on screen the debug mode should start.
  58695. * The value goes from -1 (full screen) to 1 (not visible)
  58696. * It helps with side by side comparison against the final render
  58697. * This defaults to -1
  58698. */
  58699. private debugLimit;
  58700. /**
  58701. * @hidden
  58702. * This is reserved for the inspector.
  58703. * As the default viewing range might not be enough (if the ambient is really small for instance)
  58704. * You can use the factor to better multiply the final value.
  58705. */
  58706. private debugFactor;
  58707. /**
  58708. * Defines the clear coat layer parameters for the material.
  58709. */
  58710. readonly clearCoat: PBRClearCoatConfiguration;
  58711. /**
  58712. * Defines the anisotropic parameters for the material.
  58713. */
  58714. readonly anisotropy: PBRAnisotropicConfiguration;
  58715. /**
  58716. * Defines the BRDF parameters for the material.
  58717. */
  58718. readonly brdf: PBRBRDFConfiguration;
  58719. /**
  58720. * Defines the Sheen parameters for the material.
  58721. */
  58722. readonly sheen: PBRSheenConfiguration;
  58723. /**
  58724. * Defines the SubSurface parameters for the material.
  58725. */
  58726. readonly subSurface: PBRSubSurfaceConfiguration;
  58727. /**
  58728. * Defines the detail map parameters for the material.
  58729. */
  58730. readonly detailMap: DetailMapConfiguration;
  58731. protected _rebuildInParallel: boolean;
  58732. /**
  58733. * Instantiates a new PBRMaterial instance.
  58734. *
  58735. * @param name The material name
  58736. * @param scene The scene the material will be use in.
  58737. */
  58738. constructor(name: string, scene: Scene);
  58739. /**
  58740. * Gets a boolean indicating that current material needs to register RTT
  58741. */
  58742. get hasRenderTargetTextures(): boolean;
  58743. /**
  58744. * Gets the name of the material class.
  58745. */
  58746. getClassName(): string;
  58747. /**
  58748. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58749. */
  58750. get useLogarithmicDepth(): boolean;
  58751. /**
  58752. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58753. */
  58754. set useLogarithmicDepth(value: boolean);
  58755. /**
  58756. * Returns true if alpha blending should be disabled.
  58757. */
  58758. protected get _disableAlphaBlending(): boolean;
  58759. /**
  58760. * Specifies whether or not this material should be rendered in alpha blend mode.
  58761. */
  58762. needAlphaBlending(): boolean;
  58763. /**
  58764. * Specifies whether or not this material should be rendered in alpha test mode.
  58765. */
  58766. needAlphaTesting(): boolean;
  58767. /**
  58768. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  58769. */
  58770. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  58771. /**
  58772. * Gets the texture used for the alpha test.
  58773. */
  58774. getAlphaTestTexture(): Nullable<BaseTexture>;
  58775. /**
  58776. * Specifies that the submesh is ready to be used.
  58777. * @param mesh - BJS mesh.
  58778. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  58779. * @param useInstances - Specifies that instances should be used.
  58780. * @returns - boolean indicating that the submesh is ready or not.
  58781. */
  58782. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58783. /**
  58784. * Specifies if the material uses metallic roughness workflow.
  58785. * @returns boolean specifiying if the material uses metallic roughness workflow.
  58786. */
  58787. isMetallicWorkflow(): boolean;
  58788. private _prepareEffect;
  58789. private _prepareDefines;
  58790. /**
  58791. * Force shader compilation
  58792. */
  58793. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  58794. /**
  58795. * Initializes the uniform buffer layout for the shader.
  58796. */
  58797. buildUniformLayout(): void;
  58798. /**
  58799. * Unbinds the material from the mesh
  58800. */
  58801. unbind(): void;
  58802. /**
  58803. * Binds the submesh data.
  58804. * @param world - The world matrix.
  58805. * @param mesh - The BJS mesh.
  58806. * @param subMesh - A submesh of the BJS mesh.
  58807. */
  58808. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58809. /**
  58810. * Returns the animatable textures.
  58811. * @returns - Array of animatable textures.
  58812. */
  58813. getAnimatables(): IAnimatable[];
  58814. /**
  58815. * Returns the texture used for reflections.
  58816. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  58817. */
  58818. private _getReflectionTexture;
  58819. /**
  58820. * Returns an array of the actively used textures.
  58821. * @returns - Array of BaseTextures
  58822. */
  58823. getActiveTextures(): BaseTexture[];
  58824. /**
  58825. * Checks to see if a texture is used in the material.
  58826. * @param texture - Base texture to use.
  58827. * @returns - Boolean specifying if a texture is used in the material.
  58828. */
  58829. hasTexture(texture: BaseTexture): boolean;
  58830. /**
  58831. * Sets the required values to the prepass renderer.
  58832. * @param prePassRenderer defines the prepass renderer to setup
  58833. */
  58834. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  58835. /**
  58836. * Disposes the resources of the material.
  58837. * @param forceDisposeEffect - Forces the disposal of effects.
  58838. * @param forceDisposeTextures - Forces the disposal of all textures.
  58839. */
  58840. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58841. }
  58842. }
  58843. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  58844. import { Nullable } from "babylonjs/types";
  58845. import { Scene } from "babylonjs/scene";
  58846. import { Color3 } from "babylonjs/Maths/math.color";
  58847. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  58848. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  58849. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58850. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58851. /**
  58852. * The Physically based material of BJS.
  58853. *
  58854. * This offers the main features of a standard PBR material.
  58855. * For more information, please refer to the documentation :
  58856. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58857. */
  58858. export class PBRMaterial extends PBRBaseMaterial {
  58859. /**
  58860. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58861. */
  58862. static readonly PBRMATERIAL_OPAQUE: number;
  58863. /**
  58864. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58865. */
  58866. static readonly PBRMATERIAL_ALPHATEST: number;
  58867. /**
  58868. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58869. */
  58870. static readonly PBRMATERIAL_ALPHABLEND: number;
  58871. /**
  58872. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58873. * They are also discarded below the alpha cutoff threshold to improve performances.
  58874. */
  58875. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58876. /**
  58877. * Defines the default value of how much AO map is occluding the analytical lights
  58878. * (point spot...).
  58879. */
  58880. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58881. /**
  58882. * Intensity of the direct lights e.g. the four lights available in your scene.
  58883. * This impacts both the direct diffuse and specular highlights.
  58884. */
  58885. directIntensity: number;
  58886. /**
  58887. * Intensity of the emissive part of the material.
  58888. * This helps controlling the emissive effect without modifying the emissive color.
  58889. */
  58890. emissiveIntensity: number;
  58891. /**
  58892. * Intensity of the environment e.g. how much the environment will light the object
  58893. * either through harmonics for rough material or through the refelction for shiny ones.
  58894. */
  58895. environmentIntensity: number;
  58896. /**
  58897. * This is a special control allowing the reduction of the specular highlights coming from the
  58898. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58899. */
  58900. specularIntensity: number;
  58901. /**
  58902. * Debug Control allowing disabling the bump map on this material.
  58903. */
  58904. disableBumpMap: boolean;
  58905. /**
  58906. * AKA Diffuse Texture in standard nomenclature.
  58907. */
  58908. albedoTexture: BaseTexture;
  58909. /**
  58910. * AKA Occlusion Texture in other nomenclature.
  58911. */
  58912. ambientTexture: BaseTexture;
  58913. /**
  58914. * AKA Occlusion Texture Intensity in other nomenclature.
  58915. */
  58916. ambientTextureStrength: number;
  58917. /**
  58918. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58919. * 1 means it completely occludes it
  58920. * 0 mean it has no impact
  58921. */
  58922. ambientTextureImpactOnAnalyticalLights: number;
  58923. /**
  58924. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  58925. */
  58926. opacityTexture: BaseTexture;
  58927. /**
  58928. * Stores the reflection values in a texture.
  58929. */
  58930. reflectionTexture: Nullable<BaseTexture>;
  58931. /**
  58932. * Stores the emissive values in a texture.
  58933. */
  58934. emissiveTexture: BaseTexture;
  58935. /**
  58936. * AKA Specular texture in other nomenclature.
  58937. */
  58938. reflectivityTexture: BaseTexture;
  58939. /**
  58940. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58941. */
  58942. metallicTexture: BaseTexture;
  58943. /**
  58944. * Specifies the metallic scalar of the metallic/roughness workflow.
  58945. * Can also be used to scale the metalness values of the metallic texture.
  58946. */
  58947. metallic: Nullable<number>;
  58948. /**
  58949. * Specifies the roughness scalar of the metallic/roughness workflow.
  58950. * Can also be used to scale the roughness values of the metallic texture.
  58951. */
  58952. roughness: Nullable<number>;
  58953. /**
  58954. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58955. * By default the indexOfrefraction is used to compute F0;
  58956. *
  58957. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58958. *
  58959. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58960. * F90 = metallicReflectanceColor;
  58961. */
  58962. metallicF0Factor: number;
  58963. /**
  58964. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58965. * By default the F90 is always 1;
  58966. *
  58967. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58968. *
  58969. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58970. * F90 = metallicReflectanceColor;
  58971. */
  58972. metallicReflectanceColor: Color3;
  58973. /**
  58974. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58975. * This is multiply against the scalar values defined in the material.
  58976. */
  58977. metallicReflectanceTexture: Nullable<BaseTexture>;
  58978. /**
  58979. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58980. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58981. */
  58982. microSurfaceTexture: BaseTexture;
  58983. /**
  58984. * Stores surface normal data used to displace a mesh in a texture.
  58985. */
  58986. bumpTexture: BaseTexture;
  58987. /**
  58988. * Stores the pre-calculated light information of a mesh in a texture.
  58989. */
  58990. lightmapTexture: BaseTexture;
  58991. /**
  58992. * Stores the refracted light information in a texture.
  58993. */
  58994. get refractionTexture(): Nullable<BaseTexture>;
  58995. set refractionTexture(value: Nullable<BaseTexture>);
  58996. /**
  58997. * The color of a material in ambient lighting.
  58998. */
  58999. ambientColor: Color3;
  59000. /**
  59001. * AKA Diffuse Color in other nomenclature.
  59002. */
  59003. albedoColor: Color3;
  59004. /**
  59005. * AKA Specular Color in other nomenclature.
  59006. */
  59007. reflectivityColor: Color3;
  59008. /**
  59009. * The color reflected from the material.
  59010. */
  59011. reflectionColor: Color3;
  59012. /**
  59013. * The color emitted from the material.
  59014. */
  59015. emissiveColor: Color3;
  59016. /**
  59017. * AKA Glossiness in other nomenclature.
  59018. */
  59019. microSurface: number;
  59020. /**
  59021. * Index of refraction of the material base layer.
  59022. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59023. *
  59024. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59025. *
  59026. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59027. */
  59028. get indexOfRefraction(): number;
  59029. set indexOfRefraction(value: number);
  59030. /**
  59031. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59032. */
  59033. get invertRefractionY(): boolean;
  59034. set invertRefractionY(value: boolean);
  59035. /**
  59036. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59037. * Materials half opaque for instance using refraction could benefit from this control.
  59038. */
  59039. get linkRefractionWithTransparency(): boolean;
  59040. set linkRefractionWithTransparency(value: boolean);
  59041. /**
  59042. * If true, the light map contains occlusion information instead of lighting info.
  59043. */
  59044. useLightmapAsShadowmap: boolean;
  59045. /**
  59046. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59047. */
  59048. useAlphaFromAlbedoTexture: boolean;
  59049. /**
  59050. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59051. */
  59052. forceAlphaTest: boolean;
  59053. /**
  59054. * Defines the alpha limits in alpha test mode.
  59055. */
  59056. alphaCutOff: number;
  59057. /**
  59058. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59059. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59060. */
  59061. useSpecularOverAlpha: boolean;
  59062. /**
  59063. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59064. */
  59065. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59066. /**
  59067. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59068. */
  59069. useRoughnessFromMetallicTextureAlpha: boolean;
  59070. /**
  59071. * Specifies if the metallic texture contains the roughness information in its green channel.
  59072. */
  59073. useRoughnessFromMetallicTextureGreen: boolean;
  59074. /**
  59075. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59076. */
  59077. useMetallnessFromMetallicTextureBlue: boolean;
  59078. /**
  59079. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59080. */
  59081. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59082. /**
  59083. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59084. */
  59085. useAmbientInGrayScale: boolean;
  59086. /**
  59087. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59088. * The material will try to infer what glossiness each pixel should be.
  59089. */
  59090. useAutoMicroSurfaceFromReflectivityMap: boolean;
  59091. /**
  59092. * BJS is using an harcoded light falloff based on a manually sets up range.
  59093. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59094. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59095. */
  59096. get usePhysicalLightFalloff(): boolean;
  59097. /**
  59098. * BJS is using an harcoded light falloff based on a manually sets up range.
  59099. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59100. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59101. */
  59102. set usePhysicalLightFalloff(value: boolean);
  59103. /**
  59104. * In order to support the falloff compatibility with gltf, a special mode has been added
  59105. * to reproduce the gltf light falloff.
  59106. */
  59107. get useGLTFLightFalloff(): boolean;
  59108. /**
  59109. * In order to support the falloff compatibility with gltf, a special mode has been added
  59110. * to reproduce the gltf light falloff.
  59111. */
  59112. set useGLTFLightFalloff(value: boolean);
  59113. /**
  59114. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59115. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59116. */
  59117. useRadianceOverAlpha: boolean;
  59118. /**
  59119. * Allows using an object space normal map (instead of tangent space).
  59120. */
  59121. useObjectSpaceNormalMap: boolean;
  59122. /**
  59123. * Allows using the bump map in parallax mode.
  59124. */
  59125. useParallax: boolean;
  59126. /**
  59127. * Allows using the bump map in parallax occlusion mode.
  59128. */
  59129. useParallaxOcclusion: boolean;
  59130. /**
  59131. * Controls the scale bias of the parallax mode.
  59132. */
  59133. parallaxScaleBias: number;
  59134. /**
  59135. * If sets to true, disables all the lights affecting the material.
  59136. */
  59137. disableLighting: boolean;
  59138. /**
  59139. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59140. */
  59141. forceIrradianceInFragment: boolean;
  59142. /**
  59143. * Number of Simultaneous lights allowed on the material.
  59144. */
  59145. maxSimultaneousLights: number;
  59146. /**
  59147. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59148. */
  59149. invertNormalMapX: boolean;
  59150. /**
  59151. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59152. */
  59153. invertNormalMapY: boolean;
  59154. /**
  59155. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59156. */
  59157. twoSidedLighting: boolean;
  59158. /**
  59159. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59160. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59161. */
  59162. useAlphaFresnel: boolean;
  59163. /**
  59164. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59165. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59166. */
  59167. useLinearAlphaFresnel: boolean;
  59168. /**
  59169. * Let user defines the brdf lookup texture used for IBL.
  59170. * A default 8bit version is embedded but you could point at :
  59171. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  59172. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  59173. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  59174. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  59175. */
  59176. environmentBRDFTexture: Nullable<BaseTexture>;
  59177. /**
  59178. * Force normal to face away from face.
  59179. */
  59180. forceNormalForward: boolean;
  59181. /**
  59182. * Enables specular anti aliasing in the PBR shader.
  59183. * It will both interacts on the Geometry for analytical and IBL lighting.
  59184. * It also prefilter the roughness map based on the bump values.
  59185. */
  59186. enableSpecularAntiAliasing: boolean;
  59187. /**
  59188. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59189. * makes the reflect vector face the model (under horizon).
  59190. */
  59191. useHorizonOcclusion: boolean;
  59192. /**
  59193. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59194. * too much the area relying on ambient texture to define their ambient occlusion.
  59195. */
  59196. useRadianceOcclusion: boolean;
  59197. /**
  59198. * If set to true, no lighting calculations will be applied.
  59199. */
  59200. unlit: boolean;
  59201. /**
  59202. * Gets the image processing configuration used either in this material.
  59203. */
  59204. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59205. /**
  59206. * Sets the Default image processing configuration used either in the this material.
  59207. *
  59208. * If sets to null, the scene one is in use.
  59209. */
  59210. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59211. /**
  59212. * Gets wether the color curves effect is enabled.
  59213. */
  59214. get cameraColorCurvesEnabled(): boolean;
  59215. /**
  59216. * Sets wether the color curves effect is enabled.
  59217. */
  59218. set cameraColorCurvesEnabled(value: boolean);
  59219. /**
  59220. * Gets wether the color grading effect is enabled.
  59221. */
  59222. get cameraColorGradingEnabled(): boolean;
  59223. /**
  59224. * Gets wether the color grading effect is enabled.
  59225. */
  59226. set cameraColorGradingEnabled(value: boolean);
  59227. /**
  59228. * Gets wether tonemapping is enabled or not.
  59229. */
  59230. get cameraToneMappingEnabled(): boolean;
  59231. /**
  59232. * Sets wether tonemapping is enabled or not
  59233. */
  59234. set cameraToneMappingEnabled(value: boolean);
  59235. /**
  59236. * The camera exposure used on this material.
  59237. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59238. * This corresponds to a photographic exposure.
  59239. */
  59240. get cameraExposure(): number;
  59241. /**
  59242. * The camera exposure used on this material.
  59243. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59244. * This corresponds to a photographic exposure.
  59245. */
  59246. set cameraExposure(value: number);
  59247. /**
  59248. * Gets The camera contrast used on this material.
  59249. */
  59250. get cameraContrast(): number;
  59251. /**
  59252. * Sets The camera contrast used on this material.
  59253. */
  59254. set cameraContrast(value: number);
  59255. /**
  59256. * Gets the Color Grading 2D Lookup Texture.
  59257. */
  59258. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  59259. /**
  59260. * Sets the Color Grading 2D Lookup Texture.
  59261. */
  59262. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  59263. /**
  59264. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59265. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59266. * 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;
  59267. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59268. */
  59269. get cameraColorCurves(): Nullable<ColorCurves>;
  59270. /**
  59271. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59272. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59273. * 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;
  59274. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59275. */
  59276. set cameraColorCurves(value: Nullable<ColorCurves>);
  59277. /**
  59278. * Instantiates a new PBRMaterial instance.
  59279. *
  59280. * @param name The material name
  59281. * @param scene The scene the material will be use in.
  59282. */
  59283. constructor(name: string, scene: Scene);
  59284. /**
  59285. * Returns the name of this material class.
  59286. */
  59287. getClassName(): string;
  59288. /**
  59289. * Makes a duplicate of the current material.
  59290. * @param name - name to use for the new material.
  59291. */
  59292. clone(name: string): PBRMaterial;
  59293. /**
  59294. * Serializes this PBR Material.
  59295. * @returns - An object with the serialized material.
  59296. */
  59297. serialize(): any;
  59298. /**
  59299. * Parses a PBR Material from a serialized object.
  59300. * @param source - Serialized object.
  59301. * @param scene - BJS scene instance.
  59302. * @param rootUrl - url for the scene object
  59303. * @returns - PBRMaterial
  59304. */
  59305. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  59306. }
  59307. }
  59308. declare module "babylonjs/Misc/dds" {
  59309. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59310. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59311. import { Nullable } from "babylonjs/types";
  59312. import { Scene } from "babylonjs/scene";
  59313. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  59314. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59315. /**
  59316. * Direct draw surface info
  59317. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59318. */
  59319. export interface DDSInfo {
  59320. /**
  59321. * Width of the texture
  59322. */
  59323. width: number;
  59324. /**
  59325. * Width of the texture
  59326. */
  59327. height: number;
  59328. /**
  59329. * Number of Mipmaps for the texture
  59330. * @see https://en.wikipedia.org/wiki/Mipmap
  59331. */
  59332. mipmapCount: number;
  59333. /**
  59334. * If the textures format is a known fourCC format
  59335. * @see https://www.fourcc.org/
  59336. */
  59337. isFourCC: boolean;
  59338. /**
  59339. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59340. */
  59341. isRGB: boolean;
  59342. /**
  59343. * If the texture is a lumincance format
  59344. */
  59345. isLuminance: boolean;
  59346. /**
  59347. * If this is a cube texture
  59348. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  59349. */
  59350. isCube: boolean;
  59351. /**
  59352. * If the texture is a compressed format eg. FOURCC_DXT1
  59353. */
  59354. isCompressed: boolean;
  59355. /**
  59356. * The dxgiFormat of the texture
  59357. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  59358. */
  59359. dxgiFormat: number;
  59360. /**
  59361. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  59362. */
  59363. textureType: number;
  59364. /**
  59365. * Sphericle polynomial created for the dds texture
  59366. */
  59367. sphericalPolynomial?: SphericalPolynomial;
  59368. }
  59369. /**
  59370. * Class used to provide DDS decompression tools
  59371. */
  59372. export class DDSTools {
  59373. /**
  59374. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  59375. */
  59376. static StoreLODInAlphaChannel: boolean;
  59377. /**
  59378. * Gets DDS information from an array buffer
  59379. * @param data defines the array buffer view to read data from
  59380. * @returns the DDS information
  59381. */
  59382. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59383. private static _FloatView;
  59384. private static _Int32View;
  59385. private static _ToHalfFloat;
  59386. private static _FromHalfFloat;
  59387. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59388. private static _GetHalfFloatRGBAArrayBuffer;
  59389. private static _GetFloatRGBAArrayBuffer;
  59390. private static _GetFloatAsUIntRGBAArrayBuffer;
  59391. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59392. private static _GetRGBAArrayBuffer;
  59393. private static _ExtractLongWordOrder;
  59394. private static _GetRGBArrayBuffer;
  59395. private static _GetLuminanceArrayBuffer;
  59396. /**
  59397. * Uploads DDS Levels to a Babylon Texture
  59398. * @hidden
  59399. */
  59400. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59401. }
  59402. module "babylonjs/Engines/thinEngine" {
  59403. interface ThinEngine {
  59404. /**
  59405. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  59406. * @param rootUrl defines the url where the file to load is located
  59407. * @param scene defines the current scene
  59408. * @param lodScale defines scale to apply to the mip map selection
  59409. * @param lodOffset defines offset to apply to the mip map selection
  59410. * @param onLoad defines an optional callback raised when the texture is loaded
  59411. * @param onError defines an optional callback raised if there is an issue to load the texture
  59412. * @param format defines the format of the data
  59413. * @param forcedExtension defines the extension to use to pick the right loader
  59414. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59415. * @returns the cube texture as an InternalTexture
  59416. */
  59417. 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;
  59418. }
  59419. }
  59420. }
  59421. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  59422. import { Nullable } from "babylonjs/types";
  59423. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59424. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59425. /**
  59426. * Implementation of the DDS Texture Loader.
  59427. * @hidden
  59428. */
  59429. export class _DDSTextureLoader implements IInternalTextureLoader {
  59430. /**
  59431. * Defines wether the loader supports cascade loading the different faces.
  59432. */
  59433. readonly supportCascades: boolean;
  59434. /**
  59435. * This returns if the loader support the current file information.
  59436. * @param extension defines the file extension of the file being loaded
  59437. * @returns true if the loader can load the specified file
  59438. */
  59439. canLoad(extension: string): boolean;
  59440. /**
  59441. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59442. * @param data contains the texture data
  59443. * @param texture defines the BabylonJS internal texture
  59444. * @param createPolynomials will be true if polynomials have been requested
  59445. * @param onLoad defines the callback to trigger once the texture is ready
  59446. * @param onError defines the callback to trigger in case of error
  59447. */
  59448. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59449. /**
  59450. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59451. * @param data contains the texture data
  59452. * @param texture defines the BabylonJS internal texture
  59453. * @param callback defines the method to call once ready to upload
  59454. */
  59455. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59456. }
  59457. }
  59458. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  59459. import { Nullable } from "babylonjs/types";
  59460. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59461. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59462. /**
  59463. * Implementation of the ENV Texture Loader.
  59464. * @hidden
  59465. */
  59466. export class _ENVTextureLoader implements IInternalTextureLoader {
  59467. /**
  59468. * Defines wether the loader supports cascade loading the different faces.
  59469. */
  59470. readonly supportCascades: boolean;
  59471. /**
  59472. * This returns if the loader support the current file information.
  59473. * @param extension defines the file extension of the file being loaded
  59474. * @returns true if the loader can load the specified file
  59475. */
  59476. canLoad(extension: string): boolean;
  59477. /**
  59478. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59479. * @param data contains the texture data
  59480. * @param texture defines the BabylonJS internal texture
  59481. * @param createPolynomials will be true if polynomials have been requested
  59482. * @param onLoad defines the callback to trigger once the texture is ready
  59483. * @param onError defines the callback to trigger in case of error
  59484. */
  59485. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59486. /**
  59487. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59488. * @param data contains the texture data
  59489. * @param texture defines the BabylonJS internal texture
  59490. * @param callback defines the method to call once ready to upload
  59491. */
  59492. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59493. }
  59494. }
  59495. declare module "babylonjs/Misc/khronosTextureContainer" {
  59496. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59497. /**
  59498. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59499. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59500. */
  59501. export class KhronosTextureContainer {
  59502. /** contents of the KTX container file */
  59503. data: ArrayBufferView;
  59504. private static HEADER_LEN;
  59505. private static COMPRESSED_2D;
  59506. private static COMPRESSED_3D;
  59507. private static TEX_2D;
  59508. private static TEX_3D;
  59509. /**
  59510. * Gets the openGL type
  59511. */
  59512. glType: number;
  59513. /**
  59514. * Gets the openGL type size
  59515. */
  59516. glTypeSize: number;
  59517. /**
  59518. * Gets the openGL format
  59519. */
  59520. glFormat: number;
  59521. /**
  59522. * Gets the openGL internal format
  59523. */
  59524. glInternalFormat: number;
  59525. /**
  59526. * Gets the base internal format
  59527. */
  59528. glBaseInternalFormat: number;
  59529. /**
  59530. * Gets image width in pixel
  59531. */
  59532. pixelWidth: number;
  59533. /**
  59534. * Gets image height in pixel
  59535. */
  59536. pixelHeight: number;
  59537. /**
  59538. * Gets image depth in pixels
  59539. */
  59540. pixelDepth: number;
  59541. /**
  59542. * Gets the number of array elements
  59543. */
  59544. numberOfArrayElements: number;
  59545. /**
  59546. * Gets the number of faces
  59547. */
  59548. numberOfFaces: number;
  59549. /**
  59550. * Gets the number of mipmap levels
  59551. */
  59552. numberOfMipmapLevels: number;
  59553. /**
  59554. * Gets the bytes of key value data
  59555. */
  59556. bytesOfKeyValueData: number;
  59557. /**
  59558. * Gets the load type
  59559. */
  59560. loadType: number;
  59561. /**
  59562. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59563. */
  59564. isInvalid: boolean;
  59565. /**
  59566. * Creates a new KhronosTextureContainer
  59567. * @param data contents of the KTX container file
  59568. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59569. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59570. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59571. */
  59572. constructor(
  59573. /** contents of the KTX container file */
  59574. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59575. /**
  59576. * Uploads KTX content to a Babylon Texture.
  59577. * It is assumed that the texture has already been created & is currently bound
  59578. * @hidden
  59579. */
  59580. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59581. private _upload2DCompressedLevels;
  59582. /**
  59583. * Checks if the given data starts with a KTX file identifier.
  59584. * @param data the data to check
  59585. * @returns true if the data is a KTX file or false otherwise
  59586. */
  59587. static IsValid(data: ArrayBufferView): boolean;
  59588. }
  59589. }
  59590. declare module "babylonjs/Misc/khronosTextureContainer2" {
  59591. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59592. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59593. /**
  59594. * Class for loading KTX2 files
  59595. * !!! Experimental Extension Subject to Changes !!!
  59596. * @hidden
  59597. */
  59598. export class KhronosTextureContainer2 {
  59599. private static _ModulePromise;
  59600. private static _TranscodeFormat;
  59601. constructor(engine: ThinEngine);
  59602. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  59603. private _determineTranscodeFormat;
  59604. /**
  59605. * Checks if the given data starts with a KTX2 file identifier.
  59606. * @param data the data to check
  59607. * @returns true if the data is a KTX2 file or false otherwise
  59608. */
  59609. static IsValid(data: ArrayBufferView): boolean;
  59610. }
  59611. }
  59612. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  59613. import { Nullable } from "babylonjs/types";
  59614. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59615. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59616. /**
  59617. * Implementation of the KTX Texture Loader.
  59618. * @hidden
  59619. */
  59620. export class _KTXTextureLoader implements IInternalTextureLoader {
  59621. /**
  59622. * Defines wether the loader supports cascade loading the different faces.
  59623. */
  59624. readonly supportCascades: boolean;
  59625. /**
  59626. * This returns if the loader support the current file information.
  59627. * @param extension defines the file extension of the file being loaded
  59628. * @param mimeType defines the optional mime type of the file being loaded
  59629. * @returns true if the loader can load the specified file
  59630. */
  59631. canLoad(extension: string, mimeType?: string): boolean;
  59632. /**
  59633. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59634. * @param data contains the texture data
  59635. * @param texture defines the BabylonJS internal texture
  59636. * @param createPolynomials will be true if polynomials have been requested
  59637. * @param onLoad defines the callback to trigger once the texture is ready
  59638. * @param onError defines the callback to trigger in case of error
  59639. */
  59640. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59641. /**
  59642. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59643. * @param data contains the texture data
  59644. * @param texture defines the BabylonJS internal texture
  59645. * @param callback defines the method to call once ready to upload
  59646. */
  59647. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  59648. }
  59649. }
  59650. declare module "babylonjs/Helpers/sceneHelpers" {
  59651. import { Nullable } from "babylonjs/types";
  59652. import { Mesh } from "babylonjs/Meshes/mesh";
  59653. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59654. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  59655. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  59656. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59657. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59658. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59659. import "babylonjs/Meshes/Builders/boxBuilder";
  59660. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  59661. /** @hidden */
  59662. export var _forceSceneHelpersToBundle: boolean;
  59663. module "babylonjs/scene" {
  59664. interface Scene {
  59665. /**
  59666. * Creates a default light for the scene.
  59667. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59668. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59669. */
  59670. createDefaultLight(replace?: boolean): void;
  59671. /**
  59672. * Creates a default camera for the scene.
  59673. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59674. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59675. * @param replace has default false, when true replaces the active camera in the scene
  59676. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59677. */
  59678. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59679. /**
  59680. * Creates a default camera and a default light.
  59681. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59682. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59683. * @param replace has the default false, when true replaces the active camera/light in the scene
  59684. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59685. */
  59686. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59687. /**
  59688. * Creates a new sky box
  59689. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59690. * @param environmentTexture defines the texture to use as environment texture
  59691. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59692. * @param scale defines the overall scale of the skybox
  59693. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59694. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59695. * @returns a new mesh holding the sky box
  59696. */
  59697. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59698. /**
  59699. * Creates a new environment
  59700. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59701. * @param options defines the options you can use to configure the environment
  59702. * @returns the new EnvironmentHelper
  59703. */
  59704. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59705. /**
  59706. * Creates a new VREXperienceHelper
  59707. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59708. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59709. * @returns a new VREXperienceHelper
  59710. */
  59711. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59712. /**
  59713. * Creates a new WebXRDefaultExperience
  59714. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59715. * @param options experience options
  59716. * @returns a promise for a new WebXRDefaultExperience
  59717. */
  59718. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59719. }
  59720. }
  59721. }
  59722. declare module "babylonjs/Helpers/videoDome" {
  59723. import { Scene } from "babylonjs/scene";
  59724. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59725. import { Mesh } from "babylonjs/Meshes/mesh";
  59726. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  59727. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  59728. import "babylonjs/Meshes/Builders/sphereBuilder";
  59729. /**
  59730. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59731. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59732. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59733. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59734. */
  59735. export class VideoDome extends TransformNode {
  59736. /**
  59737. * Define the video source as a Monoscopic panoramic 360 video.
  59738. */
  59739. static readonly MODE_MONOSCOPIC: number;
  59740. /**
  59741. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59742. */
  59743. static readonly MODE_TOPBOTTOM: number;
  59744. /**
  59745. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59746. */
  59747. static readonly MODE_SIDEBYSIDE: number;
  59748. private _halfDome;
  59749. private _useDirectMapping;
  59750. /**
  59751. * The video texture being displayed on the sphere
  59752. */
  59753. protected _videoTexture: VideoTexture;
  59754. /**
  59755. * Gets the video texture being displayed on the sphere
  59756. */
  59757. get videoTexture(): VideoTexture;
  59758. /**
  59759. * The skybox material
  59760. */
  59761. protected _material: BackgroundMaterial;
  59762. /**
  59763. * The surface used for the video dome
  59764. */
  59765. protected _mesh: Mesh;
  59766. /**
  59767. * Gets the mesh used for the video dome.
  59768. */
  59769. get mesh(): Mesh;
  59770. /**
  59771. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  59772. */
  59773. private _halfDomeMask;
  59774. /**
  59775. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  59776. * Also see the options.resolution property.
  59777. */
  59778. get fovMultiplier(): number;
  59779. set fovMultiplier(value: number);
  59780. private _videoMode;
  59781. /**
  59782. * Gets or set the current video mode for the video. It can be:
  59783. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  59784. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59785. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59786. */
  59787. get videoMode(): number;
  59788. set videoMode(value: number);
  59789. /**
  59790. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  59791. *
  59792. */
  59793. get halfDome(): boolean;
  59794. /**
  59795. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  59796. */
  59797. set halfDome(enabled: boolean);
  59798. /**
  59799. * Oberserver used in Stereoscopic VR Mode.
  59800. */
  59801. private _onBeforeCameraRenderObserver;
  59802. /**
  59803. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  59804. * @param name Element's name, child elements will append suffixes for their own names.
  59805. * @param urlsOrVideo defines the url(s) or the video element to use
  59806. * @param options An object containing optional or exposed sub element properties
  59807. */
  59808. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  59809. resolution?: number;
  59810. clickToPlay?: boolean;
  59811. autoPlay?: boolean;
  59812. loop?: boolean;
  59813. size?: number;
  59814. poster?: string;
  59815. faceForward?: boolean;
  59816. useDirectMapping?: boolean;
  59817. halfDomeMode?: boolean;
  59818. }, scene: Scene);
  59819. private _changeVideoMode;
  59820. /**
  59821. * Releases resources associated with this node.
  59822. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  59823. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  59824. */
  59825. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  59826. }
  59827. }
  59828. declare module "babylonjs/Helpers/index" {
  59829. export * from "babylonjs/Helpers/environmentHelper";
  59830. export * from "babylonjs/Helpers/photoDome";
  59831. export * from "babylonjs/Helpers/sceneHelpers";
  59832. export * from "babylonjs/Helpers/videoDome";
  59833. }
  59834. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  59835. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59836. import { IDisposable } from "babylonjs/scene";
  59837. import { Engine } from "babylonjs/Engines/engine";
  59838. /**
  59839. * This class can be used to get instrumentation data from a Babylon engine
  59840. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59841. */
  59842. export class EngineInstrumentation implements IDisposable {
  59843. /**
  59844. * Define the instrumented engine.
  59845. */
  59846. engine: Engine;
  59847. private _captureGPUFrameTime;
  59848. private _gpuFrameTimeToken;
  59849. private _gpuFrameTime;
  59850. private _captureShaderCompilationTime;
  59851. private _shaderCompilationTime;
  59852. private _onBeginFrameObserver;
  59853. private _onEndFrameObserver;
  59854. private _onBeforeShaderCompilationObserver;
  59855. private _onAfterShaderCompilationObserver;
  59856. /**
  59857. * Gets the perf counter used for GPU frame time
  59858. */
  59859. get gpuFrameTimeCounter(): PerfCounter;
  59860. /**
  59861. * Gets the GPU frame time capture status
  59862. */
  59863. get captureGPUFrameTime(): boolean;
  59864. /**
  59865. * Enable or disable the GPU frame time capture
  59866. */
  59867. set captureGPUFrameTime(value: boolean);
  59868. /**
  59869. * Gets the perf counter used for shader compilation time
  59870. */
  59871. get shaderCompilationTimeCounter(): PerfCounter;
  59872. /**
  59873. * Gets the shader compilation time capture status
  59874. */
  59875. get captureShaderCompilationTime(): boolean;
  59876. /**
  59877. * Enable or disable the shader compilation time capture
  59878. */
  59879. set captureShaderCompilationTime(value: boolean);
  59880. /**
  59881. * Instantiates a new engine instrumentation.
  59882. * This class can be used to get instrumentation data from a Babylon engine
  59883. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59884. * @param engine Defines the engine to instrument
  59885. */
  59886. constructor(
  59887. /**
  59888. * Define the instrumented engine.
  59889. */
  59890. engine: Engine);
  59891. /**
  59892. * Dispose and release associated resources.
  59893. */
  59894. dispose(): void;
  59895. }
  59896. }
  59897. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  59898. import { Scene, IDisposable } from "babylonjs/scene";
  59899. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59900. /**
  59901. * This class can be used to get instrumentation data from a Babylon engine
  59902. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59903. */
  59904. export class SceneInstrumentation implements IDisposable {
  59905. /**
  59906. * Defines the scene to instrument
  59907. */
  59908. scene: Scene;
  59909. private _captureActiveMeshesEvaluationTime;
  59910. private _activeMeshesEvaluationTime;
  59911. private _captureRenderTargetsRenderTime;
  59912. private _renderTargetsRenderTime;
  59913. private _captureFrameTime;
  59914. private _frameTime;
  59915. private _captureRenderTime;
  59916. private _renderTime;
  59917. private _captureInterFrameTime;
  59918. private _interFrameTime;
  59919. private _captureParticlesRenderTime;
  59920. private _particlesRenderTime;
  59921. private _captureSpritesRenderTime;
  59922. private _spritesRenderTime;
  59923. private _capturePhysicsTime;
  59924. private _physicsTime;
  59925. private _captureAnimationsTime;
  59926. private _animationsTime;
  59927. private _captureCameraRenderTime;
  59928. private _cameraRenderTime;
  59929. private _onBeforeActiveMeshesEvaluationObserver;
  59930. private _onAfterActiveMeshesEvaluationObserver;
  59931. private _onBeforeRenderTargetsRenderObserver;
  59932. private _onAfterRenderTargetsRenderObserver;
  59933. private _onAfterRenderObserver;
  59934. private _onBeforeDrawPhaseObserver;
  59935. private _onAfterDrawPhaseObserver;
  59936. private _onBeforeAnimationsObserver;
  59937. private _onBeforeParticlesRenderingObserver;
  59938. private _onAfterParticlesRenderingObserver;
  59939. private _onBeforeSpritesRenderingObserver;
  59940. private _onAfterSpritesRenderingObserver;
  59941. private _onBeforePhysicsObserver;
  59942. private _onAfterPhysicsObserver;
  59943. private _onAfterAnimationsObserver;
  59944. private _onBeforeCameraRenderObserver;
  59945. private _onAfterCameraRenderObserver;
  59946. /**
  59947. * Gets the perf counter used for active meshes evaluation time
  59948. */
  59949. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59950. /**
  59951. * Gets the active meshes evaluation time capture status
  59952. */
  59953. get captureActiveMeshesEvaluationTime(): boolean;
  59954. /**
  59955. * Enable or disable the active meshes evaluation time capture
  59956. */
  59957. set captureActiveMeshesEvaluationTime(value: boolean);
  59958. /**
  59959. * Gets the perf counter used for render targets render time
  59960. */
  59961. get renderTargetsRenderTimeCounter(): PerfCounter;
  59962. /**
  59963. * Gets the render targets render time capture status
  59964. */
  59965. get captureRenderTargetsRenderTime(): boolean;
  59966. /**
  59967. * Enable or disable the render targets render time capture
  59968. */
  59969. set captureRenderTargetsRenderTime(value: boolean);
  59970. /**
  59971. * Gets the perf counter used for particles render time
  59972. */
  59973. get particlesRenderTimeCounter(): PerfCounter;
  59974. /**
  59975. * Gets the particles render time capture status
  59976. */
  59977. get captureParticlesRenderTime(): boolean;
  59978. /**
  59979. * Enable or disable the particles render time capture
  59980. */
  59981. set captureParticlesRenderTime(value: boolean);
  59982. /**
  59983. * Gets the perf counter used for sprites render time
  59984. */
  59985. get spritesRenderTimeCounter(): PerfCounter;
  59986. /**
  59987. * Gets the sprites render time capture status
  59988. */
  59989. get captureSpritesRenderTime(): boolean;
  59990. /**
  59991. * Enable or disable the sprites render time capture
  59992. */
  59993. set captureSpritesRenderTime(value: boolean);
  59994. /**
  59995. * Gets the perf counter used for physics time
  59996. */
  59997. get physicsTimeCounter(): PerfCounter;
  59998. /**
  59999. * Gets the physics time capture status
  60000. */
  60001. get capturePhysicsTime(): boolean;
  60002. /**
  60003. * Enable or disable the physics time capture
  60004. */
  60005. set capturePhysicsTime(value: boolean);
  60006. /**
  60007. * Gets the perf counter used for animations time
  60008. */
  60009. get animationsTimeCounter(): PerfCounter;
  60010. /**
  60011. * Gets the animations time capture status
  60012. */
  60013. get captureAnimationsTime(): boolean;
  60014. /**
  60015. * Enable or disable the animations time capture
  60016. */
  60017. set captureAnimationsTime(value: boolean);
  60018. /**
  60019. * Gets the perf counter used for frame time capture
  60020. */
  60021. get frameTimeCounter(): PerfCounter;
  60022. /**
  60023. * Gets the frame time capture status
  60024. */
  60025. get captureFrameTime(): boolean;
  60026. /**
  60027. * Enable or disable the frame time capture
  60028. */
  60029. set captureFrameTime(value: boolean);
  60030. /**
  60031. * Gets the perf counter used for inter-frames time capture
  60032. */
  60033. get interFrameTimeCounter(): PerfCounter;
  60034. /**
  60035. * Gets the inter-frames time capture status
  60036. */
  60037. get captureInterFrameTime(): boolean;
  60038. /**
  60039. * Enable or disable the inter-frames time capture
  60040. */
  60041. set captureInterFrameTime(value: boolean);
  60042. /**
  60043. * Gets the perf counter used for render time capture
  60044. */
  60045. get renderTimeCounter(): PerfCounter;
  60046. /**
  60047. * Gets the render time capture status
  60048. */
  60049. get captureRenderTime(): boolean;
  60050. /**
  60051. * Enable or disable the render time capture
  60052. */
  60053. set captureRenderTime(value: boolean);
  60054. /**
  60055. * Gets the perf counter used for camera render time capture
  60056. */
  60057. get cameraRenderTimeCounter(): PerfCounter;
  60058. /**
  60059. * Gets the camera render time capture status
  60060. */
  60061. get captureCameraRenderTime(): boolean;
  60062. /**
  60063. * Enable or disable the camera render time capture
  60064. */
  60065. set captureCameraRenderTime(value: boolean);
  60066. /**
  60067. * Gets the perf counter used for draw calls
  60068. */
  60069. get drawCallsCounter(): PerfCounter;
  60070. /**
  60071. * Instantiates a new scene instrumentation.
  60072. * This class can be used to get instrumentation data from a Babylon engine
  60073. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60074. * @param scene Defines the scene to instrument
  60075. */
  60076. constructor(
  60077. /**
  60078. * Defines the scene to instrument
  60079. */
  60080. scene: Scene);
  60081. /**
  60082. * Dispose and release associated resources.
  60083. */
  60084. dispose(): void;
  60085. }
  60086. }
  60087. declare module "babylonjs/Instrumentation/index" {
  60088. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60089. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60090. export * from "babylonjs/Instrumentation/timeToken";
  60091. }
  60092. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60093. /** @hidden */
  60094. export var glowMapGenerationPixelShader: {
  60095. name: string;
  60096. shader: string;
  60097. };
  60098. }
  60099. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60100. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60101. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60102. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60103. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60104. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60105. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60106. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60107. /** @hidden */
  60108. export var glowMapGenerationVertexShader: {
  60109. name: string;
  60110. shader: string;
  60111. };
  60112. }
  60113. declare module "babylonjs/Layers/effectLayer" {
  60114. import { Observable } from "babylonjs/Misc/observable";
  60115. import { Nullable } from "babylonjs/types";
  60116. import { Camera } from "babylonjs/Cameras/camera";
  60117. import { Scene } from "babylonjs/scene";
  60118. import { ISize } from "babylonjs/Maths/math.size";
  60119. import { Color4 } from "babylonjs/Maths/math.color";
  60120. import { Engine } from "babylonjs/Engines/engine";
  60121. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60123. import { Mesh } from "babylonjs/Meshes/mesh";
  60124. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60125. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60126. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60127. import { Effect } from "babylonjs/Materials/effect";
  60128. import { Material } from "babylonjs/Materials/material";
  60129. import "babylonjs/Shaders/glowMapGeneration.fragment";
  60130. import "babylonjs/Shaders/glowMapGeneration.vertex";
  60131. /**
  60132. * Effect layer options. This helps customizing the behaviour
  60133. * of the effect layer.
  60134. */
  60135. export interface IEffectLayerOptions {
  60136. /**
  60137. * Multiplication factor apply to the canvas size to compute the render target size
  60138. * used to generated the objects (the smaller the faster).
  60139. */
  60140. mainTextureRatio: number;
  60141. /**
  60142. * Enforces a fixed size texture to ensure effect stability across devices.
  60143. */
  60144. mainTextureFixedSize?: number;
  60145. /**
  60146. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  60147. */
  60148. alphaBlendingMode: number;
  60149. /**
  60150. * The camera attached to the layer.
  60151. */
  60152. camera: Nullable<Camera>;
  60153. /**
  60154. * The rendering group to draw the layer in.
  60155. */
  60156. renderingGroupId: number;
  60157. }
  60158. /**
  60159. * The effect layer Helps adding post process effect blended with the main pass.
  60160. *
  60161. * This can be for instance use to generate glow or higlight effects on the scene.
  60162. *
  60163. * The effect layer class can not be used directly and is intented to inherited from to be
  60164. * customized per effects.
  60165. */
  60166. export abstract class EffectLayer {
  60167. private _vertexBuffers;
  60168. private _indexBuffer;
  60169. private _cachedDefines;
  60170. private _effectLayerMapGenerationEffect;
  60171. private _effectLayerOptions;
  60172. private _mergeEffect;
  60173. protected _scene: Scene;
  60174. protected _engine: Engine;
  60175. protected _maxSize: number;
  60176. protected _mainTextureDesiredSize: ISize;
  60177. protected _mainTexture: RenderTargetTexture;
  60178. protected _shouldRender: boolean;
  60179. protected _postProcesses: PostProcess[];
  60180. protected _textures: BaseTexture[];
  60181. protected _emissiveTextureAndColor: {
  60182. texture: Nullable<BaseTexture>;
  60183. color: Color4;
  60184. };
  60185. /**
  60186. * The name of the layer
  60187. */
  60188. name: string;
  60189. /**
  60190. * The clear color of the texture used to generate the glow map.
  60191. */
  60192. neutralColor: Color4;
  60193. /**
  60194. * Specifies whether the highlight layer is enabled or not.
  60195. */
  60196. isEnabled: boolean;
  60197. /**
  60198. * Gets the camera attached to the layer.
  60199. */
  60200. get camera(): Nullable<Camera>;
  60201. /**
  60202. * Gets the rendering group id the layer should render in.
  60203. */
  60204. get renderingGroupId(): number;
  60205. set renderingGroupId(renderingGroupId: number);
  60206. /**
  60207. * An event triggered when the effect layer has been disposed.
  60208. */
  60209. onDisposeObservable: Observable<EffectLayer>;
  60210. /**
  60211. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  60212. */
  60213. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  60214. /**
  60215. * An event triggered when the generated texture is being merged in the scene.
  60216. */
  60217. onBeforeComposeObservable: Observable<EffectLayer>;
  60218. /**
  60219. * An event triggered when the mesh is rendered into the effect render target.
  60220. */
  60221. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  60222. /**
  60223. * An event triggered after the mesh has been rendered into the effect render target.
  60224. */
  60225. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  60226. /**
  60227. * An event triggered when the generated texture has been merged in the scene.
  60228. */
  60229. onAfterComposeObservable: Observable<EffectLayer>;
  60230. /**
  60231. * An event triggered when the efffect layer changes its size.
  60232. */
  60233. onSizeChangedObservable: Observable<EffectLayer>;
  60234. /** @hidden */
  60235. static _SceneComponentInitialization: (scene: Scene) => void;
  60236. /**
  60237. * Instantiates a new effect Layer and references it in the scene.
  60238. * @param name The name of the layer
  60239. * @param scene The scene to use the layer in
  60240. */
  60241. constructor(
  60242. /** The Friendly of the effect in the scene */
  60243. name: string, scene: Scene);
  60244. /**
  60245. * Get the effect name of the layer.
  60246. * @return The effect name
  60247. */
  60248. abstract getEffectName(): string;
  60249. /**
  60250. * Checks for the readiness of the element composing the layer.
  60251. * @param subMesh the mesh to check for
  60252. * @param useInstances specify whether or not to use instances to render the mesh
  60253. * @return true if ready otherwise, false
  60254. */
  60255. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60256. /**
  60257. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60258. * @returns true if the effect requires stencil during the main canvas render pass.
  60259. */
  60260. abstract needStencil(): boolean;
  60261. /**
  60262. * Create the merge effect. This is the shader use to blit the information back
  60263. * to the main canvas at the end of the scene rendering.
  60264. * @returns The effect containing the shader used to merge the effect on the main canvas
  60265. */
  60266. protected abstract _createMergeEffect(): Effect;
  60267. /**
  60268. * Creates the render target textures and post processes used in the effect layer.
  60269. */
  60270. protected abstract _createTextureAndPostProcesses(): void;
  60271. /**
  60272. * Implementation specific of rendering the generating effect on the main canvas.
  60273. * @param effect The effect used to render through
  60274. */
  60275. protected abstract _internalRender(effect: Effect): void;
  60276. /**
  60277. * Sets the required values for both the emissive texture and and the main color.
  60278. */
  60279. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60280. /**
  60281. * Free any resources and references associated to a mesh.
  60282. * Internal use
  60283. * @param mesh The mesh to free.
  60284. */
  60285. abstract _disposeMesh(mesh: Mesh): void;
  60286. /**
  60287. * Serializes this layer (Glow or Highlight for example)
  60288. * @returns a serialized layer object
  60289. */
  60290. abstract serialize?(): any;
  60291. /**
  60292. * Initializes the effect layer with the required options.
  60293. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  60294. */
  60295. protected _init(options: Partial<IEffectLayerOptions>): void;
  60296. /**
  60297. * Generates the index buffer of the full screen quad blending to the main canvas.
  60298. */
  60299. private _generateIndexBuffer;
  60300. /**
  60301. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  60302. */
  60303. private _generateVertexBuffer;
  60304. /**
  60305. * Sets the main texture desired size which is the closest power of two
  60306. * of the engine canvas size.
  60307. */
  60308. private _setMainTextureSize;
  60309. /**
  60310. * Creates the main texture for the effect layer.
  60311. */
  60312. protected _createMainTexture(): void;
  60313. /**
  60314. * Adds specific effects defines.
  60315. * @param defines The defines to add specifics to.
  60316. */
  60317. protected _addCustomEffectDefines(defines: string[]): void;
  60318. /**
  60319. * Checks for the readiness of the element composing the layer.
  60320. * @param subMesh the mesh to check for
  60321. * @param useInstances specify whether or not to use instances to render the mesh
  60322. * @param emissiveTexture the associated emissive texture used to generate the glow
  60323. * @return true if ready otherwise, false
  60324. */
  60325. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  60326. /**
  60327. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  60328. */
  60329. render(): void;
  60330. /**
  60331. * Determine if a given mesh will be used in the current effect.
  60332. * @param mesh mesh to test
  60333. * @returns true if the mesh will be used
  60334. */
  60335. hasMesh(mesh: AbstractMesh): boolean;
  60336. /**
  60337. * Returns true if the layer contains information to display, otherwise false.
  60338. * @returns true if the glow layer should be rendered
  60339. */
  60340. shouldRender(): boolean;
  60341. /**
  60342. * Returns true if the mesh should render, otherwise false.
  60343. * @param mesh The mesh to render
  60344. * @returns true if it should render otherwise false
  60345. */
  60346. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  60347. /**
  60348. * Returns true if the mesh can be rendered, otherwise false.
  60349. * @param mesh The mesh to render
  60350. * @param material The material used on the mesh
  60351. * @returns true if it can be rendered otherwise false
  60352. */
  60353. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60354. /**
  60355. * Returns true if the mesh should render, otherwise false.
  60356. * @param mesh The mesh to render
  60357. * @returns true if it should render otherwise false
  60358. */
  60359. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  60360. /**
  60361. * Renders the submesh passed in parameter to the generation map.
  60362. */
  60363. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60364. /**
  60365. * Defines whether the current material of the mesh should be use to render the effect.
  60366. * @param mesh defines the current mesh to render
  60367. */
  60368. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60369. /**
  60370. * Rebuild the required buffers.
  60371. * @hidden Internal use only.
  60372. */
  60373. _rebuild(): void;
  60374. /**
  60375. * Dispose only the render target textures and post process.
  60376. */
  60377. private _disposeTextureAndPostProcesses;
  60378. /**
  60379. * Dispose the highlight layer and free resources.
  60380. */
  60381. dispose(): void;
  60382. /**
  60383. * Gets the class name of the effect layer
  60384. * @returns the string with the class name of the effect layer
  60385. */
  60386. getClassName(): string;
  60387. /**
  60388. * Creates an effect layer from parsed effect layer data
  60389. * @param parsedEffectLayer defines effect layer data
  60390. * @param scene defines the current scene
  60391. * @param rootUrl defines the root URL containing the effect layer information
  60392. * @returns a parsed effect Layer
  60393. */
  60394. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60395. }
  60396. }
  60397. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  60398. import { Scene } from "babylonjs/scene";
  60399. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60400. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60401. import { AbstractScene } from "babylonjs/abstractScene";
  60402. module "babylonjs/abstractScene" {
  60403. interface AbstractScene {
  60404. /**
  60405. * The list of effect layers (highlights/glow) added to the scene
  60406. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60407. * @see https://doc.babylonjs.com/how_to/glow_layer
  60408. */
  60409. effectLayers: Array<EffectLayer>;
  60410. /**
  60411. * Removes the given effect layer from this scene.
  60412. * @param toRemove defines the effect layer to remove
  60413. * @returns the index of the removed effect layer
  60414. */
  60415. removeEffectLayer(toRemove: EffectLayer): number;
  60416. /**
  60417. * Adds the given effect layer to this scene
  60418. * @param newEffectLayer defines the effect layer to add
  60419. */
  60420. addEffectLayer(newEffectLayer: EffectLayer): void;
  60421. }
  60422. }
  60423. /**
  60424. * Defines the layer scene component responsible to manage any effect layers
  60425. * in a given scene.
  60426. */
  60427. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60428. /**
  60429. * The component name helpfull to identify the component in the list of scene components.
  60430. */
  60431. readonly name: string;
  60432. /**
  60433. * The scene the component belongs to.
  60434. */
  60435. scene: Scene;
  60436. private _engine;
  60437. private _renderEffects;
  60438. private _needStencil;
  60439. private _previousStencilState;
  60440. /**
  60441. * Creates a new instance of the component for the given scene
  60442. * @param scene Defines the scene to register the component in
  60443. */
  60444. constructor(scene: Scene);
  60445. /**
  60446. * Registers the component in a given scene
  60447. */
  60448. register(): void;
  60449. /**
  60450. * Rebuilds the elements related to this component in case of
  60451. * context lost for instance.
  60452. */
  60453. rebuild(): void;
  60454. /**
  60455. * Serializes the component data to the specified json object
  60456. * @param serializationObject The object to serialize to
  60457. */
  60458. serialize(serializationObject: any): void;
  60459. /**
  60460. * Adds all the elements from the container to the scene
  60461. * @param container the container holding the elements
  60462. */
  60463. addFromContainer(container: AbstractScene): void;
  60464. /**
  60465. * Removes all the elements in the container from the scene
  60466. * @param container contains the elements to remove
  60467. * @param dispose if the removed element should be disposed (default: false)
  60468. */
  60469. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60470. /**
  60471. * Disposes the component and the associated ressources.
  60472. */
  60473. dispose(): void;
  60474. private _isReadyForMesh;
  60475. private _renderMainTexture;
  60476. private _setStencil;
  60477. private _setStencilBack;
  60478. private _draw;
  60479. private _drawCamera;
  60480. private _drawRenderingGroup;
  60481. }
  60482. }
  60483. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  60484. /** @hidden */
  60485. export var glowMapMergePixelShader: {
  60486. name: string;
  60487. shader: string;
  60488. };
  60489. }
  60490. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  60491. /** @hidden */
  60492. export var glowMapMergeVertexShader: {
  60493. name: string;
  60494. shader: string;
  60495. };
  60496. }
  60497. declare module "babylonjs/Layers/glowLayer" {
  60498. import { Nullable } from "babylonjs/types";
  60499. import { Camera } from "babylonjs/Cameras/camera";
  60500. import { Scene } from "babylonjs/scene";
  60501. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60503. import { Mesh } from "babylonjs/Meshes/mesh";
  60504. import { Texture } from "babylonjs/Materials/Textures/texture";
  60505. import { Effect } from "babylonjs/Materials/effect";
  60506. import { Material } from "babylonjs/Materials/material";
  60507. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60508. import { Color4 } from "babylonjs/Maths/math.color";
  60509. import "babylonjs/Shaders/glowMapMerge.fragment";
  60510. import "babylonjs/Shaders/glowMapMerge.vertex";
  60511. import "babylonjs/Layers/effectLayerSceneComponent";
  60512. module "babylonjs/abstractScene" {
  60513. interface AbstractScene {
  60514. /**
  60515. * Return a the first highlight layer of the scene with a given name.
  60516. * @param name The name of the highlight layer to look for.
  60517. * @return The highlight layer if found otherwise null.
  60518. */
  60519. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60520. }
  60521. }
  60522. /**
  60523. * Glow layer options. This helps customizing the behaviour
  60524. * of the glow layer.
  60525. */
  60526. export interface IGlowLayerOptions {
  60527. /**
  60528. * Multiplication factor apply to the canvas size to compute the render target size
  60529. * used to generated the glowing objects (the smaller the faster).
  60530. */
  60531. mainTextureRatio: number;
  60532. /**
  60533. * Enforces a fixed size texture to ensure resize independant blur.
  60534. */
  60535. mainTextureFixedSize?: number;
  60536. /**
  60537. * How big is the kernel of the blur texture.
  60538. */
  60539. blurKernelSize: number;
  60540. /**
  60541. * The camera attached to the layer.
  60542. */
  60543. camera: Nullable<Camera>;
  60544. /**
  60545. * Enable MSAA by chosing the number of samples.
  60546. */
  60547. mainTextureSamples?: number;
  60548. /**
  60549. * The rendering group to draw the layer in.
  60550. */
  60551. renderingGroupId: number;
  60552. }
  60553. /**
  60554. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60555. *
  60556. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60557. *
  60558. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60559. */
  60560. export class GlowLayer extends EffectLayer {
  60561. /**
  60562. * Effect Name of the layer.
  60563. */
  60564. static readonly EffectName: string;
  60565. /**
  60566. * The default blur kernel size used for the glow.
  60567. */
  60568. static DefaultBlurKernelSize: number;
  60569. /**
  60570. * The default texture size ratio used for the glow.
  60571. */
  60572. static DefaultTextureRatio: number;
  60573. /**
  60574. * Sets the kernel size of the blur.
  60575. */
  60576. set blurKernelSize(value: number);
  60577. /**
  60578. * Gets the kernel size of the blur.
  60579. */
  60580. get blurKernelSize(): number;
  60581. /**
  60582. * Sets the glow intensity.
  60583. */
  60584. set intensity(value: number);
  60585. /**
  60586. * Gets the glow intensity.
  60587. */
  60588. get intensity(): number;
  60589. private _options;
  60590. private _intensity;
  60591. private _horizontalBlurPostprocess1;
  60592. private _verticalBlurPostprocess1;
  60593. private _horizontalBlurPostprocess2;
  60594. private _verticalBlurPostprocess2;
  60595. private _blurTexture1;
  60596. private _blurTexture2;
  60597. private _postProcesses1;
  60598. private _postProcesses2;
  60599. private _includedOnlyMeshes;
  60600. private _excludedMeshes;
  60601. private _meshesUsingTheirOwnMaterials;
  60602. /**
  60603. * Callback used to let the user override the color selection on a per mesh basis
  60604. */
  60605. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60606. /**
  60607. * Callback used to let the user override the texture selection on a per mesh basis
  60608. */
  60609. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60610. /**
  60611. * Instantiates a new glow Layer and references it to the scene.
  60612. * @param name The name of the layer
  60613. * @param scene The scene to use the layer in
  60614. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60615. */
  60616. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60617. /**
  60618. * Get the effect name of the layer.
  60619. * @return The effect name
  60620. */
  60621. getEffectName(): string;
  60622. /**
  60623. * Create the merge effect. This is the shader use to blit the information back
  60624. * to the main canvas at the end of the scene rendering.
  60625. */
  60626. protected _createMergeEffect(): Effect;
  60627. /**
  60628. * Creates the render target textures and post processes used in the glow layer.
  60629. */
  60630. protected _createTextureAndPostProcesses(): void;
  60631. /**
  60632. * Checks for the readiness of the element composing the layer.
  60633. * @param subMesh the mesh to check for
  60634. * @param useInstances specify wether or not to use instances to render the mesh
  60635. * @param emissiveTexture the associated emissive texture used to generate the glow
  60636. * @return true if ready otherwise, false
  60637. */
  60638. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60639. /**
  60640. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60641. */
  60642. needStencil(): boolean;
  60643. /**
  60644. * Returns true if the mesh can be rendered, otherwise false.
  60645. * @param mesh The mesh to render
  60646. * @param material The material used on the mesh
  60647. * @returns true if it can be rendered otherwise false
  60648. */
  60649. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60650. /**
  60651. * Implementation specific of rendering the generating effect on the main canvas.
  60652. * @param effect The effect used to render through
  60653. */
  60654. protected _internalRender(effect: Effect): void;
  60655. /**
  60656. * Sets the required values for both the emissive texture and and the main color.
  60657. */
  60658. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60659. /**
  60660. * Returns true if the mesh should render, otherwise false.
  60661. * @param mesh The mesh to render
  60662. * @returns true if it should render otherwise false
  60663. */
  60664. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60665. /**
  60666. * Adds specific effects defines.
  60667. * @param defines The defines to add specifics to.
  60668. */
  60669. protected _addCustomEffectDefines(defines: string[]): void;
  60670. /**
  60671. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60672. * @param mesh The mesh to exclude from the glow layer
  60673. */
  60674. addExcludedMesh(mesh: Mesh): void;
  60675. /**
  60676. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60677. * @param mesh The mesh to remove
  60678. */
  60679. removeExcludedMesh(mesh: Mesh): void;
  60680. /**
  60681. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60682. * @param mesh The mesh to include in the glow layer
  60683. */
  60684. addIncludedOnlyMesh(mesh: Mesh): void;
  60685. /**
  60686. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60687. * @param mesh The mesh to remove
  60688. */
  60689. removeIncludedOnlyMesh(mesh: Mesh): void;
  60690. /**
  60691. * Determine if a given mesh will be used in the glow layer
  60692. * @param mesh The mesh to test
  60693. * @returns true if the mesh will be highlighted by the current glow layer
  60694. */
  60695. hasMesh(mesh: AbstractMesh): boolean;
  60696. /**
  60697. * Defines whether the current material of the mesh should be use to render the effect.
  60698. * @param mesh defines the current mesh to render
  60699. */
  60700. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60701. /**
  60702. * Add a mesh to be rendered through its own material and not with emissive only.
  60703. * @param mesh The mesh for which we need to use its material
  60704. */
  60705. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60706. /**
  60707. * Remove a mesh from being rendered through its own material and not with emissive only.
  60708. * @param mesh The mesh for which we need to not use its material
  60709. */
  60710. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60711. /**
  60712. * Free any resources and references associated to a mesh.
  60713. * Internal use
  60714. * @param mesh The mesh to free.
  60715. * @hidden
  60716. */
  60717. _disposeMesh(mesh: Mesh): void;
  60718. /**
  60719. * Gets the class name of the effect layer
  60720. * @returns the string with the class name of the effect layer
  60721. */
  60722. getClassName(): string;
  60723. /**
  60724. * Serializes this glow layer
  60725. * @returns a serialized glow layer object
  60726. */
  60727. serialize(): any;
  60728. /**
  60729. * Creates a Glow Layer from parsed glow layer data
  60730. * @param parsedGlowLayer defines glow layer data
  60731. * @param scene defines the current scene
  60732. * @param rootUrl defines the root URL containing the glow layer information
  60733. * @returns a parsed Glow Layer
  60734. */
  60735. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60736. }
  60737. }
  60738. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  60739. /** @hidden */
  60740. export var glowBlurPostProcessPixelShader: {
  60741. name: string;
  60742. shader: string;
  60743. };
  60744. }
  60745. declare module "babylonjs/Layers/highlightLayer" {
  60746. import { Observable } from "babylonjs/Misc/observable";
  60747. import { Nullable } from "babylonjs/types";
  60748. import { Camera } from "babylonjs/Cameras/camera";
  60749. import { Scene } from "babylonjs/scene";
  60750. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60752. import { Mesh } from "babylonjs/Meshes/mesh";
  60753. import { Effect } from "babylonjs/Materials/effect";
  60754. import { Material } from "babylonjs/Materials/material";
  60755. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60756. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60757. import "babylonjs/Shaders/glowMapMerge.fragment";
  60758. import "babylonjs/Shaders/glowMapMerge.vertex";
  60759. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  60760. module "babylonjs/abstractScene" {
  60761. interface AbstractScene {
  60762. /**
  60763. * Return a the first highlight layer of the scene with a given name.
  60764. * @param name The name of the highlight layer to look for.
  60765. * @return The highlight layer if found otherwise null.
  60766. */
  60767. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60768. }
  60769. }
  60770. /**
  60771. * Highlight layer options. This helps customizing the behaviour
  60772. * of the highlight layer.
  60773. */
  60774. export interface IHighlightLayerOptions {
  60775. /**
  60776. * Multiplication factor apply to the canvas size to compute the render target size
  60777. * used to generated the glowing objects (the smaller the faster).
  60778. */
  60779. mainTextureRatio: number;
  60780. /**
  60781. * Enforces a fixed size texture to ensure resize independant blur.
  60782. */
  60783. mainTextureFixedSize?: number;
  60784. /**
  60785. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60786. * of the picture to blur (the smaller the faster).
  60787. */
  60788. blurTextureSizeRatio: number;
  60789. /**
  60790. * How big in texel of the blur texture is the vertical blur.
  60791. */
  60792. blurVerticalSize: number;
  60793. /**
  60794. * How big in texel of the blur texture is the horizontal blur.
  60795. */
  60796. blurHorizontalSize: number;
  60797. /**
  60798. * Alpha blending mode used to apply the blur. Default is combine.
  60799. */
  60800. alphaBlendingMode: number;
  60801. /**
  60802. * The camera attached to the layer.
  60803. */
  60804. camera: Nullable<Camera>;
  60805. /**
  60806. * Should we display highlight as a solid stroke?
  60807. */
  60808. isStroke?: boolean;
  60809. /**
  60810. * The rendering group to draw the layer in.
  60811. */
  60812. renderingGroupId: number;
  60813. }
  60814. /**
  60815. * The highlight layer Helps adding a glow effect around a mesh.
  60816. *
  60817. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60818. * glowy meshes to your scene.
  60819. *
  60820. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60821. */
  60822. export class HighlightLayer extends EffectLayer {
  60823. name: string;
  60824. /**
  60825. * Effect Name of the highlight layer.
  60826. */
  60827. static readonly EffectName: string;
  60828. /**
  60829. * The neutral color used during the preparation of the glow effect.
  60830. * This is black by default as the blend operation is a blend operation.
  60831. */
  60832. static NeutralColor: Color4;
  60833. /**
  60834. * Stencil value used for glowing meshes.
  60835. */
  60836. static GlowingMeshStencilReference: number;
  60837. /**
  60838. * Stencil value used for the other meshes in the scene.
  60839. */
  60840. static NormalMeshStencilReference: number;
  60841. /**
  60842. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60843. */
  60844. innerGlow: boolean;
  60845. /**
  60846. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60847. */
  60848. outerGlow: boolean;
  60849. /**
  60850. * Specifies the horizontal size of the blur.
  60851. */
  60852. set blurHorizontalSize(value: number);
  60853. /**
  60854. * Specifies the vertical size of the blur.
  60855. */
  60856. set blurVerticalSize(value: number);
  60857. /**
  60858. * Gets the horizontal size of the blur.
  60859. */
  60860. get blurHorizontalSize(): number;
  60861. /**
  60862. * Gets the vertical size of the blur.
  60863. */
  60864. get blurVerticalSize(): number;
  60865. /**
  60866. * An event triggered when the highlight layer is being blurred.
  60867. */
  60868. onBeforeBlurObservable: Observable<HighlightLayer>;
  60869. /**
  60870. * An event triggered when the highlight layer has been blurred.
  60871. */
  60872. onAfterBlurObservable: Observable<HighlightLayer>;
  60873. private _instanceGlowingMeshStencilReference;
  60874. private _options;
  60875. private _downSamplePostprocess;
  60876. private _horizontalBlurPostprocess;
  60877. private _verticalBlurPostprocess;
  60878. private _blurTexture;
  60879. private _meshes;
  60880. private _excludedMeshes;
  60881. /**
  60882. * Instantiates a new highlight Layer and references it to the scene..
  60883. * @param name The name of the layer
  60884. * @param scene The scene to use the layer in
  60885. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60886. */
  60887. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60888. /**
  60889. * Get the effect name of the layer.
  60890. * @return The effect name
  60891. */
  60892. getEffectName(): string;
  60893. /**
  60894. * Create the merge effect. This is the shader use to blit the information back
  60895. * to the main canvas at the end of the scene rendering.
  60896. */
  60897. protected _createMergeEffect(): Effect;
  60898. /**
  60899. * Creates the render target textures and post processes used in the highlight layer.
  60900. */
  60901. protected _createTextureAndPostProcesses(): void;
  60902. /**
  60903. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60904. */
  60905. needStencil(): boolean;
  60906. /**
  60907. * Checks for the readiness of the element composing the layer.
  60908. * @param subMesh the mesh to check for
  60909. * @param useInstances specify wether or not to use instances to render the mesh
  60910. * @param emissiveTexture the associated emissive texture used to generate the glow
  60911. * @return true if ready otherwise, false
  60912. */
  60913. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60914. /**
  60915. * Implementation specific of rendering the generating effect on the main canvas.
  60916. * @param effect The effect used to render through
  60917. */
  60918. protected _internalRender(effect: Effect): void;
  60919. /**
  60920. * Returns true if the layer contains information to display, otherwise false.
  60921. */
  60922. shouldRender(): boolean;
  60923. /**
  60924. * Returns true if the mesh should render, otherwise false.
  60925. * @param mesh The mesh to render
  60926. * @returns true if it should render otherwise false
  60927. */
  60928. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60929. /**
  60930. * Returns true if the mesh can be rendered, otherwise false.
  60931. * @param mesh The mesh to render
  60932. * @param material The material used on the mesh
  60933. * @returns true if it can be rendered otherwise false
  60934. */
  60935. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60936. /**
  60937. * Adds specific effects defines.
  60938. * @param defines The defines to add specifics to.
  60939. */
  60940. protected _addCustomEffectDefines(defines: string[]): void;
  60941. /**
  60942. * Sets the required values for both the emissive texture and and the main color.
  60943. */
  60944. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60945. /**
  60946. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60947. * @param mesh The mesh to exclude from the highlight layer
  60948. */
  60949. addExcludedMesh(mesh: Mesh): void;
  60950. /**
  60951. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60952. * @param mesh The mesh to highlight
  60953. */
  60954. removeExcludedMesh(mesh: Mesh): void;
  60955. /**
  60956. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60957. * @param mesh mesh to test
  60958. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60959. */
  60960. hasMesh(mesh: AbstractMesh): boolean;
  60961. /**
  60962. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60963. * @param mesh The mesh to highlight
  60964. * @param color The color of the highlight
  60965. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60966. */
  60967. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60968. /**
  60969. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60970. * @param mesh The mesh to highlight
  60971. */
  60972. removeMesh(mesh: Mesh): void;
  60973. /**
  60974. * Remove all the meshes currently referenced in the highlight layer
  60975. */
  60976. removeAllMeshes(): void;
  60977. /**
  60978. * Force the stencil to the normal expected value for none glowing parts
  60979. */
  60980. private _defaultStencilReference;
  60981. /**
  60982. * Free any resources and references associated to a mesh.
  60983. * Internal use
  60984. * @param mesh The mesh to free.
  60985. * @hidden
  60986. */
  60987. _disposeMesh(mesh: Mesh): void;
  60988. /**
  60989. * Dispose the highlight layer and free resources.
  60990. */
  60991. dispose(): void;
  60992. /**
  60993. * Gets the class name of the effect layer
  60994. * @returns the string with the class name of the effect layer
  60995. */
  60996. getClassName(): string;
  60997. /**
  60998. * Serializes this Highlight layer
  60999. * @returns a serialized Highlight layer object
  61000. */
  61001. serialize(): any;
  61002. /**
  61003. * Creates a Highlight layer from parsed Highlight layer data
  61004. * @param parsedHightlightLayer defines the Highlight layer data
  61005. * @param scene defines the current scene
  61006. * @param rootUrl defines the root URL containing the Highlight layer information
  61007. * @returns a parsed Highlight layer
  61008. */
  61009. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61010. }
  61011. }
  61012. declare module "babylonjs/Layers/layerSceneComponent" {
  61013. import { Scene } from "babylonjs/scene";
  61014. import { ISceneComponent } from "babylonjs/sceneComponent";
  61015. import { Layer } from "babylonjs/Layers/layer";
  61016. import { AbstractScene } from "babylonjs/abstractScene";
  61017. module "babylonjs/abstractScene" {
  61018. interface AbstractScene {
  61019. /**
  61020. * The list of layers (background and foreground) of the scene
  61021. */
  61022. layers: Array<Layer>;
  61023. }
  61024. }
  61025. /**
  61026. * Defines the layer scene component responsible to manage any layers
  61027. * in a given scene.
  61028. */
  61029. export class LayerSceneComponent implements ISceneComponent {
  61030. /**
  61031. * The component name helpfull to identify the component in the list of scene components.
  61032. */
  61033. readonly name: string;
  61034. /**
  61035. * The scene the component belongs to.
  61036. */
  61037. scene: Scene;
  61038. private _engine;
  61039. /**
  61040. * Creates a new instance of the component for the given scene
  61041. * @param scene Defines the scene to register the component in
  61042. */
  61043. constructor(scene: Scene);
  61044. /**
  61045. * Registers the component in a given scene
  61046. */
  61047. register(): void;
  61048. /**
  61049. * Rebuilds the elements related to this component in case of
  61050. * context lost for instance.
  61051. */
  61052. rebuild(): void;
  61053. /**
  61054. * Disposes the component and the associated ressources.
  61055. */
  61056. dispose(): void;
  61057. private _draw;
  61058. private _drawCameraPredicate;
  61059. private _drawCameraBackground;
  61060. private _drawCameraForeground;
  61061. private _drawRenderTargetPredicate;
  61062. private _drawRenderTargetBackground;
  61063. private _drawRenderTargetForeground;
  61064. /**
  61065. * Adds all the elements from the container to the scene
  61066. * @param container the container holding the elements
  61067. */
  61068. addFromContainer(container: AbstractScene): void;
  61069. /**
  61070. * Removes all the elements in the container from the scene
  61071. * @param container contains the elements to remove
  61072. * @param dispose if the removed element should be disposed (default: false)
  61073. */
  61074. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61075. }
  61076. }
  61077. declare module "babylonjs/Shaders/layer.fragment" {
  61078. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61079. /** @hidden */
  61080. export var layerPixelShader: {
  61081. name: string;
  61082. shader: string;
  61083. };
  61084. }
  61085. declare module "babylonjs/Shaders/layer.vertex" {
  61086. /** @hidden */
  61087. export var layerVertexShader: {
  61088. name: string;
  61089. shader: string;
  61090. };
  61091. }
  61092. declare module "babylonjs/Layers/layer" {
  61093. import { Observable } from "babylonjs/Misc/observable";
  61094. import { Nullable } from "babylonjs/types";
  61095. import { Scene } from "babylonjs/scene";
  61096. import { Vector2 } from "babylonjs/Maths/math.vector";
  61097. import { Color4 } from "babylonjs/Maths/math.color";
  61098. import { Texture } from "babylonjs/Materials/Textures/texture";
  61099. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61100. import "babylonjs/Shaders/layer.fragment";
  61101. import "babylonjs/Shaders/layer.vertex";
  61102. /**
  61103. * This represents a full screen 2d layer.
  61104. * This can be useful to display a picture in the background of your scene for instance.
  61105. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61106. */
  61107. export class Layer {
  61108. /**
  61109. * Define the name of the layer.
  61110. */
  61111. name: string;
  61112. /**
  61113. * Define the texture the layer should display.
  61114. */
  61115. texture: Nullable<Texture>;
  61116. /**
  61117. * Is the layer in background or foreground.
  61118. */
  61119. isBackground: boolean;
  61120. /**
  61121. * Define the color of the layer (instead of texture).
  61122. */
  61123. color: Color4;
  61124. /**
  61125. * Define the scale of the layer in order to zoom in out of the texture.
  61126. */
  61127. scale: Vector2;
  61128. /**
  61129. * Define an offset for the layer in order to shift the texture.
  61130. */
  61131. offset: Vector2;
  61132. /**
  61133. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  61134. */
  61135. alphaBlendingMode: number;
  61136. /**
  61137. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  61138. * Alpha test will not mix with the background color in case of transparency.
  61139. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  61140. */
  61141. alphaTest: boolean;
  61142. /**
  61143. * Define a mask to restrict the layer to only some of the scene cameras.
  61144. */
  61145. layerMask: number;
  61146. /**
  61147. * Define the list of render target the layer is visible into.
  61148. */
  61149. renderTargetTextures: RenderTargetTexture[];
  61150. /**
  61151. * Define if the layer is only used in renderTarget or if it also
  61152. * renders in the main frame buffer of the canvas.
  61153. */
  61154. renderOnlyInRenderTargetTextures: boolean;
  61155. private _scene;
  61156. private _vertexBuffers;
  61157. private _indexBuffer;
  61158. private _effect;
  61159. private _previousDefines;
  61160. /**
  61161. * An event triggered when the layer is disposed.
  61162. */
  61163. onDisposeObservable: Observable<Layer>;
  61164. private _onDisposeObserver;
  61165. /**
  61166. * Back compatibility with callback before the onDisposeObservable existed.
  61167. * The set callback will be triggered when the layer has been disposed.
  61168. */
  61169. set onDispose(callback: () => void);
  61170. /**
  61171. * An event triggered before rendering the scene
  61172. */
  61173. onBeforeRenderObservable: Observable<Layer>;
  61174. private _onBeforeRenderObserver;
  61175. /**
  61176. * Back compatibility with callback before the onBeforeRenderObservable existed.
  61177. * The set callback will be triggered just before rendering the layer.
  61178. */
  61179. set onBeforeRender(callback: () => void);
  61180. /**
  61181. * An event triggered after rendering the scene
  61182. */
  61183. onAfterRenderObservable: Observable<Layer>;
  61184. private _onAfterRenderObserver;
  61185. /**
  61186. * Back compatibility with callback before the onAfterRenderObservable existed.
  61187. * The set callback will be triggered just after rendering the layer.
  61188. */
  61189. set onAfterRender(callback: () => void);
  61190. /**
  61191. * Instantiates a new layer.
  61192. * This represents a full screen 2d layer.
  61193. * This can be useful to display a picture in the background of your scene for instance.
  61194. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61195. * @param name Define the name of the layer in the scene
  61196. * @param imgUrl Define the url of the texture to display in the layer
  61197. * @param scene Define the scene the layer belongs to
  61198. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  61199. * @param color Defines a color for the layer
  61200. */
  61201. constructor(
  61202. /**
  61203. * Define the name of the layer.
  61204. */
  61205. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  61206. private _createIndexBuffer;
  61207. /** @hidden */
  61208. _rebuild(): void;
  61209. /**
  61210. * Renders the layer in the scene.
  61211. */
  61212. render(): void;
  61213. /**
  61214. * Disposes and releases the associated ressources.
  61215. */
  61216. dispose(): void;
  61217. }
  61218. }
  61219. declare module "babylonjs/Layers/index" {
  61220. export * from "babylonjs/Layers/effectLayer";
  61221. export * from "babylonjs/Layers/effectLayerSceneComponent";
  61222. export * from "babylonjs/Layers/glowLayer";
  61223. export * from "babylonjs/Layers/highlightLayer";
  61224. export * from "babylonjs/Layers/layer";
  61225. export * from "babylonjs/Layers/layerSceneComponent";
  61226. }
  61227. declare module "babylonjs/Shaders/lensFlare.fragment" {
  61228. /** @hidden */
  61229. export var lensFlarePixelShader: {
  61230. name: string;
  61231. shader: string;
  61232. };
  61233. }
  61234. declare module "babylonjs/Shaders/lensFlare.vertex" {
  61235. /** @hidden */
  61236. export var lensFlareVertexShader: {
  61237. name: string;
  61238. shader: string;
  61239. };
  61240. }
  61241. declare module "babylonjs/LensFlares/lensFlareSystem" {
  61242. import { Scene } from "babylonjs/scene";
  61243. import { Vector3 } from "babylonjs/Maths/math.vector";
  61244. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61245. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  61246. import "babylonjs/Shaders/lensFlare.fragment";
  61247. import "babylonjs/Shaders/lensFlare.vertex";
  61248. import { Viewport } from "babylonjs/Maths/math.viewport";
  61249. /**
  61250. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61251. * It is usually composed of several `lensFlare`.
  61252. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61253. */
  61254. export class LensFlareSystem {
  61255. /**
  61256. * Define the name of the lens flare system
  61257. */
  61258. name: string;
  61259. /**
  61260. * List of lens flares used in this system.
  61261. */
  61262. lensFlares: LensFlare[];
  61263. /**
  61264. * Define a limit from the border the lens flare can be visible.
  61265. */
  61266. borderLimit: number;
  61267. /**
  61268. * Define a viewport border we do not want to see the lens flare in.
  61269. */
  61270. viewportBorder: number;
  61271. /**
  61272. * Define a predicate which could limit the list of meshes able to occlude the effect.
  61273. */
  61274. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  61275. /**
  61276. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  61277. */
  61278. layerMask: number;
  61279. /**
  61280. * Define the id of the lens flare system in the scene.
  61281. * (equal to name by default)
  61282. */
  61283. id: string;
  61284. private _scene;
  61285. private _emitter;
  61286. private _vertexBuffers;
  61287. private _indexBuffer;
  61288. private _effect;
  61289. private _positionX;
  61290. private _positionY;
  61291. private _isEnabled;
  61292. /** @hidden */
  61293. static _SceneComponentInitialization: (scene: Scene) => void;
  61294. /**
  61295. * Instantiates a lens flare system.
  61296. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61297. * It is usually composed of several `lensFlare`.
  61298. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61299. * @param name Define the name of the lens flare system in the scene
  61300. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  61301. * @param scene Define the scene the lens flare system belongs to
  61302. */
  61303. constructor(
  61304. /**
  61305. * Define the name of the lens flare system
  61306. */
  61307. name: string, emitter: any, scene: Scene);
  61308. /**
  61309. * Define if the lens flare system is enabled.
  61310. */
  61311. get isEnabled(): boolean;
  61312. set isEnabled(value: boolean);
  61313. /**
  61314. * Get the scene the effects belongs to.
  61315. * @returns the scene holding the lens flare system
  61316. */
  61317. getScene(): Scene;
  61318. /**
  61319. * Get the emitter of the lens flare system.
  61320. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61321. * @returns the emitter of the lens flare system
  61322. */
  61323. getEmitter(): any;
  61324. /**
  61325. * Set the emitter of the lens flare system.
  61326. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61327. * @param newEmitter Define the new emitter of the system
  61328. */
  61329. setEmitter(newEmitter: any): void;
  61330. /**
  61331. * Get the lens flare system emitter position.
  61332. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  61333. * @returns the position
  61334. */
  61335. getEmitterPosition(): Vector3;
  61336. /**
  61337. * @hidden
  61338. */
  61339. computeEffectivePosition(globalViewport: Viewport): boolean;
  61340. /** @hidden */
  61341. _isVisible(): boolean;
  61342. /**
  61343. * @hidden
  61344. */
  61345. render(): boolean;
  61346. /**
  61347. * Dispose and release the lens flare with its associated resources.
  61348. */
  61349. dispose(): void;
  61350. /**
  61351. * Parse a lens flare system from a JSON repressentation
  61352. * @param parsedLensFlareSystem Define the JSON to parse
  61353. * @param scene Define the scene the parsed system should be instantiated in
  61354. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  61355. * @returns the parsed system
  61356. */
  61357. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  61358. /**
  61359. * Serialize the current Lens Flare System into a JSON representation.
  61360. * @returns the serialized JSON
  61361. */
  61362. serialize(): any;
  61363. }
  61364. }
  61365. declare module "babylonjs/LensFlares/lensFlare" {
  61366. import { Nullable } from "babylonjs/types";
  61367. import { Color3 } from "babylonjs/Maths/math.color";
  61368. import { Texture } from "babylonjs/Materials/Textures/texture";
  61369. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61370. /**
  61371. * This represents one of the lens effect in a `lensFlareSystem`.
  61372. * It controls one of the indiviual texture used in the effect.
  61373. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61374. */
  61375. export class LensFlare {
  61376. /**
  61377. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61378. */
  61379. size: number;
  61380. /**
  61381. * 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.
  61382. */
  61383. position: number;
  61384. /**
  61385. * Define the lens color.
  61386. */
  61387. color: Color3;
  61388. /**
  61389. * Define the lens texture.
  61390. */
  61391. texture: Nullable<Texture>;
  61392. /**
  61393. * Define the alpha mode to render this particular lens.
  61394. */
  61395. alphaMode: number;
  61396. private _system;
  61397. /**
  61398. * Creates a new Lens Flare.
  61399. * This represents one of the lens effect in a `lensFlareSystem`.
  61400. * It controls one of the indiviual texture used in the effect.
  61401. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61402. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  61403. * @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.
  61404. * @param color Define the lens color
  61405. * @param imgUrl Define the lens texture url
  61406. * @param system Define the `lensFlareSystem` this flare is part of
  61407. * @returns The newly created Lens Flare
  61408. */
  61409. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  61410. /**
  61411. * Instantiates a new Lens Flare.
  61412. * This represents one of the lens effect in a `lensFlareSystem`.
  61413. * It controls one of the indiviual texture used in the effect.
  61414. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61415. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  61416. * @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.
  61417. * @param color Define the lens color
  61418. * @param imgUrl Define the lens texture url
  61419. * @param system Define the `lensFlareSystem` this flare is part of
  61420. */
  61421. constructor(
  61422. /**
  61423. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61424. */
  61425. size: number,
  61426. /**
  61427. * 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.
  61428. */
  61429. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  61430. /**
  61431. * Dispose and release the lens flare with its associated resources.
  61432. */
  61433. dispose(): void;
  61434. }
  61435. }
  61436. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  61437. import { Nullable } from "babylonjs/types";
  61438. import { Scene } from "babylonjs/scene";
  61439. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61440. import { AbstractScene } from "babylonjs/abstractScene";
  61441. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61442. module "babylonjs/abstractScene" {
  61443. interface AbstractScene {
  61444. /**
  61445. * The list of lens flare system added to the scene
  61446. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61447. */
  61448. lensFlareSystems: Array<LensFlareSystem>;
  61449. /**
  61450. * Removes the given lens flare system from this scene.
  61451. * @param toRemove The lens flare system to remove
  61452. * @returns The index of the removed lens flare system
  61453. */
  61454. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61455. /**
  61456. * Adds the given lens flare system to this scene
  61457. * @param newLensFlareSystem The lens flare system to add
  61458. */
  61459. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61460. /**
  61461. * Gets a lens flare system using its name
  61462. * @param name defines the name to look for
  61463. * @returns the lens flare system or null if not found
  61464. */
  61465. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61466. /**
  61467. * Gets a lens flare system using its id
  61468. * @param id defines the id to look for
  61469. * @returns the lens flare system or null if not found
  61470. */
  61471. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  61472. }
  61473. }
  61474. /**
  61475. * Defines the lens flare scene component responsible to manage any lens flares
  61476. * in a given scene.
  61477. */
  61478. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  61479. /**
  61480. * The component name helpfull to identify the component in the list of scene components.
  61481. */
  61482. readonly name: string;
  61483. /**
  61484. * The scene the component belongs to.
  61485. */
  61486. scene: Scene;
  61487. /**
  61488. * Creates a new instance of the component for the given scene
  61489. * @param scene Defines the scene to register the component in
  61490. */
  61491. constructor(scene: Scene);
  61492. /**
  61493. * Registers the component in a given scene
  61494. */
  61495. register(): void;
  61496. /**
  61497. * Rebuilds the elements related to this component in case of
  61498. * context lost for instance.
  61499. */
  61500. rebuild(): void;
  61501. /**
  61502. * Adds all the elements from the container to the scene
  61503. * @param container the container holding the elements
  61504. */
  61505. addFromContainer(container: AbstractScene): void;
  61506. /**
  61507. * Removes all the elements in the container from the scene
  61508. * @param container contains the elements to remove
  61509. * @param dispose if the removed element should be disposed (default: false)
  61510. */
  61511. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61512. /**
  61513. * Serializes the component data to the specified json object
  61514. * @param serializationObject The object to serialize to
  61515. */
  61516. serialize(serializationObject: any): void;
  61517. /**
  61518. * Disposes the component and the associated ressources.
  61519. */
  61520. dispose(): void;
  61521. private _draw;
  61522. }
  61523. }
  61524. declare module "babylonjs/LensFlares/index" {
  61525. export * from "babylonjs/LensFlares/lensFlare";
  61526. export * from "babylonjs/LensFlares/lensFlareSystem";
  61527. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  61528. }
  61529. declare module "babylonjs/Shaders/depth.fragment" {
  61530. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61531. /** @hidden */
  61532. export var depthPixelShader: {
  61533. name: string;
  61534. shader: string;
  61535. };
  61536. }
  61537. declare module "babylonjs/Shaders/depth.vertex" {
  61538. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61539. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61540. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61541. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61542. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61543. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61544. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61545. /** @hidden */
  61546. export var depthVertexShader: {
  61547. name: string;
  61548. shader: string;
  61549. };
  61550. }
  61551. declare module "babylonjs/Rendering/depthRenderer" {
  61552. import { Nullable } from "babylonjs/types";
  61553. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61554. import { Scene } from "babylonjs/scene";
  61555. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61556. import { Camera } from "babylonjs/Cameras/camera";
  61557. import "babylonjs/Shaders/depth.fragment";
  61558. import "babylonjs/Shaders/depth.vertex";
  61559. /**
  61560. * This represents a depth renderer in Babylon.
  61561. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61562. */
  61563. export class DepthRenderer {
  61564. private _scene;
  61565. private _depthMap;
  61566. private _effect;
  61567. private readonly _storeNonLinearDepth;
  61568. private readonly _clearColor;
  61569. /** Get if the depth renderer is using packed depth or not */
  61570. readonly isPacked: boolean;
  61571. private _cachedDefines;
  61572. private _camera;
  61573. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61574. enabled: boolean;
  61575. /**
  61576. * Specifiess that the depth renderer will only be used within
  61577. * the camera it is created for.
  61578. * This can help forcing its rendering during the camera processing.
  61579. */
  61580. useOnlyInActiveCamera: boolean;
  61581. /** @hidden */
  61582. static _SceneComponentInitialization: (scene: Scene) => void;
  61583. /**
  61584. * Instantiates a depth renderer
  61585. * @param scene The scene the renderer belongs to
  61586. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61587. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61588. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61589. */
  61590. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61591. /**
  61592. * Creates the depth rendering effect and checks if the effect is ready.
  61593. * @param subMesh The submesh to be used to render the depth map of
  61594. * @param useInstances If multiple world instances should be used
  61595. * @returns if the depth renderer is ready to render the depth map
  61596. */
  61597. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61598. /**
  61599. * Gets the texture which the depth map will be written to.
  61600. * @returns The depth map texture
  61601. */
  61602. getDepthMap(): RenderTargetTexture;
  61603. /**
  61604. * Disposes of the depth renderer.
  61605. */
  61606. dispose(): void;
  61607. }
  61608. }
  61609. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  61610. /** @hidden */
  61611. export var minmaxReduxPixelShader: {
  61612. name: string;
  61613. shader: string;
  61614. };
  61615. }
  61616. declare module "babylonjs/Misc/minMaxReducer" {
  61617. import { Nullable } from "babylonjs/types";
  61618. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61619. import { Camera } from "babylonjs/Cameras/camera";
  61620. import { Observer } from "babylonjs/Misc/observable";
  61621. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61622. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  61623. import { Observable } from "babylonjs/Misc/observable";
  61624. import "babylonjs/Shaders/minmaxRedux.fragment";
  61625. /**
  61626. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61627. * and maximum values from all values of the texture.
  61628. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61629. * The source values are read from the red channel of the texture.
  61630. */
  61631. export class MinMaxReducer {
  61632. /**
  61633. * Observable triggered when the computation has been performed
  61634. */
  61635. onAfterReductionPerformed: Observable<{
  61636. min: number;
  61637. max: number;
  61638. }>;
  61639. protected _camera: Camera;
  61640. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61641. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61642. protected _postProcessManager: PostProcessManager;
  61643. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61644. protected _forceFullscreenViewport: boolean;
  61645. /**
  61646. * Creates a min/max reducer
  61647. * @param camera The camera to use for the post processes
  61648. */
  61649. constructor(camera: Camera);
  61650. /**
  61651. * Gets the texture used to read the values from.
  61652. */
  61653. get sourceTexture(): Nullable<RenderTargetTexture>;
  61654. /**
  61655. * Sets the source texture to read the values from.
  61656. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61657. * because in such textures '1' value must not be taken into account to compute the maximum
  61658. * as this value is used to clear the texture.
  61659. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61660. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61661. * @param depthRedux Indicates if the texture is a depth texture or not
  61662. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61663. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61664. */
  61665. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61666. /**
  61667. * Defines the refresh rate of the computation.
  61668. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61669. */
  61670. get refreshRate(): number;
  61671. set refreshRate(value: number);
  61672. protected _activated: boolean;
  61673. /**
  61674. * Gets the activation status of the reducer
  61675. */
  61676. get activated(): boolean;
  61677. /**
  61678. * Activates the reduction computation.
  61679. * When activated, the observers registered in onAfterReductionPerformed are
  61680. * called after the compuation is performed
  61681. */
  61682. activate(): void;
  61683. /**
  61684. * Deactivates the reduction computation.
  61685. */
  61686. deactivate(): void;
  61687. /**
  61688. * Disposes the min/max reducer
  61689. * @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.
  61690. */
  61691. dispose(disposeAll?: boolean): void;
  61692. }
  61693. }
  61694. declare module "babylonjs/Misc/depthReducer" {
  61695. import { Nullable } from "babylonjs/types";
  61696. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61697. import { Camera } from "babylonjs/Cameras/camera";
  61698. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61699. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  61700. /**
  61701. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61702. */
  61703. export class DepthReducer extends MinMaxReducer {
  61704. private _depthRenderer;
  61705. private _depthRendererId;
  61706. /**
  61707. * Gets the depth renderer used for the computation.
  61708. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61709. */
  61710. get depthRenderer(): Nullable<DepthRenderer>;
  61711. /**
  61712. * Creates a depth reducer
  61713. * @param camera The camera used to render the depth texture
  61714. */
  61715. constructor(camera: Camera);
  61716. /**
  61717. * Sets the depth renderer to use to generate the depth map
  61718. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61719. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61720. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61721. */
  61722. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61723. /** @hidden */
  61724. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61725. /**
  61726. * Activates the reduction computation.
  61727. * When activated, the observers registered in onAfterReductionPerformed are
  61728. * called after the compuation is performed
  61729. */
  61730. activate(): void;
  61731. /**
  61732. * Deactivates the reduction computation.
  61733. */
  61734. deactivate(): void;
  61735. /**
  61736. * Disposes the depth reducer
  61737. * @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.
  61738. */
  61739. dispose(disposeAll?: boolean): void;
  61740. }
  61741. }
  61742. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  61743. import { Nullable } from "babylonjs/types";
  61744. import { Scene } from "babylonjs/scene";
  61745. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61746. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61748. import { Effect } from "babylonjs/Materials/effect";
  61749. import "babylonjs/Shaders/shadowMap.fragment";
  61750. import "babylonjs/Shaders/shadowMap.vertex";
  61751. import "babylonjs/Shaders/depthBoxBlur.fragment";
  61752. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  61753. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61754. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61755. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61756. /**
  61757. * A CSM implementation allowing casting shadows on large scenes.
  61758. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61759. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61760. */
  61761. export class CascadedShadowGenerator extends ShadowGenerator {
  61762. private static readonly frustumCornersNDCSpace;
  61763. /**
  61764. * Name of the CSM class
  61765. */
  61766. static CLASSNAME: string;
  61767. /**
  61768. * Defines the default number of cascades used by the CSM.
  61769. */
  61770. static readonly DEFAULT_CASCADES_COUNT: number;
  61771. /**
  61772. * Defines the minimum number of cascades used by the CSM.
  61773. */
  61774. static readonly MIN_CASCADES_COUNT: number;
  61775. /**
  61776. * Defines the maximum number of cascades used by the CSM.
  61777. */
  61778. static readonly MAX_CASCADES_COUNT: number;
  61779. protected _validateFilter(filter: number): number;
  61780. /**
  61781. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61782. */
  61783. penumbraDarkness: number;
  61784. private _numCascades;
  61785. /**
  61786. * Gets or set the number of cascades used by the CSM.
  61787. */
  61788. get numCascades(): number;
  61789. set numCascades(value: number);
  61790. /**
  61791. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61792. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61793. */
  61794. stabilizeCascades: boolean;
  61795. private _freezeShadowCastersBoundingInfo;
  61796. private _freezeShadowCastersBoundingInfoObservable;
  61797. /**
  61798. * Enables or disables the shadow casters bounding info computation.
  61799. * If your shadow casters don't move, you can disable this feature.
  61800. * If it is enabled, the bounding box computation is done every frame.
  61801. */
  61802. get freezeShadowCastersBoundingInfo(): boolean;
  61803. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61804. private _scbiMin;
  61805. private _scbiMax;
  61806. protected _computeShadowCastersBoundingInfo(): void;
  61807. protected _shadowCastersBoundingInfo: BoundingInfo;
  61808. /**
  61809. * Gets or sets the shadow casters bounding info.
  61810. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61811. * so that the system won't overwrite the bounds you provide
  61812. */
  61813. get shadowCastersBoundingInfo(): BoundingInfo;
  61814. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61815. protected _breaksAreDirty: boolean;
  61816. protected _minDistance: number;
  61817. protected _maxDistance: number;
  61818. /**
  61819. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61820. *
  61821. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61822. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61823. * @param min minimal distance for the breaks (default to 0.)
  61824. * @param max maximal distance for the breaks (default to 1.)
  61825. */
  61826. setMinMaxDistance(min: number, max: number): void;
  61827. /** Gets the minimal distance used in the cascade break computation */
  61828. get minDistance(): number;
  61829. /** Gets the maximal distance used in the cascade break computation */
  61830. get maxDistance(): number;
  61831. /**
  61832. * Gets the class name of that object
  61833. * @returns "CascadedShadowGenerator"
  61834. */
  61835. getClassName(): string;
  61836. private _cascadeMinExtents;
  61837. private _cascadeMaxExtents;
  61838. /**
  61839. * Gets a cascade minimum extents
  61840. * @param cascadeIndex index of the cascade
  61841. * @returns the minimum cascade extents
  61842. */
  61843. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61844. /**
  61845. * Gets a cascade maximum extents
  61846. * @param cascadeIndex index of the cascade
  61847. * @returns the maximum cascade extents
  61848. */
  61849. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61850. private _cascades;
  61851. private _currentLayer;
  61852. private _viewSpaceFrustumsZ;
  61853. private _viewMatrices;
  61854. private _projectionMatrices;
  61855. private _transformMatrices;
  61856. private _transformMatricesAsArray;
  61857. private _frustumLengths;
  61858. private _lightSizeUVCorrection;
  61859. private _depthCorrection;
  61860. private _frustumCornersWorldSpace;
  61861. private _frustumCenter;
  61862. private _shadowCameraPos;
  61863. private _shadowMaxZ;
  61864. /**
  61865. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61866. * It defaults to camera.maxZ
  61867. */
  61868. get shadowMaxZ(): number;
  61869. /**
  61870. * Sets the shadow max z distance.
  61871. */
  61872. set shadowMaxZ(value: number);
  61873. protected _debug: boolean;
  61874. /**
  61875. * Gets or sets the debug flag.
  61876. * When enabled, the cascades are materialized by different colors on the screen.
  61877. */
  61878. get debug(): boolean;
  61879. set debug(dbg: boolean);
  61880. private _depthClamp;
  61881. /**
  61882. * Gets or sets the depth clamping value.
  61883. *
  61884. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61885. * to account for the shadow casters far away.
  61886. *
  61887. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61888. */
  61889. get depthClamp(): boolean;
  61890. set depthClamp(value: boolean);
  61891. private _cascadeBlendPercentage;
  61892. /**
  61893. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61894. * It defaults to 0.1 (10% blending).
  61895. */
  61896. get cascadeBlendPercentage(): number;
  61897. set cascadeBlendPercentage(value: number);
  61898. private _lambda;
  61899. /**
  61900. * Gets or set the lambda parameter.
  61901. * This parameter is used to split the camera frustum and create the cascades.
  61902. * 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.
  61903. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61904. */
  61905. get lambda(): number;
  61906. set lambda(value: number);
  61907. /**
  61908. * Gets the view matrix corresponding to a given cascade
  61909. * @param cascadeNum cascade to retrieve the view matrix from
  61910. * @returns the cascade view matrix
  61911. */
  61912. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61913. /**
  61914. * Gets the projection matrix corresponding to a given cascade
  61915. * @param cascadeNum cascade to retrieve the projection matrix from
  61916. * @returns the cascade projection matrix
  61917. */
  61918. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61919. /**
  61920. * Gets the transformation matrix corresponding to a given cascade
  61921. * @param cascadeNum cascade to retrieve the transformation matrix from
  61922. * @returns the cascade transformation matrix
  61923. */
  61924. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61925. private _depthRenderer;
  61926. /**
  61927. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61928. *
  61929. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61930. *
  61931. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61932. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61933. * @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
  61934. */
  61935. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61936. private _depthReducer;
  61937. private _autoCalcDepthBounds;
  61938. /**
  61939. * Gets or sets the autoCalcDepthBounds property.
  61940. *
  61941. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61942. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61943. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61944. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61945. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61946. */
  61947. get autoCalcDepthBounds(): boolean;
  61948. set autoCalcDepthBounds(value: boolean);
  61949. /**
  61950. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61951. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61952. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61953. * for setting the refresh rate on the renderer yourself!
  61954. */
  61955. get autoCalcDepthBoundsRefreshRate(): number;
  61956. set autoCalcDepthBoundsRefreshRate(value: number);
  61957. /**
  61958. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61959. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61960. * you change the camera near/far planes!
  61961. */
  61962. splitFrustum(): void;
  61963. private _splitFrustum;
  61964. private _computeMatrices;
  61965. private _computeFrustumInWorldSpace;
  61966. private _computeCascadeFrustum;
  61967. /**
  61968. * Support test.
  61969. */
  61970. static get IsSupported(): boolean;
  61971. /** @hidden */
  61972. static _SceneComponentInitialization: (scene: Scene) => void;
  61973. /**
  61974. * Creates a Cascaded Shadow Generator object.
  61975. * A ShadowGenerator is the required tool to use the shadows.
  61976. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61977. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61978. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61979. * @param light The directional light object generating the shadows.
  61980. * @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.
  61981. */
  61982. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61983. protected _initializeGenerator(): void;
  61984. protected _createTargetRenderTexture(): void;
  61985. protected _initializeShadowMap(): void;
  61986. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61987. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61988. /**
  61989. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61990. * @param defines Defines of the material we want to update
  61991. * @param lightIndex Index of the light in the enabled light list of the material
  61992. */
  61993. prepareDefines(defines: any, lightIndex: number): void;
  61994. /**
  61995. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61996. * defined in the generator but impacting the effect).
  61997. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61998. * @param effect The effect we are binfing the information for
  61999. */
  62000. bindShadowLight(lightIndex: string, effect: Effect): void;
  62001. /**
  62002. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62003. * (eq to view projection * shadow projection matrices)
  62004. * @returns The transform matrix used to create the shadow map
  62005. */
  62006. getTransformMatrix(): Matrix;
  62007. /**
  62008. * Disposes the ShadowGenerator.
  62009. * Returns nothing.
  62010. */
  62011. dispose(): void;
  62012. /**
  62013. * Serializes the shadow generator setup to a json object.
  62014. * @returns The serialized JSON object
  62015. */
  62016. serialize(): any;
  62017. /**
  62018. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62019. * @param parsedShadowGenerator The JSON object to parse
  62020. * @param scene The scene to create the shadow map for
  62021. * @returns The parsed shadow generator
  62022. */
  62023. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62024. }
  62025. }
  62026. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62027. import { Scene } from "babylonjs/scene";
  62028. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62029. import { AbstractScene } from "babylonjs/abstractScene";
  62030. /**
  62031. * Defines the shadow generator component responsible to manage any shadow generators
  62032. * in a given scene.
  62033. */
  62034. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62035. /**
  62036. * The component name helpfull to identify the component in the list of scene components.
  62037. */
  62038. readonly name: string;
  62039. /**
  62040. * The scene the component belongs to.
  62041. */
  62042. scene: Scene;
  62043. /**
  62044. * Creates a new instance of the component for the given scene
  62045. * @param scene Defines the scene to register the component in
  62046. */
  62047. constructor(scene: Scene);
  62048. /**
  62049. * Registers the component in a given scene
  62050. */
  62051. register(): void;
  62052. /**
  62053. * Rebuilds the elements related to this component in case of
  62054. * context lost for instance.
  62055. */
  62056. rebuild(): void;
  62057. /**
  62058. * Serializes the component data to the specified json object
  62059. * @param serializationObject The object to serialize to
  62060. */
  62061. serialize(serializationObject: any): void;
  62062. /**
  62063. * Adds all the elements from the container to the scene
  62064. * @param container the container holding the elements
  62065. */
  62066. addFromContainer(container: AbstractScene): void;
  62067. /**
  62068. * Removes all the elements in the container from the scene
  62069. * @param container contains the elements to remove
  62070. * @param dispose if the removed element should be disposed (default: false)
  62071. */
  62072. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62073. /**
  62074. * Rebuilds the elements related to this component in case of
  62075. * context lost for instance.
  62076. */
  62077. dispose(): void;
  62078. private _gatherRenderTargets;
  62079. }
  62080. }
  62081. declare module "babylonjs/Lights/Shadows/index" {
  62082. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62083. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62084. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62085. }
  62086. declare module "babylonjs/Lights/pointLight" {
  62087. import { Scene } from "babylonjs/scene";
  62088. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62090. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62091. import { Effect } from "babylonjs/Materials/effect";
  62092. /**
  62093. * A point light is a light defined by an unique point in world space.
  62094. * The light is emitted in every direction from this point.
  62095. * A good example of a point light is a standard light bulb.
  62096. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62097. */
  62098. export class PointLight extends ShadowLight {
  62099. private _shadowAngle;
  62100. /**
  62101. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62102. * This specifies what angle the shadow will use to be created.
  62103. *
  62104. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62105. */
  62106. get shadowAngle(): number;
  62107. /**
  62108. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62109. * This specifies what angle the shadow will use to be created.
  62110. *
  62111. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62112. */
  62113. set shadowAngle(value: number);
  62114. /**
  62115. * Gets the direction if it has been set.
  62116. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62117. */
  62118. get direction(): Vector3;
  62119. /**
  62120. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62121. */
  62122. set direction(value: Vector3);
  62123. /**
  62124. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  62125. * A PointLight emits the light in every direction.
  62126. * It can cast shadows.
  62127. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  62128. * ```javascript
  62129. * var pointLight = new PointLight("pl", camera.position, scene);
  62130. * ```
  62131. * Documentation : https://doc.babylonjs.com/babylon101/lights
  62132. * @param name The light friendly name
  62133. * @param position The position of the point light in the scene
  62134. * @param scene The scene the lights belongs to
  62135. */
  62136. constructor(name: string, position: Vector3, scene: Scene);
  62137. /**
  62138. * Returns the string "PointLight"
  62139. * @returns the class name
  62140. */
  62141. getClassName(): string;
  62142. /**
  62143. * Returns the integer 0.
  62144. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  62145. */
  62146. getTypeID(): number;
  62147. /**
  62148. * Specifies wether or not the shadowmap should be a cube texture.
  62149. * @returns true if the shadowmap needs to be a cube texture.
  62150. */
  62151. needCube(): boolean;
  62152. /**
  62153. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  62154. * @param faceIndex The index of the face we are computed the direction to generate shadow
  62155. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  62156. */
  62157. getShadowDirection(faceIndex?: number): Vector3;
  62158. /**
  62159. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  62160. * - fov = PI / 2
  62161. * - aspect ratio : 1.0
  62162. * - z-near and far equal to the active camera minZ and maxZ.
  62163. * Returns the PointLight.
  62164. */
  62165. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  62166. protected _buildUniformLayout(): void;
  62167. /**
  62168. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  62169. * @param effect The effect to update
  62170. * @param lightIndex The index of the light in the effect to update
  62171. * @returns The point light
  62172. */
  62173. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  62174. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  62175. /**
  62176. * Prepares the list of defines specific to the light type.
  62177. * @param defines the list of defines
  62178. * @param lightIndex defines the index of the light for the effect
  62179. */
  62180. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  62181. }
  62182. }
  62183. declare module "babylonjs/Lights/index" {
  62184. export * from "babylonjs/Lights/light";
  62185. export * from "babylonjs/Lights/shadowLight";
  62186. export * from "babylonjs/Lights/Shadows/index";
  62187. export * from "babylonjs/Lights/directionalLight";
  62188. export * from "babylonjs/Lights/hemisphericLight";
  62189. export * from "babylonjs/Lights/pointLight";
  62190. export * from "babylonjs/Lights/spotLight";
  62191. }
  62192. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  62193. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62194. /**
  62195. * Header information of HDR texture files.
  62196. */
  62197. export interface HDRInfo {
  62198. /**
  62199. * The height of the texture in pixels.
  62200. */
  62201. height: number;
  62202. /**
  62203. * The width of the texture in pixels.
  62204. */
  62205. width: number;
  62206. /**
  62207. * The index of the beginning of the data in the binary file.
  62208. */
  62209. dataPosition: number;
  62210. }
  62211. /**
  62212. * This groups tools to convert HDR texture to native colors array.
  62213. */
  62214. export class HDRTools {
  62215. private static Ldexp;
  62216. private static Rgbe2float;
  62217. private static readStringLine;
  62218. /**
  62219. * Reads header information from an RGBE texture stored in a native array.
  62220. * More information on this format are available here:
  62221. * https://en.wikipedia.org/wiki/RGBE_image_format
  62222. *
  62223. * @param uint8array The binary file stored in native array.
  62224. * @return The header information.
  62225. */
  62226. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  62227. /**
  62228. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  62229. * This RGBE texture needs to store the information as a panorama.
  62230. *
  62231. * More information on this format are available here:
  62232. * https://en.wikipedia.org/wiki/RGBE_image_format
  62233. *
  62234. * @param buffer The binary file stored in an array buffer.
  62235. * @param size The expected size of the extracted cubemap.
  62236. * @return The Cube Map information.
  62237. */
  62238. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  62239. /**
  62240. * Returns the pixels data extracted from an RGBE texture.
  62241. * This pixels will be stored left to right up to down in the R G B order in one array.
  62242. *
  62243. * More information on this format are available here:
  62244. * https://en.wikipedia.org/wiki/RGBE_image_format
  62245. *
  62246. * @param uint8array The binary file stored in an array buffer.
  62247. * @param hdrInfo The header information of the file.
  62248. * @return The pixels data in RGB right to left up to down order.
  62249. */
  62250. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  62251. private static RGBE_ReadPixels_RLE;
  62252. private static RGBE_ReadPixels_NOT_RLE;
  62253. }
  62254. }
  62255. declare module "babylonjs/Materials/effectRenderer" {
  62256. import { Nullable } from "babylonjs/types";
  62257. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62258. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62259. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62260. import { Viewport } from "babylonjs/Maths/math.viewport";
  62261. import { Observable } from "babylonjs/Misc/observable";
  62262. import { Effect } from "babylonjs/Materials/effect";
  62263. import "babylonjs/Shaders/postprocess.vertex";
  62264. /**
  62265. * Effect Render Options
  62266. */
  62267. export interface IEffectRendererOptions {
  62268. /**
  62269. * Defines the vertices positions.
  62270. */
  62271. positions?: number[];
  62272. /**
  62273. * Defines the indices.
  62274. */
  62275. indices?: number[];
  62276. }
  62277. /**
  62278. * Helper class to render one or more effects.
  62279. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  62280. */
  62281. export class EffectRenderer {
  62282. private engine;
  62283. private static _DefaultOptions;
  62284. private _vertexBuffers;
  62285. private _indexBuffer;
  62286. private _fullscreenViewport;
  62287. /**
  62288. * Creates an effect renderer
  62289. * @param engine the engine to use for rendering
  62290. * @param options defines the options of the effect renderer
  62291. */
  62292. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62293. /**
  62294. * Sets the current viewport in normalized coordinates 0-1
  62295. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62296. */
  62297. setViewport(viewport?: Viewport): void;
  62298. /**
  62299. * Binds the embedded attributes buffer to the effect.
  62300. * @param effect Defines the effect to bind the attributes for
  62301. */
  62302. bindBuffers(effect: Effect): void;
  62303. /**
  62304. * Sets the current effect wrapper to use during draw.
  62305. * The effect needs to be ready before calling this api.
  62306. * This also sets the default full screen position attribute.
  62307. * @param effectWrapper Defines the effect to draw with
  62308. */
  62309. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62310. /**
  62311. * Restores engine states
  62312. */
  62313. restoreStates(): void;
  62314. /**
  62315. * Draws a full screen quad.
  62316. */
  62317. draw(): void;
  62318. private isRenderTargetTexture;
  62319. /**
  62320. * renders one or more effects to a specified texture
  62321. * @param effectWrapper the effect to renderer
  62322. * @param outputTexture texture to draw to, if null it will render to the screen.
  62323. */
  62324. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  62325. /**
  62326. * Disposes of the effect renderer
  62327. */
  62328. dispose(): void;
  62329. }
  62330. /**
  62331. * Options to create an EffectWrapper
  62332. */
  62333. interface EffectWrapperCreationOptions {
  62334. /**
  62335. * Engine to use to create the effect
  62336. */
  62337. engine: ThinEngine;
  62338. /**
  62339. * Fragment shader for the effect
  62340. */
  62341. fragmentShader: string;
  62342. /**
  62343. * Use the shader store instead of direct source code
  62344. */
  62345. useShaderStore?: boolean;
  62346. /**
  62347. * Vertex shader for the effect
  62348. */
  62349. vertexShader?: string;
  62350. /**
  62351. * Attributes to use in the shader
  62352. */
  62353. attributeNames?: Array<string>;
  62354. /**
  62355. * Uniforms to use in the shader
  62356. */
  62357. uniformNames?: Array<string>;
  62358. /**
  62359. * Texture sampler names to use in the shader
  62360. */
  62361. samplerNames?: Array<string>;
  62362. /**
  62363. * Defines to use in the shader
  62364. */
  62365. defines?: Array<string>;
  62366. /**
  62367. * Callback when effect is compiled
  62368. */
  62369. onCompiled?: Nullable<(effect: Effect) => void>;
  62370. /**
  62371. * The friendly name of the effect displayed in Spector.
  62372. */
  62373. name?: string;
  62374. }
  62375. /**
  62376. * Wraps an effect to be used for rendering
  62377. */
  62378. export class EffectWrapper {
  62379. /**
  62380. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62381. */
  62382. onApplyObservable: Observable<{}>;
  62383. /**
  62384. * The underlying effect
  62385. */
  62386. effect: Effect;
  62387. /**
  62388. * Creates an effect to be renderer
  62389. * @param creationOptions options to create the effect
  62390. */
  62391. constructor(creationOptions: EffectWrapperCreationOptions);
  62392. /**
  62393. * Disposes of the effect wrapper
  62394. */
  62395. dispose(): void;
  62396. }
  62397. }
  62398. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  62399. /** @hidden */
  62400. export var hdrFilteringVertexShader: {
  62401. name: string;
  62402. shader: string;
  62403. };
  62404. }
  62405. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  62406. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62407. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  62408. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  62409. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  62410. /** @hidden */
  62411. export var hdrFilteringPixelShader: {
  62412. name: string;
  62413. shader: string;
  62414. };
  62415. }
  62416. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  62417. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62418. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62419. import { Nullable } from "babylonjs/types";
  62420. import "babylonjs/Shaders/hdrFiltering.vertex";
  62421. import "babylonjs/Shaders/hdrFiltering.fragment";
  62422. /**
  62423. * Options for texture filtering
  62424. */
  62425. interface IHDRFilteringOptions {
  62426. /**
  62427. * Scales pixel intensity for the input HDR map.
  62428. */
  62429. hdrScale?: number;
  62430. /**
  62431. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  62432. */
  62433. quality?: number;
  62434. }
  62435. /**
  62436. * Filters HDR maps to get correct renderings of PBR reflections
  62437. */
  62438. export class HDRFiltering {
  62439. private _engine;
  62440. private _effectRenderer;
  62441. private _effectWrapper;
  62442. private _lodGenerationOffset;
  62443. private _lodGenerationScale;
  62444. /**
  62445. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  62446. * you care about baking speed.
  62447. */
  62448. quality: number;
  62449. /**
  62450. * Scales pixel intensity for the input HDR map.
  62451. */
  62452. hdrScale: number;
  62453. /**
  62454. * Instantiates HDR filter for reflection maps
  62455. *
  62456. * @param engine Thin engine
  62457. * @param options Options
  62458. */
  62459. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  62460. private _createRenderTarget;
  62461. private _prefilterInternal;
  62462. private _createEffect;
  62463. /**
  62464. * Get a value indicating if the filter is ready to be used
  62465. * @param texture Texture to filter
  62466. * @returns true if the filter is ready
  62467. */
  62468. isReady(texture: BaseTexture): boolean;
  62469. /**
  62470. * Prefilters a cube texture to have mipmap levels representing roughness values.
  62471. * Prefiltering will be invoked at the end of next rendering pass.
  62472. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  62473. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  62474. * @param texture Texture to filter
  62475. * @param onFinished Callback when filtering is done
  62476. * @return Promise called when prefiltering is done
  62477. */
  62478. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  62479. }
  62480. }
  62481. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  62482. import { Nullable } from "babylonjs/types";
  62483. import { Scene } from "babylonjs/scene";
  62484. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62485. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62486. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62487. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62488. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  62489. /**
  62490. * This represents a texture coming from an HDR input.
  62491. *
  62492. * The only supported format is currently panorama picture stored in RGBE format.
  62493. * Example of such files can be found on HDRLib: http://hdrlib.com/
  62494. */
  62495. export class HDRCubeTexture extends BaseTexture {
  62496. private static _facesMapping;
  62497. private _generateHarmonics;
  62498. private _noMipmap;
  62499. private _prefilterOnLoad;
  62500. private _textureMatrix;
  62501. private _size;
  62502. private _onLoad;
  62503. private _onError;
  62504. /**
  62505. * The texture URL.
  62506. */
  62507. url: string;
  62508. /**
  62509. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  62510. */
  62511. coordinatesMode: number;
  62512. protected _isBlocking: boolean;
  62513. /**
  62514. * Sets wether or not the texture is blocking during loading.
  62515. */
  62516. set isBlocking(value: boolean);
  62517. /**
  62518. * Gets wether or not the texture is blocking during loading.
  62519. */
  62520. get isBlocking(): boolean;
  62521. protected _rotationY: number;
  62522. /**
  62523. * Sets texture matrix rotation angle around Y axis in radians.
  62524. */
  62525. set rotationY(value: number);
  62526. /**
  62527. * Gets texture matrix rotation angle around Y axis radians.
  62528. */
  62529. get rotationY(): number;
  62530. /**
  62531. * Gets or sets the center of the bounding box associated with the cube texture
  62532. * It must define where the camera used to render the texture was set
  62533. */
  62534. boundingBoxPosition: Vector3;
  62535. private _boundingBoxSize;
  62536. /**
  62537. * Gets or sets the size of the bounding box associated with the cube texture
  62538. * When defined, the cubemap will switch to local mode
  62539. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  62540. * @example https://www.babylonjs-playground.com/#RNASML
  62541. */
  62542. set boundingBoxSize(value: Vector3);
  62543. get boundingBoxSize(): Vector3;
  62544. /**
  62545. * Instantiates an HDRTexture from the following parameters.
  62546. *
  62547. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  62548. * @param sceneOrEngine The scene or engine the texture will be used in
  62549. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62550. * @param noMipmap Forces to not generate the mipmap if true
  62551. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  62552. * @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)
  62553. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  62554. */
  62555. 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>);
  62556. /**
  62557. * Get the current class name of the texture useful for serialization or dynamic coding.
  62558. * @returns "HDRCubeTexture"
  62559. */
  62560. getClassName(): string;
  62561. /**
  62562. * Occurs when the file is raw .hdr file.
  62563. */
  62564. private loadTexture;
  62565. clone(): HDRCubeTexture;
  62566. delayLoad(): void;
  62567. /**
  62568. * Get the texture reflection matrix used to rotate/transform the reflection.
  62569. * @returns the reflection matrix
  62570. */
  62571. getReflectionTextureMatrix(): Matrix;
  62572. /**
  62573. * Set the texture reflection matrix used to rotate/transform the reflection.
  62574. * @param value Define the reflection matrix to set
  62575. */
  62576. setReflectionTextureMatrix(value: Matrix): void;
  62577. /**
  62578. * Parses a JSON representation of an HDR Texture in order to create the texture
  62579. * @param parsedTexture Define the JSON representation
  62580. * @param scene Define the scene the texture should be created in
  62581. * @param rootUrl Define the root url in case we need to load relative dependencies
  62582. * @returns the newly created texture after parsing
  62583. */
  62584. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62585. serialize(): any;
  62586. }
  62587. }
  62588. declare module "babylonjs/Physics/physicsEngine" {
  62589. import { Nullable } from "babylonjs/types";
  62590. import { Vector3 } from "babylonjs/Maths/math.vector";
  62591. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62592. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  62593. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  62594. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62595. /**
  62596. * Class used to control physics engine
  62597. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62598. */
  62599. export class PhysicsEngine implements IPhysicsEngine {
  62600. private _physicsPlugin;
  62601. /**
  62602. * Global value used to control the smallest number supported by the simulation
  62603. */
  62604. static Epsilon: number;
  62605. private _impostors;
  62606. private _joints;
  62607. private _subTimeStep;
  62608. /**
  62609. * Gets the gravity vector used by the simulation
  62610. */
  62611. gravity: Vector3;
  62612. /**
  62613. * Factory used to create the default physics plugin.
  62614. * @returns The default physics plugin
  62615. */
  62616. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62617. /**
  62618. * Creates a new Physics Engine
  62619. * @param gravity defines the gravity vector used by the simulation
  62620. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62621. */
  62622. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62623. /**
  62624. * Sets the gravity vector used by the simulation
  62625. * @param gravity defines the gravity vector to use
  62626. */
  62627. setGravity(gravity: Vector3): void;
  62628. /**
  62629. * Set the time step of the physics engine.
  62630. * Default is 1/60.
  62631. * To slow it down, enter 1/600 for example.
  62632. * To speed it up, 1/30
  62633. * @param newTimeStep defines the new timestep to apply to this world.
  62634. */
  62635. setTimeStep(newTimeStep?: number): void;
  62636. /**
  62637. * Get the time step of the physics engine.
  62638. * @returns the current time step
  62639. */
  62640. getTimeStep(): number;
  62641. /**
  62642. * Set the sub time step of the physics engine.
  62643. * Default is 0 meaning there is no sub steps
  62644. * To increase physics resolution precision, set a small value (like 1 ms)
  62645. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62646. */
  62647. setSubTimeStep(subTimeStep?: number): void;
  62648. /**
  62649. * Get the sub time step of the physics engine.
  62650. * @returns the current sub time step
  62651. */
  62652. getSubTimeStep(): number;
  62653. /**
  62654. * Release all resources
  62655. */
  62656. dispose(): void;
  62657. /**
  62658. * Gets the name of the current physics plugin
  62659. * @returns the name of the plugin
  62660. */
  62661. getPhysicsPluginName(): string;
  62662. /**
  62663. * Adding a new impostor for the impostor tracking.
  62664. * This will be done by the impostor itself.
  62665. * @param impostor the impostor to add
  62666. */
  62667. addImpostor(impostor: PhysicsImpostor): void;
  62668. /**
  62669. * Remove an impostor from the engine.
  62670. * This impostor and its mesh will not longer be updated by the physics engine.
  62671. * @param impostor the impostor to remove
  62672. */
  62673. removeImpostor(impostor: PhysicsImpostor): void;
  62674. /**
  62675. * Add a joint to the physics engine
  62676. * @param mainImpostor defines the main impostor to which the joint is added.
  62677. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62678. * @param joint defines the joint that will connect both impostors.
  62679. */
  62680. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62681. /**
  62682. * Removes a joint from the simulation
  62683. * @param mainImpostor defines the impostor used with the joint
  62684. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62685. * @param joint defines the joint to remove
  62686. */
  62687. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62688. /**
  62689. * Called by the scene. No need to call it.
  62690. * @param delta defines the timespam between frames
  62691. */
  62692. _step(delta: number): void;
  62693. /**
  62694. * Gets the current plugin used to run the simulation
  62695. * @returns current plugin
  62696. */
  62697. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62698. /**
  62699. * Gets the list of physic impostors
  62700. * @returns an array of PhysicsImpostor
  62701. */
  62702. getImpostors(): Array<PhysicsImpostor>;
  62703. /**
  62704. * Gets the impostor for a physics enabled object
  62705. * @param object defines the object impersonated by the impostor
  62706. * @returns the PhysicsImpostor or null if not found
  62707. */
  62708. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62709. /**
  62710. * Gets the impostor for a physics body object
  62711. * @param body defines physics body used by the impostor
  62712. * @returns the PhysicsImpostor or null if not found
  62713. */
  62714. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62715. /**
  62716. * Does a raycast in the physics world
  62717. * @param from when should the ray start?
  62718. * @param to when should the ray end?
  62719. * @returns PhysicsRaycastResult
  62720. */
  62721. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62722. }
  62723. }
  62724. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  62725. import { Nullable } from "babylonjs/types";
  62726. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62728. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62729. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62730. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62731. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62732. /** @hidden */
  62733. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62734. private _useDeltaForWorldStep;
  62735. world: any;
  62736. name: string;
  62737. private _physicsMaterials;
  62738. private _fixedTimeStep;
  62739. private _cannonRaycastResult;
  62740. private _raycastResult;
  62741. private _physicsBodysToRemoveAfterStep;
  62742. private _firstFrame;
  62743. BJSCANNON: any;
  62744. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62745. setGravity(gravity: Vector3): void;
  62746. setTimeStep(timeStep: number): void;
  62747. getTimeStep(): number;
  62748. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62749. private _removeMarkedPhysicsBodiesFromWorld;
  62750. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62751. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62752. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62753. private _processChildMeshes;
  62754. removePhysicsBody(impostor: PhysicsImpostor): void;
  62755. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62756. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62757. private _addMaterial;
  62758. private _checkWithEpsilon;
  62759. private _createShape;
  62760. private _createHeightmap;
  62761. private _minus90X;
  62762. private _plus90X;
  62763. private _tmpPosition;
  62764. private _tmpDeltaPosition;
  62765. private _tmpUnityRotation;
  62766. private _updatePhysicsBodyTransformation;
  62767. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62768. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62769. isSupported(): boolean;
  62770. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62771. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62772. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62773. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62774. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62775. getBodyMass(impostor: PhysicsImpostor): number;
  62776. getBodyFriction(impostor: PhysicsImpostor): number;
  62777. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62778. getBodyRestitution(impostor: PhysicsImpostor): number;
  62779. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62780. sleepBody(impostor: PhysicsImpostor): void;
  62781. wakeUpBody(impostor: PhysicsImpostor): void;
  62782. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62783. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62784. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62785. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62786. getRadius(impostor: PhysicsImpostor): number;
  62787. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62788. dispose(): void;
  62789. private _extendNamespace;
  62790. /**
  62791. * Does a raycast in the physics world
  62792. * @param from when should the ray start?
  62793. * @param to when should the ray end?
  62794. * @returns PhysicsRaycastResult
  62795. */
  62796. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62797. }
  62798. }
  62799. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  62800. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62801. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62802. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62804. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62805. import { Nullable } from "babylonjs/types";
  62806. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62807. /** @hidden */
  62808. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62809. private _useDeltaForWorldStep;
  62810. world: any;
  62811. name: string;
  62812. BJSOIMO: any;
  62813. private _raycastResult;
  62814. private _fixedTimeStep;
  62815. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62816. setGravity(gravity: Vector3): void;
  62817. setTimeStep(timeStep: number): void;
  62818. getTimeStep(): number;
  62819. private _tmpImpostorsArray;
  62820. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62821. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62822. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62823. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62824. private _tmpPositionVector;
  62825. removePhysicsBody(impostor: PhysicsImpostor): void;
  62826. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62827. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62828. isSupported(): boolean;
  62829. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62830. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62831. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62832. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62833. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62834. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62835. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62836. getBodyMass(impostor: PhysicsImpostor): number;
  62837. getBodyFriction(impostor: PhysicsImpostor): number;
  62838. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62839. getBodyRestitution(impostor: PhysicsImpostor): number;
  62840. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62841. sleepBody(impostor: PhysicsImpostor): void;
  62842. wakeUpBody(impostor: PhysicsImpostor): void;
  62843. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62844. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62845. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62846. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62847. getRadius(impostor: PhysicsImpostor): number;
  62848. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62849. dispose(): void;
  62850. /**
  62851. * Does a raycast in the physics world
  62852. * @param from when should the ray start?
  62853. * @param to when should the ray end?
  62854. * @returns PhysicsRaycastResult
  62855. */
  62856. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62857. }
  62858. }
  62859. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  62860. import { Nullable } from "babylonjs/types";
  62861. import { Scene } from "babylonjs/scene";
  62862. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  62863. import { Color4 } from "babylonjs/Maths/math.color";
  62864. import { Mesh } from "babylonjs/Meshes/mesh";
  62865. /**
  62866. * Class containing static functions to help procedurally build meshes
  62867. */
  62868. export class RibbonBuilder {
  62869. /**
  62870. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62871. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62872. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62873. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62874. * * 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
  62875. * * 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
  62876. * * 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
  62877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62878. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62879. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62880. * * 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
  62881. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62882. * * 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
  62883. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62885. * @param name defines the name of the mesh
  62886. * @param options defines the options used to create the mesh
  62887. * @param scene defines the hosting scene
  62888. * @returns the ribbon mesh
  62889. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62890. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62891. */
  62892. static CreateRibbon(name: string, options: {
  62893. pathArray: Vector3[][];
  62894. closeArray?: boolean;
  62895. closePath?: boolean;
  62896. offset?: number;
  62897. updatable?: boolean;
  62898. sideOrientation?: number;
  62899. frontUVs?: Vector4;
  62900. backUVs?: Vector4;
  62901. instance?: Mesh;
  62902. invertUV?: boolean;
  62903. uvs?: Vector2[];
  62904. colors?: Color4[];
  62905. }, scene?: Nullable<Scene>): Mesh;
  62906. }
  62907. }
  62908. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  62909. import { Nullable } from "babylonjs/types";
  62910. import { Scene } from "babylonjs/scene";
  62911. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62912. import { Mesh } from "babylonjs/Meshes/mesh";
  62913. /**
  62914. * Class containing static functions to help procedurally build meshes
  62915. */
  62916. export class ShapeBuilder {
  62917. /**
  62918. * 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.
  62919. * * 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.
  62920. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62921. * * 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.
  62922. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62923. * * 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
  62924. * * 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
  62925. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62927. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62928. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62930. * @param name defines the name of the mesh
  62931. * @param options defines the options used to create the mesh
  62932. * @param scene defines the hosting scene
  62933. * @returns the extruded shape mesh
  62934. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62935. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62936. */
  62937. static ExtrudeShape(name: string, options: {
  62938. shape: Vector3[];
  62939. path: Vector3[];
  62940. scale?: number;
  62941. rotation?: number;
  62942. cap?: number;
  62943. updatable?: boolean;
  62944. sideOrientation?: number;
  62945. frontUVs?: Vector4;
  62946. backUVs?: Vector4;
  62947. instance?: Mesh;
  62948. invertUV?: boolean;
  62949. }, scene?: Nullable<Scene>): Mesh;
  62950. /**
  62951. * Creates an custom extruded shape mesh.
  62952. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62953. * * 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.
  62954. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62955. * * 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
  62956. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62957. * * 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
  62958. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62959. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62960. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62961. * * 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
  62962. * * 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
  62963. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62965. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62966. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62968. * @param name defines the name of the mesh
  62969. * @param options defines the options used to create the mesh
  62970. * @param scene defines the hosting scene
  62971. * @returns the custom extruded shape mesh
  62972. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62973. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62974. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62975. */
  62976. static ExtrudeShapeCustom(name: string, options: {
  62977. shape: Vector3[];
  62978. path: Vector3[];
  62979. scaleFunction?: any;
  62980. rotationFunction?: any;
  62981. ribbonCloseArray?: boolean;
  62982. ribbonClosePath?: boolean;
  62983. cap?: number;
  62984. updatable?: boolean;
  62985. sideOrientation?: number;
  62986. frontUVs?: Vector4;
  62987. backUVs?: Vector4;
  62988. instance?: Mesh;
  62989. invertUV?: boolean;
  62990. }, scene?: Nullable<Scene>): Mesh;
  62991. private static _ExtrudeShapeGeneric;
  62992. }
  62993. }
  62994. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  62995. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  62996. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62997. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62998. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62999. import { Nullable } from "babylonjs/types";
  63000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63001. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63002. /**
  63003. * AmmoJS Physics plugin
  63004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63005. * @see https://github.com/kripken/ammo.js/
  63006. */
  63007. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63008. private _useDeltaForWorldStep;
  63009. /**
  63010. * Reference to the Ammo library
  63011. */
  63012. bjsAMMO: any;
  63013. /**
  63014. * Created ammoJS world which physics bodies are added to
  63015. */
  63016. world: any;
  63017. /**
  63018. * Name of the plugin
  63019. */
  63020. name: string;
  63021. private _timeStep;
  63022. private _fixedTimeStep;
  63023. private _maxSteps;
  63024. private _tmpQuaternion;
  63025. private _tmpAmmoTransform;
  63026. private _tmpAmmoQuaternion;
  63027. private _tmpAmmoConcreteContactResultCallback;
  63028. private _collisionConfiguration;
  63029. private _dispatcher;
  63030. private _overlappingPairCache;
  63031. private _solver;
  63032. private _softBodySolver;
  63033. private _tmpAmmoVectorA;
  63034. private _tmpAmmoVectorB;
  63035. private _tmpAmmoVectorC;
  63036. private _tmpAmmoVectorD;
  63037. private _tmpContactCallbackResult;
  63038. private _tmpAmmoVectorRCA;
  63039. private _tmpAmmoVectorRCB;
  63040. private _raycastResult;
  63041. private static readonly DISABLE_COLLISION_FLAG;
  63042. private static readonly KINEMATIC_FLAG;
  63043. private static readonly DISABLE_DEACTIVATION_FLAG;
  63044. /**
  63045. * Initializes the ammoJS plugin
  63046. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63047. * @param ammoInjection can be used to inject your own ammo reference
  63048. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63049. */
  63050. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63051. /**
  63052. * Sets the gravity of the physics world (m/(s^2))
  63053. * @param gravity Gravity to set
  63054. */
  63055. setGravity(gravity: Vector3): void;
  63056. /**
  63057. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63058. * @param timeStep timestep to use in seconds
  63059. */
  63060. setTimeStep(timeStep: number): void;
  63061. /**
  63062. * 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)
  63063. * @param fixedTimeStep fixedTimeStep to use in seconds
  63064. */
  63065. setFixedTimeStep(fixedTimeStep: number): void;
  63066. /**
  63067. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63068. * @param maxSteps the maximum number of steps by the physics engine per frame
  63069. */
  63070. setMaxSteps(maxSteps: number): void;
  63071. /**
  63072. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63073. * @returns the current timestep in seconds
  63074. */
  63075. getTimeStep(): number;
  63076. /**
  63077. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63078. */
  63079. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63080. private _isImpostorInContact;
  63081. private _isImpostorPairInContact;
  63082. private _stepSimulation;
  63083. /**
  63084. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63085. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63086. * After the step the babylon meshes are set to the position of the physics imposters
  63087. * @param delta amount of time to step forward
  63088. * @param impostors array of imposters to update before/after the step
  63089. */
  63090. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63091. /**
  63092. * Update babylon mesh to match physics world object
  63093. * @param impostor imposter to match
  63094. */
  63095. private _afterSoftStep;
  63096. /**
  63097. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63098. * @param impostor imposter to match
  63099. */
  63100. private _ropeStep;
  63101. /**
  63102. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63103. * @param impostor imposter to match
  63104. */
  63105. private _softbodyOrClothStep;
  63106. private _tmpMatrix;
  63107. /**
  63108. * Applies an impulse on the imposter
  63109. * @param impostor imposter to apply impulse to
  63110. * @param force amount of force to be applied to the imposter
  63111. * @param contactPoint the location to apply the impulse on the imposter
  63112. */
  63113. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63114. /**
  63115. * Applies a force on the imposter
  63116. * @param impostor imposter to apply force
  63117. * @param force amount of force to be applied to the imposter
  63118. * @param contactPoint the location to apply the force on the imposter
  63119. */
  63120. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63121. /**
  63122. * Creates a physics body using the plugin
  63123. * @param impostor the imposter to create the physics body on
  63124. */
  63125. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63126. /**
  63127. * Removes the physics body from the imposter and disposes of the body's memory
  63128. * @param impostor imposter to remove the physics body from
  63129. */
  63130. removePhysicsBody(impostor: PhysicsImpostor): void;
  63131. /**
  63132. * Generates a joint
  63133. * @param impostorJoint the imposter joint to create the joint with
  63134. */
  63135. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63136. /**
  63137. * Removes a joint
  63138. * @param impostorJoint the imposter joint to remove the joint from
  63139. */
  63140. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63141. private _addMeshVerts;
  63142. /**
  63143. * Initialise the soft body vertices to match its object's (mesh) vertices
  63144. * Softbody vertices (nodes) are in world space and to match this
  63145. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63146. * @param impostor to create the softbody for
  63147. */
  63148. private _softVertexData;
  63149. /**
  63150. * Create an impostor's soft body
  63151. * @param impostor to create the softbody for
  63152. */
  63153. private _createSoftbody;
  63154. /**
  63155. * Create cloth for an impostor
  63156. * @param impostor to create the softbody for
  63157. */
  63158. private _createCloth;
  63159. /**
  63160. * Create rope for an impostor
  63161. * @param impostor to create the softbody for
  63162. */
  63163. private _createRope;
  63164. /**
  63165. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63166. * @param impostor to create the custom physics shape for
  63167. */
  63168. private _createCustom;
  63169. private _addHullVerts;
  63170. private _createShape;
  63171. /**
  63172. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63173. * @param impostor imposter containing the physics body and babylon object
  63174. */
  63175. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63176. /**
  63177. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63178. * @param impostor imposter containing the physics body and babylon object
  63179. * @param newPosition new position
  63180. * @param newRotation new rotation
  63181. */
  63182. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63183. /**
  63184. * If this plugin is supported
  63185. * @returns true if its supported
  63186. */
  63187. isSupported(): boolean;
  63188. /**
  63189. * Sets the linear velocity of the physics body
  63190. * @param impostor imposter to set the velocity on
  63191. * @param velocity velocity to set
  63192. */
  63193. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63194. /**
  63195. * Sets the angular velocity of the physics body
  63196. * @param impostor imposter to set the velocity on
  63197. * @param velocity velocity to set
  63198. */
  63199. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63200. /**
  63201. * gets the linear velocity
  63202. * @param impostor imposter to get linear velocity from
  63203. * @returns linear velocity
  63204. */
  63205. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63206. /**
  63207. * gets the angular velocity
  63208. * @param impostor imposter to get angular velocity from
  63209. * @returns angular velocity
  63210. */
  63211. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63212. /**
  63213. * Sets the mass of physics body
  63214. * @param impostor imposter to set the mass on
  63215. * @param mass mass to set
  63216. */
  63217. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63218. /**
  63219. * Gets the mass of the physics body
  63220. * @param impostor imposter to get the mass from
  63221. * @returns mass
  63222. */
  63223. getBodyMass(impostor: PhysicsImpostor): number;
  63224. /**
  63225. * Gets friction of the impostor
  63226. * @param impostor impostor to get friction from
  63227. * @returns friction value
  63228. */
  63229. getBodyFriction(impostor: PhysicsImpostor): number;
  63230. /**
  63231. * Sets friction of the impostor
  63232. * @param impostor impostor to set friction on
  63233. * @param friction friction value
  63234. */
  63235. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63236. /**
  63237. * Gets restitution of the impostor
  63238. * @param impostor impostor to get restitution from
  63239. * @returns restitution value
  63240. */
  63241. getBodyRestitution(impostor: PhysicsImpostor): number;
  63242. /**
  63243. * Sets resitution of the impostor
  63244. * @param impostor impostor to set resitution on
  63245. * @param restitution resitution value
  63246. */
  63247. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63248. /**
  63249. * Gets pressure inside the impostor
  63250. * @param impostor impostor to get pressure from
  63251. * @returns pressure value
  63252. */
  63253. getBodyPressure(impostor: PhysicsImpostor): number;
  63254. /**
  63255. * Sets pressure inside a soft body impostor
  63256. * Cloth and rope must remain 0 pressure
  63257. * @param impostor impostor to set pressure on
  63258. * @param pressure pressure value
  63259. */
  63260. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  63261. /**
  63262. * Gets stiffness of the impostor
  63263. * @param impostor impostor to get stiffness from
  63264. * @returns pressure value
  63265. */
  63266. getBodyStiffness(impostor: PhysicsImpostor): number;
  63267. /**
  63268. * Sets stiffness of the impostor
  63269. * @param impostor impostor to set stiffness on
  63270. * @param stiffness stiffness value from 0 to 1
  63271. */
  63272. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  63273. /**
  63274. * Gets velocityIterations of the impostor
  63275. * @param impostor impostor to get velocity iterations from
  63276. * @returns velocityIterations value
  63277. */
  63278. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  63279. /**
  63280. * Sets velocityIterations of the impostor
  63281. * @param impostor impostor to set velocity iterations on
  63282. * @param velocityIterations velocityIterations value
  63283. */
  63284. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  63285. /**
  63286. * Gets positionIterations of the impostor
  63287. * @param impostor impostor to get position iterations from
  63288. * @returns positionIterations value
  63289. */
  63290. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  63291. /**
  63292. * Sets positionIterations of the impostor
  63293. * @param impostor impostor to set position on
  63294. * @param positionIterations positionIterations value
  63295. */
  63296. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  63297. /**
  63298. * Append an anchor to a cloth object
  63299. * @param impostor is the cloth impostor to add anchor to
  63300. * @param otherImpostor is the rigid impostor to anchor to
  63301. * @param width ratio across width from 0 to 1
  63302. * @param height ratio up height from 0 to 1
  63303. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  63304. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63305. */
  63306. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63307. /**
  63308. * Append an hook to a rope object
  63309. * @param impostor is the rope impostor to add hook to
  63310. * @param otherImpostor is the rigid impostor to hook to
  63311. * @param length ratio along the rope from 0 to 1
  63312. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  63313. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63314. */
  63315. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63316. /**
  63317. * Sleeps the physics body and stops it from being active
  63318. * @param impostor impostor to sleep
  63319. */
  63320. sleepBody(impostor: PhysicsImpostor): void;
  63321. /**
  63322. * Activates the physics body
  63323. * @param impostor impostor to activate
  63324. */
  63325. wakeUpBody(impostor: PhysicsImpostor): void;
  63326. /**
  63327. * Updates the distance parameters of the joint
  63328. * @param joint joint to update
  63329. * @param maxDistance maximum distance of the joint
  63330. * @param minDistance minimum distance of the joint
  63331. */
  63332. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63333. /**
  63334. * Sets a motor on the joint
  63335. * @param joint joint to set motor on
  63336. * @param speed speed of the motor
  63337. * @param maxForce maximum force of the motor
  63338. * @param motorIndex index of the motor
  63339. */
  63340. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63341. /**
  63342. * Sets the motors limit
  63343. * @param joint joint to set limit on
  63344. * @param upperLimit upper limit
  63345. * @param lowerLimit lower limit
  63346. */
  63347. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63348. /**
  63349. * Syncs the position and rotation of a mesh with the impostor
  63350. * @param mesh mesh to sync
  63351. * @param impostor impostor to update the mesh with
  63352. */
  63353. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63354. /**
  63355. * Gets the radius of the impostor
  63356. * @param impostor impostor to get radius from
  63357. * @returns the radius
  63358. */
  63359. getRadius(impostor: PhysicsImpostor): number;
  63360. /**
  63361. * Gets the box size of the impostor
  63362. * @param impostor impostor to get box size from
  63363. * @param result the resulting box size
  63364. */
  63365. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63366. /**
  63367. * Disposes of the impostor
  63368. */
  63369. dispose(): void;
  63370. /**
  63371. * Does a raycast in the physics world
  63372. * @param from when should the ray start?
  63373. * @param to when should the ray end?
  63374. * @returns PhysicsRaycastResult
  63375. */
  63376. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63377. }
  63378. }
  63379. declare module "babylonjs/Probes/reflectionProbe" {
  63380. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63381. import { Vector3 } from "babylonjs/Maths/math.vector";
  63382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63383. import { Nullable } from "babylonjs/types";
  63384. import { Scene } from "babylonjs/scene";
  63385. module "babylonjs/abstractScene" {
  63386. interface AbstractScene {
  63387. /**
  63388. * The list of reflection probes added to the scene
  63389. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63390. */
  63391. reflectionProbes: Array<ReflectionProbe>;
  63392. /**
  63393. * Removes the given reflection probe from this scene.
  63394. * @param toRemove The reflection probe to remove
  63395. * @returns The index of the removed reflection probe
  63396. */
  63397. removeReflectionProbe(toRemove: ReflectionProbe): number;
  63398. /**
  63399. * Adds the given reflection probe to this scene.
  63400. * @param newReflectionProbe The reflection probe to add
  63401. */
  63402. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  63403. }
  63404. }
  63405. /**
  63406. * Class used to generate realtime reflection / refraction cube textures
  63407. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63408. */
  63409. export class ReflectionProbe {
  63410. /** defines the name of the probe */
  63411. name: string;
  63412. private _scene;
  63413. private _renderTargetTexture;
  63414. private _projectionMatrix;
  63415. private _viewMatrix;
  63416. private _target;
  63417. private _add;
  63418. private _attachedMesh;
  63419. private _invertYAxis;
  63420. /** Gets or sets probe position (center of the cube map) */
  63421. position: Vector3;
  63422. /**
  63423. * Creates a new reflection probe
  63424. * @param name defines the name of the probe
  63425. * @param size defines the texture resolution (for each face)
  63426. * @param scene defines the hosting scene
  63427. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  63428. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  63429. */
  63430. constructor(
  63431. /** defines the name of the probe */
  63432. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  63433. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  63434. get samples(): number;
  63435. set samples(value: number);
  63436. /** Gets or sets the refresh rate to use (on every frame by default) */
  63437. get refreshRate(): number;
  63438. set refreshRate(value: number);
  63439. /**
  63440. * Gets the hosting scene
  63441. * @returns a Scene
  63442. */
  63443. getScene(): Scene;
  63444. /** Gets the internal CubeTexture used to render to */
  63445. get cubeTexture(): RenderTargetTexture;
  63446. /** Gets the list of meshes to render */
  63447. get renderList(): Nullable<AbstractMesh[]>;
  63448. /**
  63449. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  63450. * @param mesh defines the mesh to attach to
  63451. */
  63452. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  63453. /**
  63454. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  63455. * @param renderingGroupId The rendering group id corresponding to its index
  63456. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  63457. */
  63458. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  63459. /**
  63460. * Clean all associated resources
  63461. */
  63462. dispose(): void;
  63463. /**
  63464. * Converts the reflection probe information to a readable string for debug purpose.
  63465. * @param fullDetails Supports for multiple levels of logging within scene loading
  63466. * @returns the human readable reflection probe info
  63467. */
  63468. toString(fullDetails?: boolean): string;
  63469. /**
  63470. * Get the class name of the relfection probe.
  63471. * @returns "ReflectionProbe"
  63472. */
  63473. getClassName(): string;
  63474. /**
  63475. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  63476. * @returns The JSON representation of the texture
  63477. */
  63478. serialize(): any;
  63479. /**
  63480. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  63481. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  63482. * @param scene Define the scene the parsed reflection probe should be instantiated in
  63483. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  63484. * @returns The parsed reflection probe if successful
  63485. */
  63486. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  63487. }
  63488. }
  63489. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  63490. /** @hidden */
  63491. export var _BabylonLoaderRegistered: boolean;
  63492. /**
  63493. * Helps setting up some configuration for the babylon file loader.
  63494. */
  63495. export class BabylonFileLoaderConfiguration {
  63496. /**
  63497. * The loader does not allow injecting custom physix engine into the plugins.
  63498. * Unfortunately in ES6, we need to manually inject them into the plugin.
  63499. * So you could set this variable to your engine import to make it work.
  63500. */
  63501. static LoaderInjectedPhysicsEngine: any;
  63502. }
  63503. }
  63504. declare module "babylonjs/Loading/Plugins/index" {
  63505. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  63506. }
  63507. declare module "babylonjs/Loading/index" {
  63508. export * from "babylonjs/Loading/loadingScreen";
  63509. export * from "babylonjs/Loading/Plugins/index";
  63510. export * from "babylonjs/Loading/sceneLoader";
  63511. export * from "babylonjs/Loading/sceneLoaderFlags";
  63512. }
  63513. declare module "babylonjs/Materials/Background/index" {
  63514. export * from "babylonjs/Materials/Background/backgroundMaterial";
  63515. }
  63516. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  63517. import { Scene } from "babylonjs/scene";
  63518. import { Color3 } from "babylonjs/Maths/math.color";
  63519. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63520. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63521. /**
  63522. * The Physically based simple base material of BJS.
  63523. *
  63524. * This enables better naming and convention enforcements on top of the pbrMaterial.
  63525. * It is used as the base class for both the specGloss and metalRough conventions.
  63526. */
  63527. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  63528. /**
  63529. * Number of Simultaneous lights allowed on the material.
  63530. */
  63531. maxSimultaneousLights: number;
  63532. /**
  63533. * If sets to true, disables all the lights affecting the material.
  63534. */
  63535. disableLighting: boolean;
  63536. /**
  63537. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  63538. */
  63539. environmentTexture: BaseTexture;
  63540. /**
  63541. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  63542. */
  63543. invertNormalMapX: boolean;
  63544. /**
  63545. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  63546. */
  63547. invertNormalMapY: boolean;
  63548. /**
  63549. * Normal map used in the model.
  63550. */
  63551. normalTexture: BaseTexture;
  63552. /**
  63553. * Emissivie color used to self-illuminate the model.
  63554. */
  63555. emissiveColor: Color3;
  63556. /**
  63557. * Emissivie texture used to self-illuminate the model.
  63558. */
  63559. emissiveTexture: BaseTexture;
  63560. /**
  63561. * Occlusion Channel Strenght.
  63562. */
  63563. occlusionStrength: number;
  63564. /**
  63565. * Occlusion Texture of the material (adding extra occlusion effects).
  63566. */
  63567. occlusionTexture: BaseTexture;
  63568. /**
  63569. * Defines the alpha limits in alpha test mode.
  63570. */
  63571. alphaCutOff: number;
  63572. /**
  63573. * Gets the current double sided mode.
  63574. */
  63575. get doubleSided(): boolean;
  63576. /**
  63577. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  63578. */
  63579. set doubleSided(value: boolean);
  63580. /**
  63581. * Stores the pre-calculated light information of a mesh in a texture.
  63582. */
  63583. lightmapTexture: BaseTexture;
  63584. /**
  63585. * If true, the light map contains occlusion information instead of lighting info.
  63586. */
  63587. useLightmapAsShadowmap: boolean;
  63588. /**
  63589. * Instantiates a new PBRMaterial instance.
  63590. *
  63591. * @param name The material name
  63592. * @param scene The scene the material will be use in.
  63593. */
  63594. constructor(name: string, scene: Scene);
  63595. getClassName(): string;
  63596. }
  63597. }
  63598. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  63599. import { Scene } from "babylonjs/scene";
  63600. import { Color3 } from "babylonjs/Maths/math.color";
  63601. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63602. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63603. /**
  63604. * The PBR material of BJS following the metal roughness convention.
  63605. *
  63606. * This fits to the PBR convention in the GLTF definition:
  63607. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  63608. */
  63609. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  63610. /**
  63611. * The base color has two different interpretations depending on the value of metalness.
  63612. * When the material is a metal, the base color is the specific measured reflectance value
  63613. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  63614. * of the material.
  63615. */
  63616. baseColor: Color3;
  63617. /**
  63618. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  63619. * well as opacity information in the alpha channel.
  63620. */
  63621. baseTexture: BaseTexture;
  63622. /**
  63623. * Specifies the metallic scalar value of the material.
  63624. * Can also be used to scale the metalness values of the metallic texture.
  63625. */
  63626. metallic: number;
  63627. /**
  63628. * Specifies the roughness scalar value of the material.
  63629. * Can also be used to scale the roughness values of the metallic texture.
  63630. */
  63631. roughness: number;
  63632. /**
  63633. * Texture containing both the metallic value in the B channel and the
  63634. * roughness value in the G channel to keep better precision.
  63635. */
  63636. metallicRoughnessTexture: BaseTexture;
  63637. /**
  63638. * Instantiates a new PBRMetalRoughnessMaterial instance.
  63639. *
  63640. * @param name The material name
  63641. * @param scene The scene the material will be use in.
  63642. */
  63643. constructor(name: string, scene: Scene);
  63644. /**
  63645. * Return the currrent class name of the material.
  63646. */
  63647. getClassName(): string;
  63648. /**
  63649. * Makes a duplicate of the current material.
  63650. * @param name - name to use for the new material.
  63651. */
  63652. clone(name: string): PBRMetallicRoughnessMaterial;
  63653. /**
  63654. * Serialize the material to a parsable JSON object.
  63655. */
  63656. serialize(): any;
  63657. /**
  63658. * Parses a JSON object correponding to the serialize function.
  63659. */
  63660. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  63661. }
  63662. }
  63663. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  63664. import { Scene } from "babylonjs/scene";
  63665. import { Color3 } from "babylonjs/Maths/math.color";
  63666. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63667. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63668. /**
  63669. * The PBR material of BJS following the specular glossiness convention.
  63670. *
  63671. * This fits to the PBR convention in the GLTF definition:
  63672. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  63673. */
  63674. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  63675. /**
  63676. * Specifies the diffuse color of the material.
  63677. */
  63678. diffuseColor: Color3;
  63679. /**
  63680. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63681. * channel.
  63682. */
  63683. diffuseTexture: BaseTexture;
  63684. /**
  63685. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63686. */
  63687. specularColor: Color3;
  63688. /**
  63689. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63690. */
  63691. glossiness: number;
  63692. /**
  63693. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63694. */
  63695. specularGlossinessTexture: BaseTexture;
  63696. /**
  63697. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63698. *
  63699. * @param name The material name
  63700. * @param scene The scene the material will be use in.
  63701. */
  63702. constructor(name: string, scene: Scene);
  63703. /**
  63704. * Return the currrent class name of the material.
  63705. */
  63706. getClassName(): string;
  63707. /**
  63708. * Makes a duplicate of the current material.
  63709. * @param name - name to use for the new material.
  63710. */
  63711. clone(name: string): PBRSpecularGlossinessMaterial;
  63712. /**
  63713. * Serialize the material to a parsable JSON object.
  63714. */
  63715. serialize(): any;
  63716. /**
  63717. * Parses a JSON object correponding to the serialize function.
  63718. */
  63719. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63720. }
  63721. }
  63722. declare module "babylonjs/Materials/PBR/index" {
  63723. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63724. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63725. export * from "babylonjs/Materials/PBR/pbrMaterial";
  63726. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  63727. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  63728. }
  63729. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  63730. import { Nullable } from "babylonjs/types";
  63731. import { Scene } from "babylonjs/scene";
  63732. import { Matrix } from "babylonjs/Maths/math.vector";
  63733. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63734. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63735. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63736. /**
  63737. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63738. * It can help converting any input color in a desired output one. This can then be used to create effects
  63739. * from sepia, black and white to sixties or futuristic rendering...
  63740. *
  63741. * The only supported format is currently 3dl.
  63742. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63743. */
  63744. export class ColorGradingTexture extends BaseTexture {
  63745. /**
  63746. * The texture URL.
  63747. */
  63748. url: string;
  63749. /**
  63750. * Empty line regex stored for GC.
  63751. */
  63752. private static _noneEmptyLineRegex;
  63753. private _textureMatrix;
  63754. private _onLoad;
  63755. /**
  63756. * Instantiates a ColorGradingTexture from the following parameters.
  63757. *
  63758. * @param url The location of the color gradind data (currently only supporting 3dl)
  63759. * @param sceneOrEngine The scene or engine the texture will be used in
  63760. * @param onLoad defines a callback triggered when the texture has been loaded
  63761. */
  63762. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63763. /**
  63764. * Fires the onload event from the constructor if requested.
  63765. */
  63766. private _triggerOnLoad;
  63767. /**
  63768. * Returns the texture matrix used in most of the material.
  63769. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63770. */
  63771. getTextureMatrix(): Matrix;
  63772. /**
  63773. * Occurs when the file being loaded is a .3dl LUT file.
  63774. */
  63775. private load3dlTexture;
  63776. /**
  63777. * Starts the loading process of the texture.
  63778. */
  63779. private loadTexture;
  63780. /**
  63781. * Clones the color gradind texture.
  63782. */
  63783. clone(): ColorGradingTexture;
  63784. /**
  63785. * Called during delayed load for textures.
  63786. */
  63787. delayLoad(): void;
  63788. /**
  63789. * Parses a color grading texture serialized by Babylon.
  63790. * @param parsedTexture The texture information being parsedTexture
  63791. * @param scene The scene to load the texture in
  63792. * @param rootUrl The root url of the data assets to load
  63793. * @return A color gradind texture
  63794. */
  63795. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63796. /**
  63797. * Serializes the LUT texture to json format.
  63798. */
  63799. serialize(): any;
  63800. }
  63801. }
  63802. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  63803. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63804. import { Scene } from "babylonjs/scene";
  63805. import { Nullable } from "babylonjs/types";
  63806. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63807. /**
  63808. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63809. */
  63810. export class EquiRectangularCubeTexture extends BaseTexture {
  63811. /** The six faces of the cube. */
  63812. private static _FacesMapping;
  63813. private _noMipmap;
  63814. private _onLoad;
  63815. private _onError;
  63816. /** The size of the cubemap. */
  63817. private _size;
  63818. /** The buffer of the image. */
  63819. private _buffer;
  63820. /** The width of the input image. */
  63821. private _width;
  63822. /** The height of the input image. */
  63823. private _height;
  63824. /** The URL to the image. */
  63825. url: string;
  63826. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  63827. coordinatesMode: number;
  63828. /**
  63829. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63830. * @param url The location of the image
  63831. * @param scene The scene the texture will be used in
  63832. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63833. * @param noMipmap Forces to not generate the mipmap if true
  63834. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63835. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63836. * @param onLoad — defines a callback called when texture is loaded
  63837. * @param onError — defines a callback called if there is an error
  63838. */
  63839. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63840. /**
  63841. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63842. */
  63843. private loadImage;
  63844. /**
  63845. * Convert the image buffer into a cubemap and create a CubeTexture.
  63846. */
  63847. private loadTexture;
  63848. /**
  63849. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63850. * @param buffer The ArrayBuffer that should be converted.
  63851. * @returns The buffer as Float32Array.
  63852. */
  63853. private getFloat32ArrayFromArrayBuffer;
  63854. /**
  63855. * Get the current class name of the texture useful for serialization or dynamic coding.
  63856. * @returns "EquiRectangularCubeTexture"
  63857. */
  63858. getClassName(): string;
  63859. /**
  63860. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63861. * @returns A clone of the current EquiRectangularCubeTexture.
  63862. */
  63863. clone(): EquiRectangularCubeTexture;
  63864. }
  63865. }
  63866. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  63867. import { Nullable } from "babylonjs/types";
  63868. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63869. import { Matrix } from "babylonjs/Maths/math.vector";
  63870. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  63871. import "babylonjs/Engines/Extensions/engine.videoTexture";
  63872. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63873. import { Scene } from "babylonjs/scene";
  63874. /**
  63875. * Defines the options related to the creation of an HtmlElementTexture
  63876. */
  63877. export interface IHtmlElementTextureOptions {
  63878. /**
  63879. * Defines wether mip maps should be created or not.
  63880. */
  63881. generateMipMaps?: boolean;
  63882. /**
  63883. * Defines the sampling mode of the texture.
  63884. */
  63885. samplingMode?: number;
  63886. /**
  63887. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63888. */
  63889. engine: Nullable<ThinEngine>;
  63890. /**
  63891. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63892. */
  63893. scene: Nullable<Scene>;
  63894. }
  63895. /**
  63896. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63897. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63898. * is automatically managed.
  63899. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63900. * in your application.
  63901. *
  63902. * As the update is not automatic, you need to call them manually.
  63903. */
  63904. export class HtmlElementTexture extends BaseTexture {
  63905. /**
  63906. * The texture URL.
  63907. */
  63908. element: HTMLVideoElement | HTMLCanvasElement;
  63909. private static readonly DefaultOptions;
  63910. private _textureMatrix;
  63911. private _isVideo;
  63912. private _generateMipMaps;
  63913. private _samplingMode;
  63914. /**
  63915. * Instantiates a HtmlElementTexture from the following parameters.
  63916. *
  63917. * @param name Defines the name of the texture
  63918. * @param element Defines the video or canvas the texture is filled with
  63919. * @param options Defines the other none mandatory texture creation options
  63920. */
  63921. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63922. private _createInternalTexture;
  63923. /**
  63924. * Returns the texture matrix used in most of the material.
  63925. */
  63926. getTextureMatrix(): Matrix;
  63927. /**
  63928. * Updates the content of the texture.
  63929. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63930. */
  63931. update(invertY?: Nullable<boolean>): void;
  63932. }
  63933. }
  63934. declare module "babylonjs/Misc/tga" {
  63935. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63936. /**
  63937. * Based on jsTGALoader - Javascript loader for TGA file
  63938. * By Vincent Thibault
  63939. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63940. */
  63941. export class TGATools {
  63942. private static _TYPE_INDEXED;
  63943. private static _TYPE_RGB;
  63944. private static _TYPE_GREY;
  63945. private static _TYPE_RLE_INDEXED;
  63946. private static _TYPE_RLE_RGB;
  63947. private static _TYPE_RLE_GREY;
  63948. private static _ORIGIN_MASK;
  63949. private static _ORIGIN_SHIFT;
  63950. private static _ORIGIN_BL;
  63951. private static _ORIGIN_BR;
  63952. private static _ORIGIN_UL;
  63953. private static _ORIGIN_UR;
  63954. /**
  63955. * Gets the header of a TGA file
  63956. * @param data defines the TGA data
  63957. * @returns the header
  63958. */
  63959. static GetTGAHeader(data: Uint8Array): any;
  63960. /**
  63961. * Uploads TGA content to a Babylon Texture
  63962. * @hidden
  63963. */
  63964. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63965. /** @hidden */
  63966. 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;
  63967. /** @hidden */
  63968. 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;
  63969. /** @hidden */
  63970. 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;
  63971. /** @hidden */
  63972. 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;
  63973. /** @hidden */
  63974. 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;
  63975. /** @hidden */
  63976. 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;
  63977. }
  63978. }
  63979. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  63980. import { Nullable } from "babylonjs/types";
  63981. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63982. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63983. /**
  63984. * Implementation of the TGA Texture Loader.
  63985. * @hidden
  63986. */
  63987. export class _TGATextureLoader implements IInternalTextureLoader {
  63988. /**
  63989. * Defines wether the loader supports cascade loading the different faces.
  63990. */
  63991. readonly supportCascades: boolean;
  63992. /**
  63993. * This returns if the loader support the current file information.
  63994. * @param extension defines the file extension of the file being loaded
  63995. * @returns true if the loader can load the specified file
  63996. */
  63997. canLoad(extension: string): boolean;
  63998. /**
  63999. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64000. * @param data contains the texture data
  64001. * @param texture defines the BabylonJS internal texture
  64002. * @param createPolynomials will be true if polynomials have been requested
  64003. * @param onLoad defines the callback to trigger once the texture is ready
  64004. * @param onError defines the callback to trigger in case of error
  64005. */
  64006. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64007. /**
  64008. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64009. * @param data contains the texture data
  64010. * @param texture defines the BabylonJS internal texture
  64011. * @param callback defines the method to call once ready to upload
  64012. */
  64013. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64014. }
  64015. }
  64016. declare module "babylonjs/Misc/basis" {
  64017. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64018. /**
  64019. * Info about the .basis files
  64020. */
  64021. class BasisFileInfo {
  64022. /**
  64023. * If the file has alpha
  64024. */
  64025. hasAlpha: boolean;
  64026. /**
  64027. * Info about each image of the basis file
  64028. */
  64029. images: Array<{
  64030. levels: Array<{
  64031. width: number;
  64032. height: number;
  64033. transcodedPixels: ArrayBufferView;
  64034. }>;
  64035. }>;
  64036. }
  64037. /**
  64038. * Result of transcoding a basis file
  64039. */
  64040. class TranscodeResult {
  64041. /**
  64042. * Info about the .basis file
  64043. */
  64044. fileInfo: BasisFileInfo;
  64045. /**
  64046. * Format to use when loading the file
  64047. */
  64048. format: number;
  64049. }
  64050. /**
  64051. * Configuration options for the Basis transcoder
  64052. */
  64053. export class BasisTranscodeConfiguration {
  64054. /**
  64055. * Supported compression formats used to determine the supported output format of the transcoder
  64056. */
  64057. supportedCompressionFormats?: {
  64058. /**
  64059. * etc1 compression format
  64060. */
  64061. etc1?: boolean;
  64062. /**
  64063. * s3tc compression format
  64064. */
  64065. s3tc?: boolean;
  64066. /**
  64067. * pvrtc compression format
  64068. */
  64069. pvrtc?: boolean;
  64070. /**
  64071. * etc2 compression format
  64072. */
  64073. etc2?: boolean;
  64074. };
  64075. /**
  64076. * If mipmap levels should be loaded for transcoded images (Default: true)
  64077. */
  64078. loadMipmapLevels?: boolean;
  64079. /**
  64080. * Index of a single image to load (Default: all images)
  64081. */
  64082. loadSingleImage?: number;
  64083. }
  64084. /**
  64085. * Used to load .Basis files
  64086. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64087. */
  64088. export class BasisTools {
  64089. private static _IgnoreSupportedFormats;
  64090. /**
  64091. * URL to use when loading the basis transcoder
  64092. */
  64093. static JSModuleURL: string;
  64094. /**
  64095. * URL to use when loading the wasm module for the transcoder
  64096. */
  64097. static WasmModuleURL: string;
  64098. /**
  64099. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64100. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64101. * @returns internal format corresponding to the Basis format
  64102. */
  64103. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64104. private static _WorkerPromise;
  64105. private static _Worker;
  64106. private static _actionId;
  64107. private static _CreateWorkerAsync;
  64108. /**
  64109. * Transcodes a loaded image file to compressed pixel data
  64110. * @param data image data to transcode
  64111. * @param config configuration options for the transcoding
  64112. * @returns a promise resulting in the transcoded image
  64113. */
  64114. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64115. /**
  64116. * Loads a texture from the transcode result
  64117. * @param texture texture load to
  64118. * @param transcodeResult the result of transcoding the basis file to load from
  64119. */
  64120. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64121. }
  64122. }
  64123. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64124. import { Nullable } from "babylonjs/types";
  64125. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64126. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64127. /**
  64128. * Loader for .basis file format
  64129. */
  64130. export class _BasisTextureLoader implements IInternalTextureLoader {
  64131. /**
  64132. * Defines whether the loader supports cascade loading the different faces.
  64133. */
  64134. readonly supportCascades: boolean;
  64135. /**
  64136. * This returns if the loader support the current file information.
  64137. * @param extension defines the file extension of the file being loaded
  64138. * @returns true if the loader can load the specified file
  64139. */
  64140. canLoad(extension: string): boolean;
  64141. /**
  64142. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64143. * @param data contains the texture data
  64144. * @param texture defines the BabylonJS internal texture
  64145. * @param createPolynomials will be true if polynomials have been requested
  64146. * @param onLoad defines the callback to trigger once the texture is ready
  64147. * @param onError defines the callback to trigger in case of error
  64148. */
  64149. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64150. /**
  64151. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64152. * @param data contains the texture data
  64153. * @param texture defines the BabylonJS internal texture
  64154. * @param callback defines the method to call once ready to upload
  64155. */
  64156. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64157. }
  64158. }
  64159. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64160. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64161. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64162. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64163. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64164. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64165. }
  64166. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64167. import { Vector2 } from "babylonjs/Maths/math.vector";
  64168. /**
  64169. * Defines the basic options interface of a TexturePacker Frame
  64170. */
  64171. export interface ITexturePackerFrame {
  64172. /**
  64173. * The frame ID
  64174. */
  64175. id: number;
  64176. /**
  64177. * The frames Scale
  64178. */
  64179. scale: Vector2;
  64180. /**
  64181. * The Frames offset
  64182. */
  64183. offset: Vector2;
  64184. }
  64185. /**
  64186. * This is a support class for frame Data on texture packer sets.
  64187. */
  64188. export class TexturePackerFrame implements ITexturePackerFrame {
  64189. /**
  64190. * The frame ID
  64191. */
  64192. id: number;
  64193. /**
  64194. * The frames Scale
  64195. */
  64196. scale: Vector2;
  64197. /**
  64198. * The Frames offset
  64199. */
  64200. offset: Vector2;
  64201. /**
  64202. * Initializes a texture package frame.
  64203. * @param id The numerical frame identifier
  64204. * @param scale Scalar Vector2 for UV frame
  64205. * @param offset Vector2 for the frame position in UV units.
  64206. * @returns TexturePackerFrame
  64207. */
  64208. constructor(id: number, scale: Vector2, offset: Vector2);
  64209. }
  64210. }
  64211. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64213. import { Scene } from "babylonjs/scene";
  64214. import { Nullable } from "babylonjs/types";
  64215. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64216. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64217. /**
  64218. * Defines the basic options interface of a TexturePacker
  64219. */
  64220. export interface ITexturePackerOptions {
  64221. /**
  64222. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64223. */
  64224. map?: string[];
  64225. /**
  64226. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64227. */
  64228. uvsIn?: string;
  64229. /**
  64230. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64231. */
  64232. uvsOut?: string;
  64233. /**
  64234. * number representing the layout style. Defaults to LAYOUT_STRIP
  64235. */
  64236. layout?: number;
  64237. /**
  64238. * number of columns if using custom column count layout(2). This defaults to 4.
  64239. */
  64240. colnum?: number;
  64241. /**
  64242. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64243. */
  64244. updateInputMeshes?: boolean;
  64245. /**
  64246. * boolean flag to dispose all the source textures. Defaults to true.
  64247. */
  64248. disposeSources?: boolean;
  64249. /**
  64250. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  64251. */
  64252. fillBlanks?: boolean;
  64253. /**
  64254. * string value representing the context fill style color. Defaults to 'black'.
  64255. */
  64256. customFillColor?: string;
  64257. /**
  64258. * Width and Height Value of each Frame in the TexturePacker Sets
  64259. */
  64260. frameSize?: number;
  64261. /**
  64262. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  64263. */
  64264. paddingRatio?: number;
  64265. /**
  64266. * Number that declares the fill method for the padding gutter.
  64267. */
  64268. paddingMode?: number;
  64269. /**
  64270. * If in SUBUV_COLOR padding mode what color to use.
  64271. */
  64272. paddingColor?: Color3 | Color4;
  64273. }
  64274. /**
  64275. * Defines the basic interface of a TexturePacker JSON File
  64276. */
  64277. export interface ITexturePackerJSON {
  64278. /**
  64279. * The frame ID
  64280. */
  64281. name: string;
  64282. /**
  64283. * The base64 channel data
  64284. */
  64285. sets: any;
  64286. /**
  64287. * The options of the Packer
  64288. */
  64289. options: ITexturePackerOptions;
  64290. /**
  64291. * The frame data of the Packer
  64292. */
  64293. frames: Array<number>;
  64294. }
  64295. /**
  64296. * This is a support class that generates a series of packed texture sets.
  64297. * @see https://doc.babylonjs.com/babylon101/materials
  64298. */
  64299. export class TexturePacker {
  64300. /** Packer Layout Constant 0 */
  64301. static readonly LAYOUT_STRIP: number;
  64302. /** Packer Layout Constant 1 */
  64303. static readonly LAYOUT_POWER2: number;
  64304. /** Packer Layout Constant 2 */
  64305. static readonly LAYOUT_COLNUM: number;
  64306. /** Packer Layout Constant 0 */
  64307. static readonly SUBUV_WRAP: number;
  64308. /** Packer Layout Constant 1 */
  64309. static readonly SUBUV_EXTEND: number;
  64310. /** Packer Layout Constant 2 */
  64311. static readonly SUBUV_COLOR: number;
  64312. /** The Name of the Texture Package */
  64313. name: string;
  64314. /** The scene scope of the TexturePacker */
  64315. scene: Scene;
  64316. /** The Meshes to target */
  64317. meshes: AbstractMesh[];
  64318. /** Arguments passed with the Constructor */
  64319. options: ITexturePackerOptions;
  64320. /** The promise that is started upon initialization */
  64321. promise: Nullable<Promise<TexturePacker | string>>;
  64322. /** The Container object for the channel sets that are generated */
  64323. sets: object;
  64324. /** The Container array for the frames that are generated */
  64325. frames: TexturePackerFrame[];
  64326. /** The expected number of textures the system is parsing. */
  64327. private _expecting;
  64328. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  64329. private _paddingValue;
  64330. /**
  64331. * Initializes a texture package series from an array of meshes or a single mesh.
  64332. * @param name The name of the package
  64333. * @param meshes The target meshes to compose the package from
  64334. * @param options The arguments that texture packer should follow while building.
  64335. * @param scene The scene which the textures are scoped to.
  64336. * @returns TexturePacker
  64337. */
  64338. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  64339. /**
  64340. * Starts the package process
  64341. * @param resolve The promises resolution function
  64342. * @returns TexturePacker
  64343. */
  64344. private _createFrames;
  64345. /**
  64346. * Calculates the Size of the Channel Sets
  64347. * @returns Vector2
  64348. */
  64349. private _calculateSize;
  64350. /**
  64351. * Calculates the UV data for the frames.
  64352. * @param baseSize the base frameSize
  64353. * @param padding the base frame padding
  64354. * @param dtSize size of the Dynamic Texture for that channel
  64355. * @param dtUnits is 1/dtSize
  64356. * @param update flag to update the input meshes
  64357. */
  64358. private _calculateMeshUVFrames;
  64359. /**
  64360. * Calculates the frames Offset.
  64361. * @param index of the frame
  64362. * @returns Vector2
  64363. */
  64364. private _getFrameOffset;
  64365. /**
  64366. * Updates a Mesh to the frame data
  64367. * @param mesh that is the target
  64368. * @param frameID or the frame index
  64369. */
  64370. private _updateMeshUV;
  64371. /**
  64372. * Updates a Meshes materials to use the texture packer channels
  64373. * @param m is the mesh to target
  64374. * @param force all channels on the packer to be set.
  64375. */
  64376. private _updateTextureReferences;
  64377. /**
  64378. * Public method to set a Mesh to a frame
  64379. * @param m that is the target
  64380. * @param frameID or the frame index
  64381. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  64382. */
  64383. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  64384. /**
  64385. * Starts the async promise to compile the texture packer.
  64386. * @returns Promise<void>
  64387. */
  64388. processAsync(): Promise<void>;
  64389. /**
  64390. * Disposes all textures associated with this packer
  64391. */
  64392. dispose(): void;
  64393. /**
  64394. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  64395. * @param imageType is the image type to use.
  64396. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  64397. */
  64398. download(imageType?: string, quality?: number): void;
  64399. /**
  64400. * Public method to load a texturePacker JSON file.
  64401. * @param data of the JSON file in string format.
  64402. */
  64403. updateFromJSON(data: string): void;
  64404. }
  64405. }
  64406. declare module "babylonjs/Materials/Textures/Packer/index" {
  64407. export * from "babylonjs/Materials/Textures/Packer/packer";
  64408. export * from "babylonjs/Materials/Textures/Packer/frame";
  64409. }
  64410. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  64411. import { Scene } from "babylonjs/scene";
  64412. import { Texture } from "babylonjs/Materials/Textures/texture";
  64413. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64414. /**
  64415. * 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.
  64416. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64417. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64418. */
  64419. export class CustomProceduralTexture extends ProceduralTexture {
  64420. private _animate;
  64421. private _time;
  64422. private _config;
  64423. private _texturePath;
  64424. /**
  64425. * Instantiates a new Custom Procedural Texture.
  64426. * 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.
  64427. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64428. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64429. * @param name Define the name of the texture
  64430. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  64431. * @param size Define the size of the texture to create
  64432. * @param scene Define the scene the texture belongs to
  64433. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  64434. * @param generateMipMaps Define if the texture should creates mip maps or not
  64435. */
  64436. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64437. private _loadJson;
  64438. /**
  64439. * Is the texture ready to be used ? (rendered at least once)
  64440. * @returns true if ready, otherwise, false.
  64441. */
  64442. isReady(): boolean;
  64443. /**
  64444. * Render the texture to its associated render target.
  64445. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  64446. */
  64447. render(useCameraPostProcess?: boolean): void;
  64448. /**
  64449. * Update the list of dependant textures samplers in the shader.
  64450. */
  64451. updateTextures(): void;
  64452. /**
  64453. * Update the uniform values of the procedural texture in the shader.
  64454. */
  64455. updateShaderUniforms(): void;
  64456. /**
  64457. * Define if the texture animates or not.
  64458. */
  64459. get animate(): boolean;
  64460. set animate(value: boolean);
  64461. }
  64462. }
  64463. declare module "babylonjs/Shaders/noise.fragment" {
  64464. /** @hidden */
  64465. export var noisePixelShader: {
  64466. name: string;
  64467. shader: string;
  64468. };
  64469. }
  64470. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  64471. import { Nullable } from "babylonjs/types";
  64472. import { Scene } from "babylonjs/scene";
  64473. import { Texture } from "babylonjs/Materials/Textures/texture";
  64474. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64475. import "babylonjs/Shaders/noise.fragment";
  64476. /**
  64477. * Class used to generate noise procedural textures
  64478. */
  64479. export class NoiseProceduralTexture extends ProceduralTexture {
  64480. private _time;
  64481. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  64482. brightness: number;
  64483. /** Defines the number of octaves to process */
  64484. octaves: number;
  64485. /** Defines the level of persistence (0.8 by default) */
  64486. persistence: number;
  64487. /** Gets or sets animation speed factor (default is 1) */
  64488. animationSpeedFactor: number;
  64489. /**
  64490. * Creates a new NoiseProceduralTexture
  64491. * @param name defines the name fo the texture
  64492. * @param size defines the size of the texture (default is 256)
  64493. * @param scene defines the hosting scene
  64494. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  64495. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  64496. */
  64497. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64498. private _updateShaderUniforms;
  64499. protected _getDefines(): string;
  64500. /** Generate the current state of the procedural texture */
  64501. render(useCameraPostProcess?: boolean): void;
  64502. /**
  64503. * Serializes this noise procedural texture
  64504. * @returns a serialized noise procedural texture object
  64505. */
  64506. serialize(): any;
  64507. /**
  64508. * Clone the texture.
  64509. * @returns the cloned texture
  64510. */
  64511. clone(): NoiseProceduralTexture;
  64512. /**
  64513. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  64514. * @param parsedTexture defines parsed texture data
  64515. * @param scene defines the current scene
  64516. * @param rootUrl defines the root URL containing noise procedural texture information
  64517. * @returns a parsed NoiseProceduralTexture
  64518. */
  64519. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  64520. }
  64521. }
  64522. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  64523. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  64524. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  64525. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64526. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  64527. }
  64528. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  64529. import { Nullable } from "babylonjs/types";
  64530. import { Scene } from "babylonjs/scene";
  64531. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  64532. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64533. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64534. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64535. /**
  64536. * Raw cube texture where the raw buffers are passed in
  64537. */
  64538. export class RawCubeTexture extends CubeTexture {
  64539. /**
  64540. * Creates a cube texture where the raw buffers are passed in.
  64541. * @param scene defines the scene the texture is attached to
  64542. * @param data defines the array of data to use to create each face
  64543. * @param size defines the size of the textures
  64544. * @param format defines the format of the data
  64545. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  64546. * @param generateMipMaps defines if the engine should generate the mip levels
  64547. * @param invertY defines if data must be stored with Y axis inverted
  64548. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  64549. * @param compression defines the compression used (null by default)
  64550. */
  64551. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  64552. /**
  64553. * Updates the raw cube texture.
  64554. * @param data defines the data to store
  64555. * @param format defines the data format
  64556. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64557. * @param invertY defines if data must be stored with Y axis inverted
  64558. * @param compression defines the compression used (null by default)
  64559. * @param level defines which level of the texture to update
  64560. */
  64561. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  64562. /**
  64563. * Updates a raw cube texture with RGBD encoded data.
  64564. * @param data defines the array of data [mipmap][face] to use to create each face
  64565. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  64566. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64567. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64568. * @returns a promsie that resolves when the operation is complete
  64569. */
  64570. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  64571. /**
  64572. * Clones the raw cube texture.
  64573. * @return a new cube texture
  64574. */
  64575. clone(): CubeTexture;
  64576. /** @hidden */
  64577. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  64578. }
  64579. }
  64580. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  64581. import { Scene } from "babylonjs/scene";
  64582. import { Texture } from "babylonjs/Materials/Textures/texture";
  64583. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64584. /**
  64585. * Class used to store 2D array textures containing user data
  64586. */
  64587. export class RawTexture2DArray extends Texture {
  64588. /** Gets or sets the texture format to use */
  64589. format: number;
  64590. /**
  64591. * Create a new RawTexture2DArray
  64592. * @param data defines the data of the texture
  64593. * @param width defines the width of the texture
  64594. * @param height defines the height of the texture
  64595. * @param depth defines the number of layers of the texture
  64596. * @param format defines the texture format to use
  64597. * @param scene defines the hosting scene
  64598. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64599. * @param invertY defines if texture must be stored with Y axis inverted
  64600. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64601. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64602. */
  64603. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64604. /** Gets or sets the texture format to use */
  64605. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64606. /**
  64607. * Update the texture with new data
  64608. * @param data defines the data to store in the texture
  64609. */
  64610. update(data: ArrayBufferView): void;
  64611. }
  64612. }
  64613. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  64614. import { Scene } from "babylonjs/scene";
  64615. import { Texture } from "babylonjs/Materials/Textures/texture";
  64616. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64617. /**
  64618. * Class used to store 3D textures containing user data
  64619. */
  64620. export class RawTexture3D extends Texture {
  64621. /** Gets or sets the texture format to use */
  64622. format: number;
  64623. /**
  64624. * Create a new RawTexture3D
  64625. * @param data defines the data of the texture
  64626. * @param width defines the width of the texture
  64627. * @param height defines the height of the texture
  64628. * @param depth defines the depth of the texture
  64629. * @param format defines the texture format to use
  64630. * @param scene defines the hosting scene
  64631. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64632. * @param invertY defines if texture must be stored with Y axis inverted
  64633. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64634. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64635. */
  64636. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64637. /** Gets or sets the texture format to use */
  64638. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64639. /**
  64640. * Update the texture with new data
  64641. * @param data defines the data to store in the texture
  64642. */
  64643. update(data: ArrayBufferView): void;
  64644. }
  64645. }
  64646. declare module "babylonjs/Materials/Textures/refractionTexture" {
  64647. import { Scene } from "babylonjs/scene";
  64648. import { Plane } from "babylonjs/Maths/math.plane";
  64649. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64650. /**
  64651. * Creates a refraction texture used by refraction channel of the standard material.
  64652. * It is like a mirror but to see through a material.
  64653. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64654. */
  64655. export class RefractionTexture extends RenderTargetTexture {
  64656. /**
  64657. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  64658. * 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.
  64659. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64660. */
  64661. refractionPlane: Plane;
  64662. /**
  64663. * Define how deep under the surface we should see.
  64664. */
  64665. depth: number;
  64666. /**
  64667. * Creates a refraction texture used by refraction channel of the standard material.
  64668. * It is like a mirror but to see through a material.
  64669. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64670. * @param name Define the texture name
  64671. * @param size Define the size of the underlying texture
  64672. * @param scene Define the scene the refraction belongs to
  64673. * @param generateMipMaps Define if we need to generate mips level for the refraction
  64674. */
  64675. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  64676. /**
  64677. * Clone the refraction texture.
  64678. * @returns the cloned texture
  64679. */
  64680. clone(): RefractionTexture;
  64681. /**
  64682. * Serialize the texture to a JSON representation you could use in Parse later on
  64683. * @returns the serialized JSON representation
  64684. */
  64685. serialize(): any;
  64686. }
  64687. }
  64688. declare module "babylonjs/Materials/Textures/index" {
  64689. export * from "babylonjs/Materials/Textures/baseTexture";
  64690. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  64691. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  64692. export * from "babylonjs/Materials/Textures/cubeTexture";
  64693. export * from "babylonjs/Materials/Textures/dynamicTexture";
  64694. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64695. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  64696. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  64697. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  64698. export * from "babylonjs/Materials/Textures/internalTexture";
  64699. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  64700. export * from "babylonjs/Materials/Textures/Loaders/index";
  64701. export * from "babylonjs/Materials/Textures/mirrorTexture";
  64702. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  64703. export * from "babylonjs/Materials/Textures/Packer/index";
  64704. export * from "babylonjs/Materials/Textures/Procedurals/index";
  64705. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  64706. export * from "babylonjs/Materials/Textures/rawTexture";
  64707. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  64708. export * from "babylonjs/Materials/Textures/rawTexture3D";
  64709. export * from "babylonjs/Materials/Textures/refractionTexture";
  64710. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  64711. export * from "babylonjs/Materials/Textures/texture";
  64712. export * from "babylonjs/Materials/Textures/videoTexture";
  64713. }
  64714. declare module "babylonjs/Materials/Node/Enums/index" {
  64715. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  64716. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  64717. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  64718. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  64719. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  64720. }
  64721. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  64722. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64723. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64725. import { Mesh } from "babylonjs/Meshes/mesh";
  64726. import { Effect } from "babylonjs/Materials/effect";
  64727. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64728. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64729. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64730. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64731. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64732. /**
  64733. * Block used to add support for vertex skinning (bones)
  64734. */
  64735. export class BonesBlock extends NodeMaterialBlock {
  64736. /**
  64737. * Creates a new BonesBlock
  64738. * @param name defines the block name
  64739. */
  64740. constructor(name: string);
  64741. /**
  64742. * Initialize the block and prepare the context for build
  64743. * @param state defines the state that will be used for the build
  64744. */
  64745. initialize(state: NodeMaterialBuildState): void;
  64746. /**
  64747. * Gets the current class name
  64748. * @returns the class name
  64749. */
  64750. getClassName(): string;
  64751. /**
  64752. * Gets the matrix indices input component
  64753. */
  64754. get matricesIndices(): NodeMaterialConnectionPoint;
  64755. /**
  64756. * Gets the matrix weights input component
  64757. */
  64758. get matricesWeights(): NodeMaterialConnectionPoint;
  64759. /**
  64760. * Gets the extra matrix indices input component
  64761. */
  64762. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  64763. /**
  64764. * Gets the extra matrix weights input component
  64765. */
  64766. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  64767. /**
  64768. * Gets the world input component
  64769. */
  64770. get world(): NodeMaterialConnectionPoint;
  64771. /**
  64772. * Gets the output component
  64773. */
  64774. get output(): NodeMaterialConnectionPoint;
  64775. autoConfigure(material: NodeMaterial): void;
  64776. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  64777. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64778. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64779. protected _buildBlock(state: NodeMaterialBuildState): this;
  64780. }
  64781. }
  64782. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  64783. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64784. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64785. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64787. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64788. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64789. /**
  64790. * Block used to add support for instances
  64791. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  64792. */
  64793. export class InstancesBlock extends NodeMaterialBlock {
  64794. /**
  64795. * Creates a new InstancesBlock
  64796. * @param name defines the block name
  64797. */
  64798. constructor(name: string);
  64799. /**
  64800. * Gets the current class name
  64801. * @returns the class name
  64802. */
  64803. getClassName(): string;
  64804. /**
  64805. * Gets the first world row input component
  64806. */
  64807. get world0(): NodeMaterialConnectionPoint;
  64808. /**
  64809. * Gets the second world row input component
  64810. */
  64811. get world1(): NodeMaterialConnectionPoint;
  64812. /**
  64813. * Gets the third world row input component
  64814. */
  64815. get world2(): NodeMaterialConnectionPoint;
  64816. /**
  64817. * Gets the forth world row input component
  64818. */
  64819. get world3(): NodeMaterialConnectionPoint;
  64820. /**
  64821. * Gets the world input component
  64822. */
  64823. get world(): NodeMaterialConnectionPoint;
  64824. /**
  64825. * Gets the output component
  64826. */
  64827. get output(): NodeMaterialConnectionPoint;
  64828. /**
  64829. * Gets the isntanceID component
  64830. */
  64831. get instanceID(): NodeMaterialConnectionPoint;
  64832. autoConfigure(material: NodeMaterial): void;
  64833. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64834. protected _buildBlock(state: NodeMaterialBuildState): this;
  64835. }
  64836. }
  64837. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  64838. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64839. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64840. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64842. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64843. import { Effect } from "babylonjs/Materials/effect";
  64844. import { Mesh } from "babylonjs/Meshes/mesh";
  64845. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64846. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64847. /**
  64848. * Block used to add morph targets support to vertex shader
  64849. */
  64850. export class MorphTargetsBlock extends NodeMaterialBlock {
  64851. private _repeatableContentAnchor;
  64852. /**
  64853. * Create a new MorphTargetsBlock
  64854. * @param name defines the block name
  64855. */
  64856. constructor(name: string);
  64857. /**
  64858. * Gets the current class name
  64859. * @returns the class name
  64860. */
  64861. getClassName(): string;
  64862. /**
  64863. * Gets the position input component
  64864. */
  64865. get position(): NodeMaterialConnectionPoint;
  64866. /**
  64867. * Gets the normal input component
  64868. */
  64869. get normal(): NodeMaterialConnectionPoint;
  64870. /**
  64871. * Gets the tangent input component
  64872. */
  64873. get tangent(): NodeMaterialConnectionPoint;
  64874. /**
  64875. * Gets the tangent input component
  64876. */
  64877. get uv(): NodeMaterialConnectionPoint;
  64878. /**
  64879. * Gets the position output component
  64880. */
  64881. get positionOutput(): NodeMaterialConnectionPoint;
  64882. /**
  64883. * Gets the normal output component
  64884. */
  64885. get normalOutput(): NodeMaterialConnectionPoint;
  64886. /**
  64887. * Gets the tangent output component
  64888. */
  64889. get tangentOutput(): NodeMaterialConnectionPoint;
  64890. /**
  64891. * Gets the tangent output component
  64892. */
  64893. get uvOutput(): NodeMaterialConnectionPoint;
  64894. initialize(state: NodeMaterialBuildState): void;
  64895. autoConfigure(material: NodeMaterial): void;
  64896. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64897. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64898. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64899. protected _buildBlock(state: NodeMaterialBuildState): this;
  64900. }
  64901. }
  64902. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  64903. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64904. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64905. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64906. import { Nullable } from "babylonjs/types";
  64907. import { Scene } from "babylonjs/scene";
  64908. import { Effect } from "babylonjs/Materials/effect";
  64909. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64910. import { Mesh } from "babylonjs/Meshes/mesh";
  64911. import { Light } from "babylonjs/Lights/light";
  64912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64913. /**
  64914. * Block used to get data information from a light
  64915. */
  64916. export class LightInformationBlock extends NodeMaterialBlock {
  64917. private _lightDataUniformName;
  64918. private _lightColorUniformName;
  64919. private _lightTypeDefineName;
  64920. /**
  64921. * Gets or sets the light associated with this block
  64922. */
  64923. light: Nullable<Light>;
  64924. /**
  64925. * Creates a new LightInformationBlock
  64926. * @param name defines the block name
  64927. */
  64928. constructor(name: string);
  64929. /**
  64930. * Gets the current class name
  64931. * @returns the class name
  64932. */
  64933. getClassName(): string;
  64934. /**
  64935. * Gets the world position input component
  64936. */
  64937. get worldPosition(): NodeMaterialConnectionPoint;
  64938. /**
  64939. * Gets the direction output component
  64940. */
  64941. get direction(): NodeMaterialConnectionPoint;
  64942. /**
  64943. * Gets the direction output component
  64944. */
  64945. get color(): NodeMaterialConnectionPoint;
  64946. /**
  64947. * Gets the direction output component
  64948. */
  64949. get intensity(): NodeMaterialConnectionPoint;
  64950. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64951. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64952. protected _buildBlock(state: NodeMaterialBuildState): this;
  64953. serialize(): any;
  64954. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64955. }
  64956. }
  64957. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  64958. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  64959. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  64960. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  64961. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  64962. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  64963. }
  64964. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  64965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64966. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64967. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64969. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64970. import { Effect } from "babylonjs/Materials/effect";
  64971. import { Mesh } from "babylonjs/Meshes/mesh";
  64972. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64973. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  64974. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  64975. /**
  64976. * Block used to add image processing support to fragment shader
  64977. */
  64978. export class ImageProcessingBlock extends NodeMaterialBlock {
  64979. /**
  64980. * Create a new ImageProcessingBlock
  64981. * @param name defines the block name
  64982. */
  64983. constructor(name: string);
  64984. /**
  64985. * Gets the current class name
  64986. * @returns the class name
  64987. */
  64988. getClassName(): string;
  64989. /**
  64990. * Gets the color input component
  64991. */
  64992. get color(): NodeMaterialConnectionPoint;
  64993. /**
  64994. * Gets the output component
  64995. */
  64996. get output(): NodeMaterialConnectionPoint;
  64997. /**
  64998. * Initialize the block and prepare the context for build
  64999. * @param state defines the state that will be used for the build
  65000. */
  65001. initialize(state: NodeMaterialBuildState): void;
  65002. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65003. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65004. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65005. protected _buildBlock(state: NodeMaterialBuildState): this;
  65006. }
  65007. }
  65008. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65009. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65010. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65011. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65012. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65014. import { Effect } from "babylonjs/Materials/effect";
  65015. import { Mesh } from "babylonjs/Meshes/mesh";
  65016. import { Scene } from "babylonjs/scene";
  65017. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65018. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65019. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65020. /**
  65021. * Block used to pertub normals based on a normal map
  65022. */
  65023. export class PerturbNormalBlock extends NodeMaterialBlock {
  65024. private _tangentSpaceParameterName;
  65025. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65026. invertX: boolean;
  65027. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65028. invertY: boolean;
  65029. /**
  65030. * Create a new PerturbNormalBlock
  65031. * @param name defines the block name
  65032. */
  65033. constructor(name: string);
  65034. /**
  65035. * Gets the current class name
  65036. * @returns the class name
  65037. */
  65038. getClassName(): string;
  65039. /**
  65040. * Gets the world position input component
  65041. */
  65042. get worldPosition(): NodeMaterialConnectionPoint;
  65043. /**
  65044. * Gets the world normal input component
  65045. */
  65046. get worldNormal(): NodeMaterialConnectionPoint;
  65047. /**
  65048. * Gets the world tangent input component
  65049. */
  65050. get worldTangent(): NodeMaterialConnectionPoint;
  65051. /**
  65052. * Gets the uv input component
  65053. */
  65054. get uv(): NodeMaterialConnectionPoint;
  65055. /**
  65056. * Gets the normal map color input component
  65057. */
  65058. get normalMapColor(): NodeMaterialConnectionPoint;
  65059. /**
  65060. * Gets the strength input component
  65061. */
  65062. get strength(): NodeMaterialConnectionPoint;
  65063. /**
  65064. * Gets the output component
  65065. */
  65066. get output(): NodeMaterialConnectionPoint;
  65067. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65068. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65069. autoConfigure(material: NodeMaterial): void;
  65070. protected _buildBlock(state: NodeMaterialBuildState): this;
  65071. protected _dumpPropertiesCode(): string;
  65072. serialize(): any;
  65073. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65074. }
  65075. }
  65076. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65077. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65078. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65079. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65080. /**
  65081. * Block used to discard a pixel if a value is smaller than a cutoff
  65082. */
  65083. export class DiscardBlock extends NodeMaterialBlock {
  65084. /**
  65085. * Create a new DiscardBlock
  65086. * @param name defines the block name
  65087. */
  65088. constructor(name: string);
  65089. /**
  65090. * Gets the current class name
  65091. * @returns the class name
  65092. */
  65093. getClassName(): string;
  65094. /**
  65095. * Gets the color input component
  65096. */
  65097. get value(): NodeMaterialConnectionPoint;
  65098. /**
  65099. * Gets the cutoff input component
  65100. */
  65101. get cutoff(): NodeMaterialConnectionPoint;
  65102. protected _buildBlock(state: NodeMaterialBuildState): this;
  65103. }
  65104. }
  65105. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65106. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65107. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65108. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65109. /**
  65110. * Block used to test if the fragment shader is front facing
  65111. */
  65112. export class FrontFacingBlock extends NodeMaterialBlock {
  65113. /**
  65114. * Creates a new FrontFacingBlock
  65115. * @param name defines the block name
  65116. */
  65117. constructor(name: string);
  65118. /**
  65119. * Gets the current class name
  65120. * @returns the class name
  65121. */
  65122. getClassName(): string;
  65123. /**
  65124. * Gets the output component
  65125. */
  65126. get output(): NodeMaterialConnectionPoint;
  65127. protected _buildBlock(state: NodeMaterialBuildState): this;
  65128. }
  65129. }
  65130. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65131. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65132. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65133. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65134. /**
  65135. * Block used to get the derivative value on x and y of a given input
  65136. */
  65137. export class DerivativeBlock extends NodeMaterialBlock {
  65138. /**
  65139. * Create a new DerivativeBlock
  65140. * @param name defines the block name
  65141. */
  65142. constructor(name: string);
  65143. /**
  65144. * Gets the current class name
  65145. * @returns the class name
  65146. */
  65147. getClassName(): string;
  65148. /**
  65149. * Gets the input component
  65150. */
  65151. get input(): NodeMaterialConnectionPoint;
  65152. /**
  65153. * Gets the derivative output on x
  65154. */
  65155. get dx(): NodeMaterialConnectionPoint;
  65156. /**
  65157. * Gets the derivative output on y
  65158. */
  65159. get dy(): NodeMaterialConnectionPoint;
  65160. protected _buildBlock(state: NodeMaterialBuildState): this;
  65161. }
  65162. }
  65163. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65164. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65165. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65166. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65167. /**
  65168. * Block used to make gl_FragCoord available
  65169. */
  65170. export class FragCoordBlock extends NodeMaterialBlock {
  65171. /**
  65172. * Creates a new FragCoordBlock
  65173. * @param name defines the block name
  65174. */
  65175. constructor(name: string);
  65176. /**
  65177. * Gets the current class name
  65178. * @returns the class name
  65179. */
  65180. getClassName(): string;
  65181. /**
  65182. * Gets the xy component
  65183. */
  65184. get xy(): NodeMaterialConnectionPoint;
  65185. /**
  65186. * Gets the xyz component
  65187. */
  65188. get xyz(): NodeMaterialConnectionPoint;
  65189. /**
  65190. * Gets the xyzw component
  65191. */
  65192. get xyzw(): NodeMaterialConnectionPoint;
  65193. /**
  65194. * Gets the x component
  65195. */
  65196. get x(): NodeMaterialConnectionPoint;
  65197. /**
  65198. * Gets the y component
  65199. */
  65200. get y(): NodeMaterialConnectionPoint;
  65201. /**
  65202. * Gets the z component
  65203. */
  65204. get z(): NodeMaterialConnectionPoint;
  65205. /**
  65206. * Gets the w component
  65207. */
  65208. get output(): NodeMaterialConnectionPoint;
  65209. protected writeOutputs(state: NodeMaterialBuildState): string;
  65210. protected _buildBlock(state: NodeMaterialBuildState): this;
  65211. }
  65212. }
  65213. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65214. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65215. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65216. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65217. import { Effect } from "babylonjs/Materials/effect";
  65218. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65219. import { Mesh } from "babylonjs/Meshes/mesh";
  65220. /**
  65221. * Block used to get the screen sizes
  65222. */
  65223. export class ScreenSizeBlock extends NodeMaterialBlock {
  65224. private _varName;
  65225. private _scene;
  65226. /**
  65227. * Creates a new ScreenSizeBlock
  65228. * @param name defines the block name
  65229. */
  65230. constructor(name: string);
  65231. /**
  65232. * Gets the current class name
  65233. * @returns the class name
  65234. */
  65235. getClassName(): string;
  65236. /**
  65237. * Gets the xy component
  65238. */
  65239. get xy(): NodeMaterialConnectionPoint;
  65240. /**
  65241. * Gets the x component
  65242. */
  65243. get x(): NodeMaterialConnectionPoint;
  65244. /**
  65245. * Gets the y component
  65246. */
  65247. get y(): NodeMaterialConnectionPoint;
  65248. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65249. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  65250. protected _buildBlock(state: NodeMaterialBuildState): this;
  65251. }
  65252. }
  65253. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  65254. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  65255. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  65256. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  65257. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  65258. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  65259. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  65260. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  65261. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  65262. }
  65263. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  65264. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65265. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65266. import { Mesh } from "babylonjs/Meshes/mesh";
  65267. import { Effect } from "babylonjs/Materials/effect";
  65268. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65270. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65271. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  65272. /**
  65273. * Block used to add support for scene fog
  65274. */
  65275. export class FogBlock extends NodeMaterialBlock {
  65276. private _fogDistanceName;
  65277. private _fogParameters;
  65278. /**
  65279. * Create a new FogBlock
  65280. * @param name defines the block name
  65281. */
  65282. constructor(name: string);
  65283. /**
  65284. * Gets the current class name
  65285. * @returns the class name
  65286. */
  65287. getClassName(): string;
  65288. /**
  65289. * Gets the world position input component
  65290. */
  65291. get worldPosition(): NodeMaterialConnectionPoint;
  65292. /**
  65293. * Gets the view input component
  65294. */
  65295. get view(): NodeMaterialConnectionPoint;
  65296. /**
  65297. * Gets the color input component
  65298. */
  65299. get input(): NodeMaterialConnectionPoint;
  65300. /**
  65301. * Gets the fog color input component
  65302. */
  65303. get fogColor(): NodeMaterialConnectionPoint;
  65304. /**
  65305. * Gets the output component
  65306. */
  65307. get output(): NodeMaterialConnectionPoint;
  65308. autoConfigure(material: NodeMaterial): void;
  65309. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65310. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65311. protected _buildBlock(state: NodeMaterialBuildState): this;
  65312. }
  65313. }
  65314. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  65315. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65316. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65317. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65319. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65320. import { Effect } from "babylonjs/Materials/effect";
  65321. import { Mesh } from "babylonjs/Meshes/mesh";
  65322. import { Light } from "babylonjs/Lights/light";
  65323. import { Nullable } from "babylonjs/types";
  65324. import { Scene } from "babylonjs/scene";
  65325. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  65326. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  65327. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  65328. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65329. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  65330. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  65331. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  65332. /**
  65333. * Block used to add light in the fragment shader
  65334. */
  65335. export class LightBlock extends NodeMaterialBlock {
  65336. private _lightId;
  65337. /**
  65338. * Gets or sets the light associated with this block
  65339. */
  65340. light: Nullable<Light>;
  65341. /**
  65342. * Create a new LightBlock
  65343. * @param name defines the block name
  65344. */
  65345. constructor(name: string);
  65346. /**
  65347. * Gets the current class name
  65348. * @returns the class name
  65349. */
  65350. getClassName(): string;
  65351. /**
  65352. * Gets the world position input component
  65353. */
  65354. get worldPosition(): NodeMaterialConnectionPoint;
  65355. /**
  65356. * Gets the world normal input component
  65357. */
  65358. get worldNormal(): NodeMaterialConnectionPoint;
  65359. /**
  65360. * Gets the camera (or eye) position component
  65361. */
  65362. get cameraPosition(): NodeMaterialConnectionPoint;
  65363. /**
  65364. * Gets the glossiness component
  65365. */
  65366. get glossiness(): NodeMaterialConnectionPoint;
  65367. /**
  65368. * Gets the glossinness power component
  65369. */
  65370. get glossPower(): NodeMaterialConnectionPoint;
  65371. /**
  65372. * Gets the diffuse color component
  65373. */
  65374. get diffuseColor(): NodeMaterialConnectionPoint;
  65375. /**
  65376. * Gets the specular color component
  65377. */
  65378. get specularColor(): NodeMaterialConnectionPoint;
  65379. /**
  65380. * Gets the diffuse output component
  65381. */
  65382. get diffuseOutput(): NodeMaterialConnectionPoint;
  65383. /**
  65384. * Gets the specular output component
  65385. */
  65386. get specularOutput(): NodeMaterialConnectionPoint;
  65387. /**
  65388. * Gets the shadow output component
  65389. */
  65390. get shadow(): NodeMaterialConnectionPoint;
  65391. autoConfigure(material: NodeMaterial): void;
  65392. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65393. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65394. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65395. private _injectVertexCode;
  65396. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65397. serialize(): any;
  65398. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65399. }
  65400. }
  65401. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  65402. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65403. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65404. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65405. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65406. /**
  65407. * Block used to read a reflection texture from a sampler
  65408. */
  65409. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  65410. /**
  65411. * Create a new ReflectionTextureBlock
  65412. * @param name defines the block name
  65413. */
  65414. constructor(name: string);
  65415. /**
  65416. * Gets the current class name
  65417. * @returns the class name
  65418. */
  65419. getClassName(): string;
  65420. /**
  65421. * Gets the world position input component
  65422. */
  65423. get position(): NodeMaterialConnectionPoint;
  65424. /**
  65425. * Gets the world position input component
  65426. */
  65427. get worldPosition(): NodeMaterialConnectionPoint;
  65428. /**
  65429. * Gets the world normal input component
  65430. */
  65431. get worldNormal(): NodeMaterialConnectionPoint;
  65432. /**
  65433. * Gets the world input component
  65434. */
  65435. get world(): NodeMaterialConnectionPoint;
  65436. /**
  65437. * Gets the camera (or eye) position component
  65438. */
  65439. get cameraPosition(): NodeMaterialConnectionPoint;
  65440. /**
  65441. * Gets the view input component
  65442. */
  65443. get view(): NodeMaterialConnectionPoint;
  65444. /**
  65445. * Gets the rgb output component
  65446. */
  65447. get rgb(): NodeMaterialConnectionPoint;
  65448. /**
  65449. * Gets the rgba output component
  65450. */
  65451. get rgba(): NodeMaterialConnectionPoint;
  65452. /**
  65453. * Gets the r output component
  65454. */
  65455. get r(): NodeMaterialConnectionPoint;
  65456. /**
  65457. * Gets the g output component
  65458. */
  65459. get g(): NodeMaterialConnectionPoint;
  65460. /**
  65461. * Gets the b output component
  65462. */
  65463. get b(): NodeMaterialConnectionPoint;
  65464. /**
  65465. * Gets the a output component
  65466. */
  65467. get a(): NodeMaterialConnectionPoint;
  65468. autoConfigure(material: NodeMaterial): void;
  65469. protected _buildBlock(state: NodeMaterialBuildState): this;
  65470. }
  65471. }
  65472. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  65473. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  65474. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  65475. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  65476. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  65477. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  65478. }
  65479. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  65480. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  65481. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  65482. }
  65483. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  65484. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65485. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65486. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65487. /**
  65488. * Block used to add 2 vectors
  65489. */
  65490. export class AddBlock extends NodeMaterialBlock {
  65491. /**
  65492. * Creates a new AddBlock
  65493. * @param name defines the block name
  65494. */
  65495. constructor(name: string);
  65496. /**
  65497. * Gets the current class name
  65498. * @returns the class name
  65499. */
  65500. getClassName(): string;
  65501. /**
  65502. * Gets the left operand input component
  65503. */
  65504. get left(): NodeMaterialConnectionPoint;
  65505. /**
  65506. * Gets the right operand input component
  65507. */
  65508. get right(): NodeMaterialConnectionPoint;
  65509. /**
  65510. * Gets the output component
  65511. */
  65512. get output(): NodeMaterialConnectionPoint;
  65513. protected _buildBlock(state: NodeMaterialBuildState): this;
  65514. }
  65515. }
  65516. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  65517. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65518. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65519. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65520. /**
  65521. * Block used to scale a vector by a float
  65522. */
  65523. export class ScaleBlock extends NodeMaterialBlock {
  65524. /**
  65525. * Creates a new ScaleBlock
  65526. * @param name defines the block name
  65527. */
  65528. constructor(name: string);
  65529. /**
  65530. * Gets the current class name
  65531. * @returns the class name
  65532. */
  65533. getClassName(): string;
  65534. /**
  65535. * Gets the input component
  65536. */
  65537. get input(): NodeMaterialConnectionPoint;
  65538. /**
  65539. * Gets the factor input component
  65540. */
  65541. get factor(): NodeMaterialConnectionPoint;
  65542. /**
  65543. * Gets the output component
  65544. */
  65545. get output(): NodeMaterialConnectionPoint;
  65546. protected _buildBlock(state: NodeMaterialBuildState): this;
  65547. }
  65548. }
  65549. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  65550. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65551. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65552. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65553. import { Scene } from "babylonjs/scene";
  65554. /**
  65555. * Block used to clamp a float
  65556. */
  65557. export class ClampBlock extends NodeMaterialBlock {
  65558. /** Gets or sets the minimum range */
  65559. minimum: number;
  65560. /** Gets or sets the maximum range */
  65561. maximum: number;
  65562. /**
  65563. * Creates a new ClampBlock
  65564. * @param name defines the block name
  65565. */
  65566. constructor(name: string);
  65567. /**
  65568. * Gets the current class name
  65569. * @returns the class name
  65570. */
  65571. getClassName(): string;
  65572. /**
  65573. * Gets the value input component
  65574. */
  65575. get value(): NodeMaterialConnectionPoint;
  65576. /**
  65577. * Gets the output component
  65578. */
  65579. get output(): NodeMaterialConnectionPoint;
  65580. protected _buildBlock(state: NodeMaterialBuildState): this;
  65581. protected _dumpPropertiesCode(): string;
  65582. serialize(): any;
  65583. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65584. }
  65585. }
  65586. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  65587. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65588. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65589. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65590. /**
  65591. * Block used to apply a cross product between 2 vectors
  65592. */
  65593. export class CrossBlock extends NodeMaterialBlock {
  65594. /**
  65595. * Creates a new CrossBlock
  65596. * @param name defines the block name
  65597. */
  65598. constructor(name: string);
  65599. /**
  65600. * Gets the current class name
  65601. * @returns the class name
  65602. */
  65603. getClassName(): string;
  65604. /**
  65605. * Gets the left operand input component
  65606. */
  65607. get left(): NodeMaterialConnectionPoint;
  65608. /**
  65609. * Gets the right operand input component
  65610. */
  65611. get right(): NodeMaterialConnectionPoint;
  65612. /**
  65613. * Gets the output component
  65614. */
  65615. get output(): NodeMaterialConnectionPoint;
  65616. protected _buildBlock(state: NodeMaterialBuildState): this;
  65617. }
  65618. }
  65619. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  65620. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65621. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65622. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65623. /**
  65624. * Block used to apply a dot product between 2 vectors
  65625. */
  65626. export class DotBlock extends NodeMaterialBlock {
  65627. /**
  65628. * Creates a new DotBlock
  65629. * @param name defines the block name
  65630. */
  65631. constructor(name: string);
  65632. /**
  65633. * Gets the current class name
  65634. * @returns the class name
  65635. */
  65636. getClassName(): string;
  65637. /**
  65638. * Gets the left operand input component
  65639. */
  65640. get left(): NodeMaterialConnectionPoint;
  65641. /**
  65642. * Gets the right operand input component
  65643. */
  65644. get right(): NodeMaterialConnectionPoint;
  65645. /**
  65646. * Gets the output component
  65647. */
  65648. get output(): NodeMaterialConnectionPoint;
  65649. protected _buildBlock(state: NodeMaterialBuildState): this;
  65650. }
  65651. }
  65652. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  65653. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65654. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65655. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65656. /**
  65657. * Block used to normalize a vector
  65658. */
  65659. export class NormalizeBlock extends NodeMaterialBlock {
  65660. /**
  65661. * Creates a new NormalizeBlock
  65662. * @param name defines the block name
  65663. */
  65664. constructor(name: string);
  65665. /**
  65666. * Gets the current class name
  65667. * @returns the class name
  65668. */
  65669. getClassName(): string;
  65670. /**
  65671. * Gets the input component
  65672. */
  65673. get input(): NodeMaterialConnectionPoint;
  65674. /**
  65675. * Gets the output component
  65676. */
  65677. get output(): NodeMaterialConnectionPoint;
  65678. protected _buildBlock(state: NodeMaterialBuildState): this;
  65679. }
  65680. }
  65681. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  65682. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65683. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65684. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65685. import { Scene } from "babylonjs/scene";
  65686. /**
  65687. * Operations supported by the Trigonometry block
  65688. */
  65689. export enum TrigonometryBlockOperations {
  65690. /** Cos */
  65691. Cos = 0,
  65692. /** Sin */
  65693. Sin = 1,
  65694. /** Abs */
  65695. Abs = 2,
  65696. /** Exp */
  65697. Exp = 3,
  65698. /** Exp2 */
  65699. Exp2 = 4,
  65700. /** Round */
  65701. Round = 5,
  65702. /** Floor */
  65703. Floor = 6,
  65704. /** Ceiling */
  65705. Ceiling = 7,
  65706. /** Square root */
  65707. Sqrt = 8,
  65708. /** Log */
  65709. Log = 9,
  65710. /** Tangent */
  65711. Tan = 10,
  65712. /** Arc tangent */
  65713. ArcTan = 11,
  65714. /** Arc cosinus */
  65715. ArcCos = 12,
  65716. /** Arc sinus */
  65717. ArcSin = 13,
  65718. /** Fraction */
  65719. Fract = 14,
  65720. /** Sign */
  65721. Sign = 15,
  65722. /** To radians (from degrees) */
  65723. Radians = 16,
  65724. /** To degrees (from radians) */
  65725. Degrees = 17
  65726. }
  65727. /**
  65728. * Block used to apply trigonometry operation to floats
  65729. */
  65730. export class TrigonometryBlock extends NodeMaterialBlock {
  65731. /**
  65732. * Gets or sets the operation applied by the block
  65733. */
  65734. operation: TrigonometryBlockOperations;
  65735. /**
  65736. * Creates a new TrigonometryBlock
  65737. * @param name defines the block name
  65738. */
  65739. constructor(name: string);
  65740. /**
  65741. * Gets the current class name
  65742. * @returns the class name
  65743. */
  65744. getClassName(): string;
  65745. /**
  65746. * Gets the input component
  65747. */
  65748. get input(): NodeMaterialConnectionPoint;
  65749. /**
  65750. * Gets the output component
  65751. */
  65752. get output(): NodeMaterialConnectionPoint;
  65753. protected _buildBlock(state: NodeMaterialBuildState): this;
  65754. serialize(): any;
  65755. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65756. protected _dumpPropertiesCode(): string;
  65757. }
  65758. }
  65759. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  65760. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65761. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65762. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65763. /**
  65764. * Block used to create a Color3/4 out of individual inputs (one for each component)
  65765. */
  65766. export class ColorMergerBlock extends NodeMaterialBlock {
  65767. /**
  65768. * Create a new ColorMergerBlock
  65769. * @param name defines the block name
  65770. */
  65771. constructor(name: string);
  65772. /**
  65773. * Gets the current class name
  65774. * @returns the class name
  65775. */
  65776. getClassName(): string;
  65777. /**
  65778. * Gets the rgb component (input)
  65779. */
  65780. get rgbIn(): NodeMaterialConnectionPoint;
  65781. /**
  65782. * Gets the r component (input)
  65783. */
  65784. get r(): NodeMaterialConnectionPoint;
  65785. /**
  65786. * Gets the g component (input)
  65787. */
  65788. get g(): NodeMaterialConnectionPoint;
  65789. /**
  65790. * Gets the b component (input)
  65791. */
  65792. get b(): NodeMaterialConnectionPoint;
  65793. /**
  65794. * Gets the a component (input)
  65795. */
  65796. get a(): NodeMaterialConnectionPoint;
  65797. /**
  65798. * Gets the rgba component (output)
  65799. */
  65800. get rgba(): NodeMaterialConnectionPoint;
  65801. /**
  65802. * Gets the rgb component (output)
  65803. */
  65804. get rgbOut(): NodeMaterialConnectionPoint;
  65805. /**
  65806. * Gets the rgb component (output)
  65807. * @deprecated Please use rgbOut instead.
  65808. */
  65809. get rgb(): NodeMaterialConnectionPoint;
  65810. protected _buildBlock(state: NodeMaterialBuildState): this;
  65811. }
  65812. }
  65813. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  65814. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65815. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65816. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65817. /**
  65818. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  65819. */
  65820. export class VectorSplitterBlock extends NodeMaterialBlock {
  65821. /**
  65822. * Create a new VectorSplitterBlock
  65823. * @param name defines the block name
  65824. */
  65825. constructor(name: string);
  65826. /**
  65827. * Gets the current class name
  65828. * @returns the class name
  65829. */
  65830. getClassName(): string;
  65831. /**
  65832. * Gets the xyzw component (input)
  65833. */
  65834. get xyzw(): NodeMaterialConnectionPoint;
  65835. /**
  65836. * Gets the xyz component (input)
  65837. */
  65838. get xyzIn(): NodeMaterialConnectionPoint;
  65839. /**
  65840. * Gets the xy component (input)
  65841. */
  65842. get xyIn(): NodeMaterialConnectionPoint;
  65843. /**
  65844. * Gets the xyz component (output)
  65845. */
  65846. get xyzOut(): NodeMaterialConnectionPoint;
  65847. /**
  65848. * Gets the xy component (output)
  65849. */
  65850. get xyOut(): NodeMaterialConnectionPoint;
  65851. /**
  65852. * Gets the x component (output)
  65853. */
  65854. get x(): NodeMaterialConnectionPoint;
  65855. /**
  65856. * Gets the y component (output)
  65857. */
  65858. get y(): NodeMaterialConnectionPoint;
  65859. /**
  65860. * Gets the z component (output)
  65861. */
  65862. get z(): NodeMaterialConnectionPoint;
  65863. /**
  65864. * Gets the w component (output)
  65865. */
  65866. get w(): NodeMaterialConnectionPoint;
  65867. protected _inputRename(name: string): string;
  65868. protected _outputRename(name: string): string;
  65869. protected _buildBlock(state: NodeMaterialBuildState): this;
  65870. }
  65871. }
  65872. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  65873. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65874. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65875. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65876. /**
  65877. * Block used to lerp between 2 values
  65878. */
  65879. export class LerpBlock extends NodeMaterialBlock {
  65880. /**
  65881. * Creates a new LerpBlock
  65882. * @param name defines the block name
  65883. */
  65884. constructor(name: string);
  65885. /**
  65886. * Gets the current class name
  65887. * @returns the class name
  65888. */
  65889. getClassName(): string;
  65890. /**
  65891. * Gets the left operand input component
  65892. */
  65893. get left(): NodeMaterialConnectionPoint;
  65894. /**
  65895. * Gets the right operand input component
  65896. */
  65897. get right(): NodeMaterialConnectionPoint;
  65898. /**
  65899. * Gets the gradient operand input component
  65900. */
  65901. get gradient(): NodeMaterialConnectionPoint;
  65902. /**
  65903. * Gets the output component
  65904. */
  65905. get output(): NodeMaterialConnectionPoint;
  65906. protected _buildBlock(state: NodeMaterialBuildState): this;
  65907. }
  65908. }
  65909. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  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 divide 2 vectors
  65915. */
  65916. export class DivideBlock extends NodeMaterialBlock {
  65917. /**
  65918. * Creates a new DivideBlock
  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 left operand input component
  65929. */
  65930. get left(): NodeMaterialConnectionPoint;
  65931. /**
  65932. * Gets the right operand input component
  65933. */
  65934. get right(): NodeMaterialConnectionPoint;
  65935. /**
  65936. * Gets the output component
  65937. */
  65938. get output(): NodeMaterialConnectionPoint;
  65939. protected _buildBlock(state: NodeMaterialBuildState): this;
  65940. }
  65941. }
  65942. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  65943. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65944. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65945. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65946. /**
  65947. * Block used to subtract 2 vectors
  65948. */
  65949. export class SubtractBlock extends NodeMaterialBlock {
  65950. /**
  65951. * Creates a new SubtractBlock
  65952. * @param name defines the block name
  65953. */
  65954. constructor(name: string);
  65955. /**
  65956. * Gets the current class name
  65957. * @returns the class name
  65958. */
  65959. getClassName(): string;
  65960. /**
  65961. * Gets the left operand input component
  65962. */
  65963. get left(): NodeMaterialConnectionPoint;
  65964. /**
  65965. * Gets the right operand input component
  65966. */
  65967. get right(): NodeMaterialConnectionPoint;
  65968. /**
  65969. * Gets the output component
  65970. */
  65971. get output(): NodeMaterialConnectionPoint;
  65972. protected _buildBlock(state: NodeMaterialBuildState): this;
  65973. }
  65974. }
  65975. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  65976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65977. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65979. /**
  65980. * Block used to step a value
  65981. */
  65982. export class StepBlock extends NodeMaterialBlock {
  65983. /**
  65984. * Creates a new StepBlock
  65985. * @param name defines the block name
  65986. */
  65987. constructor(name: string);
  65988. /**
  65989. * Gets the current class name
  65990. * @returns the class name
  65991. */
  65992. getClassName(): string;
  65993. /**
  65994. * Gets the value operand input component
  65995. */
  65996. get value(): NodeMaterialConnectionPoint;
  65997. /**
  65998. * Gets the edge operand input component
  65999. */
  66000. get edge(): NodeMaterialConnectionPoint;
  66001. /**
  66002. * Gets the output component
  66003. */
  66004. get output(): NodeMaterialConnectionPoint;
  66005. protected _buildBlock(state: NodeMaterialBuildState): this;
  66006. }
  66007. }
  66008. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66009. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66010. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66011. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66012. /**
  66013. * Block used to get the opposite (1 - x) of a value
  66014. */
  66015. export class OneMinusBlock extends NodeMaterialBlock {
  66016. /**
  66017. * Creates a new OneMinusBlock
  66018. * @param name defines the block name
  66019. */
  66020. constructor(name: string);
  66021. /**
  66022. * Gets the current class name
  66023. * @returns the class name
  66024. */
  66025. getClassName(): string;
  66026. /**
  66027. * Gets the input component
  66028. */
  66029. get input(): NodeMaterialConnectionPoint;
  66030. /**
  66031. * Gets the output component
  66032. */
  66033. get output(): NodeMaterialConnectionPoint;
  66034. protected _buildBlock(state: NodeMaterialBuildState): this;
  66035. }
  66036. }
  66037. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66038. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66039. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66040. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66041. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66042. /**
  66043. * Block used to get the view direction
  66044. */
  66045. export class ViewDirectionBlock extends NodeMaterialBlock {
  66046. /**
  66047. * Creates a new ViewDirectionBlock
  66048. * @param name defines the block name
  66049. */
  66050. constructor(name: string);
  66051. /**
  66052. * Gets the current class name
  66053. * @returns the class name
  66054. */
  66055. getClassName(): string;
  66056. /**
  66057. * Gets the world position component
  66058. */
  66059. get worldPosition(): NodeMaterialConnectionPoint;
  66060. /**
  66061. * Gets the camera position component
  66062. */
  66063. get cameraPosition(): NodeMaterialConnectionPoint;
  66064. /**
  66065. * Gets the output component
  66066. */
  66067. get output(): NodeMaterialConnectionPoint;
  66068. autoConfigure(material: NodeMaterial): void;
  66069. protected _buildBlock(state: NodeMaterialBuildState): this;
  66070. }
  66071. }
  66072. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66073. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66074. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66075. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66076. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66077. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66078. /**
  66079. * Block used to compute fresnel value
  66080. */
  66081. export class FresnelBlock extends NodeMaterialBlock {
  66082. /**
  66083. * Create a new FresnelBlock
  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 normal input component
  66094. */
  66095. get worldNormal(): NodeMaterialConnectionPoint;
  66096. /**
  66097. * Gets the view direction input component
  66098. */
  66099. get viewDirection(): NodeMaterialConnectionPoint;
  66100. /**
  66101. * Gets the bias input component
  66102. */
  66103. get bias(): NodeMaterialConnectionPoint;
  66104. /**
  66105. * Gets the camera (or eye) position component
  66106. */
  66107. get power(): NodeMaterialConnectionPoint;
  66108. /**
  66109. * Gets the fresnel output component
  66110. */
  66111. get fresnel(): NodeMaterialConnectionPoint;
  66112. autoConfigure(material: NodeMaterial): void;
  66113. protected _buildBlock(state: NodeMaterialBuildState): this;
  66114. }
  66115. }
  66116. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66117. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66118. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66119. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66120. /**
  66121. * Block used to get the max of 2 values
  66122. */
  66123. export class MaxBlock extends NodeMaterialBlock {
  66124. /**
  66125. * Creates a new MaxBlock
  66126. * @param name defines the block name
  66127. */
  66128. constructor(name: string);
  66129. /**
  66130. * Gets the current class name
  66131. * @returns the class name
  66132. */
  66133. getClassName(): string;
  66134. /**
  66135. * Gets the left operand input component
  66136. */
  66137. get left(): NodeMaterialConnectionPoint;
  66138. /**
  66139. * Gets the right operand input component
  66140. */
  66141. get right(): NodeMaterialConnectionPoint;
  66142. /**
  66143. * Gets the output component
  66144. */
  66145. get output(): NodeMaterialConnectionPoint;
  66146. protected _buildBlock(state: NodeMaterialBuildState): this;
  66147. }
  66148. }
  66149. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66150. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66151. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66152. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66153. /**
  66154. * Block used to get the min of 2 values
  66155. */
  66156. export class MinBlock extends NodeMaterialBlock {
  66157. /**
  66158. * Creates a new MinBlock
  66159. * @param name defines the block name
  66160. */
  66161. constructor(name: string);
  66162. /**
  66163. * Gets the current class name
  66164. * @returns the class name
  66165. */
  66166. getClassName(): string;
  66167. /**
  66168. * Gets the left operand input component
  66169. */
  66170. get left(): NodeMaterialConnectionPoint;
  66171. /**
  66172. * Gets the right operand input component
  66173. */
  66174. get right(): NodeMaterialConnectionPoint;
  66175. /**
  66176. * Gets the output component
  66177. */
  66178. get output(): NodeMaterialConnectionPoint;
  66179. protected _buildBlock(state: NodeMaterialBuildState): this;
  66180. }
  66181. }
  66182. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66183. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66184. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66185. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66186. /**
  66187. * Block used to get the distance between 2 values
  66188. */
  66189. export class DistanceBlock extends NodeMaterialBlock {
  66190. /**
  66191. * Creates a new DistanceBlock
  66192. * @param name defines the block name
  66193. */
  66194. constructor(name: string);
  66195. /**
  66196. * Gets the current class name
  66197. * @returns the class name
  66198. */
  66199. getClassName(): string;
  66200. /**
  66201. * Gets the left operand input component
  66202. */
  66203. get left(): NodeMaterialConnectionPoint;
  66204. /**
  66205. * Gets the right operand input component
  66206. */
  66207. get right(): NodeMaterialConnectionPoint;
  66208. /**
  66209. * Gets the output component
  66210. */
  66211. get output(): NodeMaterialConnectionPoint;
  66212. protected _buildBlock(state: NodeMaterialBuildState): this;
  66213. }
  66214. }
  66215. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66216. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66217. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66218. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66219. /**
  66220. * Block used to get the length of a vector
  66221. */
  66222. export class LengthBlock extends NodeMaterialBlock {
  66223. /**
  66224. * Creates a new LengthBlock
  66225. * @param name defines the block name
  66226. */
  66227. constructor(name: string);
  66228. /**
  66229. * Gets the current class name
  66230. * @returns the class name
  66231. */
  66232. getClassName(): string;
  66233. /**
  66234. * Gets the value input component
  66235. */
  66236. get value(): NodeMaterialConnectionPoint;
  66237. /**
  66238. * Gets the output component
  66239. */
  66240. get output(): NodeMaterialConnectionPoint;
  66241. protected _buildBlock(state: NodeMaterialBuildState): this;
  66242. }
  66243. }
  66244. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66245. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66246. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66247. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66248. /**
  66249. * Block used to get negative version of a value (i.e. x * -1)
  66250. */
  66251. export class NegateBlock extends NodeMaterialBlock {
  66252. /**
  66253. * Creates a new NegateBlock
  66254. * @param name defines the block name
  66255. */
  66256. constructor(name: string);
  66257. /**
  66258. * Gets the current class name
  66259. * @returns the class name
  66260. */
  66261. getClassName(): string;
  66262. /**
  66263. * Gets the value input component
  66264. */
  66265. get value(): NodeMaterialConnectionPoint;
  66266. /**
  66267. * Gets the output component
  66268. */
  66269. get output(): NodeMaterialConnectionPoint;
  66270. protected _buildBlock(state: NodeMaterialBuildState): this;
  66271. }
  66272. }
  66273. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66274. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66275. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66276. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66277. /**
  66278. * Block used to get the value of the first parameter raised to the power of the second
  66279. */
  66280. export class PowBlock extends NodeMaterialBlock {
  66281. /**
  66282. * Creates a new PowBlock
  66283. * @param name defines the block name
  66284. */
  66285. constructor(name: string);
  66286. /**
  66287. * Gets the current class name
  66288. * @returns the class name
  66289. */
  66290. getClassName(): string;
  66291. /**
  66292. * Gets the value operand input component
  66293. */
  66294. get value(): NodeMaterialConnectionPoint;
  66295. /**
  66296. * Gets the power operand input component
  66297. */
  66298. get power(): NodeMaterialConnectionPoint;
  66299. /**
  66300. * Gets the output component
  66301. */
  66302. get output(): NodeMaterialConnectionPoint;
  66303. protected _buildBlock(state: NodeMaterialBuildState): this;
  66304. }
  66305. }
  66306. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66307. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66308. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66309. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66310. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66311. /**
  66312. * Block used to get a random number
  66313. */
  66314. export class RandomNumberBlock extends NodeMaterialBlock {
  66315. /**
  66316. * Creates a new RandomNumberBlock
  66317. * @param name defines the block name
  66318. */
  66319. constructor(name: string);
  66320. /**
  66321. * Gets the current class name
  66322. * @returns the class name
  66323. */
  66324. getClassName(): string;
  66325. /**
  66326. * Gets the seed input component
  66327. */
  66328. get seed(): NodeMaterialConnectionPoint;
  66329. /**
  66330. * Gets the output component
  66331. */
  66332. get output(): NodeMaterialConnectionPoint;
  66333. protected _buildBlock(state: NodeMaterialBuildState): this;
  66334. }
  66335. }
  66336. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  66337. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66338. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66339. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66340. /**
  66341. * Block used to compute arc tangent of 2 values
  66342. */
  66343. export class ArcTan2Block extends NodeMaterialBlock {
  66344. /**
  66345. * Creates a new ArcTan2Block
  66346. * @param name defines the block name
  66347. */
  66348. constructor(name: string);
  66349. /**
  66350. * Gets the current class name
  66351. * @returns the class name
  66352. */
  66353. getClassName(): string;
  66354. /**
  66355. * Gets the x operand input component
  66356. */
  66357. get x(): NodeMaterialConnectionPoint;
  66358. /**
  66359. * Gets the y operand input component
  66360. */
  66361. get y(): NodeMaterialConnectionPoint;
  66362. /**
  66363. * Gets the output component
  66364. */
  66365. get output(): NodeMaterialConnectionPoint;
  66366. protected _buildBlock(state: NodeMaterialBuildState): this;
  66367. }
  66368. }
  66369. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  66370. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66371. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66372. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66373. /**
  66374. * Block used to smooth step a value
  66375. */
  66376. export class SmoothStepBlock extends NodeMaterialBlock {
  66377. /**
  66378. * Creates a new SmoothStepBlock
  66379. * @param name defines the block name
  66380. */
  66381. constructor(name: string);
  66382. /**
  66383. * Gets the current class name
  66384. * @returns the class name
  66385. */
  66386. getClassName(): string;
  66387. /**
  66388. * Gets the value operand input component
  66389. */
  66390. get value(): NodeMaterialConnectionPoint;
  66391. /**
  66392. * Gets the first edge operand input component
  66393. */
  66394. get edge0(): NodeMaterialConnectionPoint;
  66395. /**
  66396. * Gets the second edge operand input component
  66397. */
  66398. get edge1(): NodeMaterialConnectionPoint;
  66399. /**
  66400. * Gets the output component
  66401. */
  66402. get output(): NodeMaterialConnectionPoint;
  66403. protected _buildBlock(state: NodeMaterialBuildState): this;
  66404. }
  66405. }
  66406. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  66407. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66408. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66409. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66410. /**
  66411. * Block used to get the reciprocal (1 / x) of a value
  66412. */
  66413. export class ReciprocalBlock extends NodeMaterialBlock {
  66414. /**
  66415. * Creates a new ReciprocalBlock
  66416. * @param name defines the block name
  66417. */
  66418. constructor(name: string);
  66419. /**
  66420. * Gets the current class name
  66421. * @returns the class name
  66422. */
  66423. getClassName(): string;
  66424. /**
  66425. * Gets the input component
  66426. */
  66427. get input(): NodeMaterialConnectionPoint;
  66428. /**
  66429. * Gets the output component
  66430. */
  66431. get output(): NodeMaterialConnectionPoint;
  66432. protected _buildBlock(state: NodeMaterialBuildState): this;
  66433. }
  66434. }
  66435. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  66436. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66437. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66438. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66439. /**
  66440. * Block used to replace a color by another one
  66441. */
  66442. export class ReplaceColorBlock extends NodeMaterialBlock {
  66443. /**
  66444. * Creates a new ReplaceColorBlock
  66445. * @param name defines the block name
  66446. */
  66447. constructor(name: string);
  66448. /**
  66449. * Gets the current class name
  66450. * @returns the class name
  66451. */
  66452. getClassName(): string;
  66453. /**
  66454. * Gets the value input component
  66455. */
  66456. get value(): NodeMaterialConnectionPoint;
  66457. /**
  66458. * Gets the reference input component
  66459. */
  66460. get reference(): NodeMaterialConnectionPoint;
  66461. /**
  66462. * Gets the distance input component
  66463. */
  66464. get distance(): NodeMaterialConnectionPoint;
  66465. /**
  66466. * Gets the replacement input component
  66467. */
  66468. get replacement(): NodeMaterialConnectionPoint;
  66469. /**
  66470. * Gets the output component
  66471. */
  66472. get output(): NodeMaterialConnectionPoint;
  66473. protected _buildBlock(state: NodeMaterialBuildState): this;
  66474. }
  66475. }
  66476. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  66477. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66478. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66479. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66480. /**
  66481. * Block used to posterize a value
  66482. * @see https://en.wikipedia.org/wiki/Posterization
  66483. */
  66484. export class PosterizeBlock extends NodeMaterialBlock {
  66485. /**
  66486. * Creates a new PosterizeBlock
  66487. * @param name defines the block name
  66488. */
  66489. constructor(name: string);
  66490. /**
  66491. * Gets the current class name
  66492. * @returns the class name
  66493. */
  66494. getClassName(): string;
  66495. /**
  66496. * Gets the value input component
  66497. */
  66498. get value(): NodeMaterialConnectionPoint;
  66499. /**
  66500. * Gets the steps input component
  66501. */
  66502. get steps(): NodeMaterialConnectionPoint;
  66503. /**
  66504. * Gets the output component
  66505. */
  66506. get output(): NodeMaterialConnectionPoint;
  66507. protected _buildBlock(state: NodeMaterialBuildState): this;
  66508. }
  66509. }
  66510. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  66511. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66512. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66513. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66514. import { Scene } from "babylonjs/scene";
  66515. /**
  66516. * Operations supported by the Wave block
  66517. */
  66518. export enum WaveBlockKind {
  66519. /** SawTooth */
  66520. SawTooth = 0,
  66521. /** Square */
  66522. Square = 1,
  66523. /** Triangle */
  66524. Triangle = 2
  66525. }
  66526. /**
  66527. * Block used to apply wave operation to floats
  66528. */
  66529. export class WaveBlock extends NodeMaterialBlock {
  66530. /**
  66531. * Gets or sets the kibnd of wave to be applied by the block
  66532. */
  66533. kind: WaveBlockKind;
  66534. /**
  66535. * Creates a new WaveBlock
  66536. * @param name defines the block name
  66537. */
  66538. constructor(name: string);
  66539. /**
  66540. * Gets the current class name
  66541. * @returns the class name
  66542. */
  66543. getClassName(): string;
  66544. /**
  66545. * Gets the input component
  66546. */
  66547. get input(): NodeMaterialConnectionPoint;
  66548. /**
  66549. * Gets the output component
  66550. */
  66551. get output(): NodeMaterialConnectionPoint;
  66552. protected _buildBlock(state: NodeMaterialBuildState): this;
  66553. serialize(): any;
  66554. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66555. }
  66556. }
  66557. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  66558. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66559. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66560. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66561. import { Color3 } from "babylonjs/Maths/math.color";
  66562. import { Scene } from "babylonjs/scene";
  66563. /**
  66564. * Class used to store a color step for the GradientBlock
  66565. */
  66566. export class GradientBlockColorStep {
  66567. /**
  66568. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66569. */
  66570. step: number;
  66571. /**
  66572. * Gets or sets the color associated with this step
  66573. */
  66574. color: Color3;
  66575. /**
  66576. * Creates a new GradientBlockColorStep
  66577. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  66578. * @param color defines the color associated with this step
  66579. */
  66580. constructor(
  66581. /**
  66582. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66583. */
  66584. step: number,
  66585. /**
  66586. * Gets or sets the color associated with this step
  66587. */
  66588. color: Color3);
  66589. }
  66590. /**
  66591. * Block used to return a color from a gradient based on an input value between 0 and 1
  66592. */
  66593. export class GradientBlock extends NodeMaterialBlock {
  66594. /**
  66595. * Gets or sets the list of color steps
  66596. */
  66597. colorSteps: GradientBlockColorStep[];
  66598. /**
  66599. * Creates a new GradientBlock
  66600. * @param name defines the block name
  66601. */
  66602. constructor(name: string);
  66603. /**
  66604. * Gets the current class name
  66605. * @returns the class name
  66606. */
  66607. getClassName(): string;
  66608. /**
  66609. * Gets the gradient input component
  66610. */
  66611. get gradient(): NodeMaterialConnectionPoint;
  66612. /**
  66613. * Gets the output component
  66614. */
  66615. get output(): NodeMaterialConnectionPoint;
  66616. private _writeColorConstant;
  66617. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66618. serialize(): any;
  66619. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66620. protected _dumpPropertiesCode(): string;
  66621. }
  66622. }
  66623. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  66624. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66625. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66626. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66627. /**
  66628. * Block used to normalize lerp between 2 values
  66629. */
  66630. export class NLerpBlock extends NodeMaterialBlock {
  66631. /**
  66632. * Creates a new NLerpBlock
  66633. * @param name defines the block name
  66634. */
  66635. constructor(name: string);
  66636. /**
  66637. * Gets the current class name
  66638. * @returns the class name
  66639. */
  66640. getClassName(): string;
  66641. /**
  66642. * Gets the left operand input component
  66643. */
  66644. get left(): NodeMaterialConnectionPoint;
  66645. /**
  66646. * Gets the right operand input component
  66647. */
  66648. get right(): NodeMaterialConnectionPoint;
  66649. /**
  66650. * Gets the gradient operand input component
  66651. */
  66652. get gradient(): NodeMaterialConnectionPoint;
  66653. /**
  66654. * Gets the output component
  66655. */
  66656. get output(): NodeMaterialConnectionPoint;
  66657. protected _buildBlock(state: NodeMaterialBuildState): this;
  66658. }
  66659. }
  66660. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  66661. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66662. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66663. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66664. import { Scene } from "babylonjs/scene";
  66665. /**
  66666. * block used to Generate a Worley Noise 3D Noise Pattern
  66667. */
  66668. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  66669. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66670. manhattanDistance: boolean;
  66671. /**
  66672. * Creates a new WorleyNoise3DBlock
  66673. * @param name defines the block name
  66674. */
  66675. constructor(name: string);
  66676. /**
  66677. * Gets the current class name
  66678. * @returns the class name
  66679. */
  66680. getClassName(): string;
  66681. /**
  66682. * Gets the seed input component
  66683. */
  66684. get seed(): NodeMaterialConnectionPoint;
  66685. /**
  66686. * Gets the jitter input component
  66687. */
  66688. get jitter(): NodeMaterialConnectionPoint;
  66689. /**
  66690. * Gets the output component
  66691. */
  66692. get output(): NodeMaterialConnectionPoint;
  66693. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66694. /**
  66695. * Exposes the properties to the UI?
  66696. */
  66697. protected _dumpPropertiesCode(): string;
  66698. /**
  66699. * Exposes the properties to the Seralize?
  66700. */
  66701. serialize(): any;
  66702. /**
  66703. * Exposes the properties to the deseralize?
  66704. */
  66705. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66706. }
  66707. }
  66708. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  66709. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66710. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66711. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66712. /**
  66713. * block used to Generate a Simplex Perlin 3d Noise Pattern
  66714. */
  66715. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  66716. /**
  66717. * Creates a new SimplexPerlin3DBlock
  66718. * @param name defines the block name
  66719. */
  66720. constructor(name: string);
  66721. /**
  66722. * Gets the current class name
  66723. * @returns the class name
  66724. */
  66725. getClassName(): string;
  66726. /**
  66727. * Gets the seed operand input component
  66728. */
  66729. get seed(): NodeMaterialConnectionPoint;
  66730. /**
  66731. * Gets the output component
  66732. */
  66733. get output(): NodeMaterialConnectionPoint;
  66734. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66735. }
  66736. }
  66737. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  66738. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66739. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66740. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66741. /**
  66742. * Block used to blend normals
  66743. */
  66744. export class NormalBlendBlock extends NodeMaterialBlock {
  66745. /**
  66746. * Creates a new NormalBlendBlock
  66747. * @param name defines the block name
  66748. */
  66749. constructor(name: string);
  66750. /**
  66751. * Gets the current class name
  66752. * @returns the class name
  66753. */
  66754. getClassName(): string;
  66755. /**
  66756. * Gets the first input component
  66757. */
  66758. get normalMap0(): NodeMaterialConnectionPoint;
  66759. /**
  66760. * Gets the second input component
  66761. */
  66762. get normalMap1(): NodeMaterialConnectionPoint;
  66763. /**
  66764. * Gets the output component
  66765. */
  66766. get output(): NodeMaterialConnectionPoint;
  66767. protected _buildBlock(state: NodeMaterialBuildState): this;
  66768. }
  66769. }
  66770. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  66771. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66772. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66773. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66774. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66775. /**
  66776. * Block used to rotate a 2d vector by a given angle
  66777. */
  66778. export class Rotate2dBlock extends NodeMaterialBlock {
  66779. /**
  66780. * Creates a new Rotate2dBlock
  66781. * @param name defines the block name
  66782. */
  66783. constructor(name: string);
  66784. /**
  66785. * Gets the current class name
  66786. * @returns the class name
  66787. */
  66788. getClassName(): string;
  66789. /**
  66790. * Gets the input vector
  66791. */
  66792. get input(): NodeMaterialConnectionPoint;
  66793. /**
  66794. * Gets the input angle
  66795. */
  66796. get angle(): NodeMaterialConnectionPoint;
  66797. /**
  66798. * Gets the output component
  66799. */
  66800. get output(): NodeMaterialConnectionPoint;
  66801. autoConfigure(material: NodeMaterial): void;
  66802. protected _buildBlock(state: NodeMaterialBuildState): this;
  66803. }
  66804. }
  66805. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  66806. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66807. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66808. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66809. /**
  66810. * Block used to get the reflected vector from a direction and a normal
  66811. */
  66812. export class ReflectBlock extends NodeMaterialBlock {
  66813. /**
  66814. * Creates a new ReflectBlock
  66815. * @param name defines the block name
  66816. */
  66817. constructor(name: string);
  66818. /**
  66819. * Gets the current class name
  66820. * @returns the class name
  66821. */
  66822. getClassName(): string;
  66823. /**
  66824. * Gets the incident component
  66825. */
  66826. get incident(): NodeMaterialConnectionPoint;
  66827. /**
  66828. * Gets the normal component
  66829. */
  66830. get normal(): NodeMaterialConnectionPoint;
  66831. /**
  66832. * Gets the output component
  66833. */
  66834. get output(): NodeMaterialConnectionPoint;
  66835. protected _buildBlock(state: NodeMaterialBuildState): this;
  66836. }
  66837. }
  66838. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  66839. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66840. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66841. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66842. /**
  66843. * Block used to get the refracted vector from a direction and a normal
  66844. */
  66845. export class RefractBlock extends NodeMaterialBlock {
  66846. /**
  66847. * Creates a new RefractBlock
  66848. * @param name defines the block name
  66849. */
  66850. constructor(name: string);
  66851. /**
  66852. * Gets the current class name
  66853. * @returns the class name
  66854. */
  66855. getClassName(): string;
  66856. /**
  66857. * Gets the incident component
  66858. */
  66859. get incident(): NodeMaterialConnectionPoint;
  66860. /**
  66861. * Gets the normal component
  66862. */
  66863. get normal(): NodeMaterialConnectionPoint;
  66864. /**
  66865. * Gets the index of refraction component
  66866. */
  66867. get ior(): 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/desaturateBlock" {
  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 desaturate a color
  66881. */
  66882. export class DesaturateBlock extends NodeMaterialBlock {
  66883. /**
  66884. * Creates a new DesaturateBlock
  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 color operand input component
  66895. */
  66896. get color(): NodeMaterialConnectionPoint;
  66897. /**
  66898. * Gets the level operand input component
  66899. */
  66900. get level(): 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/PBR/ambientOcclusionBlock" {
  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. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66913. import { Nullable } from "babylonjs/types";
  66914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66915. import { Scene } from "babylonjs/scene";
  66916. /**
  66917. * Block used to implement the ambient occlusion module of the PBR material
  66918. */
  66919. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  66920. /**
  66921. * Create a new AmbientOcclusionBlock
  66922. * @param name defines the block name
  66923. */
  66924. constructor(name: string);
  66925. /**
  66926. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  66927. */
  66928. useAmbientInGrayScale: boolean;
  66929. /**
  66930. * Initialize the block and prepare the context for build
  66931. * @param state defines the state that will be used for the build
  66932. */
  66933. initialize(state: NodeMaterialBuildState): void;
  66934. /**
  66935. * Gets the current class name
  66936. * @returns the class name
  66937. */
  66938. getClassName(): string;
  66939. /**
  66940. * Gets the texture input component
  66941. */
  66942. get texture(): NodeMaterialConnectionPoint;
  66943. /**
  66944. * Gets the texture intensity component
  66945. */
  66946. get intensity(): NodeMaterialConnectionPoint;
  66947. /**
  66948. * Gets the direct light intensity input component
  66949. */
  66950. get directLightIntensity(): NodeMaterialConnectionPoint;
  66951. /**
  66952. * Gets the ambient occlusion object output component
  66953. */
  66954. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66955. /**
  66956. * Gets the main code of the block (fragment side)
  66957. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  66958. * @returns the shader code
  66959. */
  66960. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  66961. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66962. protected _buildBlock(state: NodeMaterialBuildState): this;
  66963. protected _dumpPropertiesCode(): string;
  66964. serialize(): any;
  66965. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66966. }
  66967. }
  66968. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  66969. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66970. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66971. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66972. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66974. import { Nullable } from "babylonjs/types";
  66975. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66976. import { Mesh } from "babylonjs/Meshes/mesh";
  66977. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66978. import { Effect } from "babylonjs/Materials/effect";
  66979. import { Scene } from "babylonjs/scene";
  66980. /**
  66981. * Block used to implement the reflection module of the PBR material
  66982. */
  66983. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  66984. /** @hidden */
  66985. _defineLODReflectionAlpha: string;
  66986. /** @hidden */
  66987. _defineLinearSpecularReflection: string;
  66988. private _vEnvironmentIrradianceName;
  66989. /** @hidden */
  66990. _vReflectionMicrosurfaceInfosName: string;
  66991. /** @hidden */
  66992. _vReflectionInfosName: string;
  66993. /** @hidden */
  66994. _vReflectionFilteringInfoName: string;
  66995. private _scene;
  66996. /**
  66997. * The three properties below are set by the main PBR block prior to calling methods of this class.
  66998. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66999. * It's less burden on the user side in the editor part.
  67000. */
  67001. /** @hidden */
  67002. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67003. /** @hidden */
  67004. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67005. /** @hidden */
  67006. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67007. /**
  67008. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67009. * diffuse part of the IBL.
  67010. */
  67011. useSphericalHarmonics: boolean;
  67012. /**
  67013. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67014. */
  67015. forceIrradianceInFragment: boolean;
  67016. /**
  67017. * Create a new ReflectionBlock
  67018. * @param name defines the block name
  67019. */
  67020. constructor(name: string);
  67021. /**
  67022. * Gets the current class name
  67023. * @returns the class name
  67024. */
  67025. getClassName(): string;
  67026. /**
  67027. * Gets the position input component
  67028. */
  67029. get position(): NodeMaterialConnectionPoint;
  67030. /**
  67031. * Gets the world position input component
  67032. */
  67033. get worldPosition(): NodeMaterialConnectionPoint;
  67034. /**
  67035. * Gets the world normal input component
  67036. */
  67037. get worldNormal(): NodeMaterialConnectionPoint;
  67038. /**
  67039. * Gets the world input component
  67040. */
  67041. get world(): NodeMaterialConnectionPoint;
  67042. /**
  67043. * Gets the camera (or eye) position component
  67044. */
  67045. get cameraPosition(): NodeMaterialConnectionPoint;
  67046. /**
  67047. * Gets the view input component
  67048. */
  67049. get view(): NodeMaterialConnectionPoint;
  67050. /**
  67051. * Gets the color input component
  67052. */
  67053. get color(): NodeMaterialConnectionPoint;
  67054. /**
  67055. * Gets the reflection object output component
  67056. */
  67057. get reflection(): NodeMaterialConnectionPoint;
  67058. /**
  67059. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67060. */
  67061. get hasTexture(): boolean;
  67062. /**
  67063. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67064. */
  67065. get reflectionColor(): string;
  67066. protected _getTexture(): Nullable<BaseTexture>;
  67067. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67068. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67069. /**
  67070. * Gets the code to inject in the vertex shader
  67071. * @param state current state of the node material building
  67072. * @returns the shader code
  67073. */
  67074. handleVertexSide(state: NodeMaterialBuildState): string;
  67075. /**
  67076. * Gets the main code of the block (fragment side)
  67077. * @param state current state of the node material building
  67078. * @param normalVarName name of the existing variable corresponding to the normal
  67079. * @returns the shader code
  67080. */
  67081. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67082. protected _buildBlock(state: NodeMaterialBuildState): this;
  67083. protected _dumpPropertiesCode(): string;
  67084. serialize(): any;
  67085. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67086. }
  67087. }
  67088. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67089. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67090. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67091. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67092. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67094. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67095. import { Scene } from "babylonjs/scene";
  67096. import { Nullable } from "babylonjs/types";
  67097. /**
  67098. * Block used to implement the sheen module of the PBR material
  67099. */
  67100. export class SheenBlock extends NodeMaterialBlock {
  67101. /**
  67102. * Create a new SheenBlock
  67103. * @param name defines the block name
  67104. */
  67105. constructor(name: string);
  67106. /**
  67107. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67108. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67109. * making it easier to setup and tweak the effect
  67110. */
  67111. albedoScaling: boolean;
  67112. /**
  67113. * Defines if the sheen is linked to the sheen color.
  67114. */
  67115. linkSheenWithAlbedo: boolean;
  67116. /**
  67117. * Initialize the block and prepare the context for build
  67118. * @param state defines the state that will be used for the build
  67119. */
  67120. initialize(state: NodeMaterialBuildState): void;
  67121. /**
  67122. * Gets the current class name
  67123. * @returns the class name
  67124. */
  67125. getClassName(): string;
  67126. /**
  67127. * Gets the intensity input component
  67128. */
  67129. get intensity(): NodeMaterialConnectionPoint;
  67130. /**
  67131. * Gets the color input component
  67132. */
  67133. get color(): NodeMaterialConnectionPoint;
  67134. /**
  67135. * Gets the roughness input component
  67136. */
  67137. get roughness(): NodeMaterialConnectionPoint;
  67138. /**
  67139. * Gets the sheen object output component
  67140. */
  67141. get sheen(): NodeMaterialConnectionPoint;
  67142. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67143. /**
  67144. * Gets the main code of the block (fragment side)
  67145. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67146. * @returns the shader code
  67147. */
  67148. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67149. protected _buildBlock(state: NodeMaterialBuildState): this;
  67150. protected _dumpPropertiesCode(): string;
  67151. serialize(): any;
  67152. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67153. }
  67154. }
  67155. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67156. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67157. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67158. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67160. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67161. import { Scene } from "babylonjs/scene";
  67162. import { Nullable } from "babylonjs/types";
  67163. import { Mesh } from "babylonjs/Meshes/mesh";
  67164. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67165. import { Effect } from "babylonjs/Materials/effect";
  67166. /**
  67167. * Block used to implement the reflectivity module of the PBR material
  67168. */
  67169. export class ReflectivityBlock extends NodeMaterialBlock {
  67170. private _metallicReflectanceColor;
  67171. private _metallicF0Factor;
  67172. /** @hidden */
  67173. _vMetallicReflectanceFactorsName: string;
  67174. /**
  67175. * The property below is set by the main PBR block prior to calling methods of this class.
  67176. */
  67177. /** @hidden */
  67178. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67179. /**
  67180. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67181. */
  67182. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67183. /**
  67184. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67185. */
  67186. useMetallnessFromMetallicTextureBlue: boolean;
  67187. /**
  67188. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67189. */
  67190. useRoughnessFromMetallicTextureAlpha: boolean;
  67191. /**
  67192. * Specifies if the metallic texture contains the roughness information in its green channel.
  67193. */
  67194. useRoughnessFromMetallicTextureGreen: boolean;
  67195. /**
  67196. * Create a new ReflectivityBlock
  67197. * @param name defines the block name
  67198. */
  67199. constructor(name: string);
  67200. /**
  67201. * Initialize the block and prepare the context for build
  67202. * @param state defines the state that will be used for the build
  67203. */
  67204. initialize(state: NodeMaterialBuildState): void;
  67205. /**
  67206. * Gets the current class name
  67207. * @returns the class name
  67208. */
  67209. getClassName(): string;
  67210. /**
  67211. * Gets the metallic input component
  67212. */
  67213. get metallic(): NodeMaterialConnectionPoint;
  67214. /**
  67215. * Gets the roughness input component
  67216. */
  67217. get roughness(): NodeMaterialConnectionPoint;
  67218. /**
  67219. * Gets the texture input component
  67220. */
  67221. get texture(): NodeMaterialConnectionPoint;
  67222. /**
  67223. * Gets the reflectivity object output component
  67224. */
  67225. get reflectivity(): NodeMaterialConnectionPoint;
  67226. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67227. /**
  67228. * Gets the main code of the block (fragment side)
  67229. * @param state current state of the node material building
  67230. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67231. * @returns the shader code
  67232. */
  67233. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67234. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67235. protected _buildBlock(state: NodeMaterialBuildState): this;
  67236. protected _dumpPropertiesCode(): string;
  67237. serialize(): any;
  67238. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67239. }
  67240. }
  67241. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67242. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67243. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67244. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67245. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67247. /**
  67248. * Block used to implement the anisotropy module of the PBR material
  67249. */
  67250. export class AnisotropyBlock extends NodeMaterialBlock {
  67251. /**
  67252. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67253. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67254. * It's less burden on the user side in the editor part.
  67255. */
  67256. /** @hidden */
  67257. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67258. /** @hidden */
  67259. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67260. /**
  67261. * Create a new AnisotropyBlock
  67262. * @param name defines the block name
  67263. */
  67264. constructor(name: string);
  67265. /**
  67266. * Initialize the block and prepare the context for build
  67267. * @param state defines the state that will be used for the build
  67268. */
  67269. initialize(state: NodeMaterialBuildState): void;
  67270. /**
  67271. * Gets the current class name
  67272. * @returns the class name
  67273. */
  67274. getClassName(): string;
  67275. /**
  67276. * Gets the intensity input component
  67277. */
  67278. get intensity(): NodeMaterialConnectionPoint;
  67279. /**
  67280. * Gets the direction input component
  67281. */
  67282. get direction(): NodeMaterialConnectionPoint;
  67283. /**
  67284. * Gets the texture input component
  67285. */
  67286. get texture(): NodeMaterialConnectionPoint;
  67287. /**
  67288. * Gets the uv input component
  67289. */
  67290. get uv(): NodeMaterialConnectionPoint;
  67291. /**
  67292. * Gets the worldTangent input component
  67293. */
  67294. get worldTangent(): NodeMaterialConnectionPoint;
  67295. /**
  67296. * Gets the anisotropy object output component
  67297. */
  67298. get anisotropy(): NodeMaterialConnectionPoint;
  67299. private _generateTBNSpace;
  67300. /**
  67301. * Gets the main code of the block (fragment side)
  67302. * @param state current state of the node material building
  67303. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67304. * @returns the shader code
  67305. */
  67306. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67307. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67308. protected _buildBlock(state: NodeMaterialBuildState): this;
  67309. }
  67310. }
  67311. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67312. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67313. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67314. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67315. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67317. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67318. import { Nullable } from "babylonjs/types";
  67319. import { Mesh } from "babylonjs/Meshes/mesh";
  67320. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67321. import { Effect } from "babylonjs/Materials/effect";
  67322. /**
  67323. * Block used to implement the clear coat module of the PBR material
  67324. */
  67325. export class ClearCoatBlock extends NodeMaterialBlock {
  67326. private _scene;
  67327. /**
  67328. * Create a new ClearCoatBlock
  67329. * @param name defines the block name
  67330. */
  67331. constructor(name: string);
  67332. /**
  67333. * Initialize the block and prepare the context for build
  67334. * @param state defines the state that will be used for the build
  67335. */
  67336. initialize(state: NodeMaterialBuildState): void;
  67337. /**
  67338. * Gets the current class name
  67339. * @returns the class name
  67340. */
  67341. getClassName(): string;
  67342. /**
  67343. * Gets the intensity input component
  67344. */
  67345. get intensity(): NodeMaterialConnectionPoint;
  67346. /**
  67347. * Gets the roughness input component
  67348. */
  67349. get roughness(): NodeMaterialConnectionPoint;
  67350. /**
  67351. * Gets the ior input component
  67352. */
  67353. get ior(): NodeMaterialConnectionPoint;
  67354. /**
  67355. * Gets the texture input component
  67356. */
  67357. get texture(): NodeMaterialConnectionPoint;
  67358. /**
  67359. * Gets the bump texture input component
  67360. */
  67361. get bumpTexture(): NodeMaterialConnectionPoint;
  67362. /**
  67363. * Gets the uv input component
  67364. */
  67365. get uv(): NodeMaterialConnectionPoint;
  67366. /**
  67367. * Gets the tint color input component
  67368. */
  67369. get tintColor(): NodeMaterialConnectionPoint;
  67370. /**
  67371. * Gets the tint "at distance" input component
  67372. */
  67373. get tintAtDistance(): NodeMaterialConnectionPoint;
  67374. /**
  67375. * Gets the tint thickness input component
  67376. */
  67377. get tintThickness(): NodeMaterialConnectionPoint;
  67378. /**
  67379. * Gets the world tangent input component
  67380. */
  67381. get worldTangent(): NodeMaterialConnectionPoint;
  67382. /**
  67383. * Gets the clear coat object output component
  67384. */
  67385. get clearcoat(): NodeMaterialConnectionPoint;
  67386. autoConfigure(material: NodeMaterial): void;
  67387. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67388. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67389. private _generateTBNSpace;
  67390. /**
  67391. * Gets the main code of the block (fragment side)
  67392. * @param state current state of the node material building
  67393. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  67394. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67395. * @param worldPosVarName name of the variable holding the world position
  67396. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67397. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  67398. * @param worldNormalVarName name of the variable holding the world normal
  67399. * @returns the shader code
  67400. */
  67401. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  67402. protected _buildBlock(state: NodeMaterialBuildState): this;
  67403. }
  67404. }
  67405. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  67406. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67407. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67408. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67409. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67411. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67412. import { Nullable } from "babylonjs/types";
  67413. /**
  67414. * Block used to implement the sub surface module of the PBR material
  67415. */
  67416. export class SubSurfaceBlock extends NodeMaterialBlock {
  67417. /**
  67418. * Create a new SubSurfaceBlock
  67419. * @param name defines the block name
  67420. */
  67421. constructor(name: string);
  67422. /**
  67423. * Stores the intensity of the different subsurface effects in the thickness texture.
  67424. * * the green channel is the translucency intensity.
  67425. * * the blue channel is the scattering intensity.
  67426. * * the alpha channel is the refraction intensity.
  67427. */
  67428. useMaskFromThicknessTexture: boolean;
  67429. /**
  67430. * Initialize the block and prepare the context for build
  67431. * @param state defines the state that will be used for the build
  67432. */
  67433. initialize(state: NodeMaterialBuildState): void;
  67434. /**
  67435. * Gets the current class name
  67436. * @returns the class name
  67437. */
  67438. getClassName(): string;
  67439. /**
  67440. * Gets the min thickness input component
  67441. */
  67442. get minThickness(): NodeMaterialConnectionPoint;
  67443. /**
  67444. * Gets the max thickness input component
  67445. */
  67446. get maxThickness(): NodeMaterialConnectionPoint;
  67447. /**
  67448. * Gets the thickness texture component
  67449. */
  67450. get thicknessTexture(): NodeMaterialConnectionPoint;
  67451. /**
  67452. * Gets the tint color input component
  67453. */
  67454. get tintColor(): NodeMaterialConnectionPoint;
  67455. /**
  67456. * Gets the translucency intensity input component
  67457. */
  67458. get translucencyIntensity(): NodeMaterialConnectionPoint;
  67459. /**
  67460. * Gets the translucency diffusion distance input component
  67461. */
  67462. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  67463. /**
  67464. * Gets the refraction object parameters
  67465. */
  67466. get refraction(): NodeMaterialConnectionPoint;
  67467. /**
  67468. * Gets the sub surface object output component
  67469. */
  67470. get subsurface(): NodeMaterialConnectionPoint;
  67471. autoConfigure(material: NodeMaterial): void;
  67472. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67473. /**
  67474. * Gets the main code of the block (fragment side)
  67475. * @param state current state of the node material building
  67476. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  67477. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67478. * @param worldPosVarName name of the variable holding the world position
  67479. * @returns the shader code
  67480. */
  67481. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  67482. protected _buildBlock(state: NodeMaterialBuildState): this;
  67483. }
  67484. }
  67485. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  67486. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67487. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67488. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67489. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67490. import { Light } from "babylonjs/Lights/light";
  67491. import { Nullable } from "babylonjs/types";
  67492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67493. import { Effect } from "babylonjs/Materials/effect";
  67494. import { Mesh } from "babylonjs/Meshes/mesh";
  67495. import { Scene } from "babylonjs/scene";
  67496. /**
  67497. * Block used to implement the PBR metallic/roughness model
  67498. */
  67499. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  67500. /**
  67501. * Gets or sets the light associated with this block
  67502. */
  67503. light: Nullable<Light>;
  67504. private _lightId;
  67505. private _scene;
  67506. private _environmentBRDFTexture;
  67507. private _environmentBrdfSamplerName;
  67508. private _vNormalWName;
  67509. private _invertNormalName;
  67510. /**
  67511. * Create a new ReflectionBlock
  67512. * @param name defines the block name
  67513. */
  67514. constructor(name: string);
  67515. /**
  67516. * Intensity of the direct lights e.g. the four lights available in your scene.
  67517. * This impacts both the direct diffuse and specular highlights.
  67518. */
  67519. directIntensity: number;
  67520. /**
  67521. * Intensity of the environment e.g. how much the environment will light the object
  67522. * either through harmonics for rough material or through the refelction for shiny ones.
  67523. */
  67524. environmentIntensity: number;
  67525. /**
  67526. * This is a special control allowing the reduction of the specular highlights coming from the
  67527. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  67528. */
  67529. specularIntensity: number;
  67530. /**
  67531. * Defines the falloff type used in this material.
  67532. * It by default is Physical.
  67533. */
  67534. lightFalloff: number;
  67535. /**
  67536. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  67537. */
  67538. useAlphaFromAlbedoTexture: boolean;
  67539. /**
  67540. * Specifies that alpha test should be used
  67541. */
  67542. useAlphaTest: boolean;
  67543. /**
  67544. * Defines the alpha limits in alpha test mode.
  67545. */
  67546. alphaTestCutoff: number;
  67547. /**
  67548. * Specifies that alpha blending should be used
  67549. */
  67550. useAlphaBlending: boolean;
  67551. /**
  67552. * Defines if the alpha value should be determined via the rgb values.
  67553. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  67554. */
  67555. opacityRGB: boolean;
  67556. /**
  67557. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  67558. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  67559. */
  67560. useRadianceOverAlpha: boolean;
  67561. /**
  67562. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  67563. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  67564. */
  67565. useSpecularOverAlpha: boolean;
  67566. /**
  67567. * Enables specular anti aliasing in the PBR shader.
  67568. * It will both interacts on the Geometry for analytical and IBL lighting.
  67569. * It also prefilter the roughness map based on the bump values.
  67570. */
  67571. enableSpecularAntiAliasing: boolean;
  67572. /**
  67573. * Enables realtime filtering on the texture.
  67574. */
  67575. realTimeFiltering: boolean;
  67576. /**
  67577. * Quality switch for realtime filtering
  67578. */
  67579. realTimeFilteringQuality: number;
  67580. /**
  67581. * Defines if the material uses energy conservation.
  67582. */
  67583. useEnergyConservation: boolean;
  67584. /**
  67585. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  67586. * too much the area relying on ambient texture to define their ambient occlusion.
  67587. */
  67588. useRadianceOcclusion: boolean;
  67589. /**
  67590. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  67591. * makes the reflect vector face the model (under horizon).
  67592. */
  67593. useHorizonOcclusion: boolean;
  67594. /**
  67595. * If set to true, no lighting calculations will be applied.
  67596. */
  67597. unlit: boolean;
  67598. /**
  67599. * Force normal to face away from face.
  67600. */
  67601. forceNormalForward: boolean;
  67602. /**
  67603. * Defines the material debug mode.
  67604. * It helps seeing only some components of the material while troubleshooting.
  67605. */
  67606. debugMode: number;
  67607. /**
  67608. * Specify from where on screen the debug mode should start.
  67609. * The value goes from -1 (full screen) to 1 (not visible)
  67610. * It helps with side by side comparison against the final render
  67611. * This defaults to 0
  67612. */
  67613. debugLimit: number;
  67614. /**
  67615. * As the default viewing range might not be enough (if the ambient is really small for instance)
  67616. * You can use the factor to better multiply the final value.
  67617. */
  67618. debugFactor: number;
  67619. /**
  67620. * Initialize the block and prepare the context for build
  67621. * @param state defines the state that will be used for the build
  67622. */
  67623. initialize(state: NodeMaterialBuildState): void;
  67624. /**
  67625. * Gets the current class name
  67626. * @returns the class name
  67627. */
  67628. getClassName(): string;
  67629. /**
  67630. * Gets the world position input component
  67631. */
  67632. get worldPosition(): NodeMaterialConnectionPoint;
  67633. /**
  67634. * Gets the world normal input component
  67635. */
  67636. get worldNormal(): NodeMaterialConnectionPoint;
  67637. /**
  67638. * Gets the perturbed normal input component
  67639. */
  67640. get perturbedNormal(): NodeMaterialConnectionPoint;
  67641. /**
  67642. * Gets the camera position input component
  67643. */
  67644. get cameraPosition(): NodeMaterialConnectionPoint;
  67645. /**
  67646. * Gets the base color input component
  67647. */
  67648. get baseColor(): NodeMaterialConnectionPoint;
  67649. /**
  67650. * Gets the opacity texture input component
  67651. */
  67652. get opacityTexture(): NodeMaterialConnectionPoint;
  67653. /**
  67654. * Gets the ambient color input component
  67655. */
  67656. get ambientColor(): NodeMaterialConnectionPoint;
  67657. /**
  67658. * Gets the reflectivity object parameters
  67659. */
  67660. get reflectivity(): NodeMaterialConnectionPoint;
  67661. /**
  67662. * Gets the ambient occlusion object parameters
  67663. */
  67664. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67665. /**
  67666. * Gets the reflection object parameters
  67667. */
  67668. get reflection(): NodeMaterialConnectionPoint;
  67669. /**
  67670. * Gets the sheen object parameters
  67671. */
  67672. get sheen(): NodeMaterialConnectionPoint;
  67673. /**
  67674. * Gets the clear coat object parameters
  67675. */
  67676. get clearcoat(): NodeMaterialConnectionPoint;
  67677. /**
  67678. * Gets the sub surface object parameters
  67679. */
  67680. get subsurface(): NodeMaterialConnectionPoint;
  67681. /**
  67682. * Gets the anisotropy object parameters
  67683. */
  67684. get anisotropy(): NodeMaterialConnectionPoint;
  67685. /**
  67686. * Gets the ambient output component
  67687. */
  67688. get ambient(): NodeMaterialConnectionPoint;
  67689. /**
  67690. * Gets the diffuse output component
  67691. */
  67692. get diffuse(): NodeMaterialConnectionPoint;
  67693. /**
  67694. * Gets the specular output component
  67695. */
  67696. get specular(): NodeMaterialConnectionPoint;
  67697. /**
  67698. * Gets the sheen output component
  67699. */
  67700. get sheenDir(): NodeMaterialConnectionPoint;
  67701. /**
  67702. * Gets the clear coat output component
  67703. */
  67704. get clearcoatDir(): NodeMaterialConnectionPoint;
  67705. /**
  67706. * Gets the indirect diffuse output component
  67707. */
  67708. get diffuseIndirect(): NodeMaterialConnectionPoint;
  67709. /**
  67710. * Gets the indirect specular output component
  67711. */
  67712. get specularIndirect(): NodeMaterialConnectionPoint;
  67713. /**
  67714. * Gets the indirect sheen output component
  67715. */
  67716. get sheenIndirect(): NodeMaterialConnectionPoint;
  67717. /**
  67718. * Gets the indirect clear coat output component
  67719. */
  67720. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  67721. /**
  67722. * Gets the refraction output component
  67723. */
  67724. get refraction(): NodeMaterialConnectionPoint;
  67725. /**
  67726. * Gets the global lighting output component
  67727. */
  67728. get lighting(): NodeMaterialConnectionPoint;
  67729. /**
  67730. * Gets the shadow output component
  67731. */
  67732. get shadow(): NodeMaterialConnectionPoint;
  67733. /**
  67734. * Gets the alpha output component
  67735. */
  67736. get alpha(): NodeMaterialConnectionPoint;
  67737. autoConfigure(material: NodeMaterial): void;
  67738. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67739. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67740. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67741. private _injectVertexCode;
  67742. /**
  67743. * Gets the code corresponding to the albedo/opacity module
  67744. * @returns the shader code
  67745. */
  67746. getAlbedoOpacityCode(): string;
  67747. protected _buildBlock(state: NodeMaterialBuildState): this;
  67748. protected _dumpPropertiesCode(): string;
  67749. serialize(): any;
  67750. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67751. }
  67752. }
  67753. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  67754. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  67755. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  67756. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  67757. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  67758. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  67759. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67760. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  67761. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  67762. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  67763. }
  67764. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  67765. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  67766. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  67767. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  67768. }
  67769. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  67770. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67771. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67772. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67773. /**
  67774. * Block used to compute value of one parameter modulo another
  67775. */
  67776. export class ModBlock extends NodeMaterialBlock {
  67777. /**
  67778. * Creates a new ModBlock
  67779. * @param name defines the block name
  67780. */
  67781. constructor(name: string);
  67782. /**
  67783. * Gets the current class name
  67784. * @returns the class name
  67785. */
  67786. getClassName(): string;
  67787. /**
  67788. * Gets the left operand input component
  67789. */
  67790. get left(): NodeMaterialConnectionPoint;
  67791. /**
  67792. * Gets the right operand input component
  67793. */
  67794. get right(): NodeMaterialConnectionPoint;
  67795. /**
  67796. * Gets the output component
  67797. */
  67798. get output(): NodeMaterialConnectionPoint;
  67799. protected _buildBlock(state: NodeMaterialBuildState): this;
  67800. }
  67801. }
  67802. declare module "babylonjs/Materials/Node/Blocks/index" {
  67803. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  67804. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  67805. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  67806. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  67807. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  67808. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  67809. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  67810. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  67811. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  67812. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  67813. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  67814. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  67815. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  67816. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  67817. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  67818. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  67819. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  67820. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  67821. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  67822. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  67823. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  67824. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  67825. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  67826. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  67827. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  67828. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  67829. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  67830. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  67831. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  67832. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  67833. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  67834. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  67835. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  67836. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  67837. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  67838. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  67839. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  67840. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  67841. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  67842. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  67843. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  67844. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  67845. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  67846. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  67847. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  67848. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  67849. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  67850. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  67851. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  67852. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  67853. }
  67854. declare module "babylonjs/Materials/Node/Optimizers/index" {
  67855. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  67856. }
  67857. declare module "babylonjs/Materials/Node/index" {
  67858. export * from "babylonjs/Materials/Node/Enums/index";
  67859. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67860. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  67861. export * from "babylonjs/Materials/Node/nodeMaterial";
  67862. export * from "babylonjs/Materials/Node/Blocks/index";
  67863. export * from "babylonjs/Materials/Node/Optimizers/index";
  67864. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  67865. }
  67866. declare module "babylonjs/Materials/index" {
  67867. export * from "babylonjs/Materials/Background/index";
  67868. export * from "babylonjs/Materials/colorCurves";
  67869. export * from "babylonjs/Materials/iEffectFallbacks";
  67870. export * from "babylonjs/Materials/effectFallbacks";
  67871. export * from "babylonjs/Materials/effect";
  67872. export * from "babylonjs/Materials/fresnelParameters";
  67873. export * from "babylonjs/Materials/imageProcessingConfiguration";
  67874. export * from "babylonjs/Materials/material";
  67875. export * from "babylonjs/Materials/materialDefines";
  67876. export * from "babylonjs/Materials/materialHelper";
  67877. export * from "babylonjs/Materials/multiMaterial";
  67878. export * from "babylonjs/Materials/PBR/index";
  67879. export * from "babylonjs/Materials/pushMaterial";
  67880. export * from "babylonjs/Materials/shaderMaterial";
  67881. export * from "babylonjs/Materials/standardMaterial";
  67882. export * from "babylonjs/Materials/Textures/index";
  67883. export * from "babylonjs/Materials/uniformBuffer";
  67884. export * from "babylonjs/Materials/materialFlags";
  67885. export * from "babylonjs/Materials/Node/index";
  67886. export * from "babylonjs/Materials/effectRenderer";
  67887. export * from "babylonjs/Materials/shadowDepthWrapper";
  67888. }
  67889. declare module "babylonjs/Maths/index" {
  67890. export * from "babylonjs/Maths/math.scalar";
  67891. export * from "babylonjs/Maths/math";
  67892. export * from "babylonjs/Maths/sphericalPolynomial";
  67893. }
  67894. declare module "babylonjs/Misc/workerPool" {
  67895. import { IDisposable } from "babylonjs/scene";
  67896. /**
  67897. * Helper class to push actions to a pool of workers.
  67898. */
  67899. export class WorkerPool implements IDisposable {
  67900. private _workerInfos;
  67901. private _pendingActions;
  67902. /**
  67903. * Constructor
  67904. * @param workers Array of workers to use for actions
  67905. */
  67906. constructor(workers: Array<Worker>);
  67907. /**
  67908. * Terminates all workers and clears any pending actions.
  67909. */
  67910. dispose(): void;
  67911. /**
  67912. * Pushes an action to the worker pool. If all the workers are active, the action will be
  67913. * pended until a worker has completed its action.
  67914. * @param action The action to perform. Call onComplete when the action is complete.
  67915. */
  67916. push(action: (worker: Worker, onComplete: () => void) => void): void;
  67917. private _execute;
  67918. }
  67919. }
  67920. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  67921. import { IDisposable } from "babylonjs/scene";
  67922. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67923. /**
  67924. * Configuration for Draco compression
  67925. */
  67926. export interface IDracoCompressionConfiguration {
  67927. /**
  67928. * Configuration for the decoder.
  67929. */
  67930. decoder: {
  67931. /**
  67932. * The url to the WebAssembly module.
  67933. */
  67934. wasmUrl?: string;
  67935. /**
  67936. * The url to the WebAssembly binary.
  67937. */
  67938. wasmBinaryUrl?: string;
  67939. /**
  67940. * The url to the fallback JavaScript module.
  67941. */
  67942. fallbackUrl?: string;
  67943. };
  67944. }
  67945. /**
  67946. * Draco compression (https://google.github.io/draco/)
  67947. *
  67948. * This class wraps the Draco module.
  67949. *
  67950. * **Encoder**
  67951. *
  67952. * The encoder is not currently implemented.
  67953. *
  67954. * **Decoder**
  67955. *
  67956. * 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.
  67957. *
  67958. * To update the configuration, use the following code:
  67959. * ```javascript
  67960. * DracoCompression.Configuration = {
  67961. * decoder: {
  67962. * wasmUrl: "<url to the WebAssembly library>",
  67963. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  67964. * fallbackUrl: "<url to the fallback JavaScript library>",
  67965. * }
  67966. * };
  67967. * ```
  67968. *
  67969. * 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.
  67970. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  67971. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  67972. *
  67973. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  67974. * ```javascript
  67975. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  67976. * ```
  67977. *
  67978. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  67979. */
  67980. export class DracoCompression implements IDisposable {
  67981. private _workerPoolPromise?;
  67982. private _decoderModulePromise?;
  67983. /**
  67984. * The configuration. Defaults to the following urls:
  67985. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  67986. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  67987. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  67988. */
  67989. static Configuration: IDracoCompressionConfiguration;
  67990. /**
  67991. * Returns true if the decoder configuration is available.
  67992. */
  67993. static get DecoderAvailable(): boolean;
  67994. /**
  67995. * Default number of workers to create when creating the draco compression object.
  67996. */
  67997. static DefaultNumWorkers: number;
  67998. private static GetDefaultNumWorkers;
  67999. private static _Default;
  68000. /**
  68001. * Default instance for the draco compression object.
  68002. */
  68003. static get Default(): DracoCompression;
  68004. /**
  68005. * Constructor
  68006. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68007. */
  68008. constructor(numWorkers?: number);
  68009. /**
  68010. * Stop all async operations and release resources.
  68011. */
  68012. dispose(): void;
  68013. /**
  68014. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68015. * @returns a promise that resolves when ready
  68016. */
  68017. whenReadyAsync(): Promise<void>;
  68018. /**
  68019. * Decode Draco compressed mesh data to vertex data.
  68020. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68021. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68022. * @returns A promise that resolves with the decoded vertex data
  68023. */
  68024. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68025. [kind: string]: number;
  68026. }): Promise<VertexData>;
  68027. }
  68028. }
  68029. declare module "babylonjs/Meshes/Compression/index" {
  68030. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68031. }
  68032. declare module "babylonjs/Meshes/csg" {
  68033. import { Nullable } from "babylonjs/types";
  68034. import { Scene } from "babylonjs/scene";
  68035. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68036. import { Mesh } from "babylonjs/Meshes/mesh";
  68037. import { Material } from "babylonjs/Materials/material";
  68038. /**
  68039. * Class for building Constructive Solid Geometry
  68040. */
  68041. export class CSG {
  68042. private polygons;
  68043. /**
  68044. * The world matrix
  68045. */
  68046. matrix: Matrix;
  68047. /**
  68048. * Stores the position
  68049. */
  68050. position: Vector3;
  68051. /**
  68052. * Stores the rotation
  68053. */
  68054. rotation: Vector3;
  68055. /**
  68056. * Stores the rotation quaternion
  68057. */
  68058. rotationQuaternion: Nullable<Quaternion>;
  68059. /**
  68060. * Stores the scaling vector
  68061. */
  68062. scaling: Vector3;
  68063. /**
  68064. * Convert the Mesh to CSG
  68065. * @param mesh The Mesh to convert to CSG
  68066. * @returns A new CSG from the Mesh
  68067. */
  68068. static FromMesh(mesh: Mesh): CSG;
  68069. /**
  68070. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68071. * @param polygons Polygons used to construct a CSG solid
  68072. */
  68073. private static FromPolygons;
  68074. /**
  68075. * Clones, or makes a deep copy, of the CSG
  68076. * @returns A new CSG
  68077. */
  68078. clone(): CSG;
  68079. /**
  68080. * Unions this CSG with another CSG
  68081. * @param csg The CSG to union against this CSG
  68082. * @returns The unioned CSG
  68083. */
  68084. union(csg: CSG): CSG;
  68085. /**
  68086. * Unions this CSG with another CSG in place
  68087. * @param csg The CSG to union against this CSG
  68088. */
  68089. unionInPlace(csg: CSG): void;
  68090. /**
  68091. * Subtracts this CSG with another CSG
  68092. * @param csg The CSG to subtract against this CSG
  68093. * @returns A new CSG
  68094. */
  68095. subtract(csg: CSG): CSG;
  68096. /**
  68097. * Subtracts this CSG with another CSG in place
  68098. * @param csg The CSG to subtact against this CSG
  68099. */
  68100. subtractInPlace(csg: CSG): void;
  68101. /**
  68102. * Intersect this CSG with another CSG
  68103. * @param csg The CSG to intersect against this CSG
  68104. * @returns A new CSG
  68105. */
  68106. intersect(csg: CSG): CSG;
  68107. /**
  68108. * Intersects this CSG with another CSG in place
  68109. * @param csg The CSG to intersect against this CSG
  68110. */
  68111. intersectInPlace(csg: CSG): void;
  68112. /**
  68113. * Return a new CSG solid with solid and empty space switched. This solid is
  68114. * not modified.
  68115. * @returns A new CSG solid with solid and empty space switched
  68116. */
  68117. inverse(): CSG;
  68118. /**
  68119. * Inverses the CSG in place
  68120. */
  68121. inverseInPlace(): void;
  68122. /**
  68123. * This is used to keep meshes transformations so they can be restored
  68124. * when we build back a Babylon Mesh
  68125. * NB : All CSG operations are performed in world coordinates
  68126. * @param csg The CSG to copy the transform attributes from
  68127. * @returns This CSG
  68128. */
  68129. copyTransformAttributes(csg: CSG): CSG;
  68130. /**
  68131. * Build Raw mesh from CSG
  68132. * Coordinates here are in world space
  68133. * @param name The name of the mesh geometry
  68134. * @param scene The Scene
  68135. * @param keepSubMeshes Specifies if the submeshes should be kept
  68136. * @returns A new Mesh
  68137. */
  68138. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68139. /**
  68140. * Build Mesh from CSG taking material and transforms into account
  68141. * @param name The name of the Mesh
  68142. * @param material The material of the Mesh
  68143. * @param scene The Scene
  68144. * @param keepSubMeshes Specifies if submeshes should be kept
  68145. * @returns The new Mesh
  68146. */
  68147. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68148. }
  68149. }
  68150. declare module "babylonjs/Meshes/trailMesh" {
  68151. import { Mesh } from "babylonjs/Meshes/mesh";
  68152. import { Scene } from "babylonjs/scene";
  68153. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68154. /**
  68155. * Class used to create a trail following a mesh
  68156. */
  68157. export class TrailMesh extends Mesh {
  68158. private _generator;
  68159. private _autoStart;
  68160. private _running;
  68161. private _diameter;
  68162. private _length;
  68163. private _sectionPolygonPointsCount;
  68164. private _sectionVectors;
  68165. private _sectionNormalVectors;
  68166. private _beforeRenderObserver;
  68167. /**
  68168. * @constructor
  68169. * @param name The value used by scene.getMeshByName() to do a lookup.
  68170. * @param generator The mesh or transform node to generate a trail.
  68171. * @param scene The scene to add this mesh to.
  68172. * @param diameter Diameter of trailing mesh. Default is 1.
  68173. * @param length Length of trailing mesh. Default is 60.
  68174. * @param autoStart Automatically start trailing mesh. Default true.
  68175. */
  68176. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68177. /**
  68178. * "TrailMesh"
  68179. * @returns "TrailMesh"
  68180. */
  68181. getClassName(): string;
  68182. private _createMesh;
  68183. /**
  68184. * Start trailing mesh.
  68185. */
  68186. start(): void;
  68187. /**
  68188. * Stop trailing mesh.
  68189. */
  68190. stop(): void;
  68191. /**
  68192. * Update trailing mesh geometry.
  68193. */
  68194. update(): void;
  68195. /**
  68196. * Returns a new TrailMesh object.
  68197. * @param name is a string, the name given to the new mesh
  68198. * @param newGenerator use new generator object for cloned trail mesh
  68199. * @returns a new mesh
  68200. */
  68201. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68202. /**
  68203. * Serializes this trail mesh
  68204. * @param serializationObject object to write serialization to
  68205. */
  68206. serialize(serializationObject: any): void;
  68207. /**
  68208. * Parses a serialized trail mesh
  68209. * @param parsedMesh the serialized mesh
  68210. * @param scene the scene to create the trail mesh in
  68211. * @returns the created trail mesh
  68212. */
  68213. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68214. }
  68215. }
  68216. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68217. import { Nullable } from "babylonjs/types";
  68218. import { Scene } from "babylonjs/scene";
  68219. import { Vector4 } from "babylonjs/Maths/math.vector";
  68220. import { Color4 } from "babylonjs/Maths/math.color";
  68221. import { Mesh } from "babylonjs/Meshes/mesh";
  68222. /**
  68223. * Class containing static functions to help procedurally build meshes
  68224. */
  68225. export class TiledBoxBuilder {
  68226. /**
  68227. * Creates a box mesh
  68228. * 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)
  68229. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68233. * @param name defines the name of the mesh
  68234. * @param options defines the options used to create the mesh
  68235. * @param scene defines the hosting scene
  68236. * @returns the box mesh
  68237. */
  68238. static CreateTiledBox(name: string, options: {
  68239. pattern?: number;
  68240. width?: number;
  68241. height?: number;
  68242. depth?: number;
  68243. tileSize?: number;
  68244. tileWidth?: number;
  68245. tileHeight?: number;
  68246. alignHorizontal?: number;
  68247. alignVertical?: number;
  68248. faceUV?: Vector4[];
  68249. faceColors?: Color4[];
  68250. sideOrientation?: number;
  68251. updatable?: boolean;
  68252. }, scene?: Nullable<Scene>): Mesh;
  68253. }
  68254. }
  68255. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68256. import { Vector4 } from "babylonjs/Maths/math.vector";
  68257. import { Mesh } from "babylonjs/Meshes/mesh";
  68258. /**
  68259. * Class containing static functions to help procedurally build meshes
  68260. */
  68261. export class TorusKnotBuilder {
  68262. /**
  68263. * Creates a torus knot mesh
  68264. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68265. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68266. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68267. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68269. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68271. * @param name defines the name of the mesh
  68272. * @param options defines the options used to create the mesh
  68273. * @param scene defines the hosting scene
  68274. * @returns the torus knot mesh
  68275. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68276. */
  68277. static CreateTorusKnot(name: string, options: {
  68278. radius?: number;
  68279. tube?: number;
  68280. radialSegments?: number;
  68281. tubularSegments?: number;
  68282. p?: number;
  68283. q?: number;
  68284. updatable?: boolean;
  68285. sideOrientation?: number;
  68286. frontUVs?: Vector4;
  68287. backUVs?: Vector4;
  68288. }, scene: any): Mesh;
  68289. }
  68290. }
  68291. declare module "babylonjs/Meshes/polygonMesh" {
  68292. import { Scene } from "babylonjs/scene";
  68293. import { Vector2 } from "babylonjs/Maths/math.vector";
  68294. import { Mesh } from "babylonjs/Meshes/mesh";
  68295. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68296. import { Path2 } from "babylonjs/Maths/math.path";
  68297. /**
  68298. * Polygon
  68299. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68300. */
  68301. export class Polygon {
  68302. /**
  68303. * Creates a rectangle
  68304. * @param xmin bottom X coord
  68305. * @param ymin bottom Y coord
  68306. * @param xmax top X coord
  68307. * @param ymax top Y coord
  68308. * @returns points that make the resulting rectation
  68309. */
  68310. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68311. /**
  68312. * Creates a circle
  68313. * @param radius radius of circle
  68314. * @param cx scale in x
  68315. * @param cy scale in y
  68316. * @param numberOfSides number of sides that make up the circle
  68317. * @returns points that make the resulting circle
  68318. */
  68319. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68320. /**
  68321. * Creates a polygon from input string
  68322. * @param input Input polygon data
  68323. * @returns the parsed points
  68324. */
  68325. static Parse(input: string): Vector2[];
  68326. /**
  68327. * Starts building a polygon from x and y coordinates
  68328. * @param x x coordinate
  68329. * @param y y coordinate
  68330. * @returns the started path2
  68331. */
  68332. static StartingAt(x: number, y: number): Path2;
  68333. }
  68334. /**
  68335. * Builds a polygon
  68336. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68337. */
  68338. export class PolygonMeshBuilder {
  68339. private _points;
  68340. private _outlinepoints;
  68341. private _holes;
  68342. private _name;
  68343. private _scene;
  68344. private _epoints;
  68345. private _eholes;
  68346. private _addToepoint;
  68347. /**
  68348. * Babylon reference to the earcut plugin.
  68349. */
  68350. bjsEarcut: any;
  68351. /**
  68352. * Creates a PolygonMeshBuilder
  68353. * @param name name of the builder
  68354. * @param contours Path of the polygon
  68355. * @param scene scene to add to when creating the mesh
  68356. * @param earcutInjection can be used to inject your own earcut reference
  68357. */
  68358. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  68359. /**
  68360. * Adds a whole within the polygon
  68361. * @param hole Array of points defining the hole
  68362. * @returns this
  68363. */
  68364. addHole(hole: Vector2[]): PolygonMeshBuilder;
  68365. /**
  68366. * Creates the polygon
  68367. * @param updatable If the mesh should be updatable
  68368. * @param depth The depth of the mesh created
  68369. * @returns the created mesh
  68370. */
  68371. build(updatable?: boolean, depth?: number): Mesh;
  68372. /**
  68373. * Creates the polygon
  68374. * @param depth The depth of the mesh created
  68375. * @returns the created VertexData
  68376. */
  68377. buildVertexData(depth?: number): VertexData;
  68378. /**
  68379. * Adds a side to the polygon
  68380. * @param positions points that make the polygon
  68381. * @param normals normals of the polygon
  68382. * @param uvs uvs of the polygon
  68383. * @param indices indices of the polygon
  68384. * @param bounds bounds of the polygon
  68385. * @param points points of the polygon
  68386. * @param depth depth of the polygon
  68387. * @param flip flip of the polygon
  68388. */
  68389. private addSide;
  68390. }
  68391. }
  68392. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  68393. import { Scene } from "babylonjs/scene";
  68394. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68395. import { Color4 } from "babylonjs/Maths/math.color";
  68396. import { Mesh } from "babylonjs/Meshes/mesh";
  68397. import { Nullable } from "babylonjs/types";
  68398. /**
  68399. * Class containing static functions to help procedurally build meshes
  68400. */
  68401. export class PolygonBuilder {
  68402. /**
  68403. * Creates a polygon mesh
  68404. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68405. * * 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
  68406. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68409. * * Remember you can only change the shape positions, not their number when updating a polygon
  68410. * @param name defines the name of the mesh
  68411. * @param options defines the options used to create the mesh
  68412. * @param scene defines the hosting scene
  68413. * @param earcutInjection can be used to inject your own earcut reference
  68414. * @returns the polygon mesh
  68415. */
  68416. static CreatePolygon(name: string, options: {
  68417. shape: Vector3[];
  68418. holes?: Vector3[][];
  68419. depth?: number;
  68420. faceUV?: Vector4[];
  68421. faceColors?: Color4[];
  68422. updatable?: boolean;
  68423. sideOrientation?: number;
  68424. frontUVs?: Vector4;
  68425. backUVs?: Vector4;
  68426. wrap?: boolean;
  68427. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68428. /**
  68429. * Creates an extruded polygon mesh, with depth in the Y direction.
  68430. * * 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)
  68431. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68432. * @param name defines the name of the mesh
  68433. * @param options defines the options used to create the mesh
  68434. * @param scene defines the hosting scene
  68435. * @param earcutInjection can be used to inject your own earcut reference
  68436. * @returns the polygon mesh
  68437. */
  68438. static ExtrudePolygon(name: string, options: {
  68439. shape: Vector3[];
  68440. holes?: Vector3[][];
  68441. depth?: number;
  68442. faceUV?: Vector4[];
  68443. faceColors?: Color4[];
  68444. updatable?: boolean;
  68445. sideOrientation?: number;
  68446. frontUVs?: Vector4;
  68447. backUVs?: Vector4;
  68448. wrap?: boolean;
  68449. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68450. }
  68451. }
  68452. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  68453. import { Scene } from "babylonjs/scene";
  68454. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68455. import { Mesh } from "babylonjs/Meshes/mesh";
  68456. import { Nullable } from "babylonjs/types";
  68457. /**
  68458. * Class containing static functions to help procedurally build meshes
  68459. */
  68460. export class LatheBuilder {
  68461. /**
  68462. * Creates lathe mesh.
  68463. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68464. * * 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
  68465. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68466. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68467. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68468. * * 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
  68469. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68470. * * 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
  68471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68473. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68475. * @param name defines the name of the mesh
  68476. * @param options defines the options used to create the mesh
  68477. * @param scene defines the hosting scene
  68478. * @returns the lathe mesh
  68479. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68480. */
  68481. static CreateLathe(name: string, options: {
  68482. shape: Vector3[];
  68483. radius?: number;
  68484. tessellation?: number;
  68485. clip?: number;
  68486. arc?: number;
  68487. closed?: boolean;
  68488. updatable?: boolean;
  68489. sideOrientation?: number;
  68490. frontUVs?: Vector4;
  68491. backUVs?: Vector4;
  68492. cap?: number;
  68493. invertUV?: boolean;
  68494. }, scene?: Nullable<Scene>): Mesh;
  68495. }
  68496. }
  68497. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  68498. import { Nullable } from "babylonjs/types";
  68499. import { Scene } from "babylonjs/scene";
  68500. import { Vector4 } from "babylonjs/Maths/math.vector";
  68501. import { Mesh } from "babylonjs/Meshes/mesh";
  68502. /**
  68503. * Class containing static functions to help procedurally build meshes
  68504. */
  68505. export class TiledPlaneBuilder {
  68506. /**
  68507. * Creates a tiled plane mesh
  68508. * * The parameter `pattern` will, depending on value, do nothing or
  68509. * * * flip (reflect about central vertical) alternate tiles across and up
  68510. * * * flip every tile on alternate rows
  68511. * * * rotate (180 degs) alternate tiles across and up
  68512. * * * rotate every tile on alternate rows
  68513. * * * flip and rotate alternate tiles across and up
  68514. * * * flip and rotate every tile on alternate rows
  68515. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  68516. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  68517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68518. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68519. * * 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)
  68520. * * 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)
  68521. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68522. * @param name defines the name of the mesh
  68523. * @param options defines the options used to create the mesh
  68524. * @param scene defines the hosting scene
  68525. * @returns the box mesh
  68526. */
  68527. static CreateTiledPlane(name: string, options: {
  68528. pattern?: number;
  68529. tileSize?: number;
  68530. tileWidth?: number;
  68531. tileHeight?: number;
  68532. size?: number;
  68533. width?: number;
  68534. height?: number;
  68535. alignHorizontal?: number;
  68536. alignVertical?: number;
  68537. sideOrientation?: number;
  68538. frontUVs?: Vector4;
  68539. backUVs?: Vector4;
  68540. updatable?: boolean;
  68541. }, scene?: Nullable<Scene>): Mesh;
  68542. }
  68543. }
  68544. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  68545. import { Nullable } from "babylonjs/types";
  68546. import { Scene } from "babylonjs/scene";
  68547. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68548. import { Mesh } from "babylonjs/Meshes/mesh";
  68549. /**
  68550. * Class containing static functions to help procedurally build meshes
  68551. */
  68552. export class TubeBuilder {
  68553. /**
  68554. * Creates a tube mesh.
  68555. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68556. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68557. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68558. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68559. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68560. * * 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)
  68561. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68562. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  68563. * * 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
  68564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68565. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68566. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68568. * @param name defines the name of the mesh
  68569. * @param options defines the options used to create the mesh
  68570. * @param scene defines the hosting scene
  68571. * @returns the tube mesh
  68572. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68573. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68574. */
  68575. static CreateTube(name: string, options: {
  68576. path: Vector3[];
  68577. radius?: number;
  68578. tessellation?: number;
  68579. radiusFunction?: {
  68580. (i: number, distance: number): number;
  68581. };
  68582. cap?: number;
  68583. arc?: number;
  68584. updatable?: boolean;
  68585. sideOrientation?: number;
  68586. frontUVs?: Vector4;
  68587. backUVs?: Vector4;
  68588. instance?: Mesh;
  68589. invertUV?: boolean;
  68590. }, scene?: Nullable<Scene>): Mesh;
  68591. }
  68592. }
  68593. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  68594. import { Scene } from "babylonjs/scene";
  68595. import { Vector4 } from "babylonjs/Maths/math.vector";
  68596. import { Mesh } from "babylonjs/Meshes/mesh";
  68597. import { Nullable } from "babylonjs/types";
  68598. /**
  68599. * Class containing static functions to help procedurally build meshes
  68600. */
  68601. export class IcoSphereBuilder {
  68602. /**
  68603. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68604. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68605. * * 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`)
  68606. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68607. * * 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
  68608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68609. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68611. * @param name defines the name of the mesh
  68612. * @param options defines the options used to create the mesh
  68613. * @param scene defines the hosting scene
  68614. * @returns the icosahedron mesh
  68615. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68616. */
  68617. static CreateIcoSphere(name: string, options: {
  68618. radius?: number;
  68619. radiusX?: number;
  68620. radiusY?: number;
  68621. radiusZ?: number;
  68622. flat?: boolean;
  68623. subdivisions?: number;
  68624. sideOrientation?: number;
  68625. frontUVs?: Vector4;
  68626. backUVs?: Vector4;
  68627. updatable?: boolean;
  68628. }, scene?: Nullable<Scene>): Mesh;
  68629. }
  68630. }
  68631. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  68632. import { Vector3 } from "babylonjs/Maths/math.vector";
  68633. import { Mesh } from "babylonjs/Meshes/mesh";
  68634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68635. /**
  68636. * Class containing static functions to help procedurally build meshes
  68637. */
  68638. export class DecalBuilder {
  68639. /**
  68640. * Creates a decal mesh.
  68641. * 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
  68642. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68643. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68644. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68645. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68646. * @param name defines the name of the mesh
  68647. * @param sourceMesh defines the mesh where the decal must be applied
  68648. * @param options defines the options used to create the mesh
  68649. * @param scene defines the hosting scene
  68650. * @returns the decal mesh
  68651. * @see https://doc.babylonjs.com/how_to/decals
  68652. */
  68653. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68654. position?: Vector3;
  68655. normal?: Vector3;
  68656. size?: Vector3;
  68657. angle?: number;
  68658. }): Mesh;
  68659. }
  68660. }
  68661. declare module "babylonjs/Meshes/meshBuilder" {
  68662. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  68663. import { Nullable } from "babylonjs/types";
  68664. import { Scene } from "babylonjs/scene";
  68665. import { Mesh } from "babylonjs/Meshes/mesh";
  68666. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  68667. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  68668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68669. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68670. import { Plane } from "babylonjs/Maths/math.plane";
  68671. /**
  68672. * Class containing static functions to help procedurally build meshes
  68673. */
  68674. export class MeshBuilder {
  68675. /**
  68676. * Creates a box mesh
  68677. * * The parameter `size` sets the size (float) of each box side (default 1)
  68678. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  68679. * * 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)
  68680. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68684. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68685. * @param name defines the name of the mesh
  68686. * @param options defines the options used to create the mesh
  68687. * @param scene defines the hosting scene
  68688. * @returns the box mesh
  68689. */
  68690. static CreateBox(name: string, options: {
  68691. size?: number;
  68692. width?: number;
  68693. height?: number;
  68694. depth?: number;
  68695. faceUV?: Vector4[];
  68696. faceColors?: Color4[];
  68697. sideOrientation?: number;
  68698. frontUVs?: Vector4;
  68699. backUVs?: Vector4;
  68700. wrap?: boolean;
  68701. topBaseAt?: number;
  68702. bottomBaseAt?: number;
  68703. updatable?: boolean;
  68704. }, scene?: Nullable<Scene>): Mesh;
  68705. /**
  68706. * Creates a tiled box mesh
  68707. * * faceTiles sets the pattern, tile size and number of tiles for a face
  68708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68709. * @param name defines the name of the mesh
  68710. * @param options defines the options used to create the mesh
  68711. * @param scene defines the hosting scene
  68712. * @returns the tiled box mesh
  68713. */
  68714. static CreateTiledBox(name: string, options: {
  68715. pattern?: number;
  68716. size?: number;
  68717. width?: number;
  68718. height?: number;
  68719. depth: number;
  68720. tileSize?: number;
  68721. tileWidth?: number;
  68722. tileHeight?: number;
  68723. faceUV?: Vector4[];
  68724. faceColors?: Color4[];
  68725. alignHorizontal?: number;
  68726. alignVertical?: number;
  68727. sideOrientation?: number;
  68728. updatable?: boolean;
  68729. }, scene?: Nullable<Scene>): Mesh;
  68730. /**
  68731. * Creates a sphere mesh
  68732. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  68733. * * 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`)
  68734. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  68735. * * 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
  68736. * * 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)
  68737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68738. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68740. * @param name defines the name of the mesh
  68741. * @param options defines the options used to create the mesh
  68742. * @param scene defines the hosting scene
  68743. * @returns the sphere mesh
  68744. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  68745. */
  68746. static CreateSphere(name: string, options: {
  68747. segments?: number;
  68748. diameter?: number;
  68749. diameterX?: number;
  68750. diameterY?: number;
  68751. diameterZ?: number;
  68752. arc?: number;
  68753. slice?: number;
  68754. sideOrientation?: number;
  68755. frontUVs?: Vector4;
  68756. backUVs?: Vector4;
  68757. updatable?: boolean;
  68758. }, scene?: Nullable<Scene>): Mesh;
  68759. /**
  68760. * Creates a plane polygonal mesh. By default, this is a disc
  68761. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  68762. * * 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
  68763. * * 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
  68764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68767. * @param name defines the name of the mesh
  68768. * @param options defines the options used to create the mesh
  68769. * @param scene defines the hosting scene
  68770. * @returns the plane polygonal mesh
  68771. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  68772. */
  68773. static CreateDisc(name: string, options: {
  68774. radius?: number;
  68775. tessellation?: number;
  68776. arc?: number;
  68777. updatable?: boolean;
  68778. sideOrientation?: number;
  68779. frontUVs?: Vector4;
  68780. backUVs?: Vector4;
  68781. }, scene?: Nullable<Scene>): Mesh;
  68782. /**
  68783. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68784. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68785. * * 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`)
  68786. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68787. * * 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
  68788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68791. * @param name defines the name of the mesh
  68792. * @param options defines the options used to create the mesh
  68793. * @param scene defines the hosting scene
  68794. * @returns the icosahedron mesh
  68795. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68796. */
  68797. static CreateIcoSphere(name: string, options: {
  68798. radius?: number;
  68799. radiusX?: number;
  68800. radiusY?: number;
  68801. radiusZ?: number;
  68802. flat?: boolean;
  68803. subdivisions?: number;
  68804. sideOrientation?: number;
  68805. frontUVs?: Vector4;
  68806. backUVs?: Vector4;
  68807. updatable?: boolean;
  68808. }, scene?: Nullable<Scene>): Mesh;
  68809. /**
  68810. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68811. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  68812. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  68813. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  68814. * * 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
  68815. * * 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
  68816. * * 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
  68817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68818. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68819. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68820. * * 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
  68821. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  68822. * * 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
  68823. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  68824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68825. * @param name defines the name of the mesh
  68826. * @param options defines the options used to create the mesh
  68827. * @param scene defines the hosting scene
  68828. * @returns the ribbon mesh
  68829. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  68830. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68831. */
  68832. static CreateRibbon(name: string, options: {
  68833. pathArray: Vector3[][];
  68834. closeArray?: boolean;
  68835. closePath?: boolean;
  68836. offset?: number;
  68837. updatable?: boolean;
  68838. sideOrientation?: number;
  68839. frontUVs?: Vector4;
  68840. backUVs?: Vector4;
  68841. instance?: Mesh;
  68842. invertUV?: boolean;
  68843. uvs?: Vector2[];
  68844. colors?: Color4[];
  68845. }, scene?: Nullable<Scene>): Mesh;
  68846. /**
  68847. * Creates a cylinder or a cone mesh
  68848. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  68849. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  68850. * * 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.
  68851. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  68852. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  68853. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  68854. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  68855. * * 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).
  68856. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  68857. * * 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).
  68858. * * 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
  68859. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  68860. * * 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
  68861. * * 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.
  68862. * * If `enclose` is false, a ring surface is one element.
  68863. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  68864. * * 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
  68865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68868. * @param name defines the name of the mesh
  68869. * @param options defines the options used to create the mesh
  68870. * @param scene defines the hosting scene
  68871. * @returns the cylinder mesh
  68872. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  68873. */
  68874. static CreateCylinder(name: string, options: {
  68875. height?: number;
  68876. diameterTop?: number;
  68877. diameterBottom?: number;
  68878. diameter?: number;
  68879. tessellation?: number;
  68880. subdivisions?: number;
  68881. arc?: number;
  68882. faceColors?: Color4[];
  68883. faceUV?: Vector4[];
  68884. updatable?: boolean;
  68885. hasRings?: boolean;
  68886. enclose?: boolean;
  68887. cap?: number;
  68888. sideOrientation?: number;
  68889. frontUVs?: Vector4;
  68890. backUVs?: Vector4;
  68891. }, scene?: Nullable<Scene>): Mesh;
  68892. /**
  68893. * Creates a torus mesh
  68894. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  68895. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  68896. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  68897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68898. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68900. * @param name defines the name of the mesh
  68901. * @param options defines the options used to create the mesh
  68902. * @param scene defines the hosting scene
  68903. * @returns the torus mesh
  68904. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  68905. */
  68906. static CreateTorus(name: string, options: {
  68907. diameter?: number;
  68908. thickness?: number;
  68909. tessellation?: number;
  68910. updatable?: boolean;
  68911. sideOrientation?: number;
  68912. frontUVs?: Vector4;
  68913. backUVs?: Vector4;
  68914. }, scene?: Nullable<Scene>): Mesh;
  68915. /**
  68916. * Creates a torus knot mesh
  68917. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68918. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68919. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68920. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68924. * @param name defines the name of the mesh
  68925. * @param options defines the options used to create the mesh
  68926. * @param scene defines the hosting scene
  68927. * @returns the torus knot mesh
  68928. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68929. */
  68930. static CreateTorusKnot(name: string, options: {
  68931. radius?: number;
  68932. tube?: number;
  68933. radialSegments?: number;
  68934. tubularSegments?: number;
  68935. p?: number;
  68936. q?: number;
  68937. updatable?: boolean;
  68938. sideOrientation?: number;
  68939. frontUVs?: Vector4;
  68940. backUVs?: Vector4;
  68941. }, scene?: Nullable<Scene>): Mesh;
  68942. /**
  68943. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  68944. * * 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
  68945. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  68946. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  68947. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  68948. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  68949. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  68950. * * 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
  68951. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  68952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68953. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  68954. * @param name defines the name of the new line system
  68955. * @param options defines the options used to create the line system
  68956. * @param scene defines the hosting scene
  68957. * @returns a new line system mesh
  68958. */
  68959. static CreateLineSystem(name: string, options: {
  68960. lines: Vector3[][];
  68961. updatable?: boolean;
  68962. instance?: Nullable<LinesMesh>;
  68963. colors?: Nullable<Color4[][]>;
  68964. useVertexAlpha?: boolean;
  68965. }, scene: Nullable<Scene>): LinesMesh;
  68966. /**
  68967. * Creates a line mesh
  68968. * 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
  68969. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68970. * * The parameter `points` is an array successive Vector3
  68971. * * 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
  68972. * * The optional parameter `colors` is an array of successive Color4, one per line point
  68973. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  68974. * * When updating an instance, remember that only point positions can change, not the number of points
  68975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68976. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  68977. * @param name defines the name of the new line system
  68978. * @param options defines the options used to create the line system
  68979. * @param scene defines the hosting scene
  68980. * @returns a new line mesh
  68981. */
  68982. static CreateLines(name: string, options: {
  68983. points: Vector3[];
  68984. updatable?: boolean;
  68985. instance?: Nullable<LinesMesh>;
  68986. colors?: Color4[];
  68987. useVertexAlpha?: boolean;
  68988. }, scene?: Nullable<Scene>): LinesMesh;
  68989. /**
  68990. * Creates a dashed line mesh
  68991. * * 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
  68992. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68993. * * The parameter `points` is an array successive Vector3
  68994. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  68995. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  68996. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  68997. * * 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
  68998. * * When updating an instance, remember that only point positions can change, not the number of points
  68999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69000. * @param name defines the name of the mesh
  69001. * @param options defines the options used to create the mesh
  69002. * @param scene defines the hosting scene
  69003. * @returns the dashed line mesh
  69004. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69005. */
  69006. static CreateDashedLines(name: string, options: {
  69007. points: Vector3[];
  69008. dashSize?: number;
  69009. gapSize?: number;
  69010. dashNb?: number;
  69011. updatable?: boolean;
  69012. instance?: LinesMesh;
  69013. }, scene?: Nullable<Scene>): LinesMesh;
  69014. /**
  69015. * 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.
  69016. * * 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.
  69017. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69018. * * 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.
  69019. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69020. * * 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
  69021. * * 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
  69022. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69024. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69025. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69027. * @param name defines the name of the mesh
  69028. * @param options defines the options used to create the mesh
  69029. * @param scene defines the hosting scene
  69030. * @returns the extruded shape mesh
  69031. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69032. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69033. */
  69034. static ExtrudeShape(name: string, options: {
  69035. shape: Vector3[];
  69036. path: Vector3[];
  69037. scale?: number;
  69038. rotation?: number;
  69039. cap?: number;
  69040. updatable?: boolean;
  69041. sideOrientation?: number;
  69042. frontUVs?: Vector4;
  69043. backUVs?: Vector4;
  69044. instance?: Mesh;
  69045. invertUV?: boolean;
  69046. }, scene?: Nullable<Scene>): Mesh;
  69047. /**
  69048. * Creates an custom extruded shape mesh.
  69049. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69050. * * 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.
  69051. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69052. * * 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
  69053. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69054. * * 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
  69055. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69056. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69057. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69058. * * 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
  69059. * * 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
  69060. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69063. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69065. * @param name defines the name of the mesh
  69066. * @param options defines the options used to create the mesh
  69067. * @param scene defines the hosting scene
  69068. * @returns the custom extruded shape mesh
  69069. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69070. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69071. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69072. */
  69073. static ExtrudeShapeCustom(name: string, options: {
  69074. shape: Vector3[];
  69075. path: Vector3[];
  69076. scaleFunction?: any;
  69077. rotationFunction?: any;
  69078. ribbonCloseArray?: boolean;
  69079. ribbonClosePath?: boolean;
  69080. cap?: number;
  69081. updatable?: boolean;
  69082. sideOrientation?: number;
  69083. frontUVs?: Vector4;
  69084. backUVs?: Vector4;
  69085. instance?: Mesh;
  69086. invertUV?: boolean;
  69087. }, scene?: Nullable<Scene>): Mesh;
  69088. /**
  69089. * Creates lathe mesh.
  69090. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69091. * * 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
  69092. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69093. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69094. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69095. * * 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
  69096. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69097. * * 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
  69098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69099. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69100. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69102. * @param name defines the name of the mesh
  69103. * @param options defines the options used to create the mesh
  69104. * @param scene defines the hosting scene
  69105. * @returns the lathe mesh
  69106. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69107. */
  69108. static CreateLathe(name: string, options: {
  69109. shape: Vector3[];
  69110. radius?: number;
  69111. tessellation?: number;
  69112. clip?: number;
  69113. arc?: number;
  69114. closed?: boolean;
  69115. updatable?: boolean;
  69116. sideOrientation?: number;
  69117. frontUVs?: Vector4;
  69118. backUVs?: Vector4;
  69119. cap?: number;
  69120. invertUV?: boolean;
  69121. }, scene?: Nullable<Scene>): Mesh;
  69122. /**
  69123. * Creates a tiled plane mesh
  69124. * * You can set a limited pattern arrangement with the tiles
  69125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69128. * @param name defines the name of the mesh
  69129. * @param options defines the options used to create the mesh
  69130. * @param scene defines the hosting scene
  69131. * @returns the plane mesh
  69132. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69133. */
  69134. static CreateTiledPlane(name: string, options: {
  69135. pattern?: number;
  69136. tileSize?: number;
  69137. tileWidth?: number;
  69138. tileHeight?: number;
  69139. size?: number;
  69140. width?: number;
  69141. height?: number;
  69142. alignHorizontal?: number;
  69143. alignVertical?: number;
  69144. sideOrientation?: number;
  69145. frontUVs?: Vector4;
  69146. backUVs?: Vector4;
  69147. updatable?: boolean;
  69148. }, scene?: Nullable<Scene>): Mesh;
  69149. /**
  69150. * Creates a plane mesh
  69151. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69152. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69153. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69157. * @param name defines the name of the mesh
  69158. * @param options defines the options used to create the mesh
  69159. * @param scene defines the hosting scene
  69160. * @returns the plane mesh
  69161. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69162. */
  69163. static CreatePlane(name: string, options: {
  69164. size?: number;
  69165. width?: number;
  69166. height?: number;
  69167. sideOrientation?: number;
  69168. frontUVs?: Vector4;
  69169. backUVs?: Vector4;
  69170. updatable?: boolean;
  69171. sourcePlane?: Plane;
  69172. }, scene?: Nullable<Scene>): Mesh;
  69173. /**
  69174. * Creates a ground mesh
  69175. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69176. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69178. * @param name defines the name of the mesh
  69179. * @param options defines the options used to create the mesh
  69180. * @param scene defines the hosting scene
  69181. * @returns the ground mesh
  69182. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69183. */
  69184. static CreateGround(name: string, options: {
  69185. width?: number;
  69186. height?: number;
  69187. subdivisions?: number;
  69188. subdivisionsX?: number;
  69189. subdivisionsY?: number;
  69190. updatable?: boolean;
  69191. }, scene?: Nullable<Scene>): Mesh;
  69192. /**
  69193. * Creates a tiled ground mesh
  69194. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69195. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69196. * * 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
  69197. * * 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
  69198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69199. * @param name defines the name of the mesh
  69200. * @param options defines the options used to create the mesh
  69201. * @param scene defines the hosting scene
  69202. * @returns the tiled ground mesh
  69203. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69204. */
  69205. static CreateTiledGround(name: string, options: {
  69206. xmin: number;
  69207. zmin: number;
  69208. xmax: number;
  69209. zmax: number;
  69210. subdivisions?: {
  69211. w: number;
  69212. h: number;
  69213. };
  69214. precision?: {
  69215. w: number;
  69216. h: number;
  69217. };
  69218. updatable?: boolean;
  69219. }, scene?: Nullable<Scene>): Mesh;
  69220. /**
  69221. * Creates a ground mesh from a height map
  69222. * * The parameter `url` sets the URL of the height map image resource.
  69223. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69224. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69225. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69226. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69227. * * 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.
  69228. * * 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).
  69229. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69231. * @param name defines the name of the mesh
  69232. * @param url defines the url to the height map
  69233. * @param options defines the options used to create the mesh
  69234. * @param scene defines the hosting scene
  69235. * @returns the ground mesh
  69236. * @see https://doc.babylonjs.com/babylon101/height_map
  69237. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69238. */
  69239. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69240. width?: number;
  69241. height?: number;
  69242. subdivisions?: number;
  69243. minHeight?: number;
  69244. maxHeight?: number;
  69245. colorFilter?: Color3;
  69246. alphaFilter?: number;
  69247. updatable?: boolean;
  69248. onReady?: (mesh: GroundMesh) => void;
  69249. }, scene?: Nullable<Scene>): GroundMesh;
  69250. /**
  69251. * Creates a polygon mesh
  69252. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69253. * * 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
  69254. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69257. * * Remember you can only change the shape positions, not their number when updating a polygon
  69258. * @param name defines the name of the mesh
  69259. * @param options defines the options used to create the mesh
  69260. * @param scene defines the hosting scene
  69261. * @param earcutInjection can be used to inject your own earcut reference
  69262. * @returns the polygon mesh
  69263. */
  69264. static CreatePolygon(name: string, options: {
  69265. shape: Vector3[];
  69266. holes?: Vector3[][];
  69267. depth?: number;
  69268. faceUV?: Vector4[];
  69269. faceColors?: Color4[];
  69270. updatable?: boolean;
  69271. sideOrientation?: number;
  69272. frontUVs?: Vector4;
  69273. backUVs?: Vector4;
  69274. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69275. /**
  69276. * Creates an extruded polygon mesh, with depth in the Y direction.
  69277. * * 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)
  69278. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69279. * @param name defines the name of the mesh
  69280. * @param options defines the options used to create the mesh
  69281. * @param scene defines the hosting scene
  69282. * @param earcutInjection can be used to inject your own earcut reference
  69283. * @returns the polygon mesh
  69284. */
  69285. static ExtrudePolygon(name: string, options: {
  69286. shape: Vector3[];
  69287. holes?: Vector3[][];
  69288. depth?: number;
  69289. faceUV?: Vector4[];
  69290. faceColors?: Color4[];
  69291. updatable?: boolean;
  69292. sideOrientation?: number;
  69293. frontUVs?: Vector4;
  69294. backUVs?: Vector4;
  69295. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69296. /**
  69297. * Creates a tube mesh.
  69298. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69299. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69300. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69301. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69302. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69303. * * 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)
  69304. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69305. * * 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
  69306. * * 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
  69307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69308. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69309. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69311. * @param name defines the name of the mesh
  69312. * @param options defines the options used to create the mesh
  69313. * @param scene defines the hosting scene
  69314. * @returns the tube mesh
  69315. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69316. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69317. */
  69318. static CreateTube(name: string, options: {
  69319. path: Vector3[];
  69320. radius?: number;
  69321. tessellation?: number;
  69322. radiusFunction?: {
  69323. (i: number, distance: number): number;
  69324. };
  69325. cap?: number;
  69326. arc?: number;
  69327. updatable?: boolean;
  69328. sideOrientation?: number;
  69329. frontUVs?: Vector4;
  69330. backUVs?: Vector4;
  69331. instance?: Mesh;
  69332. invertUV?: boolean;
  69333. }, scene?: Nullable<Scene>): Mesh;
  69334. /**
  69335. * Creates a polyhedron mesh
  69336. * * 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
  69337. * * The parameter `size` (positive float, default 1) sets the polygon size
  69338. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  69339. * * 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`
  69340. * * 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
  69341. * * 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)`)
  69342. * * 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
  69343. * * 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
  69344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69345. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69347. * @param name defines the name of the mesh
  69348. * @param options defines the options used to create the mesh
  69349. * @param scene defines the hosting scene
  69350. * @returns the polyhedron mesh
  69351. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  69352. */
  69353. static CreatePolyhedron(name: string, options: {
  69354. type?: number;
  69355. size?: number;
  69356. sizeX?: number;
  69357. sizeY?: number;
  69358. sizeZ?: number;
  69359. custom?: any;
  69360. faceUV?: Vector4[];
  69361. faceColors?: Color4[];
  69362. flat?: boolean;
  69363. updatable?: boolean;
  69364. sideOrientation?: number;
  69365. frontUVs?: Vector4;
  69366. backUVs?: Vector4;
  69367. }, scene?: Nullable<Scene>): Mesh;
  69368. /**
  69369. * Creates a decal mesh.
  69370. * 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
  69371. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69372. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69373. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69374. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69375. * @param name defines the name of the mesh
  69376. * @param sourceMesh defines the mesh where the decal must be applied
  69377. * @param options defines the options used to create the mesh
  69378. * @param scene defines the hosting scene
  69379. * @returns the decal mesh
  69380. * @see https://doc.babylonjs.com/how_to/decals
  69381. */
  69382. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69383. position?: Vector3;
  69384. normal?: Vector3;
  69385. size?: Vector3;
  69386. angle?: number;
  69387. }): Mesh;
  69388. }
  69389. }
  69390. declare module "babylonjs/Meshes/meshSimplification" {
  69391. import { Mesh } from "babylonjs/Meshes/mesh";
  69392. /**
  69393. * A simplifier interface for future simplification implementations
  69394. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69395. */
  69396. export interface ISimplifier {
  69397. /**
  69398. * Simplification of a given mesh according to the given settings.
  69399. * Since this requires computation, it is assumed that the function runs async.
  69400. * @param settings The settings of the simplification, including quality and distance
  69401. * @param successCallback A callback that will be called after the mesh was simplified.
  69402. * @param errorCallback in case of an error, this callback will be called. optional.
  69403. */
  69404. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  69405. }
  69406. /**
  69407. * Expected simplification settings.
  69408. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  69409. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69410. */
  69411. export interface ISimplificationSettings {
  69412. /**
  69413. * Gets or sets the expected quality
  69414. */
  69415. quality: number;
  69416. /**
  69417. * Gets or sets the distance when this optimized version should be used
  69418. */
  69419. distance: number;
  69420. /**
  69421. * Gets an already optimized mesh
  69422. */
  69423. optimizeMesh?: boolean;
  69424. }
  69425. /**
  69426. * Class used to specify simplification options
  69427. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69428. */
  69429. export class SimplificationSettings implements ISimplificationSettings {
  69430. /** expected quality */
  69431. quality: number;
  69432. /** distance when this optimized version should be used */
  69433. distance: number;
  69434. /** already optimized mesh */
  69435. optimizeMesh?: boolean | undefined;
  69436. /**
  69437. * Creates a SimplificationSettings
  69438. * @param quality expected quality
  69439. * @param distance distance when this optimized version should be used
  69440. * @param optimizeMesh already optimized mesh
  69441. */
  69442. constructor(
  69443. /** expected quality */
  69444. quality: number,
  69445. /** distance when this optimized version should be used */
  69446. distance: number,
  69447. /** already optimized mesh */
  69448. optimizeMesh?: boolean | undefined);
  69449. }
  69450. /**
  69451. * Interface used to define a simplification task
  69452. */
  69453. export interface ISimplificationTask {
  69454. /**
  69455. * Array of settings
  69456. */
  69457. settings: Array<ISimplificationSettings>;
  69458. /**
  69459. * Simplification type
  69460. */
  69461. simplificationType: SimplificationType;
  69462. /**
  69463. * Mesh to simplify
  69464. */
  69465. mesh: Mesh;
  69466. /**
  69467. * Callback called on success
  69468. */
  69469. successCallback?: () => void;
  69470. /**
  69471. * Defines if parallel processing can be used
  69472. */
  69473. parallelProcessing: boolean;
  69474. }
  69475. /**
  69476. * Queue used to order the simplification tasks
  69477. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69478. */
  69479. export class SimplificationQueue {
  69480. private _simplificationArray;
  69481. /**
  69482. * Gets a boolean indicating that the process is still running
  69483. */
  69484. running: boolean;
  69485. /**
  69486. * Creates a new queue
  69487. */
  69488. constructor();
  69489. /**
  69490. * Adds a new simplification task
  69491. * @param task defines a task to add
  69492. */
  69493. addTask(task: ISimplificationTask): void;
  69494. /**
  69495. * Execute next task
  69496. */
  69497. executeNext(): void;
  69498. /**
  69499. * Execute a simplification task
  69500. * @param task defines the task to run
  69501. */
  69502. runSimplification(task: ISimplificationTask): void;
  69503. private getSimplifier;
  69504. }
  69505. /**
  69506. * The implemented types of simplification
  69507. * At the moment only Quadratic Error Decimation is implemented
  69508. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69509. */
  69510. export enum SimplificationType {
  69511. /** Quadratic error decimation */
  69512. QUADRATIC = 0
  69513. }
  69514. /**
  69515. * An implementation of the Quadratic Error simplification algorithm.
  69516. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  69517. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  69518. * @author RaananW
  69519. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69520. */
  69521. export class QuadraticErrorSimplification implements ISimplifier {
  69522. private _mesh;
  69523. private triangles;
  69524. private vertices;
  69525. private references;
  69526. private _reconstructedMesh;
  69527. /** Gets or sets the number pf sync interations */
  69528. syncIterations: number;
  69529. /** Gets or sets the aggressiveness of the simplifier */
  69530. aggressiveness: number;
  69531. /** Gets or sets the number of allowed iterations for decimation */
  69532. decimationIterations: number;
  69533. /** Gets or sets the espilon to use for bounding box computation */
  69534. boundingBoxEpsilon: number;
  69535. /**
  69536. * Creates a new QuadraticErrorSimplification
  69537. * @param _mesh defines the target mesh
  69538. */
  69539. constructor(_mesh: Mesh);
  69540. /**
  69541. * Simplification of a given mesh according to the given settings.
  69542. * Since this requires computation, it is assumed that the function runs async.
  69543. * @param settings The settings of the simplification, including quality and distance
  69544. * @param successCallback A callback that will be called after the mesh was simplified.
  69545. */
  69546. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  69547. private runDecimation;
  69548. private initWithMesh;
  69549. private init;
  69550. private reconstructMesh;
  69551. private initDecimatedMesh;
  69552. private isFlipped;
  69553. private updateTriangles;
  69554. private identifyBorder;
  69555. private updateMesh;
  69556. private vertexError;
  69557. private calculateError;
  69558. }
  69559. }
  69560. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  69561. import { Scene } from "babylonjs/scene";
  69562. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  69563. import { ISceneComponent } from "babylonjs/sceneComponent";
  69564. module "babylonjs/scene" {
  69565. interface Scene {
  69566. /** @hidden (Backing field) */
  69567. _simplificationQueue: SimplificationQueue;
  69568. /**
  69569. * Gets or sets the simplification queue attached to the scene
  69570. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69571. */
  69572. simplificationQueue: SimplificationQueue;
  69573. }
  69574. }
  69575. module "babylonjs/Meshes/mesh" {
  69576. interface Mesh {
  69577. /**
  69578. * Simplify the mesh according to the given array of settings.
  69579. * Function will return immediately and will simplify async
  69580. * @param settings a collection of simplification settings
  69581. * @param parallelProcessing should all levels calculate parallel or one after the other
  69582. * @param simplificationType the type of simplification to run
  69583. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  69584. * @returns the current mesh
  69585. */
  69586. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  69587. }
  69588. }
  69589. /**
  69590. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  69591. * created in a scene
  69592. */
  69593. export class SimplicationQueueSceneComponent implements ISceneComponent {
  69594. /**
  69595. * The component name helpfull to identify the component in the list of scene components.
  69596. */
  69597. readonly name: string;
  69598. /**
  69599. * The scene the component belongs to.
  69600. */
  69601. scene: Scene;
  69602. /**
  69603. * Creates a new instance of the component for the given scene
  69604. * @param scene Defines the scene to register the component in
  69605. */
  69606. constructor(scene: Scene);
  69607. /**
  69608. * Registers the component in a given scene
  69609. */
  69610. register(): void;
  69611. /**
  69612. * Rebuilds the elements related to this component in case of
  69613. * context lost for instance.
  69614. */
  69615. rebuild(): void;
  69616. /**
  69617. * Disposes the component and the associated ressources
  69618. */
  69619. dispose(): void;
  69620. private _beforeCameraUpdate;
  69621. }
  69622. }
  69623. declare module "babylonjs/Meshes/Builders/index" {
  69624. export * from "babylonjs/Meshes/Builders/boxBuilder";
  69625. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  69626. export * from "babylonjs/Meshes/Builders/discBuilder";
  69627. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  69628. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  69629. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  69630. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  69631. export * from "babylonjs/Meshes/Builders/torusBuilder";
  69632. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  69633. export * from "babylonjs/Meshes/Builders/linesBuilder";
  69634. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  69635. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  69636. export * from "babylonjs/Meshes/Builders/latheBuilder";
  69637. export * from "babylonjs/Meshes/Builders/planeBuilder";
  69638. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  69639. export * from "babylonjs/Meshes/Builders/groundBuilder";
  69640. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  69641. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  69642. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  69643. export * from "babylonjs/Meshes/Builders/decalBuilder";
  69644. }
  69645. declare module "babylonjs/Meshes/thinInstanceMesh" {
  69646. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  69647. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  69648. import { Matrix } from "babylonjs/Maths/math.vector";
  69649. module "babylonjs/Meshes/mesh" {
  69650. interface Mesh {
  69651. /**
  69652. * Creates a new thin instance
  69653. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  69654. * @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
  69655. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  69656. */
  69657. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  69658. /**
  69659. * Adds the transformation (matrix) of the current mesh as a thin instance
  69660. * @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
  69661. * @returns the thin instance index number
  69662. */
  69663. thinInstanceAddSelf(refresh: boolean): number;
  69664. /**
  69665. * Registers a custom attribute to be used with thin instances
  69666. * @param kind name of the attribute
  69667. * @param stride size in floats of the attribute
  69668. */
  69669. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  69670. /**
  69671. * Sets the matrix of a thin instance
  69672. * @param index index of the thin instance
  69673. * @param matrix matrix to set
  69674. * @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
  69675. */
  69676. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  69677. /**
  69678. * Sets the value of a custom attribute for a thin instance
  69679. * @param kind name of the attribute
  69680. * @param index index of the thin instance
  69681. * @param value value to set
  69682. * @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
  69683. */
  69684. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  69685. /**
  69686. * 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.
  69687. */
  69688. thinInstanceCount: number;
  69689. /**
  69690. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  69691. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  69692. * @param buffer buffer to set
  69693. * @param stride size in floats of each value of the buffer
  69694. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  69695. */
  69696. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  69697. /**
  69698. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  69699. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  69700. */
  69701. thinInstanceBufferUpdated(kind: string): void;
  69702. /**
  69703. * Refreshes the bounding info, taking into account all the thin instances defined
  69704. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  69705. */
  69706. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  69707. /** @hidden */
  69708. _thinInstanceInitializeUserStorage(): void;
  69709. /** @hidden */
  69710. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  69711. /** @hidden */
  69712. _userThinInstanceBuffersStorage: {
  69713. data: {
  69714. [key: string]: Float32Array;
  69715. };
  69716. sizes: {
  69717. [key: string]: number;
  69718. };
  69719. vertexBuffers: {
  69720. [key: string]: Nullable<VertexBuffer>;
  69721. };
  69722. strides: {
  69723. [key: string]: number;
  69724. };
  69725. };
  69726. }
  69727. }
  69728. }
  69729. declare module "babylonjs/Meshes/index" {
  69730. export * from "babylonjs/Meshes/abstractMesh";
  69731. export * from "babylonjs/Meshes/buffer";
  69732. export * from "babylonjs/Meshes/Compression/index";
  69733. export * from "babylonjs/Meshes/csg";
  69734. export * from "babylonjs/Meshes/geometry";
  69735. export * from "babylonjs/Meshes/groundMesh";
  69736. export * from "babylonjs/Meshes/trailMesh";
  69737. export * from "babylonjs/Meshes/instancedMesh";
  69738. export * from "babylonjs/Meshes/linesMesh";
  69739. export * from "babylonjs/Meshes/mesh";
  69740. export * from "babylonjs/Meshes/mesh.vertexData";
  69741. export * from "babylonjs/Meshes/meshBuilder";
  69742. export * from "babylonjs/Meshes/meshSimplification";
  69743. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  69744. export * from "babylonjs/Meshes/polygonMesh";
  69745. export * from "babylonjs/Meshes/subMesh";
  69746. export * from "babylonjs/Meshes/meshLODLevel";
  69747. export * from "babylonjs/Meshes/transformNode";
  69748. export * from "babylonjs/Meshes/Builders/index";
  69749. export * from "babylonjs/Meshes/dataBuffer";
  69750. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  69751. import "babylonjs/Meshes/thinInstanceMesh";
  69752. export * from "babylonjs/Meshes/thinInstanceMesh";
  69753. }
  69754. declare module "babylonjs/Morph/index" {
  69755. export * from "babylonjs/Morph/morphTarget";
  69756. export * from "babylonjs/Morph/morphTargetManager";
  69757. }
  69758. declare module "babylonjs/Navigation/INavigationEngine" {
  69759. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69760. import { Vector3 } from "babylonjs/Maths/math";
  69761. import { Mesh } from "babylonjs/Meshes/mesh";
  69762. import { Scene } from "babylonjs/scene";
  69763. /**
  69764. * Navigation plugin interface to add navigation constrained by a navigation mesh
  69765. */
  69766. export interface INavigationEnginePlugin {
  69767. /**
  69768. * plugin name
  69769. */
  69770. name: string;
  69771. /**
  69772. * Creates a navigation mesh
  69773. * @param meshes array of all the geometry used to compute the navigatio mesh
  69774. * @param parameters bunch of parameters used to filter geometry
  69775. */
  69776. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69777. /**
  69778. * Create a navigation mesh debug mesh
  69779. * @param scene is where the mesh will be added
  69780. * @returns debug display mesh
  69781. */
  69782. createDebugNavMesh(scene: Scene): Mesh;
  69783. /**
  69784. * Get a navigation mesh constrained position, closest to the parameter position
  69785. * @param position world position
  69786. * @returns the closest point to position constrained by the navigation mesh
  69787. */
  69788. getClosestPoint(position: Vector3): Vector3;
  69789. /**
  69790. * Get a navigation mesh constrained position, closest to the parameter position
  69791. * @param position world position
  69792. * @param result output the closest point to position constrained by the navigation mesh
  69793. */
  69794. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69795. /**
  69796. * Get a navigation mesh constrained position, within a particular radius
  69797. * @param position world position
  69798. * @param maxRadius the maximum distance to the constrained world position
  69799. * @returns the closest point to position constrained by the navigation mesh
  69800. */
  69801. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69802. /**
  69803. * Get a navigation mesh constrained position, within a particular radius
  69804. * @param position world position
  69805. * @param maxRadius the maximum distance to the constrained world position
  69806. * @param result output the closest point to position constrained by the navigation mesh
  69807. */
  69808. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69809. /**
  69810. * Compute the final position from a segment made of destination-position
  69811. * @param position world position
  69812. * @param destination world position
  69813. * @returns the resulting point along the navmesh
  69814. */
  69815. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69816. /**
  69817. * Compute the final position from a segment made of destination-position
  69818. * @param position world position
  69819. * @param destination world position
  69820. * @param result output the resulting point along the navmesh
  69821. */
  69822. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69823. /**
  69824. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69825. * @param start world position
  69826. * @param end world position
  69827. * @returns array containing world position composing the path
  69828. */
  69829. computePath(start: Vector3, end: Vector3): Vector3[];
  69830. /**
  69831. * If this plugin is supported
  69832. * @returns true if plugin is supported
  69833. */
  69834. isSupported(): boolean;
  69835. /**
  69836. * Create a new Crowd so you can add agents
  69837. * @param maxAgents the maximum agent count in the crowd
  69838. * @param maxAgentRadius the maximum radius an agent can have
  69839. * @param scene to attach the crowd to
  69840. * @returns the crowd you can add agents to
  69841. */
  69842. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69843. /**
  69844. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69845. * The queries will try to find a solution within those bounds
  69846. * default is (1,1,1)
  69847. * @param extent x,y,z value that define the extent around the queries point of reference
  69848. */
  69849. setDefaultQueryExtent(extent: Vector3): void;
  69850. /**
  69851. * Get the Bounding box extent specified by setDefaultQueryExtent
  69852. * @returns the box extent values
  69853. */
  69854. getDefaultQueryExtent(): Vector3;
  69855. /**
  69856. * build the navmesh from a previously saved state using getNavmeshData
  69857. * @param data the Uint8Array returned by getNavmeshData
  69858. */
  69859. buildFromNavmeshData(data: Uint8Array): void;
  69860. /**
  69861. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69862. * @returns data the Uint8Array that can be saved and reused
  69863. */
  69864. getNavmeshData(): Uint8Array;
  69865. /**
  69866. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69867. * @param result output the box extent values
  69868. */
  69869. getDefaultQueryExtentToRef(result: Vector3): void;
  69870. /**
  69871. * Release all resources
  69872. */
  69873. dispose(): void;
  69874. }
  69875. /**
  69876. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  69877. */
  69878. export interface ICrowd {
  69879. /**
  69880. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69881. * You can attach anything to that node. The node position is updated in the scene update tick.
  69882. * @param pos world position that will be constrained by the navigation mesh
  69883. * @param parameters agent parameters
  69884. * @param transform hooked to the agent that will be update by the scene
  69885. * @returns agent index
  69886. */
  69887. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69888. /**
  69889. * Returns the agent position in world space
  69890. * @param index agent index returned by addAgent
  69891. * @returns world space position
  69892. */
  69893. getAgentPosition(index: number): Vector3;
  69894. /**
  69895. * Gets the agent position result in world space
  69896. * @param index agent index returned by addAgent
  69897. * @param result output world space position
  69898. */
  69899. getAgentPositionToRef(index: number, result: Vector3): void;
  69900. /**
  69901. * Gets the agent velocity in world space
  69902. * @param index agent index returned by addAgent
  69903. * @returns world space velocity
  69904. */
  69905. getAgentVelocity(index: number): Vector3;
  69906. /**
  69907. * Gets the agent velocity result in world space
  69908. * @param index agent index returned by addAgent
  69909. * @param result output world space velocity
  69910. */
  69911. getAgentVelocityToRef(index: number, result: Vector3): void;
  69912. /**
  69913. * remove a particular agent previously created
  69914. * @param index agent index returned by addAgent
  69915. */
  69916. removeAgent(index: number): void;
  69917. /**
  69918. * get the list of all agents attached to this crowd
  69919. * @returns list of agent indices
  69920. */
  69921. getAgents(): number[];
  69922. /**
  69923. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69924. * @param deltaTime in seconds
  69925. */
  69926. update(deltaTime: number): void;
  69927. /**
  69928. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69929. * @param index agent index returned by addAgent
  69930. * @param destination targeted world position
  69931. */
  69932. agentGoto(index: number, destination: Vector3): void;
  69933. /**
  69934. * Teleport the agent to a new position
  69935. * @param index agent index returned by addAgent
  69936. * @param destination targeted world position
  69937. */
  69938. agentTeleport(index: number, destination: Vector3): void;
  69939. /**
  69940. * Update agent parameters
  69941. * @param index agent index returned by addAgent
  69942. * @param parameters agent parameters
  69943. */
  69944. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69945. /**
  69946. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69947. * The queries will try to find a solution within those bounds
  69948. * default is (1,1,1)
  69949. * @param extent x,y,z value that define the extent around the queries point of reference
  69950. */
  69951. setDefaultQueryExtent(extent: Vector3): void;
  69952. /**
  69953. * Get the Bounding box extent specified by setDefaultQueryExtent
  69954. * @returns the box extent values
  69955. */
  69956. getDefaultQueryExtent(): Vector3;
  69957. /**
  69958. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69959. * @param result output the box extent values
  69960. */
  69961. getDefaultQueryExtentToRef(result: Vector3): void;
  69962. /**
  69963. * Release all resources
  69964. */
  69965. dispose(): void;
  69966. }
  69967. /**
  69968. * Configures an agent
  69969. */
  69970. export interface IAgentParameters {
  69971. /**
  69972. * Agent radius. [Limit: >= 0]
  69973. */
  69974. radius: number;
  69975. /**
  69976. * Agent height. [Limit: > 0]
  69977. */
  69978. height: number;
  69979. /**
  69980. * Maximum allowed acceleration. [Limit: >= 0]
  69981. */
  69982. maxAcceleration: number;
  69983. /**
  69984. * Maximum allowed speed. [Limit: >= 0]
  69985. */
  69986. maxSpeed: number;
  69987. /**
  69988. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  69989. */
  69990. collisionQueryRange: number;
  69991. /**
  69992. * The path visibility optimization range. [Limit: > 0]
  69993. */
  69994. pathOptimizationRange: number;
  69995. /**
  69996. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  69997. */
  69998. separationWeight: number;
  69999. }
  70000. /**
  70001. * Configures the navigation mesh creation
  70002. */
  70003. export interface INavMeshParameters {
  70004. /**
  70005. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70006. */
  70007. cs: number;
  70008. /**
  70009. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70010. */
  70011. ch: number;
  70012. /**
  70013. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70014. */
  70015. walkableSlopeAngle: number;
  70016. /**
  70017. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70018. * be considered walkable. [Limit: >= 3] [Units: vx]
  70019. */
  70020. walkableHeight: number;
  70021. /**
  70022. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70023. */
  70024. walkableClimb: number;
  70025. /**
  70026. * The distance to erode/shrink the walkable area of the heightfield away from
  70027. * obstructions. [Limit: >=0] [Units: vx]
  70028. */
  70029. walkableRadius: number;
  70030. /**
  70031. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70032. */
  70033. maxEdgeLen: number;
  70034. /**
  70035. * The maximum distance a simplfied contour's border edges should deviate
  70036. * the original raw contour. [Limit: >=0] [Units: vx]
  70037. */
  70038. maxSimplificationError: number;
  70039. /**
  70040. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70041. */
  70042. minRegionArea: number;
  70043. /**
  70044. * Any regions with a span count smaller than this value will, if possible,
  70045. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70046. */
  70047. mergeRegionArea: number;
  70048. /**
  70049. * The maximum number of vertices allowed for polygons generated during the
  70050. * contour to polygon conversion process. [Limit: >= 3]
  70051. */
  70052. maxVertsPerPoly: number;
  70053. /**
  70054. * Sets the sampling distance to use when generating the detail mesh.
  70055. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70056. */
  70057. detailSampleDist: number;
  70058. /**
  70059. * The maximum distance the detail mesh surface should deviate from heightfield
  70060. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70061. */
  70062. detailSampleMaxError: number;
  70063. }
  70064. }
  70065. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70066. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70067. import { Mesh } from "babylonjs/Meshes/mesh";
  70068. import { Scene } from "babylonjs/scene";
  70069. import { Vector3 } from "babylonjs/Maths/math";
  70070. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70071. /**
  70072. * RecastJS navigation plugin
  70073. */
  70074. export class RecastJSPlugin implements INavigationEnginePlugin {
  70075. /**
  70076. * Reference to the Recast library
  70077. */
  70078. bjsRECAST: any;
  70079. /**
  70080. * plugin name
  70081. */
  70082. name: string;
  70083. /**
  70084. * the first navmesh created. We might extend this to support multiple navmeshes
  70085. */
  70086. navMesh: any;
  70087. /**
  70088. * Initializes the recastJS plugin
  70089. * @param recastInjection can be used to inject your own recast reference
  70090. */
  70091. constructor(recastInjection?: any);
  70092. /**
  70093. * Creates a navigation mesh
  70094. * @param meshes array of all the geometry used to compute the navigatio mesh
  70095. * @param parameters bunch of parameters used to filter geometry
  70096. */
  70097. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70098. /**
  70099. * Create a navigation mesh debug mesh
  70100. * @param scene is where the mesh will be added
  70101. * @returns debug display mesh
  70102. */
  70103. createDebugNavMesh(scene: Scene): Mesh;
  70104. /**
  70105. * Get a navigation mesh constrained position, closest to the parameter position
  70106. * @param position world position
  70107. * @returns the closest point to position constrained by the navigation mesh
  70108. */
  70109. getClosestPoint(position: Vector3): Vector3;
  70110. /**
  70111. * Get a navigation mesh constrained position, closest to the parameter position
  70112. * @param position world position
  70113. * @param result output the closest point to position constrained by the navigation mesh
  70114. */
  70115. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70116. /**
  70117. * Get a navigation mesh constrained position, within a particular radius
  70118. * @param position world position
  70119. * @param maxRadius the maximum distance to the constrained world position
  70120. * @returns the closest point to position constrained by the navigation mesh
  70121. */
  70122. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70123. /**
  70124. * Get a navigation mesh constrained position, within a particular radius
  70125. * @param position world position
  70126. * @param maxRadius the maximum distance to the constrained world position
  70127. * @param result output the closest point to position constrained by the navigation mesh
  70128. */
  70129. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70130. /**
  70131. * Compute the final position from a segment made of destination-position
  70132. * @param position world position
  70133. * @param destination world position
  70134. * @returns the resulting point along the navmesh
  70135. */
  70136. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70137. /**
  70138. * Compute the final position from a segment made of destination-position
  70139. * @param position world position
  70140. * @param destination world position
  70141. * @param result output the resulting point along the navmesh
  70142. */
  70143. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70144. /**
  70145. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70146. * @param start world position
  70147. * @param end world position
  70148. * @returns array containing world position composing the path
  70149. */
  70150. computePath(start: Vector3, end: Vector3): Vector3[];
  70151. /**
  70152. * Create a new Crowd so you can add agents
  70153. * @param maxAgents the maximum agent count in the crowd
  70154. * @param maxAgentRadius the maximum radius an agent can have
  70155. * @param scene to attach the crowd to
  70156. * @returns the crowd you can add agents to
  70157. */
  70158. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70159. /**
  70160. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70161. * The queries will try to find a solution within those bounds
  70162. * default is (1,1,1)
  70163. * @param extent x,y,z value that define the extent around the queries point of reference
  70164. */
  70165. setDefaultQueryExtent(extent: Vector3): void;
  70166. /**
  70167. * Get the Bounding box extent specified by setDefaultQueryExtent
  70168. * @returns the box extent values
  70169. */
  70170. getDefaultQueryExtent(): Vector3;
  70171. /**
  70172. * build the navmesh from a previously saved state using getNavmeshData
  70173. * @param data the Uint8Array returned by getNavmeshData
  70174. */
  70175. buildFromNavmeshData(data: Uint8Array): void;
  70176. /**
  70177. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70178. * @returns data the Uint8Array that can be saved and reused
  70179. */
  70180. getNavmeshData(): Uint8Array;
  70181. /**
  70182. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70183. * @param result output the box extent values
  70184. */
  70185. getDefaultQueryExtentToRef(result: Vector3): void;
  70186. /**
  70187. * Disposes
  70188. */
  70189. dispose(): void;
  70190. /**
  70191. * If this plugin is supported
  70192. * @returns true if plugin is supported
  70193. */
  70194. isSupported(): boolean;
  70195. }
  70196. /**
  70197. * Recast detour crowd implementation
  70198. */
  70199. export class RecastJSCrowd implements ICrowd {
  70200. /**
  70201. * Recast/detour plugin
  70202. */
  70203. bjsRECASTPlugin: RecastJSPlugin;
  70204. /**
  70205. * Link to the detour crowd
  70206. */
  70207. recastCrowd: any;
  70208. /**
  70209. * One transform per agent
  70210. */
  70211. transforms: TransformNode[];
  70212. /**
  70213. * All agents created
  70214. */
  70215. agents: number[];
  70216. /**
  70217. * Link to the scene is kept to unregister the crowd from the scene
  70218. */
  70219. private _scene;
  70220. /**
  70221. * Observer for crowd updates
  70222. */
  70223. private _onBeforeAnimationsObserver;
  70224. /**
  70225. * Constructor
  70226. * @param plugin recastJS plugin
  70227. * @param maxAgents the maximum agent count in the crowd
  70228. * @param maxAgentRadius the maximum radius an agent can have
  70229. * @param scene to attach the crowd to
  70230. * @returns the crowd you can add agents to
  70231. */
  70232. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70233. /**
  70234. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70235. * You can attach anything to that node. The node position is updated in the scene update tick.
  70236. * @param pos world position that will be constrained by the navigation mesh
  70237. * @param parameters agent parameters
  70238. * @param transform hooked to the agent that will be update by the scene
  70239. * @returns agent index
  70240. */
  70241. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70242. /**
  70243. * Returns the agent position in world space
  70244. * @param index agent index returned by addAgent
  70245. * @returns world space position
  70246. */
  70247. getAgentPosition(index: number): Vector3;
  70248. /**
  70249. * Returns the agent position result in world space
  70250. * @param index agent index returned by addAgent
  70251. * @param result output world space position
  70252. */
  70253. getAgentPositionToRef(index: number, result: Vector3): void;
  70254. /**
  70255. * Returns the agent velocity in world space
  70256. * @param index agent index returned by addAgent
  70257. * @returns world space velocity
  70258. */
  70259. getAgentVelocity(index: number): Vector3;
  70260. /**
  70261. * Returns the agent velocity result in world space
  70262. * @param index agent index returned by addAgent
  70263. * @param result output world space velocity
  70264. */
  70265. getAgentVelocityToRef(index: number, result: Vector3): void;
  70266. /**
  70267. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70268. * @param index agent index returned by addAgent
  70269. * @param destination targeted world position
  70270. */
  70271. agentGoto(index: number, destination: Vector3): void;
  70272. /**
  70273. * Teleport the agent to a new position
  70274. * @param index agent index returned by addAgent
  70275. * @param destination targeted world position
  70276. */
  70277. agentTeleport(index: number, destination: Vector3): void;
  70278. /**
  70279. * Update agent parameters
  70280. * @param index agent index returned by addAgent
  70281. * @param parameters agent parameters
  70282. */
  70283. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70284. /**
  70285. * remove a particular agent previously created
  70286. * @param index agent index returned by addAgent
  70287. */
  70288. removeAgent(index: number): void;
  70289. /**
  70290. * get the list of all agents attached to this crowd
  70291. * @returns list of agent indices
  70292. */
  70293. getAgents(): number[];
  70294. /**
  70295. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70296. * @param deltaTime in seconds
  70297. */
  70298. update(deltaTime: number): void;
  70299. /**
  70300. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70301. * The queries will try to find a solution within those bounds
  70302. * default is (1,1,1)
  70303. * @param extent x,y,z value that define the extent around the queries point of reference
  70304. */
  70305. setDefaultQueryExtent(extent: Vector3): void;
  70306. /**
  70307. * Get the Bounding box extent specified by setDefaultQueryExtent
  70308. * @returns the box extent values
  70309. */
  70310. getDefaultQueryExtent(): Vector3;
  70311. /**
  70312. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70313. * @param result output the box extent values
  70314. */
  70315. getDefaultQueryExtentToRef(result: Vector3): void;
  70316. /**
  70317. * Release all resources
  70318. */
  70319. dispose(): void;
  70320. }
  70321. }
  70322. declare module "babylonjs/Navigation/Plugins/index" {
  70323. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  70324. }
  70325. declare module "babylonjs/Navigation/index" {
  70326. export * from "babylonjs/Navigation/INavigationEngine";
  70327. export * from "babylonjs/Navigation/Plugins/index";
  70328. }
  70329. declare module "babylonjs/Offline/database" {
  70330. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  70331. /**
  70332. * Class used to enable access to IndexedDB
  70333. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70334. */
  70335. export class Database implements IOfflineProvider {
  70336. private _callbackManifestChecked;
  70337. private _currentSceneUrl;
  70338. private _db;
  70339. private _enableSceneOffline;
  70340. private _enableTexturesOffline;
  70341. private _manifestVersionFound;
  70342. private _mustUpdateRessources;
  70343. private _hasReachedQuota;
  70344. private _isSupported;
  70345. private _idbFactory;
  70346. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  70347. private static IsUASupportingBlobStorage;
  70348. /**
  70349. * Gets a boolean indicating if Database storate is enabled (off by default)
  70350. */
  70351. static IDBStorageEnabled: boolean;
  70352. /**
  70353. * Gets a boolean indicating if scene must be saved in the database
  70354. */
  70355. get enableSceneOffline(): boolean;
  70356. /**
  70357. * Gets a boolean indicating if textures must be saved in the database
  70358. */
  70359. get enableTexturesOffline(): boolean;
  70360. /**
  70361. * Creates a new Database
  70362. * @param urlToScene defines the url to load the scene
  70363. * @param callbackManifestChecked defines the callback to use when manifest is checked
  70364. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  70365. */
  70366. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  70367. private static _ParseURL;
  70368. private static _ReturnFullUrlLocation;
  70369. private _checkManifestFile;
  70370. /**
  70371. * Open the database and make it available
  70372. * @param successCallback defines the callback to call on success
  70373. * @param errorCallback defines the callback to call on error
  70374. */
  70375. open(successCallback: () => void, errorCallback: () => void): void;
  70376. /**
  70377. * Loads an image from the database
  70378. * @param url defines the url to load from
  70379. * @param image defines the target DOM image
  70380. */
  70381. loadImage(url: string, image: HTMLImageElement): void;
  70382. private _loadImageFromDBAsync;
  70383. private _saveImageIntoDBAsync;
  70384. private _checkVersionFromDB;
  70385. private _loadVersionFromDBAsync;
  70386. private _saveVersionIntoDBAsync;
  70387. /**
  70388. * Loads a file from database
  70389. * @param url defines the URL to load from
  70390. * @param sceneLoaded defines a callback to call on success
  70391. * @param progressCallBack defines a callback to call when progress changed
  70392. * @param errorCallback defines a callback to call on error
  70393. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70394. */
  70395. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70396. private _loadFileAsync;
  70397. private _saveFileAsync;
  70398. /**
  70399. * Validates if xhr data is correct
  70400. * @param xhr defines the request to validate
  70401. * @param dataType defines the expected data type
  70402. * @returns true if data is correct
  70403. */
  70404. private static _ValidateXHRData;
  70405. }
  70406. }
  70407. declare module "babylonjs/Offline/index" {
  70408. export * from "babylonjs/Offline/database";
  70409. export * from "babylonjs/Offline/IOfflineProvider";
  70410. }
  70411. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  70412. /** @hidden */
  70413. export var gpuUpdateParticlesPixelShader: {
  70414. name: string;
  70415. shader: string;
  70416. };
  70417. }
  70418. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  70419. /** @hidden */
  70420. export var gpuUpdateParticlesVertexShader: {
  70421. name: string;
  70422. shader: string;
  70423. };
  70424. }
  70425. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  70426. /** @hidden */
  70427. export var clipPlaneFragmentDeclaration2: {
  70428. name: string;
  70429. shader: string;
  70430. };
  70431. }
  70432. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  70433. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  70434. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  70435. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70436. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  70437. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  70438. /** @hidden */
  70439. export var gpuRenderParticlesPixelShader: {
  70440. name: string;
  70441. shader: string;
  70442. };
  70443. }
  70444. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  70445. /** @hidden */
  70446. export var clipPlaneVertexDeclaration2: {
  70447. name: string;
  70448. shader: string;
  70449. };
  70450. }
  70451. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  70452. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  70453. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  70454. /** @hidden */
  70455. export var gpuRenderParticlesVertexShader: {
  70456. name: string;
  70457. shader: string;
  70458. };
  70459. }
  70460. declare module "babylonjs/Particles/gpuParticleSystem" {
  70461. import { Nullable } from "babylonjs/types";
  70462. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  70463. import { Observable } from "babylonjs/Misc/observable";
  70464. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70465. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70466. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  70467. import { Scene, IDisposable } from "babylonjs/scene";
  70468. import { Effect } from "babylonjs/Materials/effect";
  70469. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70470. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70471. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  70472. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  70473. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  70474. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  70475. /**
  70476. * This represents a GPU particle system in Babylon
  70477. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  70478. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  70479. */
  70480. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  70481. /**
  70482. * The layer mask we are rendering the particles through.
  70483. */
  70484. layerMask: number;
  70485. private _capacity;
  70486. private _activeCount;
  70487. private _currentActiveCount;
  70488. private _accumulatedCount;
  70489. private _renderEffect;
  70490. private _updateEffect;
  70491. private _buffer0;
  70492. private _buffer1;
  70493. private _spriteBuffer;
  70494. private _updateVAO;
  70495. private _renderVAO;
  70496. private _targetIndex;
  70497. private _sourceBuffer;
  70498. private _targetBuffer;
  70499. private _engine;
  70500. private _currentRenderId;
  70501. private _started;
  70502. private _stopped;
  70503. private _timeDelta;
  70504. private _randomTexture;
  70505. private _randomTexture2;
  70506. private _attributesStrideSize;
  70507. private _updateEffectOptions;
  70508. private _randomTextureSize;
  70509. private _actualFrame;
  70510. private _customEffect;
  70511. private readonly _rawTextureWidth;
  70512. /**
  70513. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  70514. */
  70515. static get IsSupported(): boolean;
  70516. /**
  70517. * An event triggered when the system is disposed.
  70518. */
  70519. onDisposeObservable: Observable<IParticleSystem>;
  70520. /**
  70521. * Gets the maximum number of particles active at the same time.
  70522. * @returns The max number of active particles.
  70523. */
  70524. getCapacity(): number;
  70525. /**
  70526. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70527. * to override the particles.
  70528. */
  70529. forceDepthWrite: boolean;
  70530. /**
  70531. * Gets or set the number of active particles
  70532. */
  70533. get activeParticleCount(): number;
  70534. set activeParticleCount(value: number);
  70535. private _preWarmDone;
  70536. /**
  70537. * Specifies if the particles are updated in emitter local space or world space.
  70538. */
  70539. isLocal: boolean;
  70540. /**
  70541. * Is this system ready to be used/rendered
  70542. * @return true if the system is ready
  70543. */
  70544. isReady(): boolean;
  70545. /**
  70546. * Gets if the system has been started. (Note: this will still be true after stop is called)
  70547. * @returns True if it has been started, otherwise false.
  70548. */
  70549. isStarted(): boolean;
  70550. /**
  70551. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  70552. * @returns True if it has been stopped, otherwise false.
  70553. */
  70554. isStopped(): boolean;
  70555. /**
  70556. * Gets a boolean indicating that the system is stopping
  70557. * @returns true if the system is currently stopping
  70558. */
  70559. isStopping(): boolean;
  70560. /**
  70561. * Gets the number of particles active at the same time.
  70562. * @returns The number of active particles.
  70563. */
  70564. getActiveCount(): number;
  70565. /**
  70566. * Starts the particle system and begins to emit
  70567. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70568. */
  70569. start(delay?: number): void;
  70570. /**
  70571. * Stops the particle system.
  70572. */
  70573. stop(): void;
  70574. /**
  70575. * Remove all active particles
  70576. */
  70577. reset(): void;
  70578. /**
  70579. * Returns the string "GPUParticleSystem"
  70580. * @returns a string containing the class name
  70581. */
  70582. getClassName(): string;
  70583. /**
  70584. * Gets the custom effect used to render the particles
  70585. * @param blendMode Blend mode for which the effect should be retrieved
  70586. * @returns The effect
  70587. */
  70588. getCustomEffect(blendMode?: number): Nullable<Effect>;
  70589. /**
  70590. * Sets the custom effect used to render the particles
  70591. * @param effect The effect to set
  70592. * @param blendMode Blend mode for which the effect should be set
  70593. */
  70594. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  70595. /** @hidden */
  70596. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  70597. /**
  70598. * Observable that will be called just before the particles are drawn
  70599. */
  70600. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  70601. /**
  70602. * Gets the name of the particle vertex shader
  70603. */
  70604. get vertexShaderName(): string;
  70605. private _colorGradientsTexture;
  70606. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  70607. /**
  70608. * Adds a new color gradient
  70609. * @param gradient defines the gradient to use (between 0 and 1)
  70610. * @param color1 defines the color to affect to the specified gradient
  70611. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70612. * @returns the current particle system
  70613. */
  70614. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  70615. private _refreshColorGradient;
  70616. /** Force the system to rebuild all gradients that need to be resync */
  70617. forceRefreshGradients(): void;
  70618. /**
  70619. * Remove a specific color gradient
  70620. * @param gradient defines the gradient to remove
  70621. * @returns the current particle system
  70622. */
  70623. removeColorGradient(gradient: number): GPUParticleSystem;
  70624. private _angularSpeedGradientsTexture;
  70625. private _sizeGradientsTexture;
  70626. private _velocityGradientsTexture;
  70627. private _limitVelocityGradientsTexture;
  70628. private _dragGradientsTexture;
  70629. private _addFactorGradient;
  70630. /**
  70631. * Adds a new size gradient
  70632. * @param gradient defines the gradient to use (between 0 and 1)
  70633. * @param factor defines the size factor to affect to the specified gradient
  70634. * @returns the current particle system
  70635. */
  70636. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  70637. /**
  70638. * Remove a specific size gradient
  70639. * @param gradient defines the gradient to remove
  70640. * @returns the current particle system
  70641. */
  70642. removeSizeGradient(gradient: number): GPUParticleSystem;
  70643. private _refreshFactorGradient;
  70644. /**
  70645. * Adds a new angular speed gradient
  70646. * @param gradient defines the gradient to use (between 0 and 1)
  70647. * @param factor defines the angular speed to affect to the specified gradient
  70648. * @returns the current particle system
  70649. */
  70650. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  70651. /**
  70652. * Remove a specific angular speed gradient
  70653. * @param gradient defines the gradient to remove
  70654. * @returns the current particle system
  70655. */
  70656. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  70657. /**
  70658. * Adds a new velocity gradient
  70659. * @param gradient defines the gradient to use (between 0 and 1)
  70660. * @param factor defines the velocity to affect to the specified gradient
  70661. * @returns the current particle system
  70662. */
  70663. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70664. /**
  70665. * Remove a specific velocity gradient
  70666. * @param gradient defines the gradient to remove
  70667. * @returns the current particle system
  70668. */
  70669. removeVelocityGradient(gradient: number): GPUParticleSystem;
  70670. /**
  70671. * Adds a new limit velocity gradient
  70672. * @param gradient defines the gradient to use (between 0 and 1)
  70673. * @param factor defines the limit velocity value to affect to the specified gradient
  70674. * @returns the current particle system
  70675. */
  70676. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70677. /**
  70678. * Remove a specific limit velocity gradient
  70679. * @param gradient defines the gradient to remove
  70680. * @returns the current particle system
  70681. */
  70682. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  70683. /**
  70684. * Adds a new drag gradient
  70685. * @param gradient defines the gradient to use (between 0 and 1)
  70686. * @param factor defines the drag value to affect to the specified gradient
  70687. * @returns the current particle system
  70688. */
  70689. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  70690. /**
  70691. * Remove a specific drag gradient
  70692. * @param gradient defines the gradient to remove
  70693. * @returns the current particle system
  70694. */
  70695. removeDragGradient(gradient: number): GPUParticleSystem;
  70696. /**
  70697. * Not supported by GPUParticleSystem
  70698. * @param gradient defines the gradient to use (between 0 and 1)
  70699. * @param factor defines the emit rate value to affect to the specified gradient
  70700. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70701. * @returns the current particle system
  70702. */
  70703. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70704. /**
  70705. * Not supported by GPUParticleSystem
  70706. * @param gradient defines the gradient to remove
  70707. * @returns the current particle system
  70708. */
  70709. removeEmitRateGradient(gradient: number): IParticleSystem;
  70710. /**
  70711. * Not supported by GPUParticleSystem
  70712. * @param gradient defines the gradient to use (between 0 and 1)
  70713. * @param factor defines the start size value to affect to the specified gradient
  70714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70715. * @returns the current particle system
  70716. */
  70717. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70718. /**
  70719. * Not supported by GPUParticleSystem
  70720. * @param gradient defines the gradient to remove
  70721. * @returns the current particle system
  70722. */
  70723. removeStartSizeGradient(gradient: number): IParticleSystem;
  70724. /**
  70725. * Not supported by GPUParticleSystem
  70726. * @param gradient defines the gradient to use (between 0 and 1)
  70727. * @param min defines the color remap minimal range
  70728. * @param max defines the color remap maximal range
  70729. * @returns the current particle system
  70730. */
  70731. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70732. /**
  70733. * Not supported by GPUParticleSystem
  70734. * @param gradient defines the gradient to remove
  70735. * @returns the current particle system
  70736. */
  70737. removeColorRemapGradient(): IParticleSystem;
  70738. /**
  70739. * Not supported by GPUParticleSystem
  70740. * @param gradient defines the gradient to use (between 0 and 1)
  70741. * @param min defines the alpha remap minimal range
  70742. * @param max defines the alpha remap maximal range
  70743. * @returns the current particle system
  70744. */
  70745. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70746. /**
  70747. * Not supported by GPUParticleSystem
  70748. * @param gradient defines the gradient to remove
  70749. * @returns the current particle system
  70750. */
  70751. removeAlphaRemapGradient(): IParticleSystem;
  70752. /**
  70753. * Not supported by GPUParticleSystem
  70754. * @param gradient defines the gradient to use (between 0 and 1)
  70755. * @param color defines the color to affect to the specified gradient
  70756. * @returns the current particle system
  70757. */
  70758. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  70759. /**
  70760. * Not supported by GPUParticleSystem
  70761. * @param gradient defines the gradient to remove
  70762. * @returns the current particle system
  70763. */
  70764. removeRampGradient(): IParticleSystem;
  70765. /**
  70766. * Not supported by GPUParticleSystem
  70767. * @returns the list of ramp gradients
  70768. */
  70769. getRampGradients(): Nullable<Array<Color3Gradient>>;
  70770. /**
  70771. * Not supported by GPUParticleSystem
  70772. * Gets or sets a boolean indicating that ramp gradients must be used
  70773. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  70774. */
  70775. get useRampGradients(): boolean;
  70776. set useRampGradients(value: boolean);
  70777. /**
  70778. * Not supported by GPUParticleSystem
  70779. * @param gradient defines the gradient to use (between 0 and 1)
  70780. * @param factor defines the life time factor to affect to the specified gradient
  70781. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70782. * @returns the current particle system
  70783. */
  70784. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70785. /**
  70786. * Not supported by GPUParticleSystem
  70787. * @param gradient defines the gradient to remove
  70788. * @returns the current particle system
  70789. */
  70790. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70791. /**
  70792. * Instantiates a GPU particle system.
  70793. * 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.
  70794. * @param name The name of the particle system
  70795. * @param options The options used to create the system
  70796. * @param scene The scene the particle system belongs to
  70797. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70798. * @param customEffect a custom effect used to change the way particles are rendered by default
  70799. */
  70800. constructor(name: string, options: Partial<{
  70801. capacity: number;
  70802. randomTextureSize: number;
  70803. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  70804. protected _reset(): void;
  70805. private _createUpdateVAO;
  70806. private _createRenderVAO;
  70807. private _initialize;
  70808. /** @hidden */
  70809. _recreateUpdateEffect(): void;
  70810. private _getEffect;
  70811. /**
  70812. * Fill the defines array according to the current settings of the particle system
  70813. * @param defines Array to be updated
  70814. * @param blendMode blend mode to take into account when updating the array
  70815. */
  70816. fillDefines(defines: Array<string>, blendMode?: number): void;
  70817. /**
  70818. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  70819. * @param uniforms Uniforms array to fill
  70820. * @param attributes Attributes array to fill
  70821. * @param samplers Samplers array to fill
  70822. */
  70823. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  70824. /** @hidden */
  70825. _recreateRenderEffect(): Effect;
  70826. /**
  70827. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70828. * @param preWarm defines if we are in the pre-warmimg phase
  70829. */
  70830. animate(preWarm?: boolean): void;
  70831. private _createFactorGradientTexture;
  70832. private _createSizeGradientTexture;
  70833. private _createAngularSpeedGradientTexture;
  70834. private _createVelocityGradientTexture;
  70835. private _createLimitVelocityGradientTexture;
  70836. private _createDragGradientTexture;
  70837. private _createColorGradientTexture;
  70838. /**
  70839. * Renders the particle system in its current state
  70840. * @param preWarm defines if the system should only update the particles but not render them
  70841. * @returns the current number of particles
  70842. */
  70843. render(preWarm?: boolean): number;
  70844. /**
  70845. * Rebuilds the particle system
  70846. */
  70847. rebuild(): void;
  70848. private _releaseBuffers;
  70849. private _releaseVAOs;
  70850. /**
  70851. * Disposes the particle system and free the associated resources
  70852. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70853. */
  70854. dispose(disposeTexture?: boolean): void;
  70855. /**
  70856. * Clones the particle system.
  70857. * @param name The name of the cloned object
  70858. * @param newEmitter The new emitter to use
  70859. * @returns the cloned particle system
  70860. */
  70861. clone(name: string, newEmitter: any): GPUParticleSystem;
  70862. /**
  70863. * Serializes the particle system to a JSON object
  70864. * @param serializeTexture defines if the texture must be serialized as well
  70865. * @returns the JSON object
  70866. */
  70867. serialize(serializeTexture?: boolean): any;
  70868. /**
  70869. * Parses a JSON object to create a GPU particle system.
  70870. * @param parsedParticleSystem The JSON object to parse
  70871. * @param scene The scene to create the particle system in
  70872. * @param rootUrl The root url to use to load external dependencies like texture
  70873. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70874. * @returns the parsed GPU particle system
  70875. */
  70876. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  70877. }
  70878. }
  70879. declare module "babylonjs/Particles/particleSystemSet" {
  70880. import { Nullable } from "babylonjs/types";
  70881. import { Color3 } from "babylonjs/Maths/math.color";
  70882. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70884. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70885. import { Scene, IDisposable } from "babylonjs/scene";
  70886. /**
  70887. * Represents a set of particle systems working together to create a specific effect
  70888. */
  70889. export class ParticleSystemSet implements IDisposable {
  70890. /**
  70891. * Gets or sets base Assets URL
  70892. */
  70893. static BaseAssetsUrl: string;
  70894. private _emitterCreationOptions;
  70895. private _emitterNode;
  70896. /**
  70897. * Gets the particle system list
  70898. */
  70899. systems: IParticleSystem[];
  70900. /**
  70901. * Gets the emitter node used with this set
  70902. */
  70903. get emitterNode(): Nullable<TransformNode>;
  70904. /**
  70905. * Creates a new emitter mesh as a sphere
  70906. * @param options defines the options used to create the sphere
  70907. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  70908. * @param scene defines the hosting scene
  70909. */
  70910. setEmitterAsSphere(options: {
  70911. diameter: number;
  70912. segments: number;
  70913. color: Color3;
  70914. }, renderingGroupId: number, scene: Scene): void;
  70915. /**
  70916. * Starts all particle systems of the set
  70917. * @param emitter defines an optional mesh to use as emitter for the particle systems
  70918. */
  70919. start(emitter?: AbstractMesh): void;
  70920. /**
  70921. * Release all associated resources
  70922. */
  70923. dispose(): void;
  70924. /**
  70925. * Serialize the set into a JSON compatible object
  70926. * @param serializeTexture defines if the texture must be serialized as well
  70927. * @returns a JSON compatible representation of the set
  70928. */
  70929. serialize(serializeTexture?: boolean): any;
  70930. /**
  70931. * Parse a new ParticleSystemSet from a serialized source
  70932. * @param data defines a JSON compatible representation of the set
  70933. * @param scene defines the hosting scene
  70934. * @param gpu defines if we want GPU particles or CPU particles
  70935. * @returns a new ParticleSystemSet
  70936. */
  70937. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  70938. }
  70939. }
  70940. declare module "babylonjs/Particles/particleHelper" {
  70941. import { Nullable } from "babylonjs/types";
  70942. import { Scene } from "babylonjs/scene";
  70943. import { Vector3 } from "babylonjs/Maths/math.vector";
  70944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70945. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70946. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  70947. /**
  70948. * This class is made for on one-liner static method to help creating particle system set.
  70949. */
  70950. export class ParticleHelper {
  70951. /**
  70952. * Gets or sets base Assets URL
  70953. */
  70954. static BaseAssetsUrl: string;
  70955. /** Define the Url to load snippets */
  70956. static SnippetUrl: string;
  70957. /**
  70958. * Create a default particle system that you can tweak
  70959. * @param emitter defines the emitter to use
  70960. * @param capacity defines the system capacity (default is 500 particles)
  70961. * @param scene defines the hosting scene
  70962. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  70963. * @returns the new Particle system
  70964. */
  70965. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  70966. /**
  70967. * This is the main static method (one-liner) of this helper to create different particle systems
  70968. * @param type This string represents the type to the particle system to create
  70969. * @param scene The scene where the particle system should live
  70970. * @param gpu If the system will use gpu
  70971. * @returns the ParticleSystemSet created
  70972. */
  70973. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  70974. /**
  70975. * Static function used to export a particle system to a ParticleSystemSet variable.
  70976. * Please note that the emitter shape is not exported
  70977. * @param systems defines the particle systems to export
  70978. * @returns the created particle system set
  70979. */
  70980. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  70981. /**
  70982. * Creates a particle system from a snippet saved in a remote file
  70983. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  70984. * @param url defines the url to load from
  70985. * @param scene defines the hosting scene
  70986. * @param gpu If the system will use gpu
  70987. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70988. * @returns a promise that will resolve to the new particle system
  70989. */
  70990. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70991. /**
  70992. * Creates a particle system from a snippet saved by the particle system editor
  70993. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  70994. * @param scene defines the hosting scene
  70995. * @param gpu If the system will use gpu
  70996. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70997. * @returns a promise that will resolve to the new particle system
  70998. */
  70999. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71000. }
  71001. }
  71002. declare module "babylonjs/Particles/particleSystemComponent" {
  71003. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71004. import { Effect } from "babylonjs/Materials/effect";
  71005. import "babylonjs/Shaders/particles.vertex";
  71006. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71007. module "babylonjs/Engines/engine" {
  71008. interface Engine {
  71009. /**
  71010. * Create an effect to use with particle systems.
  71011. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71012. * the particle system for which you want to create a custom effect in the last parameter
  71013. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71014. * @param uniformsNames defines a list of attribute names
  71015. * @param samplers defines an array of string used to represent textures
  71016. * @param defines defines the string containing the defines to use to compile the shaders
  71017. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71018. * @param onCompiled defines a function to call when the effect creation is successful
  71019. * @param onError defines a function to call when the effect creation has failed
  71020. * @param particleSystem the particle system you want to create the effect for
  71021. * @returns the new Effect
  71022. */
  71023. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71024. }
  71025. }
  71026. module "babylonjs/Meshes/mesh" {
  71027. interface Mesh {
  71028. /**
  71029. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71030. * @returns an array of IParticleSystem
  71031. */
  71032. getEmittedParticleSystems(): IParticleSystem[];
  71033. /**
  71034. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71035. * @returns an array of IParticleSystem
  71036. */
  71037. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71038. }
  71039. }
  71040. }
  71041. declare module "babylonjs/Particles/pointsCloudSystem" {
  71042. import { Color4 } from "babylonjs/Maths/math";
  71043. import { Mesh } from "babylonjs/Meshes/mesh";
  71044. import { Scene, IDisposable } from "babylonjs/scene";
  71045. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71046. /** Defines the 4 color options */
  71047. export enum PointColor {
  71048. /** color value */
  71049. Color = 2,
  71050. /** uv value */
  71051. UV = 1,
  71052. /** random value */
  71053. Random = 0,
  71054. /** stated value */
  71055. Stated = 3
  71056. }
  71057. /**
  71058. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71059. * 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.
  71060. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71061. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71062. *
  71063. * Full documentation here : TO BE ENTERED
  71064. */
  71065. export class PointsCloudSystem implements IDisposable {
  71066. /**
  71067. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71068. * Example : var p = SPS.particles[i];
  71069. */
  71070. particles: CloudPoint[];
  71071. /**
  71072. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71073. */
  71074. nbParticles: number;
  71075. /**
  71076. * This a counter for your own usage. It's not set by any SPS functions.
  71077. */
  71078. counter: number;
  71079. /**
  71080. * The PCS name. This name is also given to the underlying mesh.
  71081. */
  71082. name: string;
  71083. /**
  71084. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71085. */
  71086. mesh: Mesh;
  71087. /**
  71088. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71089. * Please read :
  71090. */
  71091. vars: any;
  71092. /**
  71093. * @hidden
  71094. */
  71095. _size: number;
  71096. private _scene;
  71097. private _promises;
  71098. private _positions;
  71099. private _indices;
  71100. private _normals;
  71101. private _colors;
  71102. private _uvs;
  71103. private _indices32;
  71104. private _positions32;
  71105. private _colors32;
  71106. private _uvs32;
  71107. private _updatable;
  71108. private _isVisibilityBoxLocked;
  71109. private _alwaysVisible;
  71110. private _groups;
  71111. private _groupCounter;
  71112. private _computeParticleColor;
  71113. private _computeParticleTexture;
  71114. private _computeParticleRotation;
  71115. private _computeBoundingBox;
  71116. private _isReady;
  71117. /**
  71118. * Creates a PCS (Points Cloud System) object
  71119. * @param name (String) is the PCS name, this will be the underlying mesh name
  71120. * @param pointSize (number) is the size for each point
  71121. * @param scene (Scene) is the scene in which the PCS is added
  71122. * @param options defines the options of the PCS e.g.
  71123. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71124. */
  71125. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71126. updatable?: boolean;
  71127. });
  71128. /**
  71129. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71130. * If no points were added to the PCS, the returned mesh is just a single point.
  71131. * @returns a promise for the created mesh
  71132. */
  71133. buildMeshAsync(): Promise<Mesh>;
  71134. /**
  71135. * @hidden
  71136. */
  71137. private _buildMesh;
  71138. private _addParticle;
  71139. private _randomUnitVector;
  71140. private _getColorIndicesForCoord;
  71141. private _setPointsColorOrUV;
  71142. private _colorFromTexture;
  71143. private _calculateDensity;
  71144. /**
  71145. * Adds points to the PCS in random positions within a unit sphere
  71146. * @param nb (positive integer) the number of particles to be created from this model
  71147. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71148. * @returns the number of groups in the system
  71149. */
  71150. addPoints(nb: number, pointFunction?: any): number;
  71151. /**
  71152. * Adds points to the PCS from the surface of the model shape
  71153. * @param mesh is any Mesh object that will be used as a surface model for the points
  71154. * @param nb (positive integer) the number of particles to be created from this model
  71155. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71156. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71157. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71158. * @returns the number of groups in the system
  71159. */
  71160. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71161. /**
  71162. * Adds points to the PCS inside the model shape
  71163. * @param mesh is any Mesh object that will be used as a surface model for the points
  71164. * @param nb (positive integer) the number of particles to be created from this model
  71165. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71166. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71167. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71168. * @returns the number of groups in the system
  71169. */
  71170. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71171. /**
  71172. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71173. * This method calls `updateParticle()` for each particle of the SPS.
  71174. * For an animated SPS, it is usually called within the render loop.
  71175. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71176. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71177. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71178. * @returns the PCS.
  71179. */
  71180. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71181. /**
  71182. * Disposes the PCS.
  71183. */
  71184. dispose(): void;
  71185. /**
  71186. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71187. * doc :
  71188. * @returns the PCS.
  71189. */
  71190. refreshVisibleSize(): PointsCloudSystem;
  71191. /**
  71192. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71193. * @param size the size (float) of the visibility box
  71194. * note : this doesn't lock the PCS mesh bounding box.
  71195. * doc :
  71196. */
  71197. setVisibilityBox(size: number): void;
  71198. /**
  71199. * Gets whether the PCS is always visible or not
  71200. * doc :
  71201. */
  71202. get isAlwaysVisible(): boolean;
  71203. /**
  71204. * Sets the PCS as always visible or not
  71205. * doc :
  71206. */
  71207. set isAlwaysVisible(val: boolean);
  71208. /**
  71209. * Tells to `setParticles()` to compute the particle rotations or not
  71210. * Default value : false. The PCS is faster when it's set to false
  71211. * Note : particle rotations are only applied to parent particles
  71212. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71213. */
  71214. set computeParticleRotation(val: boolean);
  71215. /**
  71216. * Tells to `setParticles()` to compute the particle colors or not.
  71217. * Default value : true. The PCS is faster when it's set to false.
  71218. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71219. */
  71220. set computeParticleColor(val: boolean);
  71221. set computeParticleTexture(val: boolean);
  71222. /**
  71223. * Gets if `setParticles()` computes the particle colors or not.
  71224. * Default value : false. The PCS is faster when it's set to false.
  71225. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71226. */
  71227. get computeParticleColor(): boolean;
  71228. /**
  71229. * Gets if `setParticles()` computes the particle textures or not.
  71230. * Default value : false. The PCS is faster when it's set to false.
  71231. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71232. */
  71233. get computeParticleTexture(): boolean;
  71234. /**
  71235. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71236. */
  71237. set computeBoundingBox(val: boolean);
  71238. /**
  71239. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71240. */
  71241. get computeBoundingBox(): boolean;
  71242. /**
  71243. * This function does nothing. It may be overwritten to set all the particle first values.
  71244. * The PCS doesn't call this function, you may have to call it by your own.
  71245. * doc :
  71246. */
  71247. initParticles(): void;
  71248. /**
  71249. * This function does nothing. It may be overwritten to recycle a particle
  71250. * The PCS doesn't call this function, you can to call it
  71251. * doc :
  71252. * @param particle The particle to recycle
  71253. * @returns the recycled particle
  71254. */
  71255. recycleParticle(particle: CloudPoint): CloudPoint;
  71256. /**
  71257. * Updates a particle : this function should be overwritten by the user.
  71258. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71259. * doc :
  71260. * @example : just set a particle position or velocity and recycle conditions
  71261. * @param particle The particle to update
  71262. * @returns the updated particle
  71263. */
  71264. updateParticle(particle: CloudPoint): CloudPoint;
  71265. /**
  71266. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71267. * This does nothing and may be overwritten by the user.
  71268. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71269. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71270. * @param update the boolean update value actually passed to setParticles()
  71271. */
  71272. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71273. /**
  71274. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71275. * This will be passed three parameters.
  71276. * This does nothing and may be overwritten by the user.
  71277. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71278. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71279. * @param update the boolean update value actually passed to setParticles()
  71280. */
  71281. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71282. }
  71283. }
  71284. declare module "babylonjs/Particles/cloudPoint" {
  71285. import { Nullable } from "babylonjs/types";
  71286. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71287. import { Mesh } from "babylonjs/Meshes/mesh";
  71288. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71289. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71290. /**
  71291. * Represents one particle of a points cloud system.
  71292. */
  71293. export class CloudPoint {
  71294. /**
  71295. * particle global index
  71296. */
  71297. idx: number;
  71298. /**
  71299. * The color of the particle
  71300. */
  71301. color: Nullable<Color4>;
  71302. /**
  71303. * The world space position of the particle.
  71304. */
  71305. position: Vector3;
  71306. /**
  71307. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  71308. */
  71309. rotation: Vector3;
  71310. /**
  71311. * The world space rotation quaternion of the particle.
  71312. */
  71313. rotationQuaternion: Nullable<Quaternion>;
  71314. /**
  71315. * The uv of the particle.
  71316. */
  71317. uv: Nullable<Vector2>;
  71318. /**
  71319. * The current speed of the particle.
  71320. */
  71321. velocity: Vector3;
  71322. /**
  71323. * The pivot point in the particle local space.
  71324. */
  71325. pivot: Vector3;
  71326. /**
  71327. * Must the particle be translated from its pivot point in its local space ?
  71328. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  71329. * Default : false
  71330. */
  71331. translateFromPivot: boolean;
  71332. /**
  71333. * Index of this particle in the global "positions" array (Internal use)
  71334. * @hidden
  71335. */
  71336. _pos: number;
  71337. /**
  71338. * @hidden Index of this particle in the global "indices" array (Internal use)
  71339. */
  71340. _ind: number;
  71341. /**
  71342. * Group this particle belongs to
  71343. */
  71344. _group: PointsGroup;
  71345. /**
  71346. * Group id of this particle
  71347. */
  71348. groupId: number;
  71349. /**
  71350. * Index of the particle in its group id (Internal use)
  71351. */
  71352. idxInGroup: number;
  71353. /**
  71354. * @hidden Particle BoundingInfo object (Internal use)
  71355. */
  71356. _boundingInfo: BoundingInfo;
  71357. /**
  71358. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  71359. */
  71360. _pcs: PointsCloudSystem;
  71361. /**
  71362. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  71363. */
  71364. _stillInvisible: boolean;
  71365. /**
  71366. * @hidden Last computed particle rotation matrix
  71367. */
  71368. _rotationMatrix: number[];
  71369. /**
  71370. * Parent particle Id, if any.
  71371. * Default null.
  71372. */
  71373. parentId: Nullable<number>;
  71374. /**
  71375. * @hidden Internal global position in the PCS.
  71376. */
  71377. _globalPosition: Vector3;
  71378. /**
  71379. * Creates a Point Cloud object.
  71380. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  71381. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  71382. * @param group (PointsGroup) is the group the particle belongs to
  71383. * @param groupId (integer) is the group identifier in the PCS.
  71384. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  71385. * @param pcs defines the PCS it is associated to
  71386. */
  71387. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  71388. /**
  71389. * get point size
  71390. */
  71391. get size(): Vector3;
  71392. /**
  71393. * Set point size
  71394. */
  71395. set size(scale: Vector3);
  71396. /**
  71397. * Legacy support, changed quaternion to rotationQuaternion
  71398. */
  71399. get quaternion(): Nullable<Quaternion>;
  71400. /**
  71401. * Legacy support, changed quaternion to rotationQuaternion
  71402. */
  71403. set quaternion(q: Nullable<Quaternion>);
  71404. /**
  71405. * Returns a boolean. True if the particle intersects a mesh, else false
  71406. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  71407. * @param target is the object (point or mesh) what the intersection is computed against
  71408. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  71409. * @returns true if it intersects
  71410. */
  71411. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  71412. /**
  71413. * get the rotation matrix of the particle
  71414. * @hidden
  71415. */
  71416. getRotationMatrix(m: Matrix): void;
  71417. }
  71418. /**
  71419. * Represents a group of points in a points cloud system
  71420. * * PCS internal tool, don't use it manually.
  71421. */
  71422. export class PointsGroup {
  71423. /**
  71424. * The group id
  71425. * @hidden
  71426. */
  71427. groupID: number;
  71428. /**
  71429. * image data for group (internal use)
  71430. * @hidden
  71431. */
  71432. _groupImageData: Nullable<ArrayBufferView>;
  71433. /**
  71434. * Image Width (internal use)
  71435. * @hidden
  71436. */
  71437. _groupImgWidth: number;
  71438. /**
  71439. * Image Height (internal use)
  71440. * @hidden
  71441. */
  71442. _groupImgHeight: number;
  71443. /**
  71444. * Custom position function (internal use)
  71445. * @hidden
  71446. */
  71447. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  71448. /**
  71449. * density per facet for surface points
  71450. * @hidden
  71451. */
  71452. _groupDensity: number[];
  71453. /**
  71454. * Only when points are colored by texture carries pointer to texture list array
  71455. * @hidden
  71456. */
  71457. _textureNb: number;
  71458. /**
  71459. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  71460. * PCS internal tool, don't use it manually.
  71461. * @hidden
  71462. */
  71463. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  71464. }
  71465. }
  71466. declare module "babylonjs/Particles/index" {
  71467. export * from "babylonjs/Particles/baseParticleSystem";
  71468. export * from "babylonjs/Particles/EmitterTypes/index";
  71469. export * from "babylonjs/Particles/gpuParticleSystem";
  71470. export * from "babylonjs/Particles/IParticleSystem";
  71471. export * from "babylonjs/Particles/particle";
  71472. export * from "babylonjs/Particles/particleHelper";
  71473. export * from "babylonjs/Particles/particleSystem";
  71474. import "babylonjs/Particles/particleSystemComponent";
  71475. export * from "babylonjs/Particles/particleSystemComponent";
  71476. export * from "babylonjs/Particles/particleSystemSet";
  71477. export * from "babylonjs/Particles/solidParticle";
  71478. export * from "babylonjs/Particles/solidParticleSystem";
  71479. export * from "babylonjs/Particles/cloudPoint";
  71480. export * from "babylonjs/Particles/pointsCloudSystem";
  71481. export * from "babylonjs/Particles/subEmitter";
  71482. }
  71483. declare module "babylonjs/Physics/physicsEngineComponent" {
  71484. import { Nullable } from "babylonjs/types";
  71485. import { Observable, Observer } from "babylonjs/Misc/observable";
  71486. import { Vector3 } from "babylonjs/Maths/math.vector";
  71487. import { Mesh } from "babylonjs/Meshes/mesh";
  71488. import { ISceneComponent } from "babylonjs/sceneComponent";
  71489. import { Scene } from "babylonjs/scene";
  71490. import { Node } from "babylonjs/node";
  71491. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  71492. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71493. module "babylonjs/scene" {
  71494. interface Scene {
  71495. /** @hidden (Backing field) */
  71496. _physicsEngine: Nullable<IPhysicsEngine>;
  71497. /** @hidden */
  71498. _physicsTimeAccumulator: number;
  71499. /**
  71500. * Gets the current physics engine
  71501. * @returns a IPhysicsEngine or null if none attached
  71502. */
  71503. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  71504. /**
  71505. * Enables physics to the current scene
  71506. * @param gravity defines the scene's gravity for the physics engine
  71507. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  71508. * @return a boolean indicating if the physics engine was initialized
  71509. */
  71510. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  71511. /**
  71512. * Disables and disposes the physics engine associated with the scene
  71513. */
  71514. disablePhysicsEngine(): void;
  71515. /**
  71516. * Gets a boolean indicating if there is an active physics engine
  71517. * @returns a boolean indicating if there is an active physics engine
  71518. */
  71519. isPhysicsEnabled(): boolean;
  71520. /**
  71521. * Deletes a physics compound impostor
  71522. * @param compound defines the compound to delete
  71523. */
  71524. deleteCompoundImpostor(compound: any): void;
  71525. /**
  71526. * An event triggered when physic simulation is about to be run
  71527. */
  71528. onBeforePhysicsObservable: Observable<Scene>;
  71529. /**
  71530. * An event triggered when physic simulation has been done
  71531. */
  71532. onAfterPhysicsObservable: Observable<Scene>;
  71533. }
  71534. }
  71535. module "babylonjs/Meshes/abstractMesh" {
  71536. interface AbstractMesh {
  71537. /** @hidden */
  71538. _physicsImpostor: Nullable<PhysicsImpostor>;
  71539. /**
  71540. * Gets or sets impostor used for physic simulation
  71541. * @see https://doc.babylonjs.com/features/physics_engine
  71542. */
  71543. physicsImpostor: Nullable<PhysicsImpostor>;
  71544. /**
  71545. * Gets the current physics impostor
  71546. * @see https://doc.babylonjs.com/features/physics_engine
  71547. * @returns a physics impostor or null
  71548. */
  71549. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  71550. /** Apply a physic impulse to the mesh
  71551. * @param force defines the force to apply
  71552. * @param contactPoint defines where to apply the force
  71553. * @returns the current mesh
  71554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  71555. */
  71556. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  71557. /**
  71558. * Creates a physic joint between two meshes
  71559. * @param otherMesh defines the other mesh to use
  71560. * @param pivot1 defines the pivot to use on this mesh
  71561. * @param pivot2 defines the pivot to use on the other mesh
  71562. * @param options defines additional options (can be plugin dependent)
  71563. * @returns the current mesh
  71564. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  71565. */
  71566. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  71567. /** @hidden */
  71568. _disposePhysicsObserver: Nullable<Observer<Node>>;
  71569. }
  71570. }
  71571. /**
  71572. * Defines the physics engine scene component responsible to manage a physics engine
  71573. */
  71574. export class PhysicsEngineSceneComponent implements ISceneComponent {
  71575. /**
  71576. * The component name helpful to identify the component in the list of scene components.
  71577. */
  71578. readonly name: string;
  71579. /**
  71580. * The scene the component belongs to.
  71581. */
  71582. scene: Scene;
  71583. /**
  71584. * Creates a new instance of the component for the given scene
  71585. * @param scene Defines the scene to register the component in
  71586. */
  71587. constructor(scene: Scene);
  71588. /**
  71589. * Registers the component in a given scene
  71590. */
  71591. register(): void;
  71592. /**
  71593. * Rebuilds the elements related to this component in case of
  71594. * context lost for instance.
  71595. */
  71596. rebuild(): void;
  71597. /**
  71598. * Disposes the component and the associated ressources
  71599. */
  71600. dispose(): void;
  71601. }
  71602. }
  71603. declare module "babylonjs/Physics/physicsHelper" {
  71604. import { Nullable } from "babylonjs/types";
  71605. import { Vector3 } from "babylonjs/Maths/math.vector";
  71606. import { Mesh } from "babylonjs/Meshes/mesh";
  71607. import { Scene } from "babylonjs/scene";
  71608. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71609. /**
  71610. * A helper for physics simulations
  71611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71612. */
  71613. export class PhysicsHelper {
  71614. private _scene;
  71615. private _physicsEngine;
  71616. /**
  71617. * Initializes the Physics helper
  71618. * @param scene Babylon.js scene
  71619. */
  71620. constructor(scene: Scene);
  71621. /**
  71622. * Applies a radial explosion impulse
  71623. * @param origin the origin of the explosion
  71624. * @param radiusOrEventOptions the radius or the options of radial explosion
  71625. * @param strength the explosion strength
  71626. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71627. * @returns A physics radial explosion event, or null
  71628. */
  71629. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71630. /**
  71631. * Applies a radial explosion force
  71632. * @param origin the origin of the explosion
  71633. * @param radiusOrEventOptions the radius or the options of radial explosion
  71634. * @param strength the explosion strength
  71635. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71636. * @returns A physics radial explosion event, or null
  71637. */
  71638. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71639. /**
  71640. * Creates a gravitational field
  71641. * @param origin the origin of the explosion
  71642. * @param radiusOrEventOptions the radius or the options of radial explosion
  71643. * @param strength the explosion strength
  71644. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71645. * @returns A physics gravitational field event, or null
  71646. */
  71647. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  71648. /**
  71649. * Creates a physics updraft event
  71650. * @param origin the origin of the updraft
  71651. * @param radiusOrEventOptions the radius or the options of the updraft
  71652. * @param strength the strength of the updraft
  71653. * @param height the height of the updraft
  71654. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  71655. * @returns A physics updraft event, or null
  71656. */
  71657. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  71658. /**
  71659. * Creates a physics vortex event
  71660. * @param origin the of the vortex
  71661. * @param radiusOrEventOptions the radius or the options of the vortex
  71662. * @param strength the strength of the vortex
  71663. * @param height the height of the vortex
  71664. * @returns a Physics vortex event, or null
  71665. * A physics vortex event or null
  71666. */
  71667. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  71668. }
  71669. /**
  71670. * Represents a physics radial explosion event
  71671. */
  71672. class PhysicsRadialExplosionEvent {
  71673. private _scene;
  71674. private _options;
  71675. private _sphere;
  71676. private _dataFetched;
  71677. /**
  71678. * Initializes a radial explosioin event
  71679. * @param _scene BabylonJS scene
  71680. * @param _options The options for the vortex event
  71681. */
  71682. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  71683. /**
  71684. * Returns the data related to the radial explosion event (sphere).
  71685. * @returns The radial explosion event data
  71686. */
  71687. getData(): PhysicsRadialExplosionEventData;
  71688. /**
  71689. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  71690. * @param impostor A physics imposter
  71691. * @param origin the origin of the explosion
  71692. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  71693. */
  71694. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  71695. /**
  71696. * Triggers affecterd impostors callbacks
  71697. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  71698. */
  71699. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  71700. /**
  71701. * Disposes the sphere.
  71702. * @param force Specifies if the sphere should be disposed by force
  71703. */
  71704. dispose(force?: boolean): void;
  71705. /*** Helpers ***/
  71706. private _prepareSphere;
  71707. private _intersectsWithSphere;
  71708. }
  71709. /**
  71710. * Represents a gravitational field event
  71711. */
  71712. class PhysicsGravitationalFieldEvent {
  71713. private _physicsHelper;
  71714. private _scene;
  71715. private _origin;
  71716. private _options;
  71717. private _tickCallback;
  71718. private _sphere;
  71719. private _dataFetched;
  71720. /**
  71721. * Initializes the physics gravitational field event
  71722. * @param _physicsHelper A physics helper
  71723. * @param _scene BabylonJS scene
  71724. * @param _origin The origin position of the gravitational field event
  71725. * @param _options The options for the vortex event
  71726. */
  71727. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  71728. /**
  71729. * Returns the data related to the gravitational field event (sphere).
  71730. * @returns A gravitational field event
  71731. */
  71732. getData(): PhysicsGravitationalFieldEventData;
  71733. /**
  71734. * Enables the gravitational field.
  71735. */
  71736. enable(): void;
  71737. /**
  71738. * Disables the gravitational field.
  71739. */
  71740. disable(): void;
  71741. /**
  71742. * Disposes the sphere.
  71743. * @param force The force to dispose from the gravitational field event
  71744. */
  71745. dispose(force?: boolean): void;
  71746. private _tick;
  71747. }
  71748. /**
  71749. * Represents a physics updraft event
  71750. */
  71751. class PhysicsUpdraftEvent {
  71752. private _scene;
  71753. private _origin;
  71754. private _options;
  71755. private _physicsEngine;
  71756. private _originTop;
  71757. private _originDirection;
  71758. private _tickCallback;
  71759. private _cylinder;
  71760. private _cylinderPosition;
  71761. private _dataFetched;
  71762. /**
  71763. * Initializes the physics updraft event
  71764. * @param _scene BabylonJS scene
  71765. * @param _origin The origin position of the updraft
  71766. * @param _options The options for the updraft event
  71767. */
  71768. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  71769. /**
  71770. * Returns the data related to the updraft event (cylinder).
  71771. * @returns A physics updraft event
  71772. */
  71773. getData(): PhysicsUpdraftEventData;
  71774. /**
  71775. * Enables the updraft.
  71776. */
  71777. enable(): void;
  71778. /**
  71779. * Disables the updraft.
  71780. */
  71781. disable(): void;
  71782. /**
  71783. * Disposes the cylinder.
  71784. * @param force Specifies if the updraft should be disposed by force
  71785. */
  71786. dispose(force?: boolean): void;
  71787. private getImpostorHitData;
  71788. private _tick;
  71789. /*** Helpers ***/
  71790. private _prepareCylinder;
  71791. private _intersectsWithCylinder;
  71792. }
  71793. /**
  71794. * Represents a physics vortex event
  71795. */
  71796. class PhysicsVortexEvent {
  71797. private _scene;
  71798. private _origin;
  71799. private _options;
  71800. private _physicsEngine;
  71801. private _originTop;
  71802. private _tickCallback;
  71803. private _cylinder;
  71804. private _cylinderPosition;
  71805. private _dataFetched;
  71806. /**
  71807. * Initializes the physics vortex event
  71808. * @param _scene The BabylonJS scene
  71809. * @param _origin The origin position of the vortex
  71810. * @param _options The options for the vortex event
  71811. */
  71812. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  71813. /**
  71814. * Returns the data related to the vortex event (cylinder).
  71815. * @returns The physics vortex event data
  71816. */
  71817. getData(): PhysicsVortexEventData;
  71818. /**
  71819. * Enables the vortex.
  71820. */
  71821. enable(): void;
  71822. /**
  71823. * Disables the cortex.
  71824. */
  71825. disable(): void;
  71826. /**
  71827. * Disposes the sphere.
  71828. * @param force
  71829. */
  71830. dispose(force?: boolean): void;
  71831. private getImpostorHitData;
  71832. private _tick;
  71833. /*** Helpers ***/
  71834. private _prepareCylinder;
  71835. private _intersectsWithCylinder;
  71836. }
  71837. /**
  71838. * Options fot the radial explosion event
  71839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71840. */
  71841. export class PhysicsRadialExplosionEventOptions {
  71842. /**
  71843. * The radius of the sphere for the radial explosion.
  71844. */
  71845. radius: number;
  71846. /**
  71847. * The strenth of the explosion.
  71848. */
  71849. strength: number;
  71850. /**
  71851. * The strenght of the force in correspondence to the distance of the affected object
  71852. */
  71853. falloff: PhysicsRadialImpulseFalloff;
  71854. /**
  71855. * Sphere options for the radial explosion.
  71856. */
  71857. sphere: {
  71858. segments: number;
  71859. diameter: number;
  71860. };
  71861. /**
  71862. * Sphere options for the radial explosion.
  71863. */
  71864. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  71865. }
  71866. /**
  71867. * Options fot the updraft event
  71868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71869. */
  71870. export class PhysicsUpdraftEventOptions {
  71871. /**
  71872. * The radius of the cylinder for the vortex
  71873. */
  71874. radius: number;
  71875. /**
  71876. * The strenth of the updraft.
  71877. */
  71878. strength: number;
  71879. /**
  71880. * The height of the cylinder for the updraft.
  71881. */
  71882. height: number;
  71883. /**
  71884. * The mode for the the updraft.
  71885. */
  71886. updraftMode: PhysicsUpdraftMode;
  71887. }
  71888. /**
  71889. * Options fot the vortex event
  71890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71891. */
  71892. export class PhysicsVortexEventOptions {
  71893. /**
  71894. * The radius of the cylinder for the vortex
  71895. */
  71896. radius: number;
  71897. /**
  71898. * The strenth of the vortex.
  71899. */
  71900. strength: number;
  71901. /**
  71902. * The height of the cylinder for the vortex.
  71903. */
  71904. height: number;
  71905. /**
  71906. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  71907. */
  71908. centripetalForceThreshold: number;
  71909. /**
  71910. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  71911. */
  71912. centripetalForceMultiplier: number;
  71913. /**
  71914. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  71915. */
  71916. centrifugalForceMultiplier: number;
  71917. /**
  71918. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  71919. */
  71920. updraftForceMultiplier: number;
  71921. }
  71922. /**
  71923. * The strenght of the force in correspondence to the distance of the affected object
  71924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71925. */
  71926. export enum PhysicsRadialImpulseFalloff {
  71927. /** Defines that impulse is constant in strength across it's whole radius */
  71928. Constant = 0,
  71929. /** Defines that impulse gets weaker if it's further from the origin */
  71930. Linear = 1
  71931. }
  71932. /**
  71933. * The strength of the force in correspondence to the distance of the affected object
  71934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71935. */
  71936. export enum PhysicsUpdraftMode {
  71937. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  71938. Center = 0,
  71939. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  71940. Perpendicular = 1
  71941. }
  71942. /**
  71943. * Interface for a physics hit data
  71944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71945. */
  71946. export interface PhysicsHitData {
  71947. /**
  71948. * The force applied at the contact point
  71949. */
  71950. force: Vector3;
  71951. /**
  71952. * The contact point
  71953. */
  71954. contactPoint: Vector3;
  71955. /**
  71956. * The distance from the origin to the contact point
  71957. */
  71958. distanceFromOrigin: number;
  71959. }
  71960. /**
  71961. * Interface for radial explosion event data
  71962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71963. */
  71964. export interface PhysicsRadialExplosionEventData {
  71965. /**
  71966. * A sphere used for the radial explosion event
  71967. */
  71968. sphere: Mesh;
  71969. }
  71970. /**
  71971. * Interface for gravitational field event data
  71972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71973. */
  71974. export interface PhysicsGravitationalFieldEventData {
  71975. /**
  71976. * A sphere mesh used for the gravitational field event
  71977. */
  71978. sphere: Mesh;
  71979. }
  71980. /**
  71981. * Interface for updraft event data
  71982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71983. */
  71984. export interface PhysicsUpdraftEventData {
  71985. /**
  71986. * A cylinder used for the updraft event
  71987. */
  71988. cylinder: Mesh;
  71989. }
  71990. /**
  71991. * Interface for vortex event data
  71992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71993. */
  71994. export interface PhysicsVortexEventData {
  71995. /**
  71996. * A cylinder used for the vortex event
  71997. */
  71998. cylinder: Mesh;
  71999. }
  72000. /**
  72001. * Interface for an affected physics impostor
  72002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72003. */
  72004. export interface PhysicsAffectedImpostorWithData {
  72005. /**
  72006. * The impostor affected by the effect
  72007. */
  72008. impostor: PhysicsImpostor;
  72009. /**
  72010. * The data about the hit/horce from the explosion
  72011. */
  72012. hitData: PhysicsHitData;
  72013. }
  72014. }
  72015. declare module "babylonjs/Physics/Plugins/index" {
  72016. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72017. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72018. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72019. }
  72020. declare module "babylonjs/Physics/index" {
  72021. export * from "babylonjs/Physics/IPhysicsEngine";
  72022. export * from "babylonjs/Physics/physicsEngine";
  72023. export * from "babylonjs/Physics/physicsEngineComponent";
  72024. export * from "babylonjs/Physics/physicsHelper";
  72025. export * from "babylonjs/Physics/physicsImpostor";
  72026. export * from "babylonjs/Physics/physicsJoint";
  72027. export * from "babylonjs/Physics/Plugins/index";
  72028. }
  72029. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72030. /** @hidden */
  72031. export var blackAndWhitePixelShader: {
  72032. name: string;
  72033. shader: string;
  72034. };
  72035. }
  72036. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72037. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72038. import { Camera } from "babylonjs/Cameras/camera";
  72039. import { Engine } from "babylonjs/Engines/engine";
  72040. import "babylonjs/Shaders/blackAndWhite.fragment";
  72041. /**
  72042. * Post process used to render in black and white
  72043. */
  72044. export class BlackAndWhitePostProcess extends PostProcess {
  72045. /**
  72046. * Linear about to convert he result to black and white (default: 1)
  72047. */
  72048. degree: number;
  72049. /**
  72050. * Creates a black and white post process
  72051. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72052. * @param name The name of the effect.
  72053. * @param options The required width/height ratio to downsize to before computing the render pass.
  72054. * @param camera The camera to apply the render pass to.
  72055. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72056. * @param engine The engine which the post process will be applied. (default: current engine)
  72057. * @param reusable If the post process can be reused on the same frame. (default: false)
  72058. */
  72059. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72060. }
  72061. }
  72062. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72063. import { Nullable } from "babylonjs/types";
  72064. import { Camera } from "babylonjs/Cameras/camera";
  72065. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72066. import { Engine } from "babylonjs/Engines/engine";
  72067. /**
  72068. * This represents a set of one or more post processes in Babylon.
  72069. * A post process can be used to apply a shader to a texture after it is rendered.
  72070. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72071. */
  72072. export class PostProcessRenderEffect {
  72073. private _postProcesses;
  72074. private _getPostProcesses;
  72075. private _singleInstance;
  72076. private _cameras;
  72077. private _indicesForCamera;
  72078. /**
  72079. * Name of the effect
  72080. * @hidden
  72081. */
  72082. _name: string;
  72083. /**
  72084. * Instantiates a post process render effect.
  72085. * A post process can be used to apply a shader to a texture after it is rendered.
  72086. * @param engine The engine the effect is tied to
  72087. * @param name The name of the effect
  72088. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72089. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72090. */
  72091. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72092. /**
  72093. * Checks if all the post processes in the effect are supported.
  72094. */
  72095. get isSupported(): boolean;
  72096. /**
  72097. * Updates the current state of the effect
  72098. * @hidden
  72099. */
  72100. _update(): void;
  72101. /**
  72102. * Attaches the effect on cameras
  72103. * @param cameras The camera to attach to.
  72104. * @hidden
  72105. */
  72106. _attachCameras(cameras: Camera): void;
  72107. /**
  72108. * Attaches the effect on cameras
  72109. * @param cameras The camera to attach to.
  72110. * @hidden
  72111. */
  72112. _attachCameras(cameras: Camera[]): void;
  72113. /**
  72114. * Detaches the effect on cameras
  72115. * @param cameras The camera to detatch from.
  72116. * @hidden
  72117. */
  72118. _detachCameras(cameras: Camera): void;
  72119. /**
  72120. * Detatches the effect on cameras
  72121. * @param cameras The camera to detatch from.
  72122. * @hidden
  72123. */
  72124. _detachCameras(cameras: Camera[]): void;
  72125. /**
  72126. * Enables the effect on given cameras
  72127. * @param cameras The camera to enable.
  72128. * @hidden
  72129. */
  72130. _enable(cameras: Camera): void;
  72131. /**
  72132. * Enables the effect on given cameras
  72133. * @param cameras The camera to enable.
  72134. * @hidden
  72135. */
  72136. _enable(cameras: Nullable<Camera[]>): void;
  72137. /**
  72138. * Disables the effect on the given cameras
  72139. * @param cameras The camera to disable.
  72140. * @hidden
  72141. */
  72142. _disable(cameras: Camera): void;
  72143. /**
  72144. * Disables the effect on the given cameras
  72145. * @param cameras The camera to disable.
  72146. * @hidden
  72147. */
  72148. _disable(cameras: Nullable<Camera[]>): void;
  72149. /**
  72150. * Gets a list of the post processes contained in the effect.
  72151. * @param camera The camera to get the post processes on.
  72152. * @returns The list of the post processes in the effect.
  72153. */
  72154. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72155. }
  72156. }
  72157. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72158. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72159. /** @hidden */
  72160. export var extractHighlightsPixelShader: {
  72161. name: string;
  72162. shader: string;
  72163. };
  72164. }
  72165. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72166. import { Nullable } from "babylonjs/types";
  72167. import { Camera } from "babylonjs/Cameras/camera";
  72168. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72169. import { Engine } from "babylonjs/Engines/engine";
  72170. import "babylonjs/Shaders/extractHighlights.fragment";
  72171. /**
  72172. * 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.
  72173. */
  72174. export class ExtractHighlightsPostProcess extends PostProcess {
  72175. /**
  72176. * The luminance threshold, pixels below this value will be set to black.
  72177. */
  72178. threshold: number;
  72179. /** @hidden */
  72180. _exposure: number;
  72181. /**
  72182. * Post process which has the input texture to be used when performing highlight extraction
  72183. * @hidden
  72184. */
  72185. _inputPostProcess: Nullable<PostProcess>;
  72186. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72187. }
  72188. }
  72189. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72190. /** @hidden */
  72191. export var bloomMergePixelShader: {
  72192. name: string;
  72193. shader: string;
  72194. };
  72195. }
  72196. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72197. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72198. import { Nullable } from "babylonjs/types";
  72199. import { Engine } from "babylonjs/Engines/engine";
  72200. import { Camera } from "babylonjs/Cameras/camera";
  72201. import "babylonjs/Shaders/bloomMerge.fragment";
  72202. /**
  72203. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72204. */
  72205. export class BloomMergePostProcess extends PostProcess {
  72206. /** Weight of the bloom to be added to the original input. */
  72207. weight: number;
  72208. /**
  72209. * Creates a new instance of @see BloomMergePostProcess
  72210. * @param name The name of the effect.
  72211. * @param originalFromInput Post process which's input will be used for the merge.
  72212. * @param blurred Blurred highlights post process which's output will be used.
  72213. * @param weight Weight of the bloom to be added to the original input.
  72214. * @param options The required width/height ratio to downsize to before computing the render pass.
  72215. * @param camera The camera to apply the render pass to.
  72216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72217. * @param engine The engine which the post process will be applied. (default: current engine)
  72218. * @param reusable If the post process can be reused on the same frame. (default: false)
  72219. * @param textureType Type of textures used when performing the post process. (default: 0)
  72220. * @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)
  72221. */
  72222. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72223. /** Weight of the bloom to be added to the original input. */
  72224. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72225. }
  72226. }
  72227. declare module "babylonjs/PostProcesses/bloomEffect" {
  72228. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72229. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72230. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72231. import { Camera } from "babylonjs/Cameras/camera";
  72232. import { Scene } from "babylonjs/scene";
  72233. /**
  72234. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72235. */
  72236. export class BloomEffect extends PostProcessRenderEffect {
  72237. private bloomScale;
  72238. /**
  72239. * @hidden Internal
  72240. */
  72241. _effects: Array<PostProcess>;
  72242. /**
  72243. * @hidden Internal
  72244. */
  72245. _downscale: ExtractHighlightsPostProcess;
  72246. private _blurX;
  72247. private _blurY;
  72248. private _merge;
  72249. /**
  72250. * The luminance threshold to find bright areas of the image to bloom.
  72251. */
  72252. get threshold(): number;
  72253. set threshold(value: number);
  72254. /**
  72255. * The strength of the bloom.
  72256. */
  72257. get weight(): number;
  72258. set weight(value: number);
  72259. /**
  72260. * Specifies the size of the bloom blur kernel, relative to the final output size
  72261. */
  72262. get kernel(): number;
  72263. set kernel(value: number);
  72264. /**
  72265. * Creates a new instance of @see BloomEffect
  72266. * @param scene The scene the effect belongs to.
  72267. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72268. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72269. * @param bloomWeight The the strength of bloom.
  72270. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72271. * @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)
  72272. */
  72273. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72274. /**
  72275. * Disposes each of the internal effects for a given camera.
  72276. * @param camera The camera to dispose the effect on.
  72277. */
  72278. disposeEffects(camera: Camera): void;
  72279. /**
  72280. * @hidden Internal
  72281. */
  72282. _updateEffects(): void;
  72283. /**
  72284. * Internal
  72285. * @returns if all the contained post processes are ready.
  72286. * @hidden
  72287. */
  72288. _isReady(): boolean;
  72289. }
  72290. }
  72291. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  72292. /** @hidden */
  72293. export var chromaticAberrationPixelShader: {
  72294. name: string;
  72295. shader: string;
  72296. };
  72297. }
  72298. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  72299. import { Vector2 } from "babylonjs/Maths/math.vector";
  72300. import { Nullable } from "babylonjs/types";
  72301. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72302. import { Camera } from "babylonjs/Cameras/camera";
  72303. import { Engine } from "babylonjs/Engines/engine";
  72304. import "babylonjs/Shaders/chromaticAberration.fragment";
  72305. /**
  72306. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  72307. */
  72308. export class ChromaticAberrationPostProcess extends PostProcess {
  72309. /**
  72310. * The amount of seperation of rgb channels (default: 30)
  72311. */
  72312. aberrationAmount: number;
  72313. /**
  72314. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  72315. */
  72316. radialIntensity: number;
  72317. /**
  72318. * 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))
  72319. */
  72320. direction: Vector2;
  72321. /**
  72322. * 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))
  72323. */
  72324. centerPosition: Vector2;
  72325. /**
  72326. * Creates a new instance ChromaticAberrationPostProcess
  72327. * @param name The name of the effect.
  72328. * @param screenWidth The width of the screen to apply the effect on.
  72329. * @param screenHeight The height of the screen to apply the effect on.
  72330. * @param options The required width/height ratio to downsize to before computing the render pass.
  72331. * @param camera The camera to apply the render pass to.
  72332. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72333. * @param engine The engine which the post process will be applied. (default: current engine)
  72334. * @param reusable If the post process can be reused on the same frame. (default: false)
  72335. * @param textureType Type of textures used when performing the post process. (default: 0)
  72336. * @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)
  72337. */
  72338. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72339. }
  72340. }
  72341. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  72342. /** @hidden */
  72343. export var circleOfConfusionPixelShader: {
  72344. name: string;
  72345. shader: string;
  72346. };
  72347. }
  72348. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  72349. import { Nullable } from "babylonjs/types";
  72350. import { Engine } from "babylonjs/Engines/engine";
  72351. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72352. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72353. import { Camera } from "babylonjs/Cameras/camera";
  72354. import "babylonjs/Shaders/circleOfConfusion.fragment";
  72355. /**
  72356. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  72357. */
  72358. export class CircleOfConfusionPostProcess extends PostProcess {
  72359. /**
  72360. * 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.
  72361. */
  72362. lensSize: number;
  72363. /**
  72364. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72365. */
  72366. fStop: number;
  72367. /**
  72368. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72369. */
  72370. focusDistance: number;
  72371. /**
  72372. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  72373. */
  72374. focalLength: number;
  72375. private _depthTexture;
  72376. /**
  72377. * Creates a new instance CircleOfConfusionPostProcess
  72378. * @param name The name of the effect.
  72379. * @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.
  72380. * @param options The required width/height ratio to downsize to before computing the render pass.
  72381. * @param camera The camera to apply the render pass to.
  72382. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72383. * @param engine The engine which the post process will be applied. (default: current engine)
  72384. * @param reusable If the post process can be reused on the same frame. (default: false)
  72385. * @param textureType Type of textures used when performing the post process. (default: 0)
  72386. * @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)
  72387. */
  72388. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72389. /**
  72390. * 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.
  72391. */
  72392. set depthTexture(value: RenderTargetTexture);
  72393. }
  72394. }
  72395. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  72396. /** @hidden */
  72397. export var colorCorrectionPixelShader: {
  72398. name: string;
  72399. shader: string;
  72400. };
  72401. }
  72402. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  72403. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72404. import { Engine } from "babylonjs/Engines/engine";
  72405. import { Camera } from "babylonjs/Cameras/camera";
  72406. import "babylonjs/Shaders/colorCorrection.fragment";
  72407. /**
  72408. *
  72409. * This post-process allows the modification of rendered colors by using
  72410. * a 'look-up table' (LUT). This effect is also called Color Grading.
  72411. *
  72412. * The object needs to be provided an url to a texture containing the color
  72413. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  72414. * Use an image editing software to tweak the LUT to match your needs.
  72415. *
  72416. * For an example of a color LUT, see here:
  72417. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  72418. * For explanations on color grading, see here:
  72419. * @see http://udn.epicgames.com/Three/ColorGrading.html
  72420. *
  72421. */
  72422. export class ColorCorrectionPostProcess extends PostProcess {
  72423. private _colorTableTexture;
  72424. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72425. }
  72426. }
  72427. declare module "babylonjs/Shaders/convolution.fragment" {
  72428. /** @hidden */
  72429. export var convolutionPixelShader: {
  72430. name: string;
  72431. shader: string;
  72432. };
  72433. }
  72434. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  72435. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72436. import { Nullable } from "babylonjs/types";
  72437. import { Camera } from "babylonjs/Cameras/camera";
  72438. import { Engine } from "babylonjs/Engines/engine";
  72439. import "babylonjs/Shaders/convolution.fragment";
  72440. /**
  72441. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  72442. * input texture to perform effects such as edge detection or sharpening
  72443. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72444. */
  72445. export class ConvolutionPostProcess extends PostProcess {
  72446. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72447. kernel: number[];
  72448. /**
  72449. * Creates a new instance ConvolutionPostProcess
  72450. * @param name The name of the effect.
  72451. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  72452. * @param options The required width/height ratio to downsize to before computing the render pass.
  72453. * @param camera The camera to apply the render pass to.
  72454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72455. * @param engine The engine which the post process will be applied. (default: current engine)
  72456. * @param reusable If the post process can be reused on the same frame. (default: false)
  72457. * @param textureType Type of textures used when performing the post process. (default: 0)
  72458. */
  72459. constructor(name: string,
  72460. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72461. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72462. /**
  72463. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72464. */
  72465. static EdgeDetect0Kernel: number[];
  72466. /**
  72467. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72468. */
  72469. static EdgeDetect1Kernel: number[];
  72470. /**
  72471. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72472. */
  72473. static EdgeDetect2Kernel: number[];
  72474. /**
  72475. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72476. */
  72477. static SharpenKernel: number[];
  72478. /**
  72479. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72480. */
  72481. static EmbossKernel: number[];
  72482. /**
  72483. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72484. */
  72485. static GaussianKernel: number[];
  72486. }
  72487. }
  72488. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  72489. import { Nullable } from "babylonjs/types";
  72490. import { Vector2 } from "babylonjs/Maths/math.vector";
  72491. import { Camera } from "babylonjs/Cameras/camera";
  72492. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72493. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  72494. import { Engine } from "babylonjs/Engines/engine";
  72495. import { Scene } from "babylonjs/scene";
  72496. /**
  72497. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  72498. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  72499. * based on samples that have a large difference in distance than the center pixel.
  72500. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  72501. */
  72502. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  72503. direction: Vector2;
  72504. /**
  72505. * Creates a new instance CircleOfConfusionPostProcess
  72506. * @param name The name of the effect.
  72507. * @param scene The scene the effect belongs to.
  72508. * @param direction The direction the blur should be applied.
  72509. * @param kernel The size of the kernel used to blur.
  72510. * @param options The required width/height ratio to downsize to before computing the render pass.
  72511. * @param camera The camera to apply the render pass to.
  72512. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  72513. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  72514. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72515. * @param engine The engine which the post process will be applied. (default: current engine)
  72516. * @param reusable If the post process can be reused on the same frame. (default: false)
  72517. * @param textureType Type of textures used when performing the post process. (default: 0)
  72518. * @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)
  72519. */
  72520. 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);
  72521. }
  72522. }
  72523. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  72524. /** @hidden */
  72525. export var depthOfFieldMergePixelShader: {
  72526. name: string;
  72527. shader: string;
  72528. };
  72529. }
  72530. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  72531. import { Nullable } from "babylonjs/types";
  72532. import { Camera } from "babylonjs/Cameras/camera";
  72533. import { Effect } from "babylonjs/Materials/effect";
  72534. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72535. import { Engine } from "babylonjs/Engines/engine";
  72536. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  72537. /**
  72538. * Options to be set when merging outputs from the default pipeline.
  72539. */
  72540. export class DepthOfFieldMergePostProcessOptions {
  72541. /**
  72542. * The original image to merge on top of
  72543. */
  72544. originalFromInput: PostProcess;
  72545. /**
  72546. * Parameters to perform the merge of the depth of field effect
  72547. */
  72548. depthOfField?: {
  72549. circleOfConfusion: PostProcess;
  72550. blurSteps: Array<PostProcess>;
  72551. };
  72552. /**
  72553. * Parameters to perform the merge of bloom effect
  72554. */
  72555. bloom?: {
  72556. blurred: PostProcess;
  72557. weight: number;
  72558. };
  72559. }
  72560. /**
  72561. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72562. */
  72563. export class DepthOfFieldMergePostProcess extends PostProcess {
  72564. private blurSteps;
  72565. /**
  72566. * Creates a new instance of DepthOfFieldMergePostProcess
  72567. * @param name The name of the effect.
  72568. * @param originalFromInput Post process which's input will be used for the merge.
  72569. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  72570. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  72571. * @param options The required width/height ratio to downsize to before computing the render pass.
  72572. * @param camera The camera to apply the render pass to.
  72573. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72574. * @param engine The engine which the post process will be applied. (default: current engine)
  72575. * @param reusable If the post process can be reused on the same frame. (default: false)
  72576. * @param textureType Type of textures used when performing the post process. (default: 0)
  72577. * @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)
  72578. */
  72579. 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);
  72580. /**
  72581. * Updates the effect with the current post process compile time values and recompiles the shader.
  72582. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72583. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72584. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72585. * @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
  72586. * @param onCompiled Called when the shader has been compiled.
  72587. * @param onError Called if there is an error when compiling a shader.
  72588. */
  72589. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72590. }
  72591. }
  72592. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  72593. import { Nullable } from "babylonjs/types";
  72594. import { Camera } from "babylonjs/Cameras/camera";
  72595. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72596. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72597. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72598. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72599. import { Scene } from "babylonjs/scene";
  72600. /**
  72601. * Specifies the level of max blur that should be applied when using the depth of field effect
  72602. */
  72603. export enum DepthOfFieldEffectBlurLevel {
  72604. /**
  72605. * Subtle blur
  72606. */
  72607. Low = 0,
  72608. /**
  72609. * Medium blur
  72610. */
  72611. Medium = 1,
  72612. /**
  72613. * Large blur
  72614. */
  72615. High = 2
  72616. }
  72617. /**
  72618. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  72619. */
  72620. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  72621. private _circleOfConfusion;
  72622. /**
  72623. * @hidden Internal, blurs from high to low
  72624. */
  72625. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  72626. private _depthOfFieldBlurY;
  72627. private _dofMerge;
  72628. /**
  72629. * @hidden Internal post processes in depth of field effect
  72630. */
  72631. _effects: Array<PostProcess>;
  72632. /**
  72633. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  72634. */
  72635. set focalLength(value: number);
  72636. get focalLength(): number;
  72637. /**
  72638. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72639. */
  72640. set fStop(value: number);
  72641. get fStop(): number;
  72642. /**
  72643. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72644. */
  72645. set focusDistance(value: number);
  72646. get focusDistance(): number;
  72647. /**
  72648. * 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.
  72649. */
  72650. set lensSize(value: number);
  72651. get lensSize(): number;
  72652. /**
  72653. * Creates a new instance DepthOfFieldEffect
  72654. * @param scene The scene the effect belongs to.
  72655. * @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.
  72656. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72657. * @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)
  72658. */
  72659. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  72660. /**
  72661. * Get the current class name of the current effet
  72662. * @returns "DepthOfFieldEffect"
  72663. */
  72664. getClassName(): string;
  72665. /**
  72666. * 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.
  72667. */
  72668. set depthTexture(value: RenderTargetTexture);
  72669. /**
  72670. * Disposes each of the internal effects for a given camera.
  72671. * @param camera The camera to dispose the effect on.
  72672. */
  72673. disposeEffects(camera: Camera): void;
  72674. /**
  72675. * @hidden Internal
  72676. */
  72677. _updateEffects(): void;
  72678. /**
  72679. * Internal
  72680. * @returns if all the contained post processes are ready.
  72681. * @hidden
  72682. */
  72683. _isReady(): boolean;
  72684. }
  72685. }
  72686. declare module "babylonjs/Shaders/displayPass.fragment" {
  72687. /** @hidden */
  72688. export var displayPassPixelShader: {
  72689. name: string;
  72690. shader: string;
  72691. };
  72692. }
  72693. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  72694. import { Nullable } from "babylonjs/types";
  72695. import { Camera } from "babylonjs/Cameras/camera";
  72696. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72697. import { Engine } from "babylonjs/Engines/engine";
  72698. import "babylonjs/Shaders/displayPass.fragment";
  72699. /**
  72700. * DisplayPassPostProcess which produces an output the same as it's input
  72701. */
  72702. export class DisplayPassPostProcess extends PostProcess {
  72703. /**
  72704. * Creates the DisplayPassPostProcess
  72705. * @param name The name of the effect.
  72706. * @param options The required width/height ratio to downsize to before computing the render pass.
  72707. * @param camera The camera to apply the render pass to.
  72708. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72709. * @param engine The engine which the post process will be applied. (default: current engine)
  72710. * @param reusable If the post process can be reused on the same frame. (default: false)
  72711. */
  72712. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72713. }
  72714. }
  72715. declare module "babylonjs/Shaders/filter.fragment" {
  72716. /** @hidden */
  72717. export var filterPixelShader: {
  72718. name: string;
  72719. shader: string;
  72720. };
  72721. }
  72722. declare module "babylonjs/PostProcesses/filterPostProcess" {
  72723. import { Nullable } from "babylonjs/types";
  72724. import { Matrix } from "babylonjs/Maths/math.vector";
  72725. import { Camera } from "babylonjs/Cameras/camera";
  72726. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72727. import { Engine } from "babylonjs/Engines/engine";
  72728. import "babylonjs/Shaders/filter.fragment";
  72729. /**
  72730. * Applies a kernel filter to the image
  72731. */
  72732. export class FilterPostProcess extends PostProcess {
  72733. /** The matrix to be applied to the image */
  72734. kernelMatrix: Matrix;
  72735. /**
  72736. *
  72737. * @param name The name of the effect.
  72738. * @param kernelMatrix The matrix to be applied to the image
  72739. * @param options The required width/height ratio to downsize to before computing the render pass.
  72740. * @param camera The camera to apply the render pass to.
  72741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72742. * @param engine The engine which the post process will be applied. (default: current engine)
  72743. * @param reusable If the post process can be reused on the same frame. (default: false)
  72744. */
  72745. constructor(name: string,
  72746. /** The matrix to be applied to the image */
  72747. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72748. }
  72749. }
  72750. declare module "babylonjs/Shaders/fxaa.fragment" {
  72751. /** @hidden */
  72752. export var fxaaPixelShader: {
  72753. name: string;
  72754. shader: string;
  72755. };
  72756. }
  72757. declare module "babylonjs/Shaders/fxaa.vertex" {
  72758. /** @hidden */
  72759. export var fxaaVertexShader: {
  72760. name: string;
  72761. shader: string;
  72762. };
  72763. }
  72764. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  72765. import { Nullable } from "babylonjs/types";
  72766. import { Camera } from "babylonjs/Cameras/camera";
  72767. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72768. import { Engine } from "babylonjs/Engines/engine";
  72769. import "babylonjs/Shaders/fxaa.fragment";
  72770. import "babylonjs/Shaders/fxaa.vertex";
  72771. /**
  72772. * Fxaa post process
  72773. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  72774. */
  72775. export class FxaaPostProcess extends PostProcess {
  72776. /** @hidden */
  72777. texelWidth: number;
  72778. /** @hidden */
  72779. texelHeight: number;
  72780. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72781. private _getDefines;
  72782. }
  72783. }
  72784. declare module "babylonjs/Shaders/grain.fragment" {
  72785. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72786. /** @hidden */
  72787. export var grainPixelShader: {
  72788. name: string;
  72789. shader: string;
  72790. };
  72791. }
  72792. declare module "babylonjs/PostProcesses/grainPostProcess" {
  72793. import { Nullable } from "babylonjs/types";
  72794. import { Camera } from "babylonjs/Cameras/camera";
  72795. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72796. import { Engine } from "babylonjs/Engines/engine";
  72797. import "babylonjs/Shaders/grain.fragment";
  72798. /**
  72799. * The GrainPostProcess adds noise to the image at mid luminance levels
  72800. */
  72801. export class GrainPostProcess extends PostProcess {
  72802. /**
  72803. * The intensity of the grain added (default: 30)
  72804. */
  72805. intensity: number;
  72806. /**
  72807. * If the grain should be randomized on every frame
  72808. */
  72809. animated: boolean;
  72810. /**
  72811. * Creates a new instance of @see GrainPostProcess
  72812. * @param name The name of the effect.
  72813. * @param options The required width/height ratio to downsize to before computing the render pass.
  72814. * @param camera The camera to apply the render pass to.
  72815. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72816. * @param engine The engine which the post process will be applied. (default: current engine)
  72817. * @param reusable If the post process can be reused on the same frame. (default: false)
  72818. * @param textureType Type of textures used when performing the post process. (default: 0)
  72819. * @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)
  72820. */
  72821. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72822. }
  72823. }
  72824. declare module "babylonjs/Shaders/highlights.fragment" {
  72825. /** @hidden */
  72826. export var highlightsPixelShader: {
  72827. name: string;
  72828. shader: string;
  72829. };
  72830. }
  72831. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  72832. import { Nullable } from "babylonjs/types";
  72833. import { Camera } from "babylonjs/Cameras/camera";
  72834. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72835. import { Engine } from "babylonjs/Engines/engine";
  72836. import "babylonjs/Shaders/highlights.fragment";
  72837. /**
  72838. * Extracts highlights from the image
  72839. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72840. */
  72841. export class HighlightsPostProcess extends PostProcess {
  72842. /**
  72843. * Extracts highlights from the image
  72844. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72845. * @param name The name of the effect.
  72846. * @param options The required width/height ratio to downsize to before computing the render pass.
  72847. * @param camera The camera to apply the render pass to.
  72848. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72849. * @param engine The engine which the post process will be applied. (default: current engine)
  72850. * @param reusable If the post process can be reused on the same frame. (default: false)
  72851. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  72852. */
  72853. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72854. }
  72855. }
  72856. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  72857. /** @hidden */
  72858. export var mrtFragmentDeclaration: {
  72859. name: string;
  72860. shader: string;
  72861. };
  72862. }
  72863. declare module "babylonjs/Shaders/geometry.fragment" {
  72864. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  72865. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  72866. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  72867. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  72868. /** @hidden */
  72869. export var geometryPixelShader: {
  72870. name: string;
  72871. shader: string;
  72872. };
  72873. }
  72874. declare module "babylonjs/Shaders/geometry.vertex" {
  72875. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72876. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72877. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72878. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72879. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72880. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72881. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72882. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  72883. /** @hidden */
  72884. export var geometryVertexShader: {
  72885. name: string;
  72886. shader: string;
  72887. };
  72888. }
  72889. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  72890. import { Matrix } from "babylonjs/Maths/math.vector";
  72891. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72892. import { Mesh } from "babylonjs/Meshes/mesh";
  72893. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  72894. import { Effect } from "babylonjs/Materials/effect";
  72895. import { Scene } from "babylonjs/scene";
  72896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72897. import "babylonjs/Shaders/geometry.fragment";
  72898. import "babylonjs/Shaders/geometry.vertex";
  72899. /** @hidden */
  72900. interface ISavedTransformationMatrix {
  72901. world: Matrix;
  72902. viewProjection: Matrix;
  72903. }
  72904. /**
  72905. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  72906. */
  72907. export class GeometryBufferRenderer {
  72908. /**
  72909. * Constant used to retrieve the position texture index in the G-Buffer textures array
  72910. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  72911. */
  72912. static readonly POSITION_TEXTURE_TYPE: number;
  72913. /**
  72914. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  72915. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  72916. */
  72917. static readonly VELOCITY_TEXTURE_TYPE: number;
  72918. /**
  72919. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  72920. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  72921. */
  72922. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  72923. /**
  72924. * Dictionary used to store the previous transformation matrices of each rendered mesh
  72925. * in order to compute objects velocities when enableVelocity is set to "true"
  72926. * @hidden
  72927. */
  72928. _previousTransformationMatrices: {
  72929. [index: number]: ISavedTransformationMatrix;
  72930. };
  72931. /**
  72932. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  72933. * in order to compute objects velocities when enableVelocity is set to "true"
  72934. * @hidden
  72935. */
  72936. _previousBonesTransformationMatrices: {
  72937. [index: number]: Float32Array;
  72938. };
  72939. /**
  72940. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  72941. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  72942. */
  72943. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  72944. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  72945. renderTransparentMeshes: boolean;
  72946. private _scene;
  72947. private _resizeObserver;
  72948. private _multiRenderTarget;
  72949. private _ratio;
  72950. private _enablePosition;
  72951. private _enableVelocity;
  72952. private _enableReflectivity;
  72953. private _positionIndex;
  72954. private _velocityIndex;
  72955. private _reflectivityIndex;
  72956. protected _effect: Effect;
  72957. protected _cachedDefines: string;
  72958. /**
  72959. * Set the render list (meshes to be rendered) used in the G buffer.
  72960. */
  72961. set renderList(meshes: Mesh[]);
  72962. /**
  72963. * Gets wether or not G buffer are supported by the running hardware.
  72964. * This requires draw buffer supports
  72965. */
  72966. get isSupported(): boolean;
  72967. /**
  72968. * Returns the index of the given texture type in the G-Buffer textures array
  72969. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  72970. * @returns the index of the given texture type in the G-Buffer textures array
  72971. */
  72972. getTextureIndex(textureType: number): number;
  72973. /**
  72974. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  72975. */
  72976. get enablePosition(): boolean;
  72977. /**
  72978. * Sets whether or not objects positions are enabled for the G buffer.
  72979. */
  72980. set enablePosition(enable: boolean);
  72981. /**
  72982. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  72983. */
  72984. get enableVelocity(): boolean;
  72985. /**
  72986. * Sets wether or not objects velocities are enabled for the G buffer.
  72987. */
  72988. set enableVelocity(enable: boolean);
  72989. /**
  72990. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  72991. */
  72992. get enableReflectivity(): boolean;
  72993. /**
  72994. * Sets wether or not objects roughness are enabled for the G buffer.
  72995. */
  72996. set enableReflectivity(enable: boolean);
  72997. /**
  72998. * Gets the scene associated with the buffer.
  72999. */
  73000. get scene(): Scene;
  73001. /**
  73002. * Gets the ratio used by the buffer during its creation.
  73003. * How big is the buffer related to the main canvas.
  73004. */
  73005. get ratio(): number;
  73006. /** @hidden */
  73007. static _SceneComponentInitialization: (scene: Scene) => void;
  73008. /**
  73009. * Creates a new G Buffer for the scene
  73010. * @param scene The scene the buffer belongs to
  73011. * @param ratio How big is the buffer related to the main canvas.
  73012. */
  73013. constructor(scene: Scene, ratio?: number);
  73014. /**
  73015. * Checks wether everything is ready to render a submesh to the G buffer.
  73016. * @param subMesh the submesh to check readiness for
  73017. * @param useInstances is the mesh drawn using instance or not
  73018. * @returns true if ready otherwise false
  73019. */
  73020. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73021. /**
  73022. * Gets the current underlying G Buffer.
  73023. * @returns the buffer
  73024. */
  73025. getGBuffer(): MultiRenderTarget;
  73026. /**
  73027. * Gets the number of samples used to render the buffer (anti aliasing).
  73028. */
  73029. get samples(): number;
  73030. /**
  73031. * Sets the number of samples used to render the buffer (anti aliasing).
  73032. */
  73033. set samples(value: number);
  73034. /**
  73035. * Disposes the renderer and frees up associated resources.
  73036. */
  73037. dispose(): void;
  73038. protected _createRenderTargets(): void;
  73039. private _copyBonesTransformationMatrices;
  73040. }
  73041. }
  73042. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73043. import { Nullable } from "babylonjs/types";
  73044. import { Scene } from "babylonjs/scene";
  73045. import { ISceneComponent } from "babylonjs/sceneComponent";
  73046. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73047. module "babylonjs/scene" {
  73048. interface Scene {
  73049. /** @hidden (Backing field) */
  73050. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73051. /**
  73052. * Gets or Sets the current geometry buffer associated to the scene.
  73053. */
  73054. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73055. /**
  73056. * Enables a GeometryBufferRender and associates it with the scene
  73057. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73058. * @returns the GeometryBufferRenderer
  73059. */
  73060. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73061. /**
  73062. * Disables the GeometryBufferRender associated with the scene
  73063. */
  73064. disableGeometryBufferRenderer(): void;
  73065. }
  73066. }
  73067. /**
  73068. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73069. * in several rendering techniques.
  73070. */
  73071. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73072. /**
  73073. * The component name helpful to identify the component in the list of scene components.
  73074. */
  73075. readonly name: string;
  73076. /**
  73077. * The scene the component belongs to.
  73078. */
  73079. scene: Scene;
  73080. /**
  73081. * Creates a new instance of the component for the given scene
  73082. * @param scene Defines the scene to register the component in
  73083. */
  73084. constructor(scene: Scene);
  73085. /**
  73086. * Registers the component in a given scene
  73087. */
  73088. register(): void;
  73089. /**
  73090. * Rebuilds the elements related to this component in case of
  73091. * context lost for instance.
  73092. */
  73093. rebuild(): void;
  73094. /**
  73095. * Disposes the component and the associated ressources
  73096. */
  73097. dispose(): void;
  73098. private _gatherRenderTargets;
  73099. }
  73100. }
  73101. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73102. /** @hidden */
  73103. export var motionBlurPixelShader: {
  73104. name: string;
  73105. shader: string;
  73106. };
  73107. }
  73108. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73109. import { Nullable } from "babylonjs/types";
  73110. import { Camera } from "babylonjs/Cameras/camera";
  73111. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73112. import { Scene } from "babylonjs/scene";
  73113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73114. import "babylonjs/Animations/animatable";
  73115. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73116. import "babylonjs/Shaders/motionBlur.fragment";
  73117. import { Engine } from "babylonjs/Engines/engine";
  73118. /**
  73119. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73120. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73121. * As an example, all you have to do is to create the post-process:
  73122. * var mb = new BABYLON.MotionBlurPostProcess(
  73123. * 'mb', // The name of the effect.
  73124. * scene, // The scene containing the objects to blur according to their velocity.
  73125. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73126. * camera // The camera to apply the render pass to.
  73127. * );
  73128. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73129. */
  73130. export class MotionBlurPostProcess extends PostProcess {
  73131. /**
  73132. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73133. */
  73134. motionStrength: number;
  73135. /**
  73136. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73137. */
  73138. get motionBlurSamples(): number;
  73139. /**
  73140. * Sets the number of iterations to be used for motion blur quality
  73141. */
  73142. set motionBlurSamples(samples: number);
  73143. private _motionBlurSamples;
  73144. private _geometryBufferRenderer;
  73145. /**
  73146. * Creates a new instance MotionBlurPostProcess
  73147. * @param name The name of the effect.
  73148. * @param scene The scene containing the objects to blur according to their velocity.
  73149. * @param options The required width/height ratio to downsize to before computing the render pass.
  73150. * @param camera The camera to apply the render pass to.
  73151. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73152. * @param engine The engine which the post process will be applied. (default: current engine)
  73153. * @param reusable If the post process can be reused on the same frame. (default: false)
  73154. * @param textureType Type of textures used when performing the post process. (default: 0)
  73155. * @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)
  73156. */
  73157. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73158. /**
  73159. * Excludes the given skinned mesh from computing bones velocities.
  73160. * 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.
  73161. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73162. */
  73163. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73164. /**
  73165. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73166. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73167. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73168. */
  73169. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73170. /**
  73171. * Disposes the post process.
  73172. * @param camera The camera to dispose the post process on.
  73173. */
  73174. dispose(camera?: Camera): void;
  73175. }
  73176. }
  73177. declare module "babylonjs/Shaders/refraction.fragment" {
  73178. /** @hidden */
  73179. export var refractionPixelShader: {
  73180. name: string;
  73181. shader: string;
  73182. };
  73183. }
  73184. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73185. import { Color3 } from "babylonjs/Maths/math.color";
  73186. import { Camera } from "babylonjs/Cameras/camera";
  73187. import { Texture } from "babylonjs/Materials/Textures/texture";
  73188. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73189. import { Engine } from "babylonjs/Engines/engine";
  73190. import "babylonjs/Shaders/refraction.fragment";
  73191. /**
  73192. * Post process which applies a refractin texture
  73193. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73194. */
  73195. export class RefractionPostProcess extends PostProcess {
  73196. /** the base color of the refraction (used to taint the rendering) */
  73197. color: Color3;
  73198. /** simulated refraction depth */
  73199. depth: number;
  73200. /** the coefficient of the base color (0 to remove base color tainting) */
  73201. colorLevel: number;
  73202. private _refTexture;
  73203. private _ownRefractionTexture;
  73204. /**
  73205. * Gets or sets the refraction texture
  73206. * Please note that you are responsible for disposing the texture if you set it manually
  73207. */
  73208. get refractionTexture(): Texture;
  73209. set refractionTexture(value: Texture);
  73210. /**
  73211. * Initializes the RefractionPostProcess
  73212. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73213. * @param name The name of the effect.
  73214. * @param refractionTextureUrl Url of the refraction texture to use
  73215. * @param color the base color of the refraction (used to taint the rendering)
  73216. * @param depth simulated refraction depth
  73217. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  73218. * @param camera The camera to apply the render pass to.
  73219. * @param options The required width/height ratio to downsize to before computing the render pass.
  73220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73221. * @param engine The engine which the post process will be applied. (default: current engine)
  73222. * @param reusable If the post process can be reused on the same frame. (default: false)
  73223. */
  73224. constructor(name: string, refractionTextureUrl: string,
  73225. /** the base color of the refraction (used to taint the rendering) */
  73226. color: Color3,
  73227. /** simulated refraction depth */
  73228. depth: number,
  73229. /** the coefficient of the base color (0 to remove base color tainting) */
  73230. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73231. /**
  73232. * Disposes of the post process
  73233. * @param camera Camera to dispose post process on
  73234. */
  73235. dispose(camera: Camera): void;
  73236. }
  73237. }
  73238. declare module "babylonjs/Shaders/sharpen.fragment" {
  73239. /** @hidden */
  73240. export var sharpenPixelShader: {
  73241. name: string;
  73242. shader: string;
  73243. };
  73244. }
  73245. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  73246. import { Nullable } from "babylonjs/types";
  73247. import { Camera } from "babylonjs/Cameras/camera";
  73248. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73249. import "babylonjs/Shaders/sharpen.fragment";
  73250. import { Engine } from "babylonjs/Engines/engine";
  73251. /**
  73252. * The SharpenPostProcess applies a sharpen kernel to every pixel
  73253. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73254. */
  73255. export class SharpenPostProcess extends PostProcess {
  73256. /**
  73257. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  73258. */
  73259. colorAmount: number;
  73260. /**
  73261. * How much sharpness should be applied (default: 0.3)
  73262. */
  73263. edgeAmount: number;
  73264. /**
  73265. * Creates a new instance ConvolutionPostProcess
  73266. * @param name The name of the effect.
  73267. * @param options The required width/height ratio to downsize to before computing the render pass.
  73268. * @param camera The camera to apply the render pass to.
  73269. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73270. * @param engine The engine which the post process will be applied. (default: current engine)
  73271. * @param reusable If the post process can be reused on the same frame. (default: false)
  73272. * @param textureType Type of textures used when performing the post process. (default: 0)
  73273. * @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)
  73274. */
  73275. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73276. }
  73277. }
  73278. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  73279. import { Nullable } from "babylonjs/types";
  73280. import { Camera } from "babylonjs/Cameras/camera";
  73281. import { Engine } from "babylonjs/Engines/engine";
  73282. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73283. import { IInspectable } from "babylonjs/Misc/iInspectable";
  73284. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  73285. /**
  73286. * PostProcessRenderPipeline
  73287. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73288. */
  73289. export class PostProcessRenderPipeline {
  73290. private engine;
  73291. private _renderEffects;
  73292. private _renderEffectsForIsolatedPass;
  73293. /**
  73294. * List of inspectable custom properties (used by the Inspector)
  73295. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73296. */
  73297. inspectableCustomProperties: IInspectable[];
  73298. /**
  73299. * @hidden
  73300. */
  73301. protected _cameras: Camera[];
  73302. /** @hidden */
  73303. _name: string;
  73304. /**
  73305. * Gets pipeline name
  73306. */
  73307. get name(): string;
  73308. /** Gets the list of attached cameras */
  73309. get cameras(): Camera[];
  73310. /**
  73311. * Initializes a PostProcessRenderPipeline
  73312. * @param engine engine to add the pipeline to
  73313. * @param name name of the pipeline
  73314. */
  73315. constructor(engine: Engine, name: string);
  73316. /**
  73317. * Gets the class name
  73318. * @returns "PostProcessRenderPipeline"
  73319. */
  73320. getClassName(): string;
  73321. /**
  73322. * If all the render effects in the pipeline are supported
  73323. */
  73324. get isSupported(): boolean;
  73325. /**
  73326. * Adds an effect to the pipeline
  73327. * @param renderEffect the effect to add
  73328. */
  73329. addEffect(renderEffect: PostProcessRenderEffect): void;
  73330. /** @hidden */
  73331. _rebuild(): void;
  73332. /** @hidden */
  73333. _enableEffect(renderEffectName: string, cameras: Camera): void;
  73334. /** @hidden */
  73335. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  73336. /** @hidden */
  73337. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73338. /** @hidden */
  73339. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73340. /** @hidden */
  73341. _attachCameras(cameras: Camera, unique: boolean): void;
  73342. /** @hidden */
  73343. _attachCameras(cameras: Camera[], unique: boolean): void;
  73344. /** @hidden */
  73345. _detachCameras(cameras: Camera): void;
  73346. /** @hidden */
  73347. _detachCameras(cameras: Nullable<Camera[]>): void;
  73348. /** @hidden */
  73349. _update(): void;
  73350. /** @hidden */
  73351. _reset(): void;
  73352. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  73353. /**
  73354. * Sets the required values to the prepass renderer.
  73355. * @param prePassRenderer defines the prepass renderer to setup.
  73356. * @returns true if the pre pass is needed.
  73357. */
  73358. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  73359. /**
  73360. * Disposes of the pipeline
  73361. */
  73362. dispose(): void;
  73363. }
  73364. }
  73365. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  73366. import { Camera } from "babylonjs/Cameras/camera";
  73367. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73368. /**
  73369. * PostProcessRenderPipelineManager class
  73370. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73371. */
  73372. export class PostProcessRenderPipelineManager {
  73373. private _renderPipelines;
  73374. /**
  73375. * Initializes a PostProcessRenderPipelineManager
  73376. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73377. */
  73378. constructor();
  73379. /**
  73380. * Gets the list of supported render pipelines
  73381. */
  73382. get supportedPipelines(): PostProcessRenderPipeline[];
  73383. /**
  73384. * Adds a pipeline to the manager
  73385. * @param renderPipeline The pipeline to add
  73386. */
  73387. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  73388. /**
  73389. * Attaches a camera to the pipeline
  73390. * @param renderPipelineName The name of the pipeline to attach to
  73391. * @param cameras the camera to attach
  73392. * @param unique if the camera can be attached multiple times to the pipeline
  73393. */
  73394. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  73395. /**
  73396. * Detaches a camera from the pipeline
  73397. * @param renderPipelineName The name of the pipeline to detach from
  73398. * @param cameras the camera to detach
  73399. */
  73400. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  73401. /**
  73402. * Enables an effect by name on a pipeline
  73403. * @param renderPipelineName the name of the pipeline to enable the effect in
  73404. * @param renderEffectName the name of the effect to enable
  73405. * @param cameras the cameras that the effect should be enabled on
  73406. */
  73407. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73408. /**
  73409. * Disables an effect by name on a pipeline
  73410. * @param renderPipelineName the name of the pipeline to disable the effect in
  73411. * @param renderEffectName the name of the effect to disable
  73412. * @param cameras the cameras that the effect should be disabled on
  73413. */
  73414. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73415. /**
  73416. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  73417. */
  73418. update(): void;
  73419. /** @hidden */
  73420. _rebuild(): void;
  73421. /**
  73422. * Disposes of the manager and pipelines
  73423. */
  73424. dispose(): void;
  73425. }
  73426. }
  73427. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  73428. import { ISceneComponent } from "babylonjs/sceneComponent";
  73429. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73430. import { Scene } from "babylonjs/scene";
  73431. module "babylonjs/scene" {
  73432. interface Scene {
  73433. /** @hidden (Backing field) */
  73434. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73435. /**
  73436. * Gets the postprocess render pipeline manager
  73437. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73438. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73439. */
  73440. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73441. }
  73442. }
  73443. /**
  73444. * Defines the Render Pipeline scene component responsible to rendering pipelines
  73445. */
  73446. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  73447. /**
  73448. * The component name helpfull to identify the component in the list of scene components.
  73449. */
  73450. readonly name: string;
  73451. /**
  73452. * The scene the component belongs to.
  73453. */
  73454. scene: Scene;
  73455. /**
  73456. * Creates a new instance of the component for the given scene
  73457. * @param scene Defines the scene to register the component in
  73458. */
  73459. constructor(scene: Scene);
  73460. /**
  73461. * Registers the component in a given scene
  73462. */
  73463. register(): void;
  73464. /**
  73465. * Rebuilds the elements related to this component in case of
  73466. * context lost for instance.
  73467. */
  73468. rebuild(): void;
  73469. /**
  73470. * Disposes the component and the associated ressources
  73471. */
  73472. dispose(): void;
  73473. private _gatherRenderTargets;
  73474. }
  73475. }
  73476. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  73477. import { Nullable } from "babylonjs/types";
  73478. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73479. import { Camera } from "babylonjs/Cameras/camera";
  73480. import { IDisposable } from "babylonjs/scene";
  73481. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  73482. import { Scene } from "babylonjs/scene";
  73483. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  73484. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  73485. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  73486. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  73487. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73488. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73489. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  73490. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73491. import { Animation } from "babylonjs/Animations/animation";
  73492. /**
  73493. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  73494. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73495. */
  73496. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73497. private _scene;
  73498. private _camerasToBeAttached;
  73499. /**
  73500. * ID of the sharpen post process,
  73501. */
  73502. private readonly SharpenPostProcessId;
  73503. /**
  73504. * @ignore
  73505. * ID of the image processing post process;
  73506. */
  73507. readonly ImageProcessingPostProcessId: string;
  73508. /**
  73509. * @ignore
  73510. * ID of the Fast Approximate Anti-Aliasing post process;
  73511. */
  73512. readonly FxaaPostProcessId: string;
  73513. /**
  73514. * ID of the chromatic aberration post process,
  73515. */
  73516. private readonly ChromaticAberrationPostProcessId;
  73517. /**
  73518. * ID of the grain post process
  73519. */
  73520. private readonly GrainPostProcessId;
  73521. /**
  73522. * Sharpen post process which will apply a sharpen convolution to enhance edges
  73523. */
  73524. sharpen: SharpenPostProcess;
  73525. private _sharpenEffect;
  73526. private bloom;
  73527. /**
  73528. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  73529. */
  73530. depthOfField: DepthOfFieldEffect;
  73531. /**
  73532. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73533. */
  73534. fxaa: FxaaPostProcess;
  73535. /**
  73536. * Image post processing pass used to perform operations such as tone mapping or color grading.
  73537. */
  73538. imageProcessing: ImageProcessingPostProcess;
  73539. /**
  73540. * Chromatic aberration post process which will shift rgb colors in the image
  73541. */
  73542. chromaticAberration: ChromaticAberrationPostProcess;
  73543. private _chromaticAberrationEffect;
  73544. /**
  73545. * Grain post process which add noise to the image
  73546. */
  73547. grain: GrainPostProcess;
  73548. private _grainEffect;
  73549. /**
  73550. * Glow post process which adds a glow to emissive areas of the image
  73551. */
  73552. private _glowLayer;
  73553. /**
  73554. * Animations which can be used to tweak settings over a period of time
  73555. */
  73556. animations: Animation[];
  73557. private _imageProcessingConfigurationObserver;
  73558. private _sharpenEnabled;
  73559. private _bloomEnabled;
  73560. private _depthOfFieldEnabled;
  73561. private _depthOfFieldBlurLevel;
  73562. private _fxaaEnabled;
  73563. private _imageProcessingEnabled;
  73564. private _defaultPipelineTextureType;
  73565. private _bloomScale;
  73566. private _chromaticAberrationEnabled;
  73567. private _grainEnabled;
  73568. private _buildAllowed;
  73569. /**
  73570. * Gets active scene
  73571. */
  73572. get scene(): Scene;
  73573. /**
  73574. * Enable or disable the sharpen process from the pipeline
  73575. */
  73576. set sharpenEnabled(enabled: boolean);
  73577. get sharpenEnabled(): boolean;
  73578. private _resizeObserver;
  73579. private _hardwareScaleLevel;
  73580. private _bloomKernel;
  73581. /**
  73582. * Specifies the size of the bloom blur kernel, relative to the final output size
  73583. */
  73584. get bloomKernel(): number;
  73585. set bloomKernel(value: number);
  73586. /**
  73587. * Specifies the weight of the bloom in the final rendering
  73588. */
  73589. private _bloomWeight;
  73590. /**
  73591. * Specifies the luma threshold for the area that will be blurred by the bloom
  73592. */
  73593. private _bloomThreshold;
  73594. private _hdr;
  73595. /**
  73596. * The strength of the bloom.
  73597. */
  73598. set bloomWeight(value: number);
  73599. get bloomWeight(): number;
  73600. /**
  73601. * The strength of the bloom.
  73602. */
  73603. set bloomThreshold(value: number);
  73604. get bloomThreshold(): number;
  73605. /**
  73606. * The scale of the bloom, lower value will provide better performance.
  73607. */
  73608. set bloomScale(value: number);
  73609. get bloomScale(): number;
  73610. /**
  73611. * Enable or disable the bloom from the pipeline
  73612. */
  73613. set bloomEnabled(enabled: boolean);
  73614. get bloomEnabled(): boolean;
  73615. private _rebuildBloom;
  73616. /**
  73617. * If the depth of field is enabled.
  73618. */
  73619. get depthOfFieldEnabled(): boolean;
  73620. set depthOfFieldEnabled(enabled: boolean);
  73621. /**
  73622. * Blur level of the depth of field effect. (Higher blur will effect performance)
  73623. */
  73624. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  73625. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  73626. /**
  73627. * If the anti aliasing is enabled.
  73628. */
  73629. set fxaaEnabled(enabled: boolean);
  73630. get fxaaEnabled(): boolean;
  73631. private _samples;
  73632. /**
  73633. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73634. */
  73635. set samples(sampleCount: number);
  73636. get samples(): number;
  73637. /**
  73638. * If image processing is enabled.
  73639. */
  73640. set imageProcessingEnabled(enabled: boolean);
  73641. get imageProcessingEnabled(): boolean;
  73642. /**
  73643. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  73644. */
  73645. set glowLayerEnabled(enabled: boolean);
  73646. get glowLayerEnabled(): boolean;
  73647. /**
  73648. * Gets the glow layer (or null if not defined)
  73649. */
  73650. get glowLayer(): Nullable<GlowLayer>;
  73651. /**
  73652. * Enable or disable the chromaticAberration process from the pipeline
  73653. */
  73654. set chromaticAberrationEnabled(enabled: boolean);
  73655. get chromaticAberrationEnabled(): boolean;
  73656. /**
  73657. * Enable or disable the grain process from the pipeline
  73658. */
  73659. set grainEnabled(enabled: boolean);
  73660. get grainEnabled(): boolean;
  73661. /**
  73662. * @constructor
  73663. * @param name - The rendering pipeline name (default: "")
  73664. * @param hdr - If high dynamic range textures should be used (default: true)
  73665. * @param scene - The scene linked to this pipeline (default: the last created scene)
  73666. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  73667. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  73668. */
  73669. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  73670. /**
  73671. * Get the class name
  73672. * @returns "DefaultRenderingPipeline"
  73673. */
  73674. getClassName(): string;
  73675. /**
  73676. * Force the compilation of the entire pipeline.
  73677. */
  73678. prepare(): void;
  73679. private _hasCleared;
  73680. private _prevPostProcess;
  73681. private _prevPrevPostProcess;
  73682. private _setAutoClearAndTextureSharing;
  73683. private _depthOfFieldSceneObserver;
  73684. private _buildPipeline;
  73685. private _disposePostProcesses;
  73686. /**
  73687. * Adds a camera to the pipeline
  73688. * @param camera the camera to be added
  73689. */
  73690. addCamera(camera: Camera): void;
  73691. /**
  73692. * Removes a camera from the pipeline
  73693. * @param camera the camera to remove
  73694. */
  73695. removeCamera(camera: Camera): void;
  73696. /**
  73697. * Dispose of the pipeline and stop all post processes
  73698. */
  73699. dispose(): void;
  73700. /**
  73701. * Serialize the rendering pipeline (Used when exporting)
  73702. * @returns the serialized object
  73703. */
  73704. serialize(): any;
  73705. /**
  73706. * Parse the serialized pipeline
  73707. * @param source Source pipeline.
  73708. * @param scene The scene to load the pipeline to.
  73709. * @param rootUrl The URL of the serialized pipeline.
  73710. * @returns An instantiated pipeline from the serialized object.
  73711. */
  73712. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  73713. }
  73714. }
  73715. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  73716. /** @hidden */
  73717. export var lensHighlightsPixelShader: {
  73718. name: string;
  73719. shader: string;
  73720. };
  73721. }
  73722. declare module "babylonjs/Shaders/depthOfField.fragment" {
  73723. /** @hidden */
  73724. export var depthOfFieldPixelShader: {
  73725. name: string;
  73726. shader: string;
  73727. };
  73728. }
  73729. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  73730. import { Camera } from "babylonjs/Cameras/camera";
  73731. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73732. import { Scene } from "babylonjs/scene";
  73733. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73734. import "babylonjs/Shaders/chromaticAberration.fragment";
  73735. import "babylonjs/Shaders/lensHighlights.fragment";
  73736. import "babylonjs/Shaders/depthOfField.fragment";
  73737. /**
  73738. * BABYLON.JS Chromatic Aberration GLSL Shader
  73739. * Author: Olivier Guyot
  73740. * Separates very slightly R, G and B colors on the edges of the screen
  73741. * Inspired by Francois Tarlier & Martins Upitis
  73742. */
  73743. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  73744. /**
  73745. * @ignore
  73746. * The chromatic aberration PostProcess id in the pipeline
  73747. */
  73748. LensChromaticAberrationEffect: string;
  73749. /**
  73750. * @ignore
  73751. * The highlights enhancing PostProcess id in the pipeline
  73752. */
  73753. HighlightsEnhancingEffect: string;
  73754. /**
  73755. * @ignore
  73756. * The depth-of-field PostProcess id in the pipeline
  73757. */
  73758. LensDepthOfFieldEffect: string;
  73759. private _scene;
  73760. private _depthTexture;
  73761. private _grainTexture;
  73762. private _chromaticAberrationPostProcess;
  73763. private _highlightsPostProcess;
  73764. private _depthOfFieldPostProcess;
  73765. private _edgeBlur;
  73766. private _grainAmount;
  73767. private _chromaticAberration;
  73768. private _distortion;
  73769. private _highlightsGain;
  73770. private _highlightsThreshold;
  73771. private _dofDistance;
  73772. private _dofAperture;
  73773. private _dofDarken;
  73774. private _dofPentagon;
  73775. private _blurNoise;
  73776. /**
  73777. * @constructor
  73778. *
  73779. * Effect parameters are as follow:
  73780. * {
  73781. * chromatic_aberration: number; // from 0 to x (1 for realism)
  73782. * edge_blur: number; // from 0 to x (1 for realism)
  73783. * distortion: number; // from 0 to x (1 for realism)
  73784. * grain_amount: number; // from 0 to 1
  73785. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  73786. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  73787. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  73788. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  73789. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  73790. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  73791. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  73792. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  73793. * }
  73794. * Note: if an effect parameter is unset, effect is disabled
  73795. *
  73796. * @param name The rendering pipeline name
  73797. * @param parameters - An object containing all parameters (see above)
  73798. * @param scene The scene linked to this pipeline
  73799. * @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)
  73800. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73801. */
  73802. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  73803. /**
  73804. * Get the class name
  73805. * @returns "LensRenderingPipeline"
  73806. */
  73807. getClassName(): string;
  73808. /**
  73809. * Gets associated scene
  73810. */
  73811. get scene(): Scene;
  73812. /**
  73813. * Gets or sets the edge blur
  73814. */
  73815. get edgeBlur(): number;
  73816. set edgeBlur(value: number);
  73817. /**
  73818. * Gets or sets the grain amount
  73819. */
  73820. get grainAmount(): number;
  73821. set grainAmount(value: number);
  73822. /**
  73823. * Gets or sets the chromatic aberration amount
  73824. */
  73825. get chromaticAberration(): number;
  73826. set chromaticAberration(value: number);
  73827. /**
  73828. * Gets or sets the depth of field aperture
  73829. */
  73830. get dofAperture(): number;
  73831. set dofAperture(value: number);
  73832. /**
  73833. * Gets or sets the edge distortion
  73834. */
  73835. get edgeDistortion(): number;
  73836. set edgeDistortion(value: number);
  73837. /**
  73838. * Gets or sets the depth of field distortion
  73839. */
  73840. get dofDistortion(): number;
  73841. set dofDistortion(value: number);
  73842. /**
  73843. * Gets or sets the darken out of focus amount
  73844. */
  73845. get darkenOutOfFocus(): number;
  73846. set darkenOutOfFocus(value: number);
  73847. /**
  73848. * Gets or sets a boolean indicating if blur noise is enabled
  73849. */
  73850. get blurNoise(): boolean;
  73851. set blurNoise(value: boolean);
  73852. /**
  73853. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  73854. */
  73855. get pentagonBokeh(): boolean;
  73856. set pentagonBokeh(value: boolean);
  73857. /**
  73858. * Gets or sets the highlight grain amount
  73859. */
  73860. get highlightsGain(): number;
  73861. set highlightsGain(value: number);
  73862. /**
  73863. * Gets or sets the highlight threshold
  73864. */
  73865. get highlightsThreshold(): number;
  73866. set highlightsThreshold(value: number);
  73867. /**
  73868. * Sets the amount of blur at the edges
  73869. * @param amount blur amount
  73870. */
  73871. setEdgeBlur(amount: number): void;
  73872. /**
  73873. * Sets edge blur to 0
  73874. */
  73875. disableEdgeBlur(): void;
  73876. /**
  73877. * Sets the amout of grain
  73878. * @param amount Amount of grain
  73879. */
  73880. setGrainAmount(amount: number): void;
  73881. /**
  73882. * Set grain amount to 0
  73883. */
  73884. disableGrain(): void;
  73885. /**
  73886. * Sets the chromatic aberration amount
  73887. * @param amount amount of chromatic aberration
  73888. */
  73889. setChromaticAberration(amount: number): void;
  73890. /**
  73891. * Sets chromatic aberration amount to 0
  73892. */
  73893. disableChromaticAberration(): void;
  73894. /**
  73895. * Sets the EdgeDistortion amount
  73896. * @param amount amount of EdgeDistortion
  73897. */
  73898. setEdgeDistortion(amount: number): void;
  73899. /**
  73900. * Sets edge distortion to 0
  73901. */
  73902. disableEdgeDistortion(): void;
  73903. /**
  73904. * Sets the FocusDistance amount
  73905. * @param amount amount of FocusDistance
  73906. */
  73907. setFocusDistance(amount: number): void;
  73908. /**
  73909. * Disables depth of field
  73910. */
  73911. disableDepthOfField(): void;
  73912. /**
  73913. * Sets the Aperture amount
  73914. * @param amount amount of Aperture
  73915. */
  73916. setAperture(amount: number): void;
  73917. /**
  73918. * Sets the DarkenOutOfFocus amount
  73919. * @param amount amount of DarkenOutOfFocus
  73920. */
  73921. setDarkenOutOfFocus(amount: number): void;
  73922. private _pentagonBokehIsEnabled;
  73923. /**
  73924. * Creates a pentagon bokeh effect
  73925. */
  73926. enablePentagonBokeh(): void;
  73927. /**
  73928. * Disables the pentagon bokeh effect
  73929. */
  73930. disablePentagonBokeh(): void;
  73931. /**
  73932. * Enables noise blur
  73933. */
  73934. enableNoiseBlur(): void;
  73935. /**
  73936. * Disables noise blur
  73937. */
  73938. disableNoiseBlur(): void;
  73939. /**
  73940. * Sets the HighlightsGain amount
  73941. * @param amount amount of HighlightsGain
  73942. */
  73943. setHighlightsGain(amount: number): void;
  73944. /**
  73945. * Sets the HighlightsThreshold amount
  73946. * @param amount amount of HighlightsThreshold
  73947. */
  73948. setHighlightsThreshold(amount: number): void;
  73949. /**
  73950. * Disables highlights
  73951. */
  73952. disableHighlights(): void;
  73953. /**
  73954. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  73955. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  73956. */
  73957. dispose(disableDepthRender?: boolean): void;
  73958. private _createChromaticAberrationPostProcess;
  73959. private _createHighlightsPostProcess;
  73960. private _createDepthOfFieldPostProcess;
  73961. private _createGrainTexture;
  73962. }
  73963. }
  73964. declare module "babylonjs/Shaders/ssao2.fragment" {
  73965. /** @hidden */
  73966. export var ssao2PixelShader: {
  73967. name: string;
  73968. shader: string;
  73969. };
  73970. }
  73971. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  73972. /** @hidden */
  73973. export var ssaoCombinePixelShader: {
  73974. name: string;
  73975. shader: string;
  73976. };
  73977. }
  73978. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  73979. import { Camera } from "babylonjs/Cameras/camera";
  73980. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73981. import { Scene } from "babylonjs/scene";
  73982. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73983. import "babylonjs/Shaders/ssao2.fragment";
  73984. import "babylonjs/Shaders/ssaoCombine.fragment";
  73985. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  73986. /**
  73987. * Render pipeline to produce ssao effect
  73988. */
  73989. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  73990. /**
  73991. * @ignore
  73992. * The PassPostProcess id in the pipeline that contains the original scene color
  73993. */
  73994. SSAOOriginalSceneColorEffect: string;
  73995. /**
  73996. * @ignore
  73997. * The SSAO PostProcess id in the pipeline
  73998. */
  73999. SSAORenderEffect: string;
  74000. /**
  74001. * @ignore
  74002. * The horizontal blur PostProcess id in the pipeline
  74003. */
  74004. SSAOBlurHRenderEffect: string;
  74005. /**
  74006. * @ignore
  74007. * The vertical blur PostProcess id in the pipeline
  74008. */
  74009. SSAOBlurVRenderEffect: string;
  74010. /**
  74011. * @ignore
  74012. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74013. */
  74014. SSAOCombineRenderEffect: string;
  74015. /**
  74016. * The output strength of the SSAO post-process. Default value is 1.0.
  74017. */
  74018. totalStrength: number;
  74019. /**
  74020. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74021. */
  74022. maxZ: number;
  74023. /**
  74024. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74025. */
  74026. minZAspect: number;
  74027. private _samples;
  74028. /**
  74029. * Number of samples used for the SSAO calculations. Default value is 8
  74030. */
  74031. set samples(n: number);
  74032. get samples(): number;
  74033. private _textureSamples;
  74034. /**
  74035. * Number of samples to use for antialiasing
  74036. */
  74037. set textureSamples(n: number);
  74038. get textureSamples(): number;
  74039. /**
  74040. * Force rendering the geometry through geometry buffer
  74041. */
  74042. private _forceGeometryBuffer;
  74043. /**
  74044. * Ratio object used for SSAO ratio and blur ratio
  74045. */
  74046. private _ratio;
  74047. /**
  74048. * Dynamically generated sphere sampler.
  74049. */
  74050. private _sampleSphere;
  74051. /**
  74052. * Blur filter offsets
  74053. */
  74054. private _samplerOffsets;
  74055. private _expensiveBlur;
  74056. /**
  74057. * If bilateral blur should be used
  74058. */
  74059. set expensiveBlur(b: boolean);
  74060. get expensiveBlur(): boolean;
  74061. /**
  74062. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74063. */
  74064. radius: number;
  74065. /**
  74066. * The base color of the SSAO post-process
  74067. * The final result is "base + ssao" between [0, 1]
  74068. */
  74069. base: number;
  74070. /**
  74071. * Support test.
  74072. */
  74073. static get IsSupported(): boolean;
  74074. private _scene;
  74075. private _randomTexture;
  74076. private _originalColorPostProcess;
  74077. private _ssaoPostProcess;
  74078. private _blurHPostProcess;
  74079. private _blurVPostProcess;
  74080. private _ssaoCombinePostProcess;
  74081. private _prePassRenderer;
  74082. /**
  74083. * Gets active scene
  74084. */
  74085. get scene(): Scene;
  74086. /**
  74087. * @constructor
  74088. * @param name The rendering pipeline name
  74089. * @param scene The scene linked to this pipeline
  74090. * @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 }
  74091. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74092. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74093. */
  74094. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74095. /**
  74096. * Get the class name
  74097. * @returns "SSAO2RenderingPipeline"
  74098. */
  74099. getClassName(): string;
  74100. /**
  74101. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74102. */
  74103. dispose(disableGeometryBufferRenderer?: boolean): void;
  74104. private _createBlurPostProcess;
  74105. /** @hidden */
  74106. _rebuild(): void;
  74107. private _bits;
  74108. private _radicalInverse_VdC;
  74109. private _hammersley;
  74110. private _hemisphereSample_uniform;
  74111. private _generateHemisphere;
  74112. private _getDefinesForSSAO;
  74113. private _createSSAOPostProcess;
  74114. private _createSSAOCombinePostProcess;
  74115. private _createRandomTexture;
  74116. /**
  74117. * Serialize the rendering pipeline (Used when exporting)
  74118. * @returns the serialized object
  74119. */
  74120. serialize(): any;
  74121. /**
  74122. * Parse the serialized pipeline
  74123. * @param source Source pipeline.
  74124. * @param scene The scene to load the pipeline to.
  74125. * @param rootUrl The URL of the serialized pipeline.
  74126. * @returns An instantiated pipeline from the serialized object.
  74127. */
  74128. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74129. /**
  74130. * Sets the required values to the prepass renderer.
  74131. * @param prePassRenderer defines the prepass renderer to setup
  74132. * @returns true if the pre pass is needed.
  74133. */
  74134. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74135. }
  74136. }
  74137. declare module "babylonjs/Shaders/ssao.fragment" {
  74138. /** @hidden */
  74139. export var ssaoPixelShader: {
  74140. name: string;
  74141. shader: string;
  74142. };
  74143. }
  74144. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74145. import { Camera } from "babylonjs/Cameras/camera";
  74146. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74147. import { Scene } from "babylonjs/scene";
  74148. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74149. import "babylonjs/Shaders/ssao.fragment";
  74150. import "babylonjs/Shaders/ssaoCombine.fragment";
  74151. /**
  74152. * Render pipeline to produce ssao effect
  74153. */
  74154. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74155. /**
  74156. * @ignore
  74157. * The PassPostProcess id in the pipeline that contains the original scene color
  74158. */
  74159. SSAOOriginalSceneColorEffect: string;
  74160. /**
  74161. * @ignore
  74162. * The SSAO PostProcess id in the pipeline
  74163. */
  74164. SSAORenderEffect: string;
  74165. /**
  74166. * @ignore
  74167. * The horizontal blur PostProcess id in the pipeline
  74168. */
  74169. SSAOBlurHRenderEffect: string;
  74170. /**
  74171. * @ignore
  74172. * The vertical blur PostProcess id in the pipeline
  74173. */
  74174. SSAOBlurVRenderEffect: string;
  74175. /**
  74176. * @ignore
  74177. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74178. */
  74179. SSAOCombineRenderEffect: string;
  74180. /**
  74181. * The output strength of the SSAO post-process. Default value is 1.0.
  74182. */
  74183. totalStrength: number;
  74184. /**
  74185. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  74186. */
  74187. radius: number;
  74188. /**
  74189. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  74190. * Must not be equal to fallOff and superior to fallOff.
  74191. * Default value is 0.0075
  74192. */
  74193. area: number;
  74194. /**
  74195. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  74196. * Must not be equal to area and inferior to area.
  74197. * Default value is 0.000001
  74198. */
  74199. fallOff: number;
  74200. /**
  74201. * The base color of the SSAO post-process
  74202. * The final result is "base + ssao" between [0, 1]
  74203. */
  74204. base: number;
  74205. private _scene;
  74206. private _depthTexture;
  74207. private _randomTexture;
  74208. private _originalColorPostProcess;
  74209. private _ssaoPostProcess;
  74210. private _blurHPostProcess;
  74211. private _blurVPostProcess;
  74212. private _ssaoCombinePostProcess;
  74213. private _firstUpdate;
  74214. /**
  74215. * Gets active scene
  74216. */
  74217. get scene(): Scene;
  74218. /**
  74219. * @constructor
  74220. * @param name - The rendering pipeline name
  74221. * @param scene - The scene linked to this pipeline
  74222. * @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 }
  74223. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  74224. */
  74225. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  74226. /**
  74227. * Get the class name
  74228. * @returns "SSAORenderingPipeline"
  74229. */
  74230. getClassName(): string;
  74231. /**
  74232. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74233. */
  74234. dispose(disableDepthRender?: boolean): void;
  74235. private _createBlurPostProcess;
  74236. /** @hidden */
  74237. _rebuild(): void;
  74238. private _createSSAOPostProcess;
  74239. private _createSSAOCombinePostProcess;
  74240. private _createRandomTexture;
  74241. }
  74242. }
  74243. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  74244. /** @hidden */
  74245. export var screenSpaceReflectionPixelShader: {
  74246. name: string;
  74247. shader: string;
  74248. };
  74249. }
  74250. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  74251. import { Nullable } from "babylonjs/types";
  74252. import { Camera } from "babylonjs/Cameras/camera";
  74253. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74254. import { Scene } from "babylonjs/scene";
  74255. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  74256. import { Engine } from "babylonjs/Engines/engine";
  74257. /**
  74258. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  74259. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  74260. */
  74261. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  74262. /**
  74263. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  74264. */
  74265. threshold: number;
  74266. /**
  74267. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  74268. */
  74269. strength: number;
  74270. /**
  74271. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  74272. */
  74273. reflectionSpecularFalloffExponent: number;
  74274. /**
  74275. * 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]
  74276. */
  74277. step: number;
  74278. /**
  74279. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  74280. */
  74281. roughnessFactor: number;
  74282. private _geometryBufferRenderer;
  74283. private _enableSmoothReflections;
  74284. private _reflectionSamples;
  74285. private _smoothSteps;
  74286. /**
  74287. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  74288. * @param name The name of the effect.
  74289. * @param scene The scene containing the objects to calculate reflections.
  74290. * @param options The required width/height ratio to downsize to before computing the render pass.
  74291. * @param camera The camera to apply the render pass to.
  74292. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74293. * @param engine The engine which the post process will be applied. (default: current engine)
  74294. * @param reusable If the post process can be reused on the same frame. (default: false)
  74295. * @param textureType Type of textures used when performing the post process. (default: 0)
  74296. * @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)
  74297. */
  74298. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74299. /**
  74300. * Gets wether or not smoothing reflections is enabled.
  74301. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74302. */
  74303. get enableSmoothReflections(): boolean;
  74304. /**
  74305. * Sets wether or not smoothing reflections is enabled.
  74306. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74307. */
  74308. set enableSmoothReflections(enabled: boolean);
  74309. /**
  74310. * Gets the number of samples taken while computing reflections. More samples count is high,
  74311. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74312. */
  74313. get reflectionSamples(): number;
  74314. /**
  74315. * Sets the number of samples taken while computing reflections. More samples count is high,
  74316. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74317. */
  74318. set reflectionSamples(samples: number);
  74319. /**
  74320. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  74321. * more the post-process will require GPU power and can generate a drop in FPS.
  74322. * Default value (5.0) work pretty well in all cases but can be adjusted.
  74323. */
  74324. get smoothSteps(): number;
  74325. set smoothSteps(steps: number);
  74326. private _updateEffectDefines;
  74327. }
  74328. }
  74329. declare module "babylonjs/Shaders/standard.fragment" {
  74330. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  74331. /** @hidden */
  74332. export var standardPixelShader: {
  74333. name: string;
  74334. shader: string;
  74335. };
  74336. }
  74337. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  74338. import { Nullable } from "babylonjs/types";
  74339. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74340. import { Camera } from "babylonjs/Cameras/camera";
  74341. import { Texture } from "babylonjs/Materials/Textures/texture";
  74342. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74343. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74344. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74345. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74346. import { IDisposable } from "babylonjs/scene";
  74347. import { SpotLight } from "babylonjs/Lights/spotLight";
  74348. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  74349. import { Scene } from "babylonjs/scene";
  74350. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74351. import { Animation } from "babylonjs/Animations/animation";
  74352. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74353. import "babylonjs/Shaders/standard.fragment";
  74354. /**
  74355. * Standard rendering pipeline
  74356. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74357. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  74358. */
  74359. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74360. /**
  74361. * Public members
  74362. */
  74363. /**
  74364. * Post-process which contains the original scene color before the pipeline applies all the effects
  74365. */
  74366. originalPostProcess: Nullable<PostProcess>;
  74367. /**
  74368. * Post-process used to down scale an image x4
  74369. */
  74370. downSampleX4PostProcess: Nullable<PostProcess>;
  74371. /**
  74372. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  74373. */
  74374. brightPassPostProcess: Nullable<PostProcess>;
  74375. /**
  74376. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  74377. */
  74378. blurHPostProcesses: PostProcess[];
  74379. /**
  74380. * Post-process array storing all the vertical blur post-processes used by the pipeline
  74381. */
  74382. blurVPostProcesses: PostProcess[];
  74383. /**
  74384. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  74385. */
  74386. textureAdderPostProcess: Nullable<PostProcess>;
  74387. /**
  74388. * Post-process used to create volumetric lighting effect
  74389. */
  74390. volumetricLightPostProcess: Nullable<PostProcess>;
  74391. /**
  74392. * Post-process used to smooth the previous volumetric light post-process on the X axis
  74393. */
  74394. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  74395. /**
  74396. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  74397. */
  74398. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  74399. /**
  74400. * Post-process used to merge the volumetric light effect and the real scene color
  74401. */
  74402. volumetricLightMergePostProces: Nullable<PostProcess>;
  74403. /**
  74404. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  74405. */
  74406. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  74407. /**
  74408. * Base post-process used to calculate the average luminance of the final image for HDR
  74409. */
  74410. luminancePostProcess: Nullable<PostProcess>;
  74411. /**
  74412. * Post-processes used to create down sample post-processes in order to get
  74413. * the average luminance of the final image for HDR
  74414. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  74415. */
  74416. luminanceDownSamplePostProcesses: PostProcess[];
  74417. /**
  74418. * Post-process used to create a HDR effect (light adaptation)
  74419. */
  74420. hdrPostProcess: Nullable<PostProcess>;
  74421. /**
  74422. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  74423. */
  74424. textureAdderFinalPostProcess: Nullable<PostProcess>;
  74425. /**
  74426. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  74427. */
  74428. lensFlareFinalPostProcess: Nullable<PostProcess>;
  74429. /**
  74430. * Post-process used to merge the final HDR post-process and the real scene color
  74431. */
  74432. hdrFinalPostProcess: Nullable<PostProcess>;
  74433. /**
  74434. * Post-process used to create a lens flare effect
  74435. */
  74436. lensFlarePostProcess: Nullable<PostProcess>;
  74437. /**
  74438. * Post-process that merges the result of the lens flare post-process and the real scene color
  74439. */
  74440. lensFlareComposePostProcess: Nullable<PostProcess>;
  74441. /**
  74442. * Post-process used to create a motion blur effect
  74443. */
  74444. motionBlurPostProcess: Nullable<PostProcess>;
  74445. /**
  74446. * Post-process used to create a depth of field effect
  74447. */
  74448. depthOfFieldPostProcess: Nullable<PostProcess>;
  74449. /**
  74450. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74451. */
  74452. fxaaPostProcess: Nullable<FxaaPostProcess>;
  74453. /**
  74454. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  74455. */
  74456. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  74457. /**
  74458. * Represents the brightness threshold in order to configure the illuminated surfaces
  74459. */
  74460. brightThreshold: number;
  74461. /**
  74462. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  74463. */
  74464. blurWidth: number;
  74465. /**
  74466. * Sets if the blur for highlighted surfaces must be only horizontal
  74467. */
  74468. horizontalBlur: boolean;
  74469. /**
  74470. * Gets the overall exposure used by the pipeline
  74471. */
  74472. get exposure(): number;
  74473. /**
  74474. * Sets the overall exposure used by the pipeline
  74475. */
  74476. set exposure(value: number);
  74477. /**
  74478. * Texture used typically to simulate "dirty" on camera lens
  74479. */
  74480. lensTexture: Nullable<Texture>;
  74481. /**
  74482. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  74483. */
  74484. volumetricLightCoefficient: number;
  74485. /**
  74486. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  74487. */
  74488. volumetricLightPower: number;
  74489. /**
  74490. * Used the set the blur intensity to smooth the volumetric lights
  74491. */
  74492. volumetricLightBlurScale: number;
  74493. /**
  74494. * Light (spot or directional) used to generate the volumetric lights rays
  74495. * The source light must have a shadow generate so the pipeline can get its
  74496. * depth map
  74497. */
  74498. sourceLight: Nullable<SpotLight | DirectionalLight>;
  74499. /**
  74500. * For eye adaptation, represents the minimum luminance the eye can see
  74501. */
  74502. hdrMinimumLuminance: number;
  74503. /**
  74504. * For eye adaptation, represents the decrease luminance speed
  74505. */
  74506. hdrDecreaseRate: number;
  74507. /**
  74508. * For eye adaptation, represents the increase luminance speed
  74509. */
  74510. hdrIncreaseRate: number;
  74511. /**
  74512. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74513. */
  74514. get hdrAutoExposure(): boolean;
  74515. /**
  74516. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74517. */
  74518. set hdrAutoExposure(value: boolean);
  74519. /**
  74520. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  74521. */
  74522. lensColorTexture: Nullable<Texture>;
  74523. /**
  74524. * The overall strengh for the lens flare effect
  74525. */
  74526. lensFlareStrength: number;
  74527. /**
  74528. * Dispersion coefficient for lens flare ghosts
  74529. */
  74530. lensFlareGhostDispersal: number;
  74531. /**
  74532. * Main lens flare halo width
  74533. */
  74534. lensFlareHaloWidth: number;
  74535. /**
  74536. * Based on the lens distortion effect, defines how much the lens flare result
  74537. * is distorted
  74538. */
  74539. lensFlareDistortionStrength: number;
  74540. /**
  74541. * Configures the blur intensity used for for lens flare (halo)
  74542. */
  74543. lensFlareBlurWidth: number;
  74544. /**
  74545. * Lens star texture must be used to simulate rays on the flares and is available
  74546. * in the documentation
  74547. */
  74548. lensStarTexture: Nullable<Texture>;
  74549. /**
  74550. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  74551. * flare effect by taking account of the dirt texture
  74552. */
  74553. lensFlareDirtTexture: Nullable<Texture>;
  74554. /**
  74555. * Represents the focal length for the depth of field effect
  74556. */
  74557. depthOfFieldDistance: number;
  74558. /**
  74559. * Represents the blur intensity for the blurred part of the depth of field effect
  74560. */
  74561. depthOfFieldBlurWidth: number;
  74562. /**
  74563. * Gets how much the image is blurred by the movement while using the motion blur post-process
  74564. */
  74565. get motionStrength(): number;
  74566. /**
  74567. * Sets how much the image is blurred by the movement while using the motion blur post-process
  74568. */
  74569. set motionStrength(strength: number);
  74570. /**
  74571. * Gets wether or not the motion blur post-process is object based or screen based.
  74572. */
  74573. get objectBasedMotionBlur(): boolean;
  74574. /**
  74575. * Sets wether or not the motion blur post-process should be object based or screen based
  74576. */
  74577. set objectBasedMotionBlur(value: boolean);
  74578. /**
  74579. * List of animations for the pipeline (IAnimatable implementation)
  74580. */
  74581. animations: Animation[];
  74582. /**
  74583. * Private members
  74584. */
  74585. private _scene;
  74586. private _currentDepthOfFieldSource;
  74587. private _basePostProcess;
  74588. private _fixedExposure;
  74589. private _currentExposure;
  74590. private _hdrAutoExposure;
  74591. private _hdrCurrentLuminance;
  74592. private _motionStrength;
  74593. private _isObjectBasedMotionBlur;
  74594. private _floatTextureType;
  74595. private _camerasToBeAttached;
  74596. private _ratio;
  74597. private _bloomEnabled;
  74598. private _depthOfFieldEnabled;
  74599. private _vlsEnabled;
  74600. private _lensFlareEnabled;
  74601. private _hdrEnabled;
  74602. private _motionBlurEnabled;
  74603. private _fxaaEnabled;
  74604. private _screenSpaceReflectionsEnabled;
  74605. private _motionBlurSamples;
  74606. private _volumetricLightStepsCount;
  74607. private _samples;
  74608. /**
  74609. * @ignore
  74610. * Specifies if the bloom pipeline is enabled
  74611. */
  74612. get BloomEnabled(): boolean;
  74613. set BloomEnabled(enabled: boolean);
  74614. /**
  74615. * @ignore
  74616. * Specifies if the depth of field pipeline is enabed
  74617. */
  74618. get DepthOfFieldEnabled(): boolean;
  74619. set DepthOfFieldEnabled(enabled: boolean);
  74620. /**
  74621. * @ignore
  74622. * Specifies if the lens flare pipeline is enabed
  74623. */
  74624. get LensFlareEnabled(): boolean;
  74625. set LensFlareEnabled(enabled: boolean);
  74626. /**
  74627. * @ignore
  74628. * Specifies if the HDR pipeline is enabled
  74629. */
  74630. get HDREnabled(): boolean;
  74631. set HDREnabled(enabled: boolean);
  74632. /**
  74633. * @ignore
  74634. * Specifies if the volumetric lights scattering effect is enabled
  74635. */
  74636. get VLSEnabled(): boolean;
  74637. set VLSEnabled(enabled: boolean);
  74638. /**
  74639. * @ignore
  74640. * Specifies if the motion blur effect is enabled
  74641. */
  74642. get MotionBlurEnabled(): boolean;
  74643. set MotionBlurEnabled(enabled: boolean);
  74644. /**
  74645. * Specifies if anti-aliasing is enabled
  74646. */
  74647. get fxaaEnabled(): boolean;
  74648. set fxaaEnabled(enabled: boolean);
  74649. /**
  74650. * Specifies if screen space reflections are enabled.
  74651. */
  74652. get screenSpaceReflectionsEnabled(): boolean;
  74653. set screenSpaceReflectionsEnabled(enabled: boolean);
  74654. /**
  74655. * Specifies the number of steps used to calculate the volumetric lights
  74656. * Typically in interval [50, 200]
  74657. */
  74658. get volumetricLightStepsCount(): number;
  74659. set volumetricLightStepsCount(count: number);
  74660. /**
  74661. * Specifies the number of samples used for the motion blur effect
  74662. * Typically in interval [16, 64]
  74663. */
  74664. get motionBlurSamples(): number;
  74665. set motionBlurSamples(samples: number);
  74666. /**
  74667. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74668. */
  74669. get samples(): number;
  74670. set samples(sampleCount: number);
  74671. /**
  74672. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74673. * @constructor
  74674. * @param name The rendering pipeline name
  74675. * @param scene The scene linked to this pipeline
  74676. * @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)
  74677. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  74678. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74679. */
  74680. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  74681. private _buildPipeline;
  74682. private _createDownSampleX4PostProcess;
  74683. private _createBrightPassPostProcess;
  74684. private _createBlurPostProcesses;
  74685. private _createTextureAdderPostProcess;
  74686. private _createVolumetricLightPostProcess;
  74687. private _createLuminancePostProcesses;
  74688. private _createHdrPostProcess;
  74689. private _createLensFlarePostProcess;
  74690. private _createDepthOfFieldPostProcess;
  74691. private _createMotionBlurPostProcess;
  74692. private _getDepthTexture;
  74693. private _disposePostProcesses;
  74694. /**
  74695. * Dispose of the pipeline and stop all post processes
  74696. */
  74697. dispose(): void;
  74698. /**
  74699. * Serialize the rendering pipeline (Used when exporting)
  74700. * @returns the serialized object
  74701. */
  74702. serialize(): any;
  74703. /**
  74704. * Parse the serialized pipeline
  74705. * @param source Source pipeline.
  74706. * @param scene The scene to load the pipeline to.
  74707. * @param rootUrl The URL of the serialized pipeline.
  74708. * @returns An instantiated pipeline from the serialized object.
  74709. */
  74710. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  74711. /**
  74712. * Luminance steps
  74713. */
  74714. static LuminanceSteps: number;
  74715. }
  74716. }
  74717. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  74718. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  74719. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  74720. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  74721. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  74722. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  74723. }
  74724. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  74725. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  74726. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74727. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74728. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74729. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74730. }
  74731. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  74732. /** @hidden */
  74733. export var stereoscopicInterlacePixelShader: {
  74734. name: string;
  74735. shader: string;
  74736. };
  74737. }
  74738. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  74739. import { Camera } from "babylonjs/Cameras/camera";
  74740. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74741. import { Engine } from "babylonjs/Engines/engine";
  74742. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  74743. /**
  74744. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  74745. */
  74746. export class StereoscopicInterlacePostProcessI extends PostProcess {
  74747. private _stepSize;
  74748. private _passedProcess;
  74749. /**
  74750. * Initializes a StereoscopicInterlacePostProcessI
  74751. * @param name The name of the effect.
  74752. * @param rigCameras The rig cameras to be appled to the post process
  74753. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  74754. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  74755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74756. * @param engine The engine which the post process will be applied. (default: current engine)
  74757. * @param reusable If the post process can be reused on the same frame. (default: false)
  74758. */
  74759. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74760. }
  74761. /**
  74762. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  74763. */
  74764. export class StereoscopicInterlacePostProcess extends PostProcess {
  74765. private _stepSize;
  74766. private _passedProcess;
  74767. /**
  74768. * Initializes a StereoscopicInterlacePostProcess
  74769. * @param name The name of the effect.
  74770. * @param rigCameras The rig cameras to be appled to the post process
  74771. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  74772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74773. * @param engine The engine which the post process will be applied. (default: current engine)
  74774. * @param reusable If the post process can be reused on the same frame. (default: false)
  74775. */
  74776. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74777. }
  74778. }
  74779. declare module "babylonjs/Shaders/tonemap.fragment" {
  74780. /** @hidden */
  74781. export var tonemapPixelShader: {
  74782. name: string;
  74783. shader: string;
  74784. };
  74785. }
  74786. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  74787. import { Camera } from "babylonjs/Cameras/camera";
  74788. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74789. import "babylonjs/Shaders/tonemap.fragment";
  74790. import { Engine } from "babylonjs/Engines/engine";
  74791. /** Defines operator used for tonemapping */
  74792. export enum TonemappingOperator {
  74793. /** Hable */
  74794. Hable = 0,
  74795. /** Reinhard */
  74796. Reinhard = 1,
  74797. /** HejiDawson */
  74798. HejiDawson = 2,
  74799. /** Photographic */
  74800. Photographic = 3
  74801. }
  74802. /**
  74803. * Defines a post process to apply tone mapping
  74804. */
  74805. export class TonemapPostProcess extends PostProcess {
  74806. private _operator;
  74807. /** Defines the required exposure adjustement */
  74808. exposureAdjustment: number;
  74809. /**
  74810. * Creates a new TonemapPostProcess
  74811. * @param name defines the name of the postprocess
  74812. * @param _operator defines the operator to use
  74813. * @param exposureAdjustment defines the required exposure adjustement
  74814. * @param camera defines the camera to use (can be null)
  74815. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  74816. * @param engine defines the hosting engine (can be ignore if camera is set)
  74817. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  74818. */
  74819. constructor(name: string, _operator: TonemappingOperator,
  74820. /** Defines the required exposure adjustement */
  74821. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  74822. }
  74823. }
  74824. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  74825. /** @hidden */
  74826. export var volumetricLightScatteringPixelShader: {
  74827. name: string;
  74828. shader: string;
  74829. };
  74830. }
  74831. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  74832. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74833. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74834. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74835. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74836. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74837. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74838. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74839. /** @hidden */
  74840. export var volumetricLightScatteringPassVertexShader: {
  74841. name: string;
  74842. shader: string;
  74843. };
  74844. }
  74845. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  74846. /** @hidden */
  74847. export var volumetricLightScatteringPassPixelShader: {
  74848. name: string;
  74849. shader: string;
  74850. };
  74851. }
  74852. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  74853. import { Vector3 } from "babylonjs/Maths/math.vector";
  74854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74855. import { Mesh } from "babylonjs/Meshes/mesh";
  74856. import { Camera } from "babylonjs/Cameras/camera";
  74857. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74858. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74859. import { Scene } from "babylonjs/scene";
  74860. import "babylonjs/Meshes/Builders/planeBuilder";
  74861. import "babylonjs/Shaders/depth.vertex";
  74862. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  74863. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  74864. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  74865. import { Engine } from "babylonjs/Engines/engine";
  74866. /**
  74867. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  74868. */
  74869. export class VolumetricLightScatteringPostProcess extends PostProcess {
  74870. private _volumetricLightScatteringPass;
  74871. private _volumetricLightScatteringRTT;
  74872. private _viewPort;
  74873. private _screenCoordinates;
  74874. private _cachedDefines;
  74875. /**
  74876. * If not undefined, the mesh position is computed from the attached node position
  74877. */
  74878. attachedNode: {
  74879. position: Vector3;
  74880. };
  74881. /**
  74882. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  74883. */
  74884. customMeshPosition: Vector3;
  74885. /**
  74886. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  74887. */
  74888. useCustomMeshPosition: boolean;
  74889. /**
  74890. * If the post-process should inverse the light scattering direction
  74891. */
  74892. invert: boolean;
  74893. /**
  74894. * The internal mesh used by the post-process
  74895. */
  74896. mesh: Mesh;
  74897. /**
  74898. * @hidden
  74899. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  74900. */
  74901. get useDiffuseColor(): boolean;
  74902. set useDiffuseColor(useDiffuseColor: boolean);
  74903. /**
  74904. * Array containing the excluded meshes not rendered in the internal pass
  74905. */
  74906. excludedMeshes: AbstractMesh[];
  74907. /**
  74908. * Controls the overall intensity of the post-process
  74909. */
  74910. exposure: number;
  74911. /**
  74912. * Dissipates each sample's contribution in range [0, 1]
  74913. */
  74914. decay: number;
  74915. /**
  74916. * Controls the overall intensity of each sample
  74917. */
  74918. weight: number;
  74919. /**
  74920. * Controls the density of each sample
  74921. */
  74922. density: number;
  74923. /**
  74924. * @constructor
  74925. * @param name The post-process name
  74926. * @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)
  74927. * @param camera The camera that the post-process will be attached to
  74928. * @param mesh The mesh used to create the light scattering
  74929. * @param samples The post-process quality, default 100
  74930. * @param samplingModeThe post-process filtering mode
  74931. * @param engine The babylon engine
  74932. * @param reusable If the post-process is reusable
  74933. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  74934. */
  74935. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  74936. /**
  74937. * Returns the string "VolumetricLightScatteringPostProcess"
  74938. * @returns "VolumetricLightScatteringPostProcess"
  74939. */
  74940. getClassName(): string;
  74941. private _isReady;
  74942. /**
  74943. * Sets the new light position for light scattering effect
  74944. * @param position The new custom light position
  74945. */
  74946. setCustomMeshPosition(position: Vector3): void;
  74947. /**
  74948. * Returns the light position for light scattering effect
  74949. * @return Vector3 The custom light position
  74950. */
  74951. getCustomMeshPosition(): Vector3;
  74952. /**
  74953. * Disposes the internal assets and detaches the post-process from the camera
  74954. */
  74955. dispose(camera: Camera): void;
  74956. /**
  74957. * Returns the render target texture used by the post-process
  74958. * @return the render target texture used by the post-process
  74959. */
  74960. getPass(): RenderTargetTexture;
  74961. private _meshExcluded;
  74962. private _createPass;
  74963. private _updateMeshScreenCoordinates;
  74964. /**
  74965. * Creates a default mesh for the Volumeric Light Scattering post-process
  74966. * @param name The mesh name
  74967. * @param scene The scene where to create the mesh
  74968. * @return the default mesh
  74969. */
  74970. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  74971. }
  74972. }
  74973. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  74974. /** @hidden */
  74975. export var screenSpaceCurvaturePixelShader: {
  74976. name: string;
  74977. shader: string;
  74978. };
  74979. }
  74980. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  74981. import { Nullable } from "babylonjs/types";
  74982. import { Camera } from "babylonjs/Cameras/camera";
  74983. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74984. import { Scene } from "babylonjs/scene";
  74985. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74986. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  74987. import { Engine } from "babylonjs/Engines/engine";
  74988. /**
  74989. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  74990. */
  74991. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  74992. /**
  74993. * Defines how much ridge the curvature effect displays.
  74994. */
  74995. ridge: number;
  74996. /**
  74997. * Defines how much valley the curvature effect displays.
  74998. */
  74999. valley: number;
  75000. private _geometryBufferRenderer;
  75001. /**
  75002. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75003. * @param name The name of the effect.
  75004. * @param scene The scene containing the objects to blur according to their velocity.
  75005. * @param options The required width/height ratio to downsize to before computing the render pass.
  75006. * @param camera The camera to apply the render pass to.
  75007. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75008. * @param engine The engine which the post process will be applied. (default: current engine)
  75009. * @param reusable If the post process can be reused on the same frame. (default: false)
  75010. * @param textureType Type of textures used when performing the post process. (default: 0)
  75011. * @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)
  75012. */
  75013. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75014. /**
  75015. * Support test.
  75016. */
  75017. static get IsSupported(): boolean;
  75018. }
  75019. }
  75020. declare module "babylonjs/PostProcesses/index" {
  75021. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75022. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75023. export * from "babylonjs/PostProcesses/bloomEffect";
  75024. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75025. export * from "babylonjs/PostProcesses/blurPostProcess";
  75026. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75027. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75028. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75029. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75030. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75031. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75032. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75033. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75034. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75035. export * from "babylonjs/PostProcesses/filterPostProcess";
  75036. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75037. export * from "babylonjs/PostProcesses/grainPostProcess";
  75038. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75039. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75040. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75041. export * from "babylonjs/PostProcesses/passPostProcess";
  75042. export * from "babylonjs/PostProcesses/postProcess";
  75043. export * from "babylonjs/PostProcesses/postProcessManager";
  75044. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75045. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75046. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75047. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75048. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75049. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75050. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75051. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75052. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75053. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75054. }
  75055. declare module "babylonjs/Probes/index" {
  75056. export * from "babylonjs/Probes/reflectionProbe";
  75057. }
  75058. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75059. import { Scene } from "babylonjs/scene";
  75060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75061. import { SmartArray } from "babylonjs/Misc/smartArray";
  75062. import { ISceneComponent } from "babylonjs/sceneComponent";
  75063. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75064. import "babylonjs/Meshes/Builders/boxBuilder";
  75065. import "babylonjs/Shaders/color.fragment";
  75066. import "babylonjs/Shaders/color.vertex";
  75067. import { Color3 } from "babylonjs/Maths/math.color";
  75068. import { Observable } from "babylonjs/Misc/observable";
  75069. module "babylonjs/scene" {
  75070. interface Scene {
  75071. /** @hidden (Backing field) */
  75072. _boundingBoxRenderer: BoundingBoxRenderer;
  75073. /** @hidden (Backing field) */
  75074. _forceShowBoundingBoxes: boolean;
  75075. /**
  75076. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75077. */
  75078. forceShowBoundingBoxes: boolean;
  75079. /**
  75080. * Gets the bounding box renderer associated with the scene
  75081. * @returns a BoundingBoxRenderer
  75082. */
  75083. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75084. }
  75085. }
  75086. module "babylonjs/Meshes/abstractMesh" {
  75087. interface AbstractMesh {
  75088. /** @hidden (Backing field) */
  75089. _showBoundingBox: boolean;
  75090. /**
  75091. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75092. */
  75093. showBoundingBox: boolean;
  75094. }
  75095. }
  75096. /**
  75097. * Component responsible of rendering the bounding box of the meshes in a scene.
  75098. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75099. */
  75100. export class BoundingBoxRenderer implements ISceneComponent {
  75101. /**
  75102. * The component name helpfull to identify the component in the list of scene components.
  75103. */
  75104. readonly name: string;
  75105. /**
  75106. * The scene the component belongs to.
  75107. */
  75108. scene: Scene;
  75109. /**
  75110. * Color of the bounding box lines placed in front of an object
  75111. */
  75112. frontColor: Color3;
  75113. /**
  75114. * Color of the bounding box lines placed behind an object
  75115. */
  75116. backColor: Color3;
  75117. /**
  75118. * Defines if the renderer should show the back lines or not
  75119. */
  75120. showBackLines: boolean;
  75121. /**
  75122. * Observable raised before rendering a bounding box
  75123. */
  75124. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75125. /**
  75126. * Observable raised after rendering a bounding box
  75127. */
  75128. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75129. /**
  75130. * @hidden
  75131. */
  75132. renderList: SmartArray<BoundingBox>;
  75133. private _colorShader;
  75134. private _vertexBuffers;
  75135. private _indexBuffer;
  75136. private _fillIndexBuffer;
  75137. private _fillIndexData;
  75138. /**
  75139. * Instantiates a new bounding box renderer in a scene.
  75140. * @param scene the scene the renderer renders in
  75141. */
  75142. constructor(scene: Scene);
  75143. /**
  75144. * Registers the component in a given scene
  75145. */
  75146. register(): void;
  75147. private _evaluateSubMesh;
  75148. private _activeMesh;
  75149. private _prepareRessources;
  75150. private _createIndexBuffer;
  75151. /**
  75152. * Rebuilds the elements related to this component in case of
  75153. * context lost for instance.
  75154. */
  75155. rebuild(): void;
  75156. /**
  75157. * @hidden
  75158. */
  75159. reset(): void;
  75160. /**
  75161. * Render the bounding boxes of a specific rendering group
  75162. * @param renderingGroupId defines the rendering group to render
  75163. */
  75164. render(renderingGroupId: number): void;
  75165. /**
  75166. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75167. * @param mesh Define the mesh to render the occlusion bounding box for
  75168. */
  75169. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  75170. /**
  75171. * Dispose and release the resources attached to this renderer.
  75172. */
  75173. dispose(): void;
  75174. }
  75175. }
  75176. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  75177. import { Nullable } from "babylonjs/types";
  75178. import { Scene } from "babylonjs/scene";
  75179. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  75180. import { Camera } from "babylonjs/Cameras/camera";
  75181. import { ISceneComponent } from "babylonjs/sceneComponent";
  75182. module "babylonjs/scene" {
  75183. interface Scene {
  75184. /** @hidden (Backing field) */
  75185. _depthRenderer: {
  75186. [id: string]: DepthRenderer;
  75187. };
  75188. /**
  75189. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  75190. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  75191. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  75192. * @returns the created depth renderer
  75193. */
  75194. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  75195. /**
  75196. * Disables a depth renderer for a given camera
  75197. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  75198. */
  75199. disableDepthRenderer(camera?: Nullable<Camera>): void;
  75200. }
  75201. }
  75202. /**
  75203. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  75204. * in several rendering techniques.
  75205. */
  75206. export class DepthRendererSceneComponent implements ISceneComponent {
  75207. /**
  75208. * The component name helpfull to identify the component in the list of scene components.
  75209. */
  75210. readonly name: string;
  75211. /**
  75212. * The scene the component belongs to.
  75213. */
  75214. scene: Scene;
  75215. /**
  75216. * Creates a new instance of the component for the given scene
  75217. * @param scene Defines the scene to register the component in
  75218. */
  75219. constructor(scene: Scene);
  75220. /**
  75221. * Registers the component in a given scene
  75222. */
  75223. register(): void;
  75224. /**
  75225. * Rebuilds the elements related to this component in case of
  75226. * context lost for instance.
  75227. */
  75228. rebuild(): void;
  75229. /**
  75230. * Disposes the component and the associated ressources
  75231. */
  75232. dispose(): void;
  75233. private _gatherRenderTargets;
  75234. private _gatherActiveCameraRenderTargets;
  75235. }
  75236. }
  75237. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  75238. import { Nullable } from "babylonjs/types";
  75239. import { Scene } from "babylonjs/scene";
  75240. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  75241. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75242. import { AbstractScene } from "babylonjs/abstractScene";
  75243. module "babylonjs/abstractScene" {
  75244. interface AbstractScene {
  75245. /** @hidden (Backing field) */
  75246. _prePassRenderer: Nullable<PrePassRenderer>;
  75247. /**
  75248. * Gets or Sets the current prepass renderer associated to the scene.
  75249. */
  75250. prePassRenderer: Nullable<PrePassRenderer>;
  75251. /**
  75252. * Enables the prepass and associates it with the scene
  75253. * @returns the PrePassRenderer
  75254. */
  75255. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  75256. /**
  75257. * Disables the prepass associated with the scene
  75258. */
  75259. disablePrePassRenderer(): void;
  75260. }
  75261. }
  75262. /**
  75263. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75264. * in several rendering techniques.
  75265. */
  75266. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  75267. /**
  75268. * The component name helpful to identify the component in the list of scene components.
  75269. */
  75270. readonly name: string;
  75271. /**
  75272. * The scene the component belongs to.
  75273. */
  75274. scene: Scene;
  75275. /**
  75276. * Creates a new instance of the component for the given scene
  75277. * @param scene Defines the scene to register the component in
  75278. */
  75279. constructor(scene: Scene);
  75280. /**
  75281. * Registers the component in a given scene
  75282. */
  75283. register(): void;
  75284. private _beforeCameraDraw;
  75285. private _afterCameraDraw;
  75286. private _beforeClearStage;
  75287. /**
  75288. * Serializes the component data to the specified json object
  75289. * @param serializationObject The object to serialize to
  75290. */
  75291. serialize(serializationObject: any): void;
  75292. /**
  75293. * Adds all the elements from the container to the scene
  75294. * @param container the container holding the elements
  75295. */
  75296. addFromContainer(container: AbstractScene): void;
  75297. /**
  75298. * Removes all the elements in the container from the scene
  75299. * @param container contains the elements to remove
  75300. * @param dispose if the removed element should be disposed (default: false)
  75301. */
  75302. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75303. /**
  75304. * Rebuilds the elements related to this component in case of
  75305. * context lost for instance.
  75306. */
  75307. rebuild(): void;
  75308. /**
  75309. * Disposes the component and the associated ressources
  75310. */
  75311. dispose(): void;
  75312. }
  75313. }
  75314. declare module "babylonjs/Shaders/outline.fragment" {
  75315. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75316. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  75317. /** @hidden */
  75318. export var outlinePixelShader: {
  75319. name: string;
  75320. shader: string;
  75321. };
  75322. }
  75323. declare module "babylonjs/Shaders/outline.vertex" {
  75324. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75325. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75326. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75327. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75328. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75329. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75330. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75331. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75332. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  75333. /** @hidden */
  75334. export var outlineVertexShader: {
  75335. name: string;
  75336. shader: string;
  75337. };
  75338. }
  75339. declare module "babylonjs/Rendering/outlineRenderer" {
  75340. import { SubMesh } from "babylonjs/Meshes/subMesh";
  75341. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  75342. import { Scene } from "babylonjs/scene";
  75343. import { ISceneComponent } from "babylonjs/sceneComponent";
  75344. import "babylonjs/Shaders/outline.fragment";
  75345. import "babylonjs/Shaders/outline.vertex";
  75346. module "babylonjs/scene" {
  75347. interface Scene {
  75348. /** @hidden */
  75349. _outlineRenderer: OutlineRenderer;
  75350. /**
  75351. * Gets the outline renderer associated with the scene
  75352. * @returns a OutlineRenderer
  75353. */
  75354. getOutlineRenderer(): OutlineRenderer;
  75355. }
  75356. }
  75357. module "babylonjs/Meshes/abstractMesh" {
  75358. interface AbstractMesh {
  75359. /** @hidden (Backing field) */
  75360. _renderOutline: boolean;
  75361. /**
  75362. * Gets or sets a boolean indicating if the outline must be rendered as well
  75363. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  75364. */
  75365. renderOutline: boolean;
  75366. /** @hidden (Backing field) */
  75367. _renderOverlay: boolean;
  75368. /**
  75369. * Gets or sets a boolean indicating if the overlay must be rendered as well
  75370. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  75371. */
  75372. renderOverlay: boolean;
  75373. }
  75374. }
  75375. /**
  75376. * This class is responsible to draw bothe outline/overlay of meshes.
  75377. * It should not be used directly but through the available method on mesh.
  75378. */
  75379. export class OutlineRenderer implements ISceneComponent {
  75380. /**
  75381. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  75382. */
  75383. private static _StencilReference;
  75384. /**
  75385. * The name of the component. Each component must have a unique name.
  75386. */
  75387. name: string;
  75388. /**
  75389. * The scene the component belongs to.
  75390. */
  75391. scene: Scene;
  75392. /**
  75393. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  75394. */
  75395. zOffset: number;
  75396. private _engine;
  75397. private _effect;
  75398. private _cachedDefines;
  75399. private _savedDepthWrite;
  75400. /**
  75401. * Instantiates a new outline renderer. (There could be only one per scene).
  75402. * @param scene Defines the scene it belongs to
  75403. */
  75404. constructor(scene: Scene);
  75405. /**
  75406. * Register the component to one instance of a scene.
  75407. */
  75408. register(): void;
  75409. /**
  75410. * Rebuilds the elements related to this component in case of
  75411. * context lost for instance.
  75412. */
  75413. rebuild(): void;
  75414. /**
  75415. * Disposes the component and the associated ressources.
  75416. */
  75417. dispose(): void;
  75418. /**
  75419. * Renders the outline in the canvas.
  75420. * @param subMesh Defines the sumesh to render
  75421. * @param batch Defines the batch of meshes in case of instances
  75422. * @param useOverlay Defines if the rendering is for the overlay or the outline
  75423. */
  75424. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  75425. /**
  75426. * Returns whether or not the outline renderer is ready for a given submesh.
  75427. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  75428. * @param subMesh Defines the submesh to check readyness for
  75429. * @param useInstances Defines wheter wee are trying to render instances or not
  75430. * @returns true if ready otherwise false
  75431. */
  75432. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75433. private _beforeRenderingMesh;
  75434. private _afterRenderingMesh;
  75435. }
  75436. }
  75437. declare module "babylonjs/Rendering/index" {
  75438. export * from "babylonjs/Rendering/boundingBoxRenderer";
  75439. export * from "babylonjs/Rendering/depthRenderer";
  75440. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  75441. export * from "babylonjs/Rendering/edgesRenderer";
  75442. export * from "babylonjs/Rendering/geometryBufferRenderer";
  75443. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75444. export * from "babylonjs/Rendering/prePassRenderer";
  75445. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  75446. export * from "babylonjs/Rendering/outlineRenderer";
  75447. export * from "babylonjs/Rendering/renderingGroup";
  75448. export * from "babylonjs/Rendering/renderingManager";
  75449. export * from "babylonjs/Rendering/utilityLayerRenderer";
  75450. }
  75451. declare module "babylonjs/Sprites/ISprites" {
  75452. /**
  75453. * Defines the basic options interface of a Sprite Frame Source Size.
  75454. */
  75455. export interface ISpriteJSONSpriteSourceSize {
  75456. /**
  75457. * number of the original width of the Frame
  75458. */
  75459. w: number;
  75460. /**
  75461. * number of the original height of the Frame
  75462. */
  75463. h: number;
  75464. }
  75465. /**
  75466. * Defines the basic options interface of a Sprite Frame Data.
  75467. */
  75468. export interface ISpriteJSONSpriteFrameData {
  75469. /**
  75470. * number of the x offset of the Frame
  75471. */
  75472. x: number;
  75473. /**
  75474. * number of the y offset of the Frame
  75475. */
  75476. y: number;
  75477. /**
  75478. * number of the width of the Frame
  75479. */
  75480. w: number;
  75481. /**
  75482. * number of the height of the Frame
  75483. */
  75484. h: number;
  75485. }
  75486. /**
  75487. * Defines the basic options interface of a JSON Sprite.
  75488. */
  75489. export interface ISpriteJSONSprite {
  75490. /**
  75491. * string name of the Frame
  75492. */
  75493. filename: string;
  75494. /**
  75495. * ISpriteJSONSpriteFrame basic object of the frame data
  75496. */
  75497. frame: ISpriteJSONSpriteFrameData;
  75498. /**
  75499. * boolean to flag is the frame was rotated.
  75500. */
  75501. rotated: boolean;
  75502. /**
  75503. * boolean to flag is the frame was trimmed.
  75504. */
  75505. trimmed: boolean;
  75506. /**
  75507. * ISpriteJSONSpriteFrame basic object of the source data
  75508. */
  75509. spriteSourceSize: ISpriteJSONSpriteFrameData;
  75510. /**
  75511. * ISpriteJSONSpriteFrame basic object of the source data
  75512. */
  75513. sourceSize: ISpriteJSONSpriteSourceSize;
  75514. }
  75515. /**
  75516. * Defines the basic options interface of a JSON atlas.
  75517. */
  75518. export interface ISpriteJSONAtlas {
  75519. /**
  75520. * Array of objects that contain the frame data.
  75521. */
  75522. frames: Array<ISpriteJSONSprite>;
  75523. /**
  75524. * object basic object containing the sprite meta data.
  75525. */
  75526. meta?: object;
  75527. }
  75528. }
  75529. declare module "babylonjs/Shaders/spriteMap.fragment" {
  75530. /** @hidden */
  75531. export var spriteMapPixelShader: {
  75532. name: string;
  75533. shader: string;
  75534. };
  75535. }
  75536. declare module "babylonjs/Shaders/spriteMap.vertex" {
  75537. /** @hidden */
  75538. export var spriteMapVertexShader: {
  75539. name: string;
  75540. shader: string;
  75541. };
  75542. }
  75543. declare module "babylonjs/Sprites/spriteMap" {
  75544. import { IDisposable, Scene } from "babylonjs/scene";
  75545. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  75546. import { Texture } from "babylonjs/Materials/Textures/texture";
  75547. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  75548. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  75549. import "babylonjs/Meshes/Builders/planeBuilder";
  75550. import "babylonjs/Shaders/spriteMap.fragment";
  75551. import "babylonjs/Shaders/spriteMap.vertex";
  75552. /**
  75553. * Defines the basic options interface of a SpriteMap
  75554. */
  75555. export interface ISpriteMapOptions {
  75556. /**
  75557. * Vector2 of the number of cells in the grid.
  75558. */
  75559. stageSize?: Vector2;
  75560. /**
  75561. * Vector2 of the size of the output plane in World Units.
  75562. */
  75563. outputSize?: Vector2;
  75564. /**
  75565. * Vector3 of the position of the output plane in World Units.
  75566. */
  75567. outputPosition?: Vector3;
  75568. /**
  75569. * Vector3 of the rotation of the output plane.
  75570. */
  75571. outputRotation?: Vector3;
  75572. /**
  75573. * number of layers that the system will reserve in resources.
  75574. */
  75575. layerCount?: number;
  75576. /**
  75577. * number of max animation frames a single cell will reserve in resources.
  75578. */
  75579. maxAnimationFrames?: number;
  75580. /**
  75581. * number cell index of the base tile when the system compiles.
  75582. */
  75583. baseTile?: number;
  75584. /**
  75585. * boolean flip the sprite after its been repositioned by the framing data.
  75586. */
  75587. flipU?: boolean;
  75588. /**
  75589. * Vector3 scalar of the global RGB values of the SpriteMap.
  75590. */
  75591. colorMultiply?: Vector3;
  75592. }
  75593. /**
  75594. * Defines the IDisposable interface in order to be cleanable from resources.
  75595. */
  75596. export interface ISpriteMap extends IDisposable {
  75597. /**
  75598. * String name of the SpriteMap.
  75599. */
  75600. name: string;
  75601. /**
  75602. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  75603. */
  75604. atlasJSON: ISpriteJSONAtlas;
  75605. /**
  75606. * Texture of the SpriteMap.
  75607. */
  75608. spriteSheet: Texture;
  75609. /**
  75610. * The parameters to initialize the SpriteMap with.
  75611. */
  75612. options: ISpriteMapOptions;
  75613. }
  75614. /**
  75615. * Class used to manage a grid restricted sprite deployment on an Output plane.
  75616. */
  75617. export class SpriteMap implements ISpriteMap {
  75618. /** The Name of the spriteMap */
  75619. name: string;
  75620. /** The JSON file with the frame and meta data */
  75621. atlasJSON: ISpriteJSONAtlas;
  75622. /** The systems Sprite Sheet Texture */
  75623. spriteSheet: Texture;
  75624. /** Arguments passed with the Constructor */
  75625. options: ISpriteMapOptions;
  75626. /** Public Sprite Storage array, parsed from atlasJSON */
  75627. sprites: Array<ISpriteJSONSprite>;
  75628. /** Returns the Number of Sprites in the System */
  75629. get spriteCount(): number;
  75630. /** Returns the Position of Output Plane*/
  75631. get position(): Vector3;
  75632. /** Returns the Position of Output Plane*/
  75633. set position(v: Vector3);
  75634. /** Returns the Rotation of Output Plane*/
  75635. get rotation(): Vector3;
  75636. /** Returns the Rotation of Output Plane*/
  75637. set rotation(v: Vector3);
  75638. /** Sets the AnimationMap*/
  75639. get animationMap(): RawTexture;
  75640. /** Sets the AnimationMap*/
  75641. set animationMap(v: RawTexture);
  75642. /** Scene that the SpriteMap was created in */
  75643. private _scene;
  75644. /** Texture Buffer of Float32 that holds tile frame data*/
  75645. private _frameMap;
  75646. /** Texture Buffers of Float32 that holds tileMap data*/
  75647. private _tileMaps;
  75648. /** Texture Buffer of Float32 that holds Animation Data*/
  75649. private _animationMap;
  75650. /** Custom ShaderMaterial Central to the System*/
  75651. private _material;
  75652. /** Custom ShaderMaterial Central to the System*/
  75653. private _output;
  75654. /** Systems Time Ticker*/
  75655. private _time;
  75656. /**
  75657. * Creates a new SpriteMap
  75658. * @param name defines the SpriteMaps Name
  75659. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  75660. * @param spriteSheet is the Texture that the Sprites are on.
  75661. * @param options a basic deployment configuration
  75662. * @param scene The Scene that the map is deployed on
  75663. */
  75664. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  75665. /**
  75666. * Returns tileID location
  75667. * @returns Vector2 the cell position ID
  75668. */
  75669. getTileID(): Vector2;
  75670. /**
  75671. * Gets the UV location of the mouse over the SpriteMap.
  75672. * @returns Vector2 the UV position of the mouse interaction
  75673. */
  75674. getMousePosition(): Vector2;
  75675. /**
  75676. * Creates the "frame" texture Buffer
  75677. * -------------------------------------
  75678. * Structure of frames
  75679. * "filename": "Falling-Water-2.png",
  75680. * "frame": {"x":69,"y":103,"w":24,"h":32},
  75681. * "rotated": true,
  75682. * "trimmed": true,
  75683. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  75684. * "sourceSize": {"w":32,"h":32}
  75685. * @returns RawTexture of the frameMap
  75686. */
  75687. private _createFrameBuffer;
  75688. /**
  75689. * Creates the tileMap texture Buffer
  75690. * @param buffer normally and array of numbers, or a false to generate from scratch
  75691. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  75692. * @returns RawTexture of the tileMap
  75693. */
  75694. private _createTileBuffer;
  75695. /**
  75696. * Modifies the data of the tileMaps
  75697. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  75698. * @param pos is the iVector2 Coordinates of the Tile
  75699. * @param tile The SpriteIndex of the new Tile
  75700. */
  75701. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  75702. /**
  75703. * Creates the animationMap texture Buffer
  75704. * @param buffer normally and array of numbers, or a false to generate from scratch
  75705. * @returns RawTexture of the animationMap
  75706. */
  75707. private _createTileAnimationBuffer;
  75708. /**
  75709. * Modifies the data of the animationMap
  75710. * @param cellID is the Index of the Sprite
  75711. * @param _frame is the target Animation frame
  75712. * @param toCell is the Target Index of the next frame of the animation
  75713. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  75714. * @param speed is a global scalar of the time variable on the map.
  75715. */
  75716. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  75717. /**
  75718. * Exports the .tilemaps file
  75719. */
  75720. saveTileMaps(): void;
  75721. /**
  75722. * Imports the .tilemaps file
  75723. * @param url of the .tilemaps file
  75724. */
  75725. loadTileMaps(url: string): void;
  75726. /**
  75727. * Release associated resources
  75728. */
  75729. dispose(): void;
  75730. }
  75731. }
  75732. declare module "babylonjs/Sprites/spritePackedManager" {
  75733. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  75734. import { Scene } from "babylonjs/scene";
  75735. /**
  75736. * Class used to manage multiple sprites of different sizes on the same spritesheet
  75737. * @see https://doc.babylonjs.com/babylon101/sprites
  75738. */
  75739. export class SpritePackedManager extends SpriteManager {
  75740. /** defines the packed manager's name */
  75741. name: string;
  75742. /**
  75743. * Creates a new sprite manager from a packed sprite sheet
  75744. * @param name defines the manager's name
  75745. * @param imgUrl defines the sprite sheet url
  75746. * @param capacity defines the maximum allowed number of sprites
  75747. * @param scene defines the hosting scene
  75748. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  75749. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75750. * @param samplingMode defines the smapling mode to use with spritesheet
  75751. * @param fromPacked set to true; do not alter
  75752. */
  75753. constructor(
  75754. /** defines the packed manager's name */
  75755. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  75756. }
  75757. }
  75758. declare module "babylonjs/Sprites/index" {
  75759. export * from "babylonjs/Sprites/sprite";
  75760. export * from "babylonjs/Sprites/ISprites";
  75761. export * from "babylonjs/Sprites/spriteManager";
  75762. export * from "babylonjs/Sprites/spriteMap";
  75763. export * from "babylonjs/Sprites/spritePackedManager";
  75764. export * from "babylonjs/Sprites/spriteSceneComponent";
  75765. }
  75766. declare module "babylonjs/States/index" {
  75767. export * from "babylonjs/States/alphaCullingState";
  75768. export * from "babylonjs/States/depthCullingState";
  75769. export * from "babylonjs/States/stencilState";
  75770. }
  75771. declare module "babylonjs/Misc/assetsManager" {
  75772. import { Scene } from "babylonjs/scene";
  75773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75774. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75775. import { Skeleton } from "babylonjs/Bones/skeleton";
  75776. import { Observable } from "babylonjs/Misc/observable";
  75777. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  75778. import { Texture } from "babylonjs/Materials/Textures/texture";
  75779. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  75780. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  75781. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  75782. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  75783. /**
  75784. * Defines the list of states available for a task inside a AssetsManager
  75785. */
  75786. export enum AssetTaskState {
  75787. /**
  75788. * Initialization
  75789. */
  75790. INIT = 0,
  75791. /**
  75792. * Running
  75793. */
  75794. RUNNING = 1,
  75795. /**
  75796. * Done
  75797. */
  75798. DONE = 2,
  75799. /**
  75800. * Error
  75801. */
  75802. ERROR = 3
  75803. }
  75804. /**
  75805. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  75806. */
  75807. export abstract class AbstractAssetTask {
  75808. /**
  75809. * Task name
  75810. */ name: string;
  75811. /**
  75812. * Callback called when the task is successful
  75813. */
  75814. onSuccess: (task: any) => void;
  75815. /**
  75816. * Callback called when the task is not successful
  75817. */
  75818. onError: (task: any, message?: string, exception?: any) => void;
  75819. /**
  75820. * Creates a new AssetsManager
  75821. * @param name defines the name of the task
  75822. */
  75823. constructor(
  75824. /**
  75825. * Task name
  75826. */ name: string);
  75827. private _isCompleted;
  75828. private _taskState;
  75829. private _errorObject;
  75830. /**
  75831. * Get if the task is completed
  75832. */
  75833. get isCompleted(): boolean;
  75834. /**
  75835. * Gets the current state of the task
  75836. */
  75837. get taskState(): AssetTaskState;
  75838. /**
  75839. * Gets the current error object (if task is in error)
  75840. */
  75841. get errorObject(): {
  75842. message?: string;
  75843. exception?: any;
  75844. };
  75845. /**
  75846. * Internal only
  75847. * @hidden
  75848. */
  75849. _setErrorObject(message?: string, exception?: any): void;
  75850. /**
  75851. * Execute the current task
  75852. * @param scene defines the scene where you want your assets to be loaded
  75853. * @param onSuccess is a callback called when the task is successfully executed
  75854. * @param onError is a callback called if an error occurs
  75855. */
  75856. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75857. /**
  75858. * Execute the current task
  75859. * @param scene defines the scene where you want your assets to be loaded
  75860. * @param onSuccess is a callback called when the task is successfully executed
  75861. * @param onError is a callback called if an error occurs
  75862. */
  75863. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75864. /**
  75865. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  75866. * This can be used with failed tasks that have the reason for failure fixed.
  75867. */
  75868. reset(): void;
  75869. private onErrorCallback;
  75870. private onDoneCallback;
  75871. }
  75872. /**
  75873. * Define the interface used by progress events raised during assets loading
  75874. */
  75875. export interface IAssetsProgressEvent {
  75876. /**
  75877. * Defines the number of remaining tasks to process
  75878. */
  75879. remainingCount: number;
  75880. /**
  75881. * Defines the total number of tasks
  75882. */
  75883. totalCount: number;
  75884. /**
  75885. * Defines the task that was just processed
  75886. */
  75887. task: AbstractAssetTask;
  75888. }
  75889. /**
  75890. * Class used to share progress information about assets loading
  75891. */
  75892. export class AssetsProgressEvent implements IAssetsProgressEvent {
  75893. /**
  75894. * Defines the number of remaining tasks to process
  75895. */
  75896. remainingCount: number;
  75897. /**
  75898. * Defines the total number of tasks
  75899. */
  75900. totalCount: number;
  75901. /**
  75902. * Defines the task that was just processed
  75903. */
  75904. task: AbstractAssetTask;
  75905. /**
  75906. * Creates a AssetsProgressEvent
  75907. * @param remainingCount defines the number of remaining tasks to process
  75908. * @param totalCount defines the total number of tasks
  75909. * @param task defines the task that was just processed
  75910. */
  75911. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  75912. }
  75913. /**
  75914. * Define a task used by AssetsManager to load meshes
  75915. */
  75916. export class MeshAssetTask extends AbstractAssetTask {
  75917. /**
  75918. * Defines the name of the task
  75919. */
  75920. name: string;
  75921. /**
  75922. * Defines the list of mesh's names you want to load
  75923. */
  75924. meshesNames: any;
  75925. /**
  75926. * Defines the root url to use as a base to load your meshes and associated resources
  75927. */
  75928. rootUrl: string;
  75929. /**
  75930. * Defines the filename or File of the scene to load from
  75931. */
  75932. sceneFilename: string | File;
  75933. /**
  75934. * Gets the list of loaded meshes
  75935. */
  75936. loadedMeshes: Array<AbstractMesh>;
  75937. /**
  75938. * Gets the list of loaded particle systems
  75939. */
  75940. loadedParticleSystems: Array<IParticleSystem>;
  75941. /**
  75942. * Gets the list of loaded skeletons
  75943. */
  75944. loadedSkeletons: Array<Skeleton>;
  75945. /**
  75946. * Gets the list of loaded animation groups
  75947. */
  75948. loadedAnimationGroups: Array<AnimationGroup>;
  75949. /**
  75950. * Callback called when the task is successful
  75951. */
  75952. onSuccess: (task: MeshAssetTask) => void;
  75953. /**
  75954. * Callback called when the task is successful
  75955. */
  75956. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  75957. /**
  75958. * Creates a new MeshAssetTask
  75959. * @param name defines the name of the task
  75960. * @param meshesNames defines the list of mesh's names you want to load
  75961. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  75962. * @param sceneFilename defines the filename or File of the scene to load from
  75963. */
  75964. constructor(
  75965. /**
  75966. * Defines the name of the task
  75967. */
  75968. name: string,
  75969. /**
  75970. * Defines the list of mesh's names you want to load
  75971. */
  75972. meshesNames: any,
  75973. /**
  75974. * Defines the root url to use as a base to load your meshes and associated resources
  75975. */
  75976. rootUrl: string,
  75977. /**
  75978. * Defines the filename or File of the scene to load from
  75979. */
  75980. sceneFilename: string | File);
  75981. /**
  75982. * Execute the current task
  75983. * @param scene defines the scene where you want your assets to be loaded
  75984. * @param onSuccess is a callback called when the task is successfully executed
  75985. * @param onError is a callback called if an error occurs
  75986. */
  75987. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75988. }
  75989. /**
  75990. * Define a task used by AssetsManager to load text content
  75991. */
  75992. export class TextFileAssetTask extends AbstractAssetTask {
  75993. /**
  75994. * Defines the name of the task
  75995. */
  75996. name: string;
  75997. /**
  75998. * Defines the location of the file to load
  75999. */
  76000. url: string;
  76001. /**
  76002. * Gets the loaded text string
  76003. */
  76004. text: string;
  76005. /**
  76006. * Callback called when the task is successful
  76007. */
  76008. onSuccess: (task: TextFileAssetTask) => void;
  76009. /**
  76010. * Callback called when the task is successful
  76011. */
  76012. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  76013. /**
  76014. * Creates a new TextFileAssetTask object
  76015. * @param name defines the name of the task
  76016. * @param url defines the location of the file to load
  76017. */
  76018. constructor(
  76019. /**
  76020. * Defines the name of the task
  76021. */
  76022. name: string,
  76023. /**
  76024. * Defines the location of the file to load
  76025. */
  76026. url: string);
  76027. /**
  76028. * Execute the current task
  76029. * @param scene defines the scene where you want your assets to be loaded
  76030. * @param onSuccess is a callback called when the task is successfully executed
  76031. * @param onError is a callback called if an error occurs
  76032. */
  76033. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76034. }
  76035. /**
  76036. * Define a task used by AssetsManager to load binary data
  76037. */
  76038. export class BinaryFileAssetTask extends AbstractAssetTask {
  76039. /**
  76040. * Defines the name of the task
  76041. */
  76042. name: string;
  76043. /**
  76044. * Defines the location of the file to load
  76045. */
  76046. url: string;
  76047. /**
  76048. * Gets the lodaded data (as an array buffer)
  76049. */
  76050. data: ArrayBuffer;
  76051. /**
  76052. * Callback called when the task is successful
  76053. */
  76054. onSuccess: (task: BinaryFileAssetTask) => void;
  76055. /**
  76056. * Callback called when the task is successful
  76057. */
  76058. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  76059. /**
  76060. * Creates a new BinaryFileAssetTask object
  76061. * @param name defines the name of the new task
  76062. * @param url defines the location of the file to load
  76063. */
  76064. constructor(
  76065. /**
  76066. * Defines the name of the task
  76067. */
  76068. name: string,
  76069. /**
  76070. * Defines the location of the file to load
  76071. */
  76072. url: string);
  76073. /**
  76074. * Execute the current task
  76075. * @param scene defines the scene where you want your assets to be loaded
  76076. * @param onSuccess is a callback called when the task is successfully executed
  76077. * @param onError is a callback called if an error occurs
  76078. */
  76079. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76080. }
  76081. /**
  76082. * Define a task used by AssetsManager to load images
  76083. */
  76084. export class ImageAssetTask extends AbstractAssetTask {
  76085. /**
  76086. * Defines the name of the task
  76087. */
  76088. name: string;
  76089. /**
  76090. * Defines the location of the image to load
  76091. */
  76092. url: string;
  76093. /**
  76094. * Gets the loaded images
  76095. */
  76096. image: HTMLImageElement;
  76097. /**
  76098. * Callback called when the task is successful
  76099. */
  76100. onSuccess: (task: ImageAssetTask) => void;
  76101. /**
  76102. * Callback called when the task is successful
  76103. */
  76104. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  76105. /**
  76106. * Creates a new ImageAssetTask
  76107. * @param name defines the name of the task
  76108. * @param url defines the location of the image to load
  76109. */
  76110. constructor(
  76111. /**
  76112. * Defines the name of the task
  76113. */
  76114. name: string,
  76115. /**
  76116. * Defines the location of the image to load
  76117. */
  76118. url: string);
  76119. /**
  76120. * Execute the current task
  76121. * @param scene defines the scene where you want your assets to be loaded
  76122. * @param onSuccess is a callback called when the task is successfully executed
  76123. * @param onError is a callback called if an error occurs
  76124. */
  76125. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76126. }
  76127. /**
  76128. * Defines the interface used by texture loading tasks
  76129. */
  76130. export interface ITextureAssetTask<TEX extends BaseTexture> {
  76131. /**
  76132. * Gets the loaded texture
  76133. */
  76134. texture: TEX;
  76135. }
  76136. /**
  76137. * Define a task used by AssetsManager to load 2D textures
  76138. */
  76139. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  76140. /**
  76141. * Defines the name of the task
  76142. */
  76143. name: string;
  76144. /**
  76145. * Defines the location of the file to load
  76146. */
  76147. url: string;
  76148. /**
  76149. * Defines if mipmap should not be generated (default is false)
  76150. */
  76151. noMipmap?: boolean | undefined;
  76152. /**
  76153. * Defines if texture must be inverted on Y axis (default is true)
  76154. */
  76155. invertY: boolean;
  76156. /**
  76157. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76158. */
  76159. samplingMode: number;
  76160. /**
  76161. * Gets the loaded texture
  76162. */
  76163. texture: Texture;
  76164. /**
  76165. * Callback called when the task is successful
  76166. */
  76167. onSuccess: (task: TextureAssetTask) => void;
  76168. /**
  76169. * Callback called when the task is successful
  76170. */
  76171. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  76172. /**
  76173. * Creates a new TextureAssetTask object
  76174. * @param name defines the name of the task
  76175. * @param url defines the location of the file to load
  76176. * @param noMipmap defines if mipmap should not be generated (default is false)
  76177. * @param invertY defines if texture must be inverted on Y axis (default is true)
  76178. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76179. */
  76180. constructor(
  76181. /**
  76182. * Defines the name of the task
  76183. */
  76184. name: string,
  76185. /**
  76186. * Defines the location of the file to load
  76187. */
  76188. url: string,
  76189. /**
  76190. * Defines if mipmap should not be generated (default is false)
  76191. */
  76192. noMipmap?: boolean | undefined,
  76193. /**
  76194. * Defines if texture must be inverted on Y axis (default is true)
  76195. */
  76196. invertY?: boolean,
  76197. /**
  76198. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76199. */
  76200. samplingMode?: number);
  76201. /**
  76202. * Execute the current task
  76203. * @param scene defines the scene where you want your assets to be loaded
  76204. * @param onSuccess is a callback called when the task is successfully executed
  76205. * @param onError is a callback called if an error occurs
  76206. */
  76207. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76208. }
  76209. /**
  76210. * Define a task used by AssetsManager to load cube textures
  76211. */
  76212. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  76213. /**
  76214. * Defines the name of the task
  76215. */
  76216. name: string;
  76217. /**
  76218. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76219. */
  76220. url: string;
  76221. /**
  76222. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76223. */
  76224. extensions?: string[] | undefined;
  76225. /**
  76226. * Defines if mipmaps should not be generated (default is false)
  76227. */
  76228. noMipmap?: boolean | undefined;
  76229. /**
  76230. * Defines the explicit list of files (undefined by default)
  76231. */
  76232. files?: string[] | undefined;
  76233. /**
  76234. * Gets the loaded texture
  76235. */
  76236. texture: CubeTexture;
  76237. /**
  76238. * Callback called when the task is successful
  76239. */
  76240. onSuccess: (task: CubeTextureAssetTask) => void;
  76241. /**
  76242. * Callback called when the task is successful
  76243. */
  76244. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  76245. /**
  76246. * Creates a new CubeTextureAssetTask
  76247. * @param name defines the name of the task
  76248. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76249. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76250. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76251. * @param files defines the explicit list of files (undefined by default)
  76252. */
  76253. constructor(
  76254. /**
  76255. * Defines the name of the task
  76256. */
  76257. name: string,
  76258. /**
  76259. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76260. */
  76261. url: string,
  76262. /**
  76263. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76264. */
  76265. extensions?: string[] | undefined,
  76266. /**
  76267. * Defines if mipmaps should not be generated (default is false)
  76268. */
  76269. noMipmap?: boolean | undefined,
  76270. /**
  76271. * Defines the explicit list of files (undefined by default)
  76272. */
  76273. files?: string[] | undefined);
  76274. /**
  76275. * Execute the current task
  76276. * @param scene defines the scene where you want your assets to be loaded
  76277. * @param onSuccess is a callback called when the task is successfully executed
  76278. * @param onError is a callback called if an error occurs
  76279. */
  76280. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76281. }
  76282. /**
  76283. * Define a task used by AssetsManager to load HDR cube textures
  76284. */
  76285. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  76286. /**
  76287. * Defines the name of the task
  76288. */
  76289. name: string;
  76290. /**
  76291. * Defines the location of the file to load
  76292. */
  76293. url: string;
  76294. /**
  76295. * Defines the desired size (the more it increases the longer the generation will be)
  76296. */
  76297. size: number;
  76298. /**
  76299. * Defines if mipmaps should not be generated (default is false)
  76300. */
  76301. noMipmap: boolean;
  76302. /**
  76303. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76304. */
  76305. generateHarmonics: boolean;
  76306. /**
  76307. * 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)
  76308. */
  76309. gammaSpace: boolean;
  76310. /**
  76311. * Internal Use Only
  76312. */
  76313. reserved: boolean;
  76314. /**
  76315. * Gets the loaded texture
  76316. */
  76317. texture: HDRCubeTexture;
  76318. /**
  76319. * Callback called when the task is successful
  76320. */
  76321. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  76322. /**
  76323. * Callback called when the task is successful
  76324. */
  76325. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  76326. /**
  76327. * Creates a new HDRCubeTextureAssetTask object
  76328. * @param name defines the name of the task
  76329. * @param url defines the location of the file to load
  76330. * @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.
  76331. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76332. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76333. * @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)
  76334. * @param reserved Internal use only
  76335. */
  76336. constructor(
  76337. /**
  76338. * Defines the name of the task
  76339. */
  76340. name: string,
  76341. /**
  76342. * Defines the location of the file to load
  76343. */
  76344. url: string,
  76345. /**
  76346. * Defines the desired size (the more it increases the longer the generation will be)
  76347. */
  76348. size: number,
  76349. /**
  76350. * Defines if mipmaps should not be generated (default is false)
  76351. */
  76352. noMipmap?: boolean,
  76353. /**
  76354. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76355. */
  76356. generateHarmonics?: boolean,
  76357. /**
  76358. * 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)
  76359. */
  76360. gammaSpace?: boolean,
  76361. /**
  76362. * Internal Use Only
  76363. */
  76364. reserved?: boolean);
  76365. /**
  76366. * Execute the current task
  76367. * @param scene defines the scene where you want your assets to be loaded
  76368. * @param onSuccess is a callback called when the task is successfully executed
  76369. * @param onError is a callback called if an error occurs
  76370. */
  76371. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76372. }
  76373. /**
  76374. * Define a task used by AssetsManager to load Equirectangular cube textures
  76375. */
  76376. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  76377. /**
  76378. * Defines the name of the task
  76379. */
  76380. name: string;
  76381. /**
  76382. * Defines the location of the file to load
  76383. */
  76384. url: string;
  76385. /**
  76386. * Defines the desired size (the more it increases the longer the generation will be)
  76387. */
  76388. size: number;
  76389. /**
  76390. * Defines if mipmaps should not be generated (default is false)
  76391. */
  76392. noMipmap: boolean;
  76393. /**
  76394. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76395. * but the standard material would require them in Gamma space) (default is true)
  76396. */
  76397. gammaSpace: boolean;
  76398. /**
  76399. * Gets the loaded texture
  76400. */
  76401. texture: EquiRectangularCubeTexture;
  76402. /**
  76403. * Callback called when the task is successful
  76404. */
  76405. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  76406. /**
  76407. * Callback called when the task is successful
  76408. */
  76409. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  76410. /**
  76411. * Creates a new EquiRectangularCubeTextureAssetTask object
  76412. * @param name defines the name of the task
  76413. * @param url defines the location of the file to load
  76414. * @param size defines the desired size (the more it increases the longer the generation will be)
  76415. * If the size is omitted this implies you are using a preprocessed cubemap.
  76416. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76417. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  76418. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  76419. * (default is true)
  76420. */
  76421. constructor(
  76422. /**
  76423. * Defines the name of the task
  76424. */
  76425. name: string,
  76426. /**
  76427. * Defines the location of the file to load
  76428. */
  76429. url: string,
  76430. /**
  76431. * Defines the desired size (the more it increases the longer the generation will be)
  76432. */
  76433. size: number,
  76434. /**
  76435. * Defines if mipmaps should not be generated (default is false)
  76436. */
  76437. noMipmap?: boolean,
  76438. /**
  76439. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76440. * but the standard material would require them in Gamma space) (default is true)
  76441. */
  76442. gammaSpace?: boolean);
  76443. /**
  76444. * Execute the current task
  76445. * @param scene defines the scene where you want your assets to be loaded
  76446. * @param onSuccess is a callback called when the task is successfully executed
  76447. * @param onError is a callback called if an error occurs
  76448. */
  76449. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76450. }
  76451. /**
  76452. * This class can be used to easily import assets into a scene
  76453. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  76454. */
  76455. export class AssetsManager {
  76456. private _scene;
  76457. private _isLoading;
  76458. protected _tasks: AbstractAssetTask[];
  76459. protected _waitingTasksCount: number;
  76460. protected _totalTasksCount: number;
  76461. /**
  76462. * Callback called when all tasks are processed
  76463. */
  76464. onFinish: (tasks: AbstractAssetTask[]) => void;
  76465. /**
  76466. * Callback called when a task is successful
  76467. */
  76468. onTaskSuccess: (task: AbstractAssetTask) => void;
  76469. /**
  76470. * Callback called when a task had an error
  76471. */
  76472. onTaskError: (task: AbstractAssetTask) => void;
  76473. /**
  76474. * Callback called when a task is done (whatever the result is)
  76475. */
  76476. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  76477. /**
  76478. * Observable called when all tasks are processed
  76479. */
  76480. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  76481. /**
  76482. * Observable called when a task had an error
  76483. */
  76484. onTaskErrorObservable: Observable<AbstractAssetTask>;
  76485. /**
  76486. * Observable called when all tasks were executed
  76487. */
  76488. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  76489. /**
  76490. * Observable called when a task is done (whatever the result is)
  76491. */
  76492. onProgressObservable: Observable<IAssetsProgressEvent>;
  76493. /**
  76494. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  76495. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  76496. */
  76497. useDefaultLoadingScreen: boolean;
  76498. /**
  76499. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  76500. * when all assets have been downloaded.
  76501. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  76502. */
  76503. autoHideLoadingUI: boolean;
  76504. /**
  76505. * Creates a new AssetsManager
  76506. * @param scene defines the scene to work on
  76507. */
  76508. constructor(scene: Scene);
  76509. /**
  76510. * Add a MeshAssetTask to the list of active tasks
  76511. * @param taskName defines the name of the new task
  76512. * @param meshesNames defines the name of meshes to load
  76513. * @param rootUrl defines the root url to use to locate files
  76514. * @param sceneFilename defines the filename of the scene file
  76515. * @returns a new MeshAssetTask object
  76516. */
  76517. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  76518. /**
  76519. * Add a TextFileAssetTask to the list of active tasks
  76520. * @param taskName defines the name of the new task
  76521. * @param url defines the url of the file to load
  76522. * @returns a new TextFileAssetTask object
  76523. */
  76524. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  76525. /**
  76526. * Add a BinaryFileAssetTask to the list of active tasks
  76527. * @param taskName defines the name of the new task
  76528. * @param url defines the url of the file to load
  76529. * @returns a new BinaryFileAssetTask object
  76530. */
  76531. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  76532. /**
  76533. * Add a ImageAssetTask to the list of active tasks
  76534. * @param taskName defines the name of the new task
  76535. * @param url defines the url of the file to load
  76536. * @returns a new ImageAssetTask object
  76537. */
  76538. addImageTask(taskName: string, url: string): ImageAssetTask;
  76539. /**
  76540. * Add a TextureAssetTask to the list of active tasks
  76541. * @param taskName defines the name of the new task
  76542. * @param url defines the url of the file to load
  76543. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76544. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  76545. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  76546. * @returns a new TextureAssetTask object
  76547. */
  76548. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  76549. /**
  76550. * Add a CubeTextureAssetTask to the list of active tasks
  76551. * @param taskName defines the name of the new task
  76552. * @param url defines the url of the file to load
  76553. * @param extensions defines the extension to use to load the cube map (can be null)
  76554. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76555. * @param files defines the list of files to load (can be null)
  76556. * @returns a new CubeTextureAssetTask object
  76557. */
  76558. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  76559. /**
  76560. *
  76561. * Add a HDRCubeTextureAssetTask to the list of active tasks
  76562. * @param taskName defines the name of the new task
  76563. * @param url defines the url of the file to load
  76564. * @param size defines the size you want for the cubemap (can be null)
  76565. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76566. * @param generateHarmonics defines if you want to automatically generate (true by default)
  76567. * @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)
  76568. * @param reserved Internal use only
  76569. * @returns a new HDRCubeTextureAssetTask object
  76570. */
  76571. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  76572. /**
  76573. *
  76574. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  76575. * @param taskName defines the name of the new task
  76576. * @param url defines the url of the file to load
  76577. * @param size defines the size you want for the cubemap (can be null)
  76578. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76579. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  76580. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  76581. * @returns a new EquiRectangularCubeTextureAssetTask object
  76582. */
  76583. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  76584. /**
  76585. * Remove a task from the assets manager.
  76586. * @param task the task to remove
  76587. */
  76588. removeTask(task: AbstractAssetTask): void;
  76589. private _decreaseWaitingTasksCount;
  76590. private _runTask;
  76591. /**
  76592. * Reset the AssetsManager and remove all tasks
  76593. * @return the current instance of the AssetsManager
  76594. */
  76595. reset(): AssetsManager;
  76596. /**
  76597. * Start the loading process
  76598. * @return the current instance of the AssetsManager
  76599. */
  76600. load(): AssetsManager;
  76601. /**
  76602. * Start the loading process as an async operation
  76603. * @return a promise returning the list of failed tasks
  76604. */
  76605. loadAsync(): Promise<void>;
  76606. }
  76607. }
  76608. declare module "babylonjs/Misc/deferred" {
  76609. /**
  76610. * Wrapper class for promise with external resolve and reject.
  76611. */
  76612. export class Deferred<T> {
  76613. /**
  76614. * The promise associated with this deferred object.
  76615. */
  76616. readonly promise: Promise<T>;
  76617. private _resolve;
  76618. private _reject;
  76619. /**
  76620. * The resolve method of the promise associated with this deferred object.
  76621. */
  76622. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  76623. /**
  76624. * The reject method of the promise associated with this deferred object.
  76625. */
  76626. get reject(): (reason?: any) => void;
  76627. /**
  76628. * Constructor for this deferred object.
  76629. */
  76630. constructor();
  76631. }
  76632. }
  76633. declare module "babylonjs/Misc/meshExploder" {
  76634. import { Mesh } from "babylonjs/Meshes/mesh";
  76635. /**
  76636. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  76637. */
  76638. export class MeshExploder {
  76639. private _centerMesh;
  76640. private _meshes;
  76641. private _meshesOrigins;
  76642. private _toCenterVectors;
  76643. private _scaledDirection;
  76644. private _newPosition;
  76645. private _centerPosition;
  76646. /**
  76647. * Explodes meshes from a center mesh.
  76648. * @param meshes The meshes to explode.
  76649. * @param centerMesh The mesh to be center of explosion.
  76650. */
  76651. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  76652. private _setCenterMesh;
  76653. /**
  76654. * Get class name
  76655. * @returns "MeshExploder"
  76656. */
  76657. getClassName(): string;
  76658. /**
  76659. * "Exploded meshes"
  76660. * @returns Array of meshes with the centerMesh at index 0.
  76661. */
  76662. getMeshes(): Array<Mesh>;
  76663. /**
  76664. * Explodes meshes giving a specific direction
  76665. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  76666. */
  76667. explode(direction?: number): void;
  76668. }
  76669. }
  76670. declare module "babylonjs/Misc/filesInput" {
  76671. import { Engine } from "babylonjs/Engines/engine";
  76672. import { Scene } from "babylonjs/scene";
  76673. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  76674. import { Nullable } from "babylonjs/types";
  76675. /**
  76676. * Class used to help managing file picking and drag'n'drop
  76677. */
  76678. export class FilesInput {
  76679. /**
  76680. * List of files ready to be loaded
  76681. */
  76682. static get FilesToLoad(): {
  76683. [key: string]: File;
  76684. };
  76685. /**
  76686. * Callback called when a file is processed
  76687. */
  76688. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  76689. private _engine;
  76690. private _currentScene;
  76691. private _sceneLoadedCallback;
  76692. private _progressCallback;
  76693. private _additionalRenderLoopLogicCallback;
  76694. private _textureLoadingCallback;
  76695. private _startingProcessingFilesCallback;
  76696. private _onReloadCallback;
  76697. private _errorCallback;
  76698. private _elementToMonitor;
  76699. private _sceneFileToLoad;
  76700. private _filesToLoad;
  76701. /**
  76702. * Creates a new FilesInput
  76703. * @param engine defines the rendering engine
  76704. * @param scene defines the hosting scene
  76705. * @param sceneLoadedCallback callback called when scene is loaded
  76706. * @param progressCallback callback called to track progress
  76707. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  76708. * @param textureLoadingCallback callback called when a texture is loading
  76709. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  76710. * @param onReloadCallback callback called when a reload is requested
  76711. * @param errorCallback callback call if an error occurs
  76712. */
  76713. 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>);
  76714. private _dragEnterHandler;
  76715. private _dragOverHandler;
  76716. private _dropHandler;
  76717. /**
  76718. * Calls this function to listen to drag'n'drop events on a specific DOM element
  76719. * @param elementToMonitor defines the DOM element to track
  76720. */
  76721. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  76722. /** Gets the current list of files to load */
  76723. get filesToLoad(): File[];
  76724. /**
  76725. * Release all associated resources
  76726. */
  76727. dispose(): void;
  76728. private renderFunction;
  76729. private drag;
  76730. private drop;
  76731. private _traverseFolder;
  76732. private _processFiles;
  76733. /**
  76734. * Load files from a drop event
  76735. * @param event defines the drop event to use as source
  76736. */
  76737. loadFiles(event: any): void;
  76738. private _processReload;
  76739. /**
  76740. * Reload the current scene from the loaded files
  76741. */
  76742. reload(): void;
  76743. }
  76744. }
  76745. declare module "babylonjs/Misc/HighDynamicRange/index" {
  76746. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  76747. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  76748. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  76749. }
  76750. declare module "babylonjs/Misc/sceneOptimizer" {
  76751. import { Scene, IDisposable } from "babylonjs/scene";
  76752. import { Observable } from "babylonjs/Misc/observable";
  76753. /**
  76754. * Defines the root class used to create scene optimization to use with SceneOptimizer
  76755. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76756. */
  76757. export class SceneOptimization {
  76758. /**
  76759. * Defines the priority of this optimization (0 by default which means first in the list)
  76760. */
  76761. priority: number;
  76762. /**
  76763. * Gets a string describing the action executed by the current optimization
  76764. * @returns description string
  76765. */
  76766. getDescription(): string;
  76767. /**
  76768. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76769. * @param scene defines the current scene where to apply this optimization
  76770. * @param optimizer defines the current optimizer
  76771. * @returns true if everything that can be done was applied
  76772. */
  76773. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76774. /**
  76775. * Creates the SceneOptimization object
  76776. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76777. * @param desc defines the description associated with the optimization
  76778. */
  76779. constructor(
  76780. /**
  76781. * Defines the priority of this optimization (0 by default which means first in the list)
  76782. */
  76783. priority?: number);
  76784. }
  76785. /**
  76786. * Defines an optimization used to reduce the size of render target textures
  76787. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76788. */
  76789. export class TextureOptimization extends SceneOptimization {
  76790. /**
  76791. * Defines the priority of this optimization (0 by default which means first in the list)
  76792. */
  76793. priority: number;
  76794. /**
  76795. * 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
  76796. */
  76797. maximumSize: number;
  76798. /**
  76799. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76800. */
  76801. step: number;
  76802. /**
  76803. * Gets a string describing the action executed by the current optimization
  76804. * @returns description string
  76805. */
  76806. getDescription(): string;
  76807. /**
  76808. * Creates the TextureOptimization object
  76809. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76810. * @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
  76811. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76812. */
  76813. constructor(
  76814. /**
  76815. * Defines the priority of this optimization (0 by default which means first in the list)
  76816. */
  76817. priority?: number,
  76818. /**
  76819. * 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
  76820. */
  76821. maximumSize?: number,
  76822. /**
  76823. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76824. */
  76825. step?: number);
  76826. /**
  76827. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76828. * @param scene defines the current scene where to apply this optimization
  76829. * @param optimizer defines the current optimizer
  76830. * @returns true if everything that can be done was applied
  76831. */
  76832. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76833. }
  76834. /**
  76835. * Defines an optimization used to increase or decrease the rendering resolution
  76836. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76837. */
  76838. export class HardwareScalingOptimization extends SceneOptimization {
  76839. /**
  76840. * Defines the priority of this optimization (0 by default which means first in the list)
  76841. */
  76842. priority: number;
  76843. /**
  76844. * Defines the maximum scale to use (2 by default)
  76845. */
  76846. maximumScale: number;
  76847. /**
  76848. * Defines the step to use between two passes (0.5 by default)
  76849. */
  76850. step: number;
  76851. private _currentScale;
  76852. private _directionOffset;
  76853. /**
  76854. * Gets a string describing the action executed by the current optimization
  76855. * @return description string
  76856. */
  76857. getDescription(): string;
  76858. /**
  76859. * Creates the HardwareScalingOptimization object
  76860. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76861. * @param maximumScale defines the maximum scale to use (2 by default)
  76862. * @param step defines the step to use between two passes (0.5 by default)
  76863. */
  76864. constructor(
  76865. /**
  76866. * Defines the priority of this optimization (0 by default which means first in the list)
  76867. */
  76868. priority?: number,
  76869. /**
  76870. * Defines the maximum scale to use (2 by default)
  76871. */
  76872. maximumScale?: number,
  76873. /**
  76874. * Defines the step to use between two passes (0.5 by default)
  76875. */
  76876. step?: number);
  76877. /**
  76878. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76879. * @param scene defines the current scene where to apply this optimization
  76880. * @param optimizer defines the current optimizer
  76881. * @returns true if everything that can be done was applied
  76882. */
  76883. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76884. }
  76885. /**
  76886. * Defines an optimization used to remove shadows
  76887. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76888. */
  76889. export class ShadowsOptimization extends SceneOptimization {
  76890. /**
  76891. * Gets a string describing the action executed by the current optimization
  76892. * @return description string
  76893. */
  76894. getDescription(): string;
  76895. /**
  76896. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76897. * @param scene defines the current scene where to apply this optimization
  76898. * @param optimizer defines the current optimizer
  76899. * @returns true if everything that can be done was applied
  76900. */
  76901. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76902. }
  76903. /**
  76904. * Defines an optimization used to turn post-processes off
  76905. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76906. */
  76907. export class PostProcessesOptimization extends SceneOptimization {
  76908. /**
  76909. * Gets a string describing the action executed by the current optimization
  76910. * @return description string
  76911. */
  76912. getDescription(): string;
  76913. /**
  76914. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76915. * @param scene defines the current scene where to apply this optimization
  76916. * @param optimizer defines the current optimizer
  76917. * @returns true if everything that can be done was applied
  76918. */
  76919. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76920. }
  76921. /**
  76922. * Defines an optimization used to turn lens flares off
  76923. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76924. */
  76925. export class LensFlaresOptimization extends SceneOptimization {
  76926. /**
  76927. * Gets a string describing the action executed by the current optimization
  76928. * @return description string
  76929. */
  76930. getDescription(): string;
  76931. /**
  76932. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76933. * @param scene defines the current scene where to apply this optimization
  76934. * @param optimizer defines the current optimizer
  76935. * @returns true if everything that can be done was applied
  76936. */
  76937. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76938. }
  76939. /**
  76940. * Defines an optimization based on user defined callback.
  76941. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76942. */
  76943. export class CustomOptimization extends SceneOptimization {
  76944. /**
  76945. * Callback called to apply the custom optimization.
  76946. */
  76947. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  76948. /**
  76949. * Callback called to get custom description
  76950. */
  76951. onGetDescription: () => string;
  76952. /**
  76953. * Gets a string describing the action executed by the current optimization
  76954. * @returns description string
  76955. */
  76956. getDescription(): string;
  76957. /**
  76958. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76959. * @param scene defines the current scene where to apply this optimization
  76960. * @param optimizer defines the current optimizer
  76961. * @returns true if everything that can be done was applied
  76962. */
  76963. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76964. }
  76965. /**
  76966. * Defines an optimization used to turn particles off
  76967. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76968. */
  76969. export class ParticlesOptimization extends SceneOptimization {
  76970. /**
  76971. * Gets a string describing the action executed by the current optimization
  76972. * @return description string
  76973. */
  76974. getDescription(): string;
  76975. /**
  76976. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76977. * @param scene defines the current scene where to apply this optimization
  76978. * @param optimizer defines the current optimizer
  76979. * @returns true if everything that can be done was applied
  76980. */
  76981. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76982. }
  76983. /**
  76984. * Defines an optimization used to turn render targets off
  76985. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76986. */
  76987. export class RenderTargetsOptimization extends SceneOptimization {
  76988. /**
  76989. * Gets a string describing the action executed by the current optimization
  76990. * @return description string
  76991. */
  76992. getDescription(): string;
  76993. /**
  76994. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76995. * @param scene defines the current scene where to apply this optimization
  76996. * @param optimizer defines the current optimizer
  76997. * @returns true if everything that can be done was applied
  76998. */
  76999. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77000. }
  77001. /**
  77002. * Defines an optimization used to merge meshes with compatible materials
  77003. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77004. */
  77005. export class MergeMeshesOptimization extends SceneOptimization {
  77006. private static _UpdateSelectionTree;
  77007. /**
  77008. * Gets or sets a boolean which defines if optimization octree has to be updated
  77009. */
  77010. static get UpdateSelectionTree(): boolean;
  77011. /**
  77012. * Gets or sets a boolean which defines if optimization octree has to be updated
  77013. */
  77014. static set UpdateSelectionTree(value: boolean);
  77015. /**
  77016. * Gets a string describing the action executed by the current optimization
  77017. * @return description string
  77018. */
  77019. getDescription(): string;
  77020. private _canBeMerged;
  77021. /**
  77022. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77023. * @param scene defines the current scene where to apply this optimization
  77024. * @param optimizer defines the current optimizer
  77025. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  77026. * @returns true if everything that can be done was applied
  77027. */
  77028. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  77029. }
  77030. /**
  77031. * Defines a list of options used by SceneOptimizer
  77032. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77033. */
  77034. export class SceneOptimizerOptions {
  77035. /**
  77036. * Defines the target frame rate to reach (60 by default)
  77037. */
  77038. targetFrameRate: number;
  77039. /**
  77040. * Defines the interval between two checkes (2000ms by default)
  77041. */
  77042. trackerDuration: number;
  77043. /**
  77044. * Gets the list of optimizations to apply
  77045. */
  77046. optimizations: SceneOptimization[];
  77047. /**
  77048. * Creates a new list of options used by SceneOptimizer
  77049. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  77050. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  77051. */
  77052. constructor(
  77053. /**
  77054. * Defines the target frame rate to reach (60 by default)
  77055. */
  77056. targetFrameRate?: number,
  77057. /**
  77058. * Defines the interval between two checkes (2000ms by default)
  77059. */
  77060. trackerDuration?: number);
  77061. /**
  77062. * Add a new optimization
  77063. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  77064. * @returns the current SceneOptimizerOptions
  77065. */
  77066. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  77067. /**
  77068. * Add a new custom optimization
  77069. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  77070. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  77071. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77072. * @returns the current SceneOptimizerOptions
  77073. */
  77074. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  77075. /**
  77076. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  77077. * @param targetFrameRate defines the target frame rate (60 by default)
  77078. * @returns a SceneOptimizerOptions object
  77079. */
  77080. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77081. /**
  77082. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  77083. * @param targetFrameRate defines the target frame rate (60 by default)
  77084. * @returns a SceneOptimizerOptions object
  77085. */
  77086. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77087. /**
  77088. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  77089. * @param targetFrameRate defines the target frame rate (60 by default)
  77090. * @returns a SceneOptimizerOptions object
  77091. */
  77092. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77093. }
  77094. /**
  77095. * Class used to run optimizations in order to reach a target frame rate
  77096. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77097. */
  77098. export class SceneOptimizer implements IDisposable {
  77099. private _isRunning;
  77100. private _options;
  77101. private _scene;
  77102. private _currentPriorityLevel;
  77103. private _targetFrameRate;
  77104. private _trackerDuration;
  77105. private _currentFrameRate;
  77106. private _sceneDisposeObserver;
  77107. private _improvementMode;
  77108. /**
  77109. * Defines an observable called when the optimizer reaches the target frame rate
  77110. */
  77111. onSuccessObservable: Observable<SceneOptimizer>;
  77112. /**
  77113. * Defines an observable called when the optimizer enables an optimization
  77114. */
  77115. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  77116. /**
  77117. * Defines an observable called when the optimizer is not able to reach the target frame rate
  77118. */
  77119. onFailureObservable: Observable<SceneOptimizer>;
  77120. /**
  77121. * Gets a boolean indicating if the optimizer is in improvement mode
  77122. */
  77123. get isInImprovementMode(): boolean;
  77124. /**
  77125. * Gets the current priority level (0 at start)
  77126. */
  77127. get currentPriorityLevel(): number;
  77128. /**
  77129. * Gets the current frame rate checked by the SceneOptimizer
  77130. */
  77131. get currentFrameRate(): number;
  77132. /**
  77133. * Gets or sets the current target frame rate (60 by default)
  77134. */
  77135. get targetFrameRate(): number;
  77136. /**
  77137. * Gets or sets the current target frame rate (60 by default)
  77138. */
  77139. set targetFrameRate(value: number);
  77140. /**
  77141. * Gets or sets the current interval between two checks (every 2000ms by default)
  77142. */
  77143. get trackerDuration(): number;
  77144. /**
  77145. * Gets or sets the current interval between two checks (every 2000ms by default)
  77146. */
  77147. set trackerDuration(value: number);
  77148. /**
  77149. * Gets the list of active optimizations
  77150. */
  77151. get optimizations(): SceneOptimization[];
  77152. /**
  77153. * Creates a new SceneOptimizer
  77154. * @param scene defines the scene to work on
  77155. * @param options defines the options to use with the SceneOptimizer
  77156. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  77157. * @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)
  77158. */
  77159. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  77160. /**
  77161. * Stops the current optimizer
  77162. */
  77163. stop(): void;
  77164. /**
  77165. * Reset the optimizer to initial step (current priority level = 0)
  77166. */
  77167. reset(): void;
  77168. /**
  77169. * Start the optimizer. By default it will try to reach a specific framerate
  77170. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  77171. */
  77172. start(): void;
  77173. private _checkCurrentState;
  77174. /**
  77175. * Release all resources
  77176. */
  77177. dispose(): void;
  77178. /**
  77179. * Helper function to create a SceneOptimizer with one single line of code
  77180. * @param scene defines the scene to work on
  77181. * @param options defines the options to use with the SceneOptimizer
  77182. * @param onSuccess defines a callback to call on success
  77183. * @param onFailure defines a callback to call on failure
  77184. * @returns the new SceneOptimizer object
  77185. */
  77186. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  77187. }
  77188. }
  77189. declare module "babylonjs/Misc/sceneSerializer" {
  77190. import { Scene } from "babylonjs/scene";
  77191. /**
  77192. * Class used to serialize a scene into a string
  77193. */
  77194. export class SceneSerializer {
  77195. /**
  77196. * Clear cache used by a previous serialization
  77197. */
  77198. static ClearCache(): void;
  77199. /**
  77200. * Serialize a scene into a JSON compatible object
  77201. * @param scene defines the scene to serialize
  77202. * @returns a JSON compatible object
  77203. */
  77204. static Serialize(scene: Scene): any;
  77205. /**
  77206. * Serialize a mesh into a JSON compatible object
  77207. * @param toSerialize defines the mesh to serialize
  77208. * @param withParents defines if parents must be serialized as well
  77209. * @param withChildren defines if children must be serialized as well
  77210. * @returns a JSON compatible object
  77211. */
  77212. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  77213. }
  77214. }
  77215. declare module "babylonjs/Misc/textureTools" {
  77216. import { Texture } from "babylonjs/Materials/Textures/texture";
  77217. /**
  77218. * Class used to host texture specific utilities
  77219. */
  77220. export class TextureTools {
  77221. /**
  77222. * Uses the GPU to create a copy texture rescaled at a given size
  77223. * @param texture Texture to copy from
  77224. * @param width defines the desired width
  77225. * @param height defines the desired height
  77226. * @param useBilinearMode defines if bilinear mode has to be used
  77227. * @return the generated texture
  77228. */
  77229. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  77230. }
  77231. }
  77232. declare module "babylonjs/Misc/videoRecorder" {
  77233. import { Nullable } from "babylonjs/types";
  77234. import { Engine } from "babylonjs/Engines/engine";
  77235. /**
  77236. * This represents the different options available for the video capture.
  77237. */
  77238. export interface VideoRecorderOptions {
  77239. /** Defines the mime type of the video. */
  77240. mimeType: string;
  77241. /** Defines the FPS the video should be recorded at. */
  77242. fps: number;
  77243. /** Defines the chunk size for the recording data. */
  77244. recordChunckSize: number;
  77245. /** The audio tracks to attach to the recording. */
  77246. audioTracks?: MediaStreamTrack[];
  77247. }
  77248. /**
  77249. * This can help with recording videos from BabylonJS.
  77250. * This is based on the available WebRTC functionalities of the browser.
  77251. *
  77252. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  77253. */
  77254. export class VideoRecorder {
  77255. private static readonly _defaultOptions;
  77256. /**
  77257. * Returns whether or not the VideoRecorder is available in your browser.
  77258. * @param engine Defines the Babylon Engine.
  77259. * @returns true if supported otherwise false.
  77260. */
  77261. static IsSupported(engine: Engine): boolean;
  77262. private readonly _options;
  77263. private _canvas;
  77264. private _mediaRecorder;
  77265. private _recordedChunks;
  77266. private _fileName;
  77267. private _resolve;
  77268. private _reject;
  77269. /**
  77270. * True when a recording is already in progress.
  77271. */
  77272. get isRecording(): boolean;
  77273. /**
  77274. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  77275. * @param engine Defines the BabylonJS Engine you wish to record.
  77276. * @param options Defines options that can be used to customize the capture.
  77277. */
  77278. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  77279. /**
  77280. * Stops the current recording before the default capture timeout passed in the startRecording function.
  77281. */
  77282. stopRecording(): void;
  77283. /**
  77284. * Starts recording the canvas for a max duration specified in parameters.
  77285. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  77286. * If null no automatic download will start and you can rely on the promise to get the data back.
  77287. * @param maxDuration Defines the maximum recording time in seconds.
  77288. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  77289. * @return A promise callback at the end of the recording with the video data in Blob.
  77290. */
  77291. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  77292. /**
  77293. * Releases internal resources used during the recording.
  77294. */
  77295. dispose(): void;
  77296. private _handleDataAvailable;
  77297. private _handleError;
  77298. private _handleStop;
  77299. }
  77300. }
  77301. declare module "babylonjs/Misc/screenshotTools" {
  77302. import { Camera } from "babylonjs/Cameras/camera";
  77303. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  77304. import { Engine } from "babylonjs/Engines/engine";
  77305. /**
  77306. * Class containing a set of static utilities functions for screenshots
  77307. */
  77308. export class ScreenshotTools {
  77309. /**
  77310. * Captures a screenshot of the current rendering
  77311. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77312. * @param engine defines the rendering engine
  77313. * @param camera defines the source camera
  77314. * @param size This parameter can be set to a single number or to an object with the
  77315. * following (optional) properties: precision, width, height. If a single number is passed,
  77316. * it will be used for both width and height. If an object is passed, the screenshot size
  77317. * will be derived from the parameters. The precision property is a multiplier allowing
  77318. * rendering at a higher or lower resolution
  77319. * @param successCallback defines the callback receives a single parameter which contains the
  77320. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77321. * src parameter of an <img> to display it
  77322. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77323. * Check your browser for supported MIME types
  77324. */
  77325. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  77326. /**
  77327. * Captures a screenshot of the current rendering
  77328. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77329. * @param engine defines the rendering engine
  77330. * @param camera defines the source camera
  77331. * @param size This parameter can be set to a single number or to an object with the
  77332. * following (optional) properties: precision, width, height. If a single number is passed,
  77333. * it will be used for both width and height. If an object is passed, the screenshot size
  77334. * will be derived from the parameters. The precision property is a multiplier allowing
  77335. * rendering at a higher or lower resolution
  77336. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77337. * Check your browser for supported MIME types
  77338. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77339. * to the src parameter of an <img> to display it
  77340. */
  77341. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  77342. /**
  77343. * Generates an image screenshot from the specified camera.
  77344. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77345. * @param engine The engine to use for rendering
  77346. * @param camera The camera to use for rendering
  77347. * @param size This parameter can be set to a single number or to an object with the
  77348. * following (optional) properties: precision, width, height. If a single number is passed,
  77349. * it will be used for both width and height. If an object is passed, the screenshot size
  77350. * will be derived from the parameters. The precision property is a multiplier allowing
  77351. * rendering at a higher or lower resolution
  77352. * @param successCallback The callback receives a single parameter which contains the
  77353. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77354. * src parameter of an <img> to display it
  77355. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77356. * Check your browser for supported MIME types
  77357. * @param samples Texture samples (default: 1)
  77358. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77359. * @param fileName A name for for the downloaded file.
  77360. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77361. */
  77362. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  77363. /**
  77364. * Generates an image screenshot from the specified camera.
  77365. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77366. * @param engine The engine to use for rendering
  77367. * @param camera The camera to use for rendering
  77368. * @param size This parameter can be set to a single number or to an object with the
  77369. * following (optional) properties: precision, width, height. If a single number is passed,
  77370. * it will be used for both width and height. If an object is passed, the screenshot size
  77371. * will be derived from the parameters. The precision property is a multiplier allowing
  77372. * rendering at a higher or lower resolution
  77373. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77374. * Check your browser for supported MIME types
  77375. * @param samples Texture samples (default: 1)
  77376. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77377. * @param fileName A name for for the downloaded file.
  77378. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77379. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77380. * to the src parameter of an <img> to display it
  77381. */
  77382. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  77383. /**
  77384. * Gets height and width for screenshot size
  77385. * @private
  77386. */
  77387. private static _getScreenshotSize;
  77388. }
  77389. }
  77390. declare module "babylonjs/Misc/dataReader" {
  77391. /**
  77392. * Interface for a data buffer
  77393. */
  77394. export interface IDataBuffer {
  77395. /**
  77396. * Reads bytes from the data buffer.
  77397. * @param byteOffset The byte offset to read
  77398. * @param byteLength The byte length to read
  77399. * @returns A promise that resolves when the bytes are read
  77400. */
  77401. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  77402. /**
  77403. * The byte length of the buffer.
  77404. */
  77405. readonly byteLength: number;
  77406. }
  77407. /**
  77408. * Utility class for reading from a data buffer
  77409. */
  77410. export class DataReader {
  77411. /**
  77412. * The data buffer associated with this data reader.
  77413. */
  77414. readonly buffer: IDataBuffer;
  77415. /**
  77416. * The current byte offset from the beginning of the data buffer.
  77417. */
  77418. byteOffset: number;
  77419. private _dataView;
  77420. private _dataByteOffset;
  77421. /**
  77422. * Constructor
  77423. * @param buffer The buffer to read
  77424. */
  77425. constructor(buffer: IDataBuffer);
  77426. /**
  77427. * Loads the given byte length.
  77428. * @param byteLength The byte length to load
  77429. * @returns A promise that resolves when the load is complete
  77430. */
  77431. loadAsync(byteLength: number): Promise<void>;
  77432. /**
  77433. * Read a unsigned 32-bit integer from the currently loaded data range.
  77434. * @returns The 32-bit integer read
  77435. */
  77436. readUint32(): number;
  77437. /**
  77438. * Read a byte array from the currently loaded data range.
  77439. * @param byteLength The byte length to read
  77440. * @returns The byte array read
  77441. */
  77442. readUint8Array(byteLength: number): Uint8Array;
  77443. /**
  77444. * Read a string from the currently loaded data range.
  77445. * @param byteLength The byte length to read
  77446. * @returns The string read
  77447. */
  77448. readString(byteLength: number): string;
  77449. /**
  77450. * Skips the given byte length the currently loaded data range.
  77451. * @param byteLength The byte length to skip
  77452. */
  77453. skipBytes(byteLength: number): void;
  77454. }
  77455. }
  77456. declare module "babylonjs/Misc/dataStorage" {
  77457. /**
  77458. * Class for storing data to local storage if available or in-memory storage otherwise
  77459. */
  77460. export class DataStorage {
  77461. private static _Storage;
  77462. private static _GetStorage;
  77463. /**
  77464. * Reads a string from the data storage
  77465. * @param key The key to read
  77466. * @param defaultValue The value if the key doesn't exist
  77467. * @returns The string value
  77468. */
  77469. static ReadString(key: string, defaultValue: string): string;
  77470. /**
  77471. * Writes a string to the data storage
  77472. * @param key The key to write
  77473. * @param value The value to write
  77474. */
  77475. static WriteString(key: string, value: string): void;
  77476. /**
  77477. * Reads a boolean from the data storage
  77478. * @param key The key to read
  77479. * @param defaultValue The value if the key doesn't exist
  77480. * @returns The boolean value
  77481. */
  77482. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  77483. /**
  77484. * Writes a boolean to the data storage
  77485. * @param key The key to write
  77486. * @param value The value to write
  77487. */
  77488. static WriteBoolean(key: string, value: boolean): void;
  77489. /**
  77490. * Reads a number from the data storage
  77491. * @param key The key to read
  77492. * @param defaultValue The value if the key doesn't exist
  77493. * @returns The number value
  77494. */
  77495. static ReadNumber(key: string, defaultValue: number): number;
  77496. /**
  77497. * Writes a number to the data storage
  77498. * @param key The key to write
  77499. * @param value The value to write
  77500. */
  77501. static WriteNumber(key: string, value: number): void;
  77502. }
  77503. }
  77504. declare module "babylonjs/Misc/sceneRecorder" {
  77505. import { Scene } from "babylonjs/scene";
  77506. /**
  77507. * Class used to record delta files between 2 scene states
  77508. */
  77509. export class SceneRecorder {
  77510. private _trackedScene;
  77511. private _savedJSON;
  77512. /**
  77513. * Track a given scene. This means the current scene state will be considered the original state
  77514. * @param scene defines the scene to track
  77515. */
  77516. track(scene: Scene): void;
  77517. /**
  77518. * Get the delta between current state and original state
  77519. * @returns a string containing the delta
  77520. */
  77521. getDelta(): any;
  77522. private _compareArray;
  77523. private _compareObjects;
  77524. private _compareCollections;
  77525. /**
  77526. * Apply a given delta to a given scene
  77527. * @param deltaJSON defines the JSON containing the delta
  77528. * @param scene defines the scene to apply the delta to
  77529. */
  77530. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  77531. private static _ApplyPropertiesToEntity;
  77532. private static _ApplyDeltaForEntity;
  77533. }
  77534. }
  77535. declare module "babylonjs/Misc/index" {
  77536. export * from "babylonjs/Misc/andOrNotEvaluator";
  77537. export * from "babylonjs/Misc/assetsManager";
  77538. export * from "babylonjs/Misc/basis";
  77539. export * from "babylonjs/Misc/dds";
  77540. export * from "babylonjs/Misc/decorators";
  77541. export * from "babylonjs/Misc/deferred";
  77542. export * from "babylonjs/Misc/environmentTextureTools";
  77543. export * from "babylonjs/Misc/meshExploder";
  77544. export * from "babylonjs/Misc/filesInput";
  77545. export * from "babylonjs/Misc/HighDynamicRange/index";
  77546. export * from "babylonjs/Misc/khronosTextureContainer";
  77547. export * from "babylonjs/Misc/observable";
  77548. export * from "babylonjs/Misc/performanceMonitor";
  77549. export * from "babylonjs/Misc/promise";
  77550. export * from "babylonjs/Misc/sceneOptimizer";
  77551. export * from "babylonjs/Misc/sceneSerializer";
  77552. export * from "babylonjs/Misc/smartArray";
  77553. export * from "babylonjs/Misc/stringDictionary";
  77554. export * from "babylonjs/Misc/tags";
  77555. export * from "babylonjs/Misc/textureTools";
  77556. export * from "babylonjs/Misc/tga";
  77557. export * from "babylonjs/Misc/tools";
  77558. export * from "babylonjs/Misc/videoRecorder";
  77559. export * from "babylonjs/Misc/virtualJoystick";
  77560. export * from "babylonjs/Misc/workerPool";
  77561. export * from "babylonjs/Misc/logger";
  77562. export * from "babylonjs/Misc/typeStore";
  77563. export * from "babylonjs/Misc/filesInputStore";
  77564. export * from "babylonjs/Misc/deepCopier";
  77565. export * from "babylonjs/Misc/pivotTools";
  77566. export * from "babylonjs/Misc/precisionDate";
  77567. export * from "babylonjs/Misc/screenshotTools";
  77568. export * from "babylonjs/Misc/typeStore";
  77569. export * from "babylonjs/Misc/webRequest";
  77570. export * from "babylonjs/Misc/iInspectable";
  77571. export * from "babylonjs/Misc/brdfTextureTools";
  77572. export * from "babylonjs/Misc/rgbdTextureTools";
  77573. export * from "babylonjs/Misc/gradients";
  77574. export * from "babylonjs/Misc/perfCounter";
  77575. export * from "babylonjs/Misc/fileRequest";
  77576. export * from "babylonjs/Misc/customAnimationFrameRequester";
  77577. export * from "babylonjs/Misc/retryStrategy";
  77578. export * from "babylonjs/Misc/interfaces/screenshotSize";
  77579. export * from "babylonjs/Misc/canvasGenerator";
  77580. export * from "babylonjs/Misc/fileTools";
  77581. export * from "babylonjs/Misc/stringTools";
  77582. export * from "babylonjs/Misc/dataReader";
  77583. export * from "babylonjs/Misc/minMaxReducer";
  77584. export * from "babylonjs/Misc/depthReducer";
  77585. export * from "babylonjs/Misc/dataStorage";
  77586. export * from "babylonjs/Misc/sceneRecorder";
  77587. }
  77588. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  77589. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  77590. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77591. import { Observable } from "babylonjs/Misc/observable";
  77592. import { Matrix } from "babylonjs/Maths/math.vector";
  77593. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77594. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77595. /**
  77596. * An interface for all Hit test features
  77597. */
  77598. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  77599. /**
  77600. * Triggered when new babylon (transformed) hit test results are available
  77601. */
  77602. onHitTestResultObservable: Observable<T[]>;
  77603. }
  77604. /**
  77605. * Options used for hit testing
  77606. */
  77607. export interface IWebXRLegacyHitTestOptions {
  77608. /**
  77609. * Only test when user interacted with the scene. Default - hit test every frame
  77610. */
  77611. testOnPointerDownOnly?: boolean;
  77612. /**
  77613. * The node to use to transform the local results to world coordinates
  77614. */
  77615. worldParentNode?: TransformNode;
  77616. }
  77617. /**
  77618. * Interface defining the babylon result of raycasting/hit-test
  77619. */
  77620. export interface IWebXRLegacyHitResult {
  77621. /**
  77622. * Transformation matrix that can be applied to a node that will put it in the hit point location
  77623. */
  77624. transformationMatrix: Matrix;
  77625. /**
  77626. * The native hit test result
  77627. */
  77628. xrHitResult: XRHitResult | XRHitTestResult;
  77629. }
  77630. /**
  77631. * The currently-working hit-test module.
  77632. * Hit test (or Ray-casting) is used to interact with the real world.
  77633. * For further information read here - https://github.com/immersive-web/hit-test
  77634. */
  77635. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  77636. /**
  77637. * options to use when constructing this feature
  77638. */
  77639. readonly options: IWebXRLegacyHitTestOptions;
  77640. private _direction;
  77641. private _mat;
  77642. private _onSelectEnabled;
  77643. private _origin;
  77644. /**
  77645. * The module's name
  77646. */
  77647. static readonly Name: string;
  77648. /**
  77649. * The (Babylon) version of this module.
  77650. * This is an integer representing the implementation version.
  77651. * This number does not correspond to the WebXR specs version
  77652. */
  77653. static readonly Version: number;
  77654. /**
  77655. * Populated with the last native XR Hit Results
  77656. */
  77657. lastNativeXRHitResults: XRHitResult[];
  77658. /**
  77659. * Triggered when new babylon (transformed) hit test results are available
  77660. */
  77661. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  77662. /**
  77663. * Creates a new instance of the (legacy version) hit test feature
  77664. * @param _xrSessionManager an instance of WebXRSessionManager
  77665. * @param options options to use when constructing this feature
  77666. */
  77667. constructor(_xrSessionManager: WebXRSessionManager,
  77668. /**
  77669. * options to use when constructing this feature
  77670. */
  77671. options?: IWebXRLegacyHitTestOptions);
  77672. /**
  77673. * execute a hit test with an XR Ray
  77674. *
  77675. * @param xrSession a native xrSession that will execute this hit test
  77676. * @param xrRay the ray (position and direction) to use for ray-casting
  77677. * @param referenceSpace native XR reference space to use for the hit-test
  77678. * @param filter filter function that will filter the results
  77679. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77680. */
  77681. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  77682. /**
  77683. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  77684. * @param event the (select) event to use to select with
  77685. * @param referenceSpace the reference space to use for this hit test
  77686. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77687. */
  77688. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77689. /**
  77690. * attach this feature
  77691. * Will usually be called by the features manager
  77692. *
  77693. * @returns true if successful.
  77694. */
  77695. attach(): boolean;
  77696. /**
  77697. * detach this feature.
  77698. * Will usually be called by the features manager
  77699. *
  77700. * @returns true if successful.
  77701. */
  77702. detach(): boolean;
  77703. /**
  77704. * Dispose this feature and all of the resources attached
  77705. */
  77706. dispose(): void;
  77707. protected _onXRFrame(frame: XRFrame): void;
  77708. private _onHitTestResults;
  77709. private _onSelect;
  77710. }
  77711. }
  77712. declare module "babylonjs/XR/features/WebXRHitTest" {
  77713. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77714. import { Observable } from "babylonjs/Misc/observable";
  77715. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77716. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77717. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  77718. /**
  77719. * Options used for hit testing (version 2)
  77720. */
  77721. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  77722. /**
  77723. * Do not create a permanent hit test. Will usually be used when only
  77724. * transient inputs are needed.
  77725. */
  77726. disablePermanentHitTest?: boolean;
  77727. /**
  77728. * Enable transient (for example touch-based) hit test inspections
  77729. */
  77730. enableTransientHitTest?: boolean;
  77731. /**
  77732. * Offset ray for the permanent hit test
  77733. */
  77734. offsetRay?: Vector3;
  77735. /**
  77736. * Offset ray for the transient hit test
  77737. */
  77738. transientOffsetRay?: Vector3;
  77739. /**
  77740. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  77741. */
  77742. useReferenceSpace?: boolean;
  77743. }
  77744. /**
  77745. * Interface defining the babylon result of hit-test
  77746. */
  77747. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  77748. /**
  77749. * The input source that generated this hit test (if transient)
  77750. */
  77751. inputSource?: XRInputSource;
  77752. /**
  77753. * Is this a transient hit test
  77754. */
  77755. isTransient?: boolean;
  77756. /**
  77757. * Position of the hit test result
  77758. */
  77759. position: Vector3;
  77760. /**
  77761. * Rotation of the hit test result
  77762. */
  77763. rotationQuaternion: Quaternion;
  77764. /**
  77765. * The native hit test result
  77766. */
  77767. xrHitResult: XRHitTestResult;
  77768. }
  77769. /**
  77770. * The currently-working hit-test module.
  77771. * Hit test (or Ray-casting) is used to interact with the real world.
  77772. * For further information read here - https://github.com/immersive-web/hit-test
  77773. *
  77774. * Tested on chrome (mobile) 80.
  77775. */
  77776. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  77777. /**
  77778. * options to use when constructing this feature
  77779. */
  77780. readonly options: IWebXRHitTestOptions;
  77781. private _tmpMat;
  77782. private _tmpPos;
  77783. private _tmpQuat;
  77784. private _transientXrHitTestSource;
  77785. private _xrHitTestSource;
  77786. private initHitTestSource;
  77787. /**
  77788. * The module's name
  77789. */
  77790. static readonly Name: string;
  77791. /**
  77792. * The (Babylon) version of this module.
  77793. * This is an integer representing the implementation version.
  77794. * This number does not correspond to the WebXR specs version
  77795. */
  77796. static readonly Version: number;
  77797. /**
  77798. * When set to true, each hit test will have its own position/rotation objects
  77799. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  77800. * the developers will clone them or copy them as they see fit.
  77801. */
  77802. autoCloneTransformation: boolean;
  77803. /**
  77804. * Triggered when new babylon (transformed) hit test results are available
  77805. */
  77806. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  77807. /**
  77808. * Use this to temporarily pause hit test checks.
  77809. */
  77810. paused: boolean;
  77811. /**
  77812. * Creates a new instance of the hit test feature
  77813. * @param _xrSessionManager an instance of WebXRSessionManager
  77814. * @param options options to use when constructing this feature
  77815. */
  77816. constructor(_xrSessionManager: WebXRSessionManager,
  77817. /**
  77818. * options to use when constructing this feature
  77819. */
  77820. options?: IWebXRHitTestOptions);
  77821. /**
  77822. * attach this feature
  77823. * Will usually be called by the features manager
  77824. *
  77825. * @returns true if successful.
  77826. */
  77827. attach(): boolean;
  77828. /**
  77829. * detach this feature.
  77830. * Will usually be called by the features manager
  77831. *
  77832. * @returns true if successful.
  77833. */
  77834. detach(): boolean;
  77835. /**
  77836. * Dispose this feature and all of the resources attached
  77837. */
  77838. dispose(): void;
  77839. protected _onXRFrame(frame: XRFrame): void;
  77840. private _processWebXRHitTestResult;
  77841. }
  77842. }
  77843. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  77844. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77845. import { Observable } from "babylonjs/Misc/observable";
  77846. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77847. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77848. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77849. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  77850. /**
  77851. * Configuration options of the anchor system
  77852. */
  77853. export interface IWebXRAnchorSystemOptions {
  77854. /**
  77855. * a node that will be used to convert local to world coordinates
  77856. */
  77857. worldParentNode?: TransformNode;
  77858. /**
  77859. * If set to true a reference of the created anchors will be kept until the next session starts
  77860. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  77861. */
  77862. doNotRemoveAnchorsOnSessionEnded?: boolean;
  77863. }
  77864. /**
  77865. * A babylon container for an XR Anchor
  77866. */
  77867. export interface IWebXRAnchor {
  77868. /**
  77869. * A babylon-assigned ID for this anchor
  77870. */
  77871. id: number;
  77872. /**
  77873. * Transformation matrix to apply to an object attached to this anchor
  77874. */
  77875. transformationMatrix: Matrix;
  77876. /**
  77877. * The native anchor object
  77878. */
  77879. xrAnchor: XRAnchor;
  77880. /**
  77881. * if defined, this object will be constantly updated by the anchor's position and rotation
  77882. */
  77883. attachedNode?: TransformNode;
  77884. }
  77885. /**
  77886. * An implementation of the anchor system for WebXR.
  77887. * For further information see https://github.com/immersive-web/anchors/
  77888. */
  77889. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  77890. private _options;
  77891. private _lastFrameDetected;
  77892. private _trackedAnchors;
  77893. private _referenceSpaceForFrameAnchors;
  77894. private _futureAnchors;
  77895. /**
  77896. * The module's name
  77897. */
  77898. static readonly Name: string;
  77899. /**
  77900. * The (Babylon) version of this module.
  77901. * This is an integer representing the implementation version.
  77902. * This number does not correspond to the WebXR specs version
  77903. */
  77904. static readonly Version: number;
  77905. /**
  77906. * Observers registered here will be executed when a new anchor was added to the session
  77907. */
  77908. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  77909. /**
  77910. * Observers registered here will be executed when an anchor was removed from the session
  77911. */
  77912. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  77913. /**
  77914. * Observers registered here will be executed when an existing anchor updates
  77915. * This can execute N times every frame
  77916. */
  77917. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  77918. /**
  77919. * Set the reference space to use for anchor creation, when not using a hit test.
  77920. * Will default to the session's reference space if not defined
  77921. */
  77922. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  77923. /**
  77924. * constructs a new anchor system
  77925. * @param _xrSessionManager an instance of WebXRSessionManager
  77926. * @param _options configuration object for this feature
  77927. */
  77928. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  77929. private _tmpVector;
  77930. private _tmpQuaternion;
  77931. private _populateTmpTransformation;
  77932. /**
  77933. * Create a new anchor point using a hit test result at a specific point in the scene
  77934. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77935. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77936. *
  77937. * @param hitTestResult The hit test result to use for this anchor creation
  77938. * @param position an optional position offset for this anchor
  77939. * @param rotationQuaternion an optional rotation offset for this anchor
  77940. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77941. */
  77942. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  77943. /**
  77944. * Add a new anchor at a specific position and rotation
  77945. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  77946. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  77947. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77948. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77949. *
  77950. * @param position the position in which to add an anchor
  77951. * @param rotationQuaternion an optional rotation for the anchor transformation
  77952. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  77953. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77954. */
  77955. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  77956. /**
  77957. * detach this feature.
  77958. * Will usually be called by the features manager
  77959. *
  77960. * @returns true if successful.
  77961. */
  77962. detach(): boolean;
  77963. /**
  77964. * Dispose this feature and all of the resources attached
  77965. */
  77966. dispose(): void;
  77967. protected _onXRFrame(frame: XRFrame): void;
  77968. /**
  77969. * avoiding using Array.find for global support.
  77970. * @param xrAnchor the plane to find in the array
  77971. */
  77972. private _findIndexInAnchorArray;
  77973. private _updateAnchorWithXRFrame;
  77974. private _createAnchorAtTransformation;
  77975. }
  77976. }
  77977. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  77978. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77979. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77980. import { Observable } from "babylonjs/Misc/observable";
  77981. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  77982. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77983. /**
  77984. * Options used in the plane detector module
  77985. */
  77986. export interface IWebXRPlaneDetectorOptions {
  77987. /**
  77988. * The node to use to transform the local results to world coordinates
  77989. */
  77990. worldParentNode?: TransformNode;
  77991. /**
  77992. * If set to true a reference of the created planes will be kept until the next session starts
  77993. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  77994. */
  77995. doNotRemovePlanesOnSessionEnded?: boolean;
  77996. }
  77997. /**
  77998. * A babylon interface for a WebXR plane.
  77999. * A Plane is actually a polygon, built from N points in space
  78000. *
  78001. * Supported in chrome 79, not supported in canary 81 ATM
  78002. */
  78003. export interface IWebXRPlane {
  78004. /**
  78005. * a babylon-assigned ID for this polygon
  78006. */
  78007. id: number;
  78008. /**
  78009. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  78010. */
  78011. polygonDefinition: Array<Vector3>;
  78012. /**
  78013. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  78014. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  78015. */
  78016. transformationMatrix: Matrix;
  78017. /**
  78018. * the native xr-plane object
  78019. */
  78020. xrPlane: XRPlane;
  78021. }
  78022. /**
  78023. * The plane detector is used to detect planes in the real world when in AR
  78024. * For more information see https://github.com/immersive-web/real-world-geometry/
  78025. */
  78026. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  78027. private _options;
  78028. private _detectedPlanes;
  78029. private _enabled;
  78030. private _lastFrameDetected;
  78031. /**
  78032. * The module's name
  78033. */
  78034. static readonly Name: string;
  78035. /**
  78036. * The (Babylon) version of this module.
  78037. * This is an integer representing the implementation version.
  78038. * This number does not correspond to the WebXR specs version
  78039. */
  78040. static readonly Version: number;
  78041. /**
  78042. * Observers registered here will be executed when a new plane was added to the session
  78043. */
  78044. onPlaneAddedObservable: Observable<IWebXRPlane>;
  78045. /**
  78046. * Observers registered here will be executed when a plane is no longer detected in the session
  78047. */
  78048. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  78049. /**
  78050. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  78051. * This can execute N times every frame
  78052. */
  78053. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  78054. /**
  78055. * construct a new Plane Detector
  78056. * @param _xrSessionManager an instance of xr Session manager
  78057. * @param _options configuration to use when constructing this feature
  78058. */
  78059. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  78060. /**
  78061. * detach this feature.
  78062. * Will usually be called by the features manager
  78063. *
  78064. * @returns true if successful.
  78065. */
  78066. detach(): boolean;
  78067. /**
  78068. * Dispose this feature and all of the resources attached
  78069. */
  78070. dispose(): void;
  78071. protected _onXRFrame(frame: XRFrame): void;
  78072. private _init;
  78073. private _updatePlaneWithXRPlane;
  78074. /**
  78075. * avoiding using Array.find for global support.
  78076. * @param xrPlane the plane to find in the array
  78077. */
  78078. private findIndexInPlaneArray;
  78079. }
  78080. }
  78081. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  78082. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78084. import { Observable } from "babylonjs/Misc/observable";
  78085. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78086. /**
  78087. * Options interface for the background remover plugin
  78088. */
  78089. export interface IWebXRBackgroundRemoverOptions {
  78090. /**
  78091. * Further background meshes to disable when entering AR
  78092. */
  78093. backgroundMeshes?: AbstractMesh[];
  78094. /**
  78095. * flags to configure the removal of the environment helper.
  78096. * If not set, the entire background will be removed. If set, flags should be set as well.
  78097. */
  78098. environmentHelperRemovalFlags?: {
  78099. /**
  78100. * Should the skybox be removed (default false)
  78101. */
  78102. skyBox?: boolean;
  78103. /**
  78104. * Should the ground be removed (default false)
  78105. */
  78106. ground?: boolean;
  78107. };
  78108. /**
  78109. * don't disable the environment helper
  78110. */
  78111. ignoreEnvironmentHelper?: boolean;
  78112. }
  78113. /**
  78114. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  78115. */
  78116. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  78117. /**
  78118. * read-only options to be used in this module
  78119. */
  78120. readonly options: IWebXRBackgroundRemoverOptions;
  78121. /**
  78122. * The module's name
  78123. */
  78124. static readonly Name: string;
  78125. /**
  78126. * The (Babylon) version of this module.
  78127. * This is an integer representing the implementation version.
  78128. * This number does not correspond to the WebXR specs version
  78129. */
  78130. static readonly Version: number;
  78131. /**
  78132. * registered observers will be triggered when the background state changes
  78133. */
  78134. onBackgroundStateChangedObservable: Observable<boolean>;
  78135. /**
  78136. * constructs a new background remover module
  78137. * @param _xrSessionManager the session manager for this module
  78138. * @param options read-only options to be used in this module
  78139. */
  78140. constructor(_xrSessionManager: WebXRSessionManager,
  78141. /**
  78142. * read-only options to be used in this module
  78143. */
  78144. options?: IWebXRBackgroundRemoverOptions);
  78145. /**
  78146. * attach this feature
  78147. * Will usually be called by the features manager
  78148. *
  78149. * @returns true if successful.
  78150. */
  78151. attach(): boolean;
  78152. /**
  78153. * detach this feature.
  78154. * Will usually be called by the features manager
  78155. *
  78156. * @returns true if successful.
  78157. */
  78158. detach(): boolean;
  78159. /**
  78160. * Dispose this feature and all of the resources attached
  78161. */
  78162. dispose(): void;
  78163. protected _onXRFrame(_xrFrame: XRFrame): void;
  78164. private _setBackgroundState;
  78165. }
  78166. }
  78167. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  78168. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78169. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  78170. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  78171. import { WebXRInput } from "babylonjs/XR/webXRInput";
  78172. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78173. import { Nullable } from "babylonjs/types";
  78174. /**
  78175. * Options for the controller physics feature
  78176. */
  78177. export class IWebXRControllerPhysicsOptions {
  78178. /**
  78179. * Should the headset get its own impostor
  78180. */
  78181. enableHeadsetImpostor?: boolean;
  78182. /**
  78183. * Optional parameters for the headset impostor
  78184. */
  78185. headsetImpostorParams?: {
  78186. /**
  78187. * The type of impostor to create. Default is sphere
  78188. */
  78189. impostorType: number;
  78190. /**
  78191. * the size of the impostor. Defaults to 10cm
  78192. */
  78193. impostorSize?: number | {
  78194. width: number;
  78195. height: number;
  78196. depth: number;
  78197. };
  78198. /**
  78199. * Friction definitions
  78200. */
  78201. friction?: number;
  78202. /**
  78203. * Restitution
  78204. */
  78205. restitution?: number;
  78206. };
  78207. /**
  78208. * The physics properties of the future impostors
  78209. */
  78210. physicsProperties?: {
  78211. /**
  78212. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  78213. * Note that this requires a physics engine that supports mesh impostors!
  78214. */
  78215. useControllerMesh?: boolean;
  78216. /**
  78217. * The type of impostor to create. Default is sphere
  78218. */
  78219. impostorType?: number;
  78220. /**
  78221. * the size of the impostor. Defaults to 10cm
  78222. */
  78223. impostorSize?: number | {
  78224. width: number;
  78225. height: number;
  78226. depth: number;
  78227. };
  78228. /**
  78229. * Friction definitions
  78230. */
  78231. friction?: number;
  78232. /**
  78233. * Restitution
  78234. */
  78235. restitution?: number;
  78236. };
  78237. /**
  78238. * the xr input to use with this pointer selection
  78239. */
  78240. xrInput: WebXRInput;
  78241. }
  78242. /**
  78243. * Add physics impostor to your webxr controllers,
  78244. * including naive calculation of their linear and angular velocity
  78245. */
  78246. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  78247. private readonly _options;
  78248. private _attachController;
  78249. private _controllers;
  78250. private _debugMode;
  78251. private _delta;
  78252. private _headsetImpostor?;
  78253. private _headsetMesh?;
  78254. private _lastTimestamp;
  78255. private _tmpQuaternion;
  78256. private _tmpVector;
  78257. /**
  78258. * The module's name
  78259. */
  78260. static readonly Name: string;
  78261. /**
  78262. * The (Babylon) version of this module.
  78263. * This is an integer representing the implementation version.
  78264. * This number does not correspond to the webxr specs version
  78265. */
  78266. static readonly Version: number;
  78267. /**
  78268. * Construct a new Controller Physics Feature
  78269. * @param _xrSessionManager the corresponding xr session manager
  78270. * @param _options options to create this feature with
  78271. */
  78272. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  78273. /**
  78274. * @hidden
  78275. * enable debugging - will show console outputs and the impostor mesh
  78276. */
  78277. _enablePhysicsDebug(): void;
  78278. /**
  78279. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  78280. * @param xrController the controller to add
  78281. */
  78282. addController(xrController: WebXRInputSource): void;
  78283. /**
  78284. * attach this feature
  78285. * Will usually be called by the features manager
  78286. *
  78287. * @returns true if successful.
  78288. */
  78289. attach(): boolean;
  78290. /**
  78291. * detach this feature.
  78292. * Will usually be called by the features manager
  78293. *
  78294. * @returns true if successful.
  78295. */
  78296. detach(): boolean;
  78297. /**
  78298. * Get the headset impostor, if enabled
  78299. * @returns the impostor
  78300. */
  78301. getHeadsetImpostor(): PhysicsImpostor | undefined;
  78302. /**
  78303. * Get the physics impostor of a specific controller.
  78304. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  78305. * @param controller the controller or the controller id of which to get the impostor
  78306. * @returns the impostor or null
  78307. */
  78308. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  78309. /**
  78310. * Update the physics properties provided in the constructor
  78311. * @param newProperties the new properties object
  78312. */
  78313. setPhysicsProperties(newProperties: {
  78314. impostorType?: number;
  78315. impostorSize?: number | {
  78316. width: number;
  78317. height: number;
  78318. depth: number;
  78319. };
  78320. friction?: number;
  78321. restitution?: number;
  78322. }): void;
  78323. protected _onXRFrame(_xrFrame: any): void;
  78324. private _detachController;
  78325. }
  78326. }
  78327. declare module "babylonjs/XR/features/index" {
  78328. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  78329. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  78330. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  78331. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  78332. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  78333. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  78334. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  78335. export * from "babylonjs/XR/features/WebXRHitTest";
  78336. }
  78337. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  78338. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78340. import { Scene } from "babylonjs/scene";
  78341. /**
  78342. * The motion controller class for all microsoft mixed reality controllers
  78343. */
  78344. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  78345. protected readonly _mapping: {
  78346. defaultButton: {
  78347. valueNodeName: string;
  78348. unpressedNodeName: string;
  78349. pressedNodeName: string;
  78350. };
  78351. defaultAxis: {
  78352. valueNodeName: string;
  78353. minNodeName: string;
  78354. maxNodeName: string;
  78355. };
  78356. buttons: {
  78357. "xr-standard-trigger": {
  78358. rootNodeName: string;
  78359. componentProperty: string;
  78360. states: string[];
  78361. };
  78362. "xr-standard-squeeze": {
  78363. rootNodeName: string;
  78364. componentProperty: string;
  78365. states: string[];
  78366. };
  78367. "xr-standard-touchpad": {
  78368. rootNodeName: string;
  78369. labelAnchorNodeName: string;
  78370. touchPointNodeName: string;
  78371. };
  78372. "xr-standard-thumbstick": {
  78373. rootNodeName: string;
  78374. componentProperty: string;
  78375. states: string[];
  78376. };
  78377. };
  78378. axes: {
  78379. "xr-standard-touchpad": {
  78380. "x-axis": {
  78381. rootNodeName: string;
  78382. };
  78383. "y-axis": {
  78384. rootNodeName: string;
  78385. };
  78386. };
  78387. "xr-standard-thumbstick": {
  78388. "x-axis": {
  78389. rootNodeName: string;
  78390. };
  78391. "y-axis": {
  78392. rootNodeName: string;
  78393. };
  78394. };
  78395. };
  78396. };
  78397. /**
  78398. * The base url used to load the left and right controller models
  78399. */
  78400. static MODEL_BASE_URL: string;
  78401. /**
  78402. * The name of the left controller model file
  78403. */
  78404. static MODEL_LEFT_FILENAME: string;
  78405. /**
  78406. * The name of the right controller model file
  78407. */
  78408. static MODEL_RIGHT_FILENAME: string;
  78409. profileId: string;
  78410. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78411. protected _getFilenameAndPath(): {
  78412. filename: string;
  78413. path: string;
  78414. };
  78415. protected _getModelLoadingConstraints(): boolean;
  78416. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78417. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78418. protected _updateModel(): void;
  78419. }
  78420. }
  78421. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  78422. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78424. import { Scene } from "babylonjs/scene";
  78425. /**
  78426. * The motion controller class for oculus touch (quest, rift).
  78427. * This class supports legacy mapping as well the standard xr mapping
  78428. */
  78429. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  78430. private _forceLegacyControllers;
  78431. private _modelRootNode;
  78432. /**
  78433. * The base url used to load the left and right controller models
  78434. */
  78435. static MODEL_BASE_URL: string;
  78436. /**
  78437. * The name of the left controller model file
  78438. */
  78439. static MODEL_LEFT_FILENAME: string;
  78440. /**
  78441. * The name of the right controller model file
  78442. */
  78443. static MODEL_RIGHT_FILENAME: string;
  78444. /**
  78445. * Base Url for the Quest controller model.
  78446. */
  78447. static QUEST_MODEL_BASE_URL: string;
  78448. profileId: string;
  78449. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  78450. protected _getFilenameAndPath(): {
  78451. filename: string;
  78452. path: string;
  78453. };
  78454. protected _getModelLoadingConstraints(): boolean;
  78455. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78456. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78457. protected _updateModel(): void;
  78458. /**
  78459. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  78460. * between the touch and touch 2.
  78461. */
  78462. private _isQuest;
  78463. }
  78464. }
  78465. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  78466. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78467. import { Scene } from "babylonjs/scene";
  78468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78469. /**
  78470. * The motion controller class for the standard HTC-Vive controllers
  78471. */
  78472. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  78473. private _modelRootNode;
  78474. /**
  78475. * The base url used to load the left and right controller models
  78476. */
  78477. static MODEL_BASE_URL: string;
  78478. /**
  78479. * File name for the controller model.
  78480. */
  78481. static MODEL_FILENAME: string;
  78482. profileId: string;
  78483. /**
  78484. * Create a new Vive motion controller object
  78485. * @param scene the scene to use to create this controller
  78486. * @param gamepadObject the corresponding gamepad object
  78487. * @param handedness the handedness of the controller
  78488. */
  78489. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78490. protected _getFilenameAndPath(): {
  78491. filename: string;
  78492. path: string;
  78493. };
  78494. protected _getModelLoadingConstraints(): boolean;
  78495. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78496. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78497. protected _updateModel(): void;
  78498. }
  78499. }
  78500. declare module "babylonjs/XR/motionController/index" {
  78501. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78502. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  78503. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  78504. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  78505. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  78506. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  78507. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  78508. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  78509. }
  78510. declare module "babylonjs/XR/index" {
  78511. export * from "babylonjs/XR/webXRCamera";
  78512. export * from "babylonjs/XR/webXREnterExitUI";
  78513. export * from "babylonjs/XR/webXRExperienceHelper";
  78514. export * from "babylonjs/XR/webXRInput";
  78515. export * from "babylonjs/XR/webXRInputSource";
  78516. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  78517. export * from "babylonjs/XR/webXRTypes";
  78518. export * from "babylonjs/XR/webXRSessionManager";
  78519. export * from "babylonjs/XR/webXRDefaultExperience";
  78520. export * from "babylonjs/XR/webXRFeaturesManager";
  78521. export * from "babylonjs/XR/features/index";
  78522. export * from "babylonjs/XR/motionController/index";
  78523. }
  78524. declare module "babylonjs/index" {
  78525. export * from "babylonjs/abstractScene";
  78526. export * from "babylonjs/Actions/index";
  78527. export * from "babylonjs/Animations/index";
  78528. export * from "babylonjs/assetContainer";
  78529. export * from "babylonjs/Audio/index";
  78530. export * from "babylonjs/Behaviors/index";
  78531. export * from "babylonjs/Bones/index";
  78532. export * from "babylonjs/Cameras/index";
  78533. export * from "babylonjs/Collisions/index";
  78534. export * from "babylonjs/Culling/index";
  78535. export * from "babylonjs/Debug/index";
  78536. export * from "babylonjs/DeviceInput/index";
  78537. export * from "babylonjs/Engines/index";
  78538. export * from "babylonjs/Events/index";
  78539. export * from "babylonjs/Gamepads/index";
  78540. export * from "babylonjs/Gizmos/index";
  78541. export * from "babylonjs/Helpers/index";
  78542. export * from "babylonjs/Instrumentation/index";
  78543. export * from "babylonjs/Layers/index";
  78544. export * from "babylonjs/LensFlares/index";
  78545. export * from "babylonjs/Lights/index";
  78546. export * from "babylonjs/Loading/index";
  78547. export * from "babylonjs/Materials/index";
  78548. export * from "babylonjs/Maths/index";
  78549. export * from "babylonjs/Meshes/index";
  78550. export * from "babylonjs/Morph/index";
  78551. export * from "babylonjs/Navigation/index";
  78552. export * from "babylonjs/node";
  78553. export * from "babylonjs/Offline/index";
  78554. export * from "babylonjs/Particles/index";
  78555. export * from "babylonjs/Physics/index";
  78556. export * from "babylonjs/PostProcesses/index";
  78557. export * from "babylonjs/Probes/index";
  78558. export * from "babylonjs/Rendering/index";
  78559. export * from "babylonjs/scene";
  78560. export * from "babylonjs/sceneComponent";
  78561. export * from "babylonjs/Sprites/index";
  78562. export * from "babylonjs/States/index";
  78563. export * from "babylonjs/Misc/index";
  78564. export * from "babylonjs/XR/index";
  78565. export * from "babylonjs/types";
  78566. }
  78567. declare module "babylonjs/Animations/pathCursor" {
  78568. import { Vector3 } from "babylonjs/Maths/math.vector";
  78569. import { Path2 } from "babylonjs/Maths/math.path";
  78570. /**
  78571. * A cursor which tracks a point on a path
  78572. */
  78573. export class PathCursor {
  78574. private path;
  78575. /**
  78576. * Stores path cursor callbacks for when an onchange event is triggered
  78577. */
  78578. private _onchange;
  78579. /**
  78580. * The value of the path cursor
  78581. */
  78582. value: number;
  78583. /**
  78584. * The animation array of the path cursor
  78585. */
  78586. animations: Animation[];
  78587. /**
  78588. * Initializes the path cursor
  78589. * @param path The path to track
  78590. */
  78591. constructor(path: Path2);
  78592. /**
  78593. * Gets the cursor point on the path
  78594. * @returns A point on the path cursor at the cursor location
  78595. */
  78596. getPoint(): Vector3;
  78597. /**
  78598. * Moves the cursor ahead by the step amount
  78599. * @param step The amount to move the cursor forward
  78600. * @returns This path cursor
  78601. */
  78602. moveAhead(step?: number): PathCursor;
  78603. /**
  78604. * Moves the cursor behind by the step amount
  78605. * @param step The amount to move the cursor back
  78606. * @returns This path cursor
  78607. */
  78608. moveBack(step?: number): PathCursor;
  78609. /**
  78610. * Moves the cursor by the step amount
  78611. * If the step amount is greater than one, an exception is thrown
  78612. * @param step The amount to move the cursor
  78613. * @returns This path cursor
  78614. */
  78615. move(step: number): PathCursor;
  78616. /**
  78617. * Ensures that the value is limited between zero and one
  78618. * @returns This path cursor
  78619. */
  78620. private ensureLimits;
  78621. /**
  78622. * Runs onchange callbacks on change (used by the animation engine)
  78623. * @returns This path cursor
  78624. */
  78625. private raiseOnChange;
  78626. /**
  78627. * Executes a function on change
  78628. * @param f A path cursor onchange callback
  78629. * @returns This path cursor
  78630. */
  78631. onchange(f: (cursor: PathCursor) => void): PathCursor;
  78632. }
  78633. }
  78634. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  78635. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  78636. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  78637. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  78638. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  78639. }
  78640. declare module "babylonjs/Engines/Processors/Expressions/index" {
  78641. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  78642. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  78643. }
  78644. declare module "babylonjs/Engines/Processors/index" {
  78645. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  78646. export * from "babylonjs/Engines/Processors/Expressions/index";
  78647. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  78648. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  78649. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  78650. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  78651. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  78652. export * from "babylonjs/Engines/Processors/shaderProcessor";
  78653. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  78654. }
  78655. declare module "babylonjs/Legacy/legacy" {
  78656. import * as Babylon from "babylonjs/index";
  78657. export * from "babylonjs/index";
  78658. }
  78659. declare module "babylonjs/Shaders/blur.fragment" {
  78660. /** @hidden */
  78661. export var blurPixelShader: {
  78662. name: string;
  78663. shader: string;
  78664. };
  78665. }
  78666. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  78667. /** @hidden */
  78668. export var pointCloudVertexDeclaration: {
  78669. name: string;
  78670. shader: string;
  78671. };
  78672. }
  78673. declare module "babylonjs" {
  78674. export * from "babylonjs/Legacy/legacy";
  78675. }
  78676. declare module BABYLON {
  78677. /** Alias type for value that can be null */
  78678. export type Nullable<T> = T | null;
  78679. /**
  78680. * Alias type for number that are floats
  78681. * @ignorenaming
  78682. */
  78683. export type float = number;
  78684. /**
  78685. * Alias type for number that are doubles.
  78686. * @ignorenaming
  78687. */
  78688. export type double = number;
  78689. /**
  78690. * Alias type for number that are integer
  78691. * @ignorenaming
  78692. */
  78693. export type int = number;
  78694. /** Alias type for number array or Float32Array */
  78695. export type FloatArray = number[] | Float32Array;
  78696. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  78697. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  78698. /**
  78699. * Alias for types that can be used by a Buffer or VertexBuffer.
  78700. */
  78701. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  78702. /**
  78703. * Alias type for primitive types
  78704. * @ignorenaming
  78705. */
  78706. type Primitive = undefined | null | boolean | string | number | Function;
  78707. /**
  78708. * Type modifier to make all the properties of an object Readonly
  78709. */
  78710. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  78711. /**
  78712. * Type modifier to make all the properties of an object Readonly recursively
  78713. */
  78714. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  78715. /**
  78716. * Type modifier to make object properties readonly.
  78717. */
  78718. export type DeepImmutableObject<T> = {
  78719. readonly [K in keyof T]: DeepImmutable<T[K]>;
  78720. };
  78721. /** @hidden */
  78722. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  78723. }
  78724. }
  78725. declare module BABYLON {
  78726. /**
  78727. * A class serves as a medium between the observable and its observers
  78728. */
  78729. export class EventState {
  78730. /**
  78731. * Create a new EventState
  78732. * @param mask defines the mask associated with this state
  78733. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78734. * @param target defines the original target of the state
  78735. * @param currentTarget defines the current target of the state
  78736. */
  78737. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  78738. /**
  78739. * Initialize the current event state
  78740. * @param mask defines the mask associated with this state
  78741. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78742. * @param target defines the original target of the state
  78743. * @param currentTarget defines the current target of the state
  78744. * @returns the current event state
  78745. */
  78746. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  78747. /**
  78748. * An Observer can set this property to true to prevent subsequent observers of being notified
  78749. */
  78750. skipNextObservers: boolean;
  78751. /**
  78752. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78753. */
  78754. mask: number;
  78755. /**
  78756. * The object that originally notified the event
  78757. */
  78758. target?: any;
  78759. /**
  78760. * The current object in the bubbling phase
  78761. */
  78762. currentTarget?: any;
  78763. /**
  78764. * This will be populated with the return value of the last function that was executed.
  78765. * If it is the first function in the callback chain it will be the event data.
  78766. */
  78767. lastReturnValue?: any;
  78768. }
  78769. /**
  78770. * Represent an Observer registered to a given Observable object.
  78771. */
  78772. export class Observer<T> {
  78773. /**
  78774. * Defines the callback to call when the observer is notified
  78775. */
  78776. callback: (eventData: T, eventState: EventState) => void;
  78777. /**
  78778. * Defines the mask of the observer (used to filter notifications)
  78779. */
  78780. mask: number;
  78781. /**
  78782. * Defines the current scope used to restore the JS context
  78783. */
  78784. scope: any;
  78785. /** @hidden */
  78786. _willBeUnregistered: boolean;
  78787. /**
  78788. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  78789. */
  78790. unregisterOnNextCall: boolean;
  78791. /**
  78792. * Creates a new observer
  78793. * @param callback defines the callback to call when the observer is notified
  78794. * @param mask defines the mask of the observer (used to filter notifications)
  78795. * @param scope defines the current scope used to restore the JS context
  78796. */
  78797. constructor(
  78798. /**
  78799. * Defines the callback to call when the observer is notified
  78800. */
  78801. callback: (eventData: T, eventState: EventState) => void,
  78802. /**
  78803. * Defines the mask of the observer (used to filter notifications)
  78804. */
  78805. mask: number,
  78806. /**
  78807. * Defines the current scope used to restore the JS context
  78808. */
  78809. scope?: any);
  78810. }
  78811. /**
  78812. * Represent a list of observers registered to multiple Observables object.
  78813. */
  78814. export class MultiObserver<T> {
  78815. private _observers;
  78816. private _observables;
  78817. /**
  78818. * Release associated resources
  78819. */
  78820. dispose(): void;
  78821. /**
  78822. * Raise a callback when one of the observable will notify
  78823. * @param observables defines a list of observables to watch
  78824. * @param callback defines the callback to call on notification
  78825. * @param mask defines the mask used to filter notifications
  78826. * @param scope defines the current scope used to restore the JS context
  78827. * @returns the new MultiObserver
  78828. */
  78829. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  78830. }
  78831. /**
  78832. * The Observable class is a simple implementation of the Observable pattern.
  78833. *
  78834. * 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.
  78835. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  78836. * 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).
  78837. * 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.
  78838. */
  78839. export class Observable<T> {
  78840. private _observers;
  78841. private _eventState;
  78842. private _onObserverAdded;
  78843. /**
  78844. * Gets the list of observers
  78845. */
  78846. get observers(): Array<Observer<T>>;
  78847. /**
  78848. * Creates a new observable
  78849. * @param onObserverAdded defines a callback to call when a new observer is added
  78850. */
  78851. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  78852. /**
  78853. * Create a new Observer with the specified callback
  78854. * @param callback the callback that will be executed for that Observer
  78855. * @param mask the mask used to filter observers
  78856. * @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.
  78857. * @param scope optional scope for the callback to be called from
  78858. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  78859. * @returns the new observer created for the callback
  78860. */
  78861. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  78862. /**
  78863. * Create a new Observer with the specified callback and unregisters after the next notification
  78864. * @param callback the callback that will be executed for that Observer
  78865. * @returns the new observer created for the callback
  78866. */
  78867. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  78868. /**
  78869. * Remove an Observer from the Observable object
  78870. * @param observer the instance of the Observer to remove
  78871. * @returns false if it doesn't belong to this Observable
  78872. */
  78873. remove(observer: Nullable<Observer<T>>): boolean;
  78874. /**
  78875. * Remove a callback from the Observable object
  78876. * @param callback the callback to remove
  78877. * @param scope optional scope. If used only the callbacks with this scope will be removed
  78878. * @returns false if it doesn't belong to this Observable
  78879. */
  78880. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  78881. private _deferUnregister;
  78882. private _remove;
  78883. /**
  78884. * Moves the observable to the top of the observer list making it get called first when notified
  78885. * @param observer the observer to move
  78886. */
  78887. makeObserverTopPriority(observer: Observer<T>): void;
  78888. /**
  78889. * Moves the observable to the bottom of the observer list making it get called last when notified
  78890. * @param observer the observer to move
  78891. */
  78892. makeObserverBottomPriority(observer: Observer<T>): void;
  78893. /**
  78894. * Notify all Observers by calling their respective callback with the given data
  78895. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  78896. * @param eventData defines the data to send to all observers
  78897. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  78898. * @param target defines the original target of the state
  78899. * @param currentTarget defines the current target of the state
  78900. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  78901. */
  78902. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  78903. /**
  78904. * Calling this will execute each callback, expecting it to be a promise or return a value.
  78905. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  78906. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  78907. * and it is crucial that all callbacks will be executed.
  78908. * The order of the callbacks is kept, callbacks are not executed parallel.
  78909. *
  78910. * @param eventData The data to be sent to each callback
  78911. * @param mask is used to filter observers defaults to -1
  78912. * @param target defines the callback target (see EventState)
  78913. * @param currentTarget defines he current object in the bubbling phase
  78914. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  78915. */
  78916. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  78917. /**
  78918. * Notify a specific observer
  78919. * @param observer defines the observer to notify
  78920. * @param eventData defines the data to be sent to each callback
  78921. * @param mask is used to filter observers defaults to -1
  78922. */
  78923. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  78924. /**
  78925. * Gets a boolean indicating if the observable has at least one observer
  78926. * @returns true is the Observable has at least one Observer registered
  78927. */
  78928. hasObservers(): boolean;
  78929. /**
  78930. * Clear the list of observers
  78931. */
  78932. clear(): void;
  78933. /**
  78934. * Clone the current observable
  78935. * @returns a new observable
  78936. */
  78937. clone(): Observable<T>;
  78938. /**
  78939. * Does this observable handles observer registered with a given mask
  78940. * @param mask defines the mask to be tested
  78941. * @return whether or not one observer registered with the given mask is handeled
  78942. **/
  78943. hasSpecificMask(mask?: number): boolean;
  78944. }
  78945. }
  78946. declare module BABYLON {
  78947. /**
  78948. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  78949. * Babylon.js
  78950. */
  78951. export class DomManagement {
  78952. /**
  78953. * Checks if the window object exists
  78954. * @returns true if the window object exists
  78955. */
  78956. static IsWindowObjectExist(): boolean;
  78957. /**
  78958. * Checks if the navigator object exists
  78959. * @returns true if the navigator object exists
  78960. */
  78961. static IsNavigatorAvailable(): boolean;
  78962. /**
  78963. * Check if the document object exists
  78964. * @returns true if the document object exists
  78965. */
  78966. static IsDocumentAvailable(): boolean;
  78967. /**
  78968. * Extracts text content from a DOM element hierarchy
  78969. * @param element defines the root element
  78970. * @returns a string
  78971. */
  78972. static GetDOMTextContent(element: HTMLElement): string;
  78973. }
  78974. }
  78975. declare module BABYLON {
  78976. /**
  78977. * Logger used througouht the application to allow configuration of
  78978. * the log level required for the messages.
  78979. */
  78980. export class Logger {
  78981. /**
  78982. * No log
  78983. */
  78984. static readonly NoneLogLevel: number;
  78985. /**
  78986. * Only message logs
  78987. */
  78988. static readonly MessageLogLevel: number;
  78989. /**
  78990. * Only warning logs
  78991. */
  78992. static readonly WarningLogLevel: number;
  78993. /**
  78994. * Only error logs
  78995. */
  78996. static readonly ErrorLogLevel: number;
  78997. /**
  78998. * All logs
  78999. */
  79000. static readonly AllLogLevel: number;
  79001. private static _LogCache;
  79002. /**
  79003. * Gets a value indicating the number of loading errors
  79004. * @ignorenaming
  79005. */
  79006. static errorsCount: number;
  79007. /**
  79008. * Callback called when a new log is added
  79009. */
  79010. static OnNewCacheEntry: (entry: string) => void;
  79011. private static _AddLogEntry;
  79012. private static _FormatMessage;
  79013. private static _LogDisabled;
  79014. private static _LogEnabled;
  79015. private static _WarnDisabled;
  79016. private static _WarnEnabled;
  79017. private static _ErrorDisabled;
  79018. private static _ErrorEnabled;
  79019. /**
  79020. * Log a message to the console
  79021. */
  79022. static Log: (message: string) => void;
  79023. /**
  79024. * Write a warning message to the console
  79025. */
  79026. static Warn: (message: string) => void;
  79027. /**
  79028. * Write an error message to the console
  79029. */
  79030. static Error: (message: string) => void;
  79031. /**
  79032. * Gets current log cache (list of logs)
  79033. */
  79034. static get LogCache(): string;
  79035. /**
  79036. * Clears the log cache
  79037. */
  79038. static ClearLogCache(): void;
  79039. /**
  79040. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  79041. */
  79042. static set LogLevels(level: number);
  79043. }
  79044. }
  79045. declare module BABYLON {
  79046. /** @hidden */
  79047. export class _TypeStore {
  79048. /** @hidden */
  79049. static RegisteredTypes: {
  79050. [key: string]: Object;
  79051. };
  79052. /** @hidden */
  79053. static GetClass(fqdn: string): any;
  79054. }
  79055. }
  79056. declare module BABYLON {
  79057. /**
  79058. * Helper to manipulate strings
  79059. */
  79060. export class StringTools {
  79061. /**
  79062. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  79063. * @param str Source string
  79064. * @param suffix Suffix to search for in the source string
  79065. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  79066. */
  79067. static EndsWith(str: string, suffix: string): boolean;
  79068. /**
  79069. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  79070. * @param str Source string
  79071. * @param suffix Suffix to search for in the source string
  79072. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  79073. */
  79074. static StartsWith(str: string, suffix: string): boolean;
  79075. /**
  79076. * Decodes a buffer into a string
  79077. * @param buffer The buffer to decode
  79078. * @returns The decoded string
  79079. */
  79080. static Decode(buffer: Uint8Array | Uint16Array): string;
  79081. /**
  79082. * Encode a buffer to a base64 string
  79083. * @param buffer defines the buffer to encode
  79084. * @returns the encoded string
  79085. */
  79086. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  79087. /**
  79088. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  79089. * @param num the number to convert and pad
  79090. * @param length the expected length of the string
  79091. * @returns the padded string
  79092. */
  79093. static PadNumber(num: number, length: number): string;
  79094. }
  79095. }
  79096. declare module BABYLON {
  79097. /**
  79098. * Class containing a set of static utilities functions for deep copy.
  79099. */
  79100. export class DeepCopier {
  79101. /**
  79102. * Tries to copy an object by duplicating every property
  79103. * @param source defines the source object
  79104. * @param destination defines the target object
  79105. * @param doNotCopyList defines a list of properties to avoid
  79106. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  79107. */
  79108. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  79109. }
  79110. }
  79111. declare module BABYLON {
  79112. /**
  79113. * Class containing a set of static utilities functions for precision date
  79114. */
  79115. export class PrecisionDate {
  79116. /**
  79117. * Gets either window.performance.now() if supported or Date.now() else
  79118. */
  79119. static get Now(): number;
  79120. }
  79121. }
  79122. declare module BABYLON {
  79123. /** @hidden */
  79124. export class _DevTools {
  79125. static WarnImport(name: string): string;
  79126. }
  79127. }
  79128. declare module BABYLON {
  79129. /**
  79130. * Interface used to define the mechanism to get data from the network
  79131. */
  79132. export interface IWebRequest {
  79133. /**
  79134. * Returns client's response url
  79135. */
  79136. responseURL: string;
  79137. /**
  79138. * Returns client's status
  79139. */
  79140. status: number;
  79141. /**
  79142. * Returns client's status as a text
  79143. */
  79144. statusText: string;
  79145. }
  79146. }
  79147. declare module BABYLON {
  79148. /**
  79149. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  79150. */
  79151. export class WebRequest implements IWebRequest {
  79152. private _xhr;
  79153. /**
  79154. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  79155. * i.e. when loading files, where the server/service expects an Authorization header
  79156. */
  79157. static CustomRequestHeaders: {
  79158. [key: string]: string;
  79159. };
  79160. /**
  79161. * Add callback functions in this array to update all the requests before they get sent to the network
  79162. */
  79163. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  79164. private _injectCustomRequestHeaders;
  79165. /**
  79166. * Gets or sets a function to be called when loading progress changes
  79167. */
  79168. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  79169. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  79170. /**
  79171. * Returns client's state
  79172. */
  79173. get readyState(): number;
  79174. /**
  79175. * Returns client's status
  79176. */
  79177. get status(): number;
  79178. /**
  79179. * Returns client's status as a text
  79180. */
  79181. get statusText(): string;
  79182. /**
  79183. * Returns client's response
  79184. */
  79185. get response(): any;
  79186. /**
  79187. * Returns client's response url
  79188. */
  79189. get responseURL(): string;
  79190. /**
  79191. * Returns client's response as text
  79192. */
  79193. get responseText(): string;
  79194. /**
  79195. * Gets or sets the expected response type
  79196. */
  79197. get responseType(): XMLHttpRequestResponseType;
  79198. set responseType(value: XMLHttpRequestResponseType);
  79199. /** @hidden */
  79200. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  79201. /** @hidden */
  79202. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  79203. /**
  79204. * Cancels any network activity
  79205. */
  79206. abort(): void;
  79207. /**
  79208. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  79209. * @param body defines an optional request body
  79210. */
  79211. send(body?: Document | BodyInit | null): void;
  79212. /**
  79213. * Sets the request method, request URL
  79214. * @param method defines the method to use (GET, POST, etc..)
  79215. * @param url defines the url to connect with
  79216. */
  79217. open(method: string, url: string): void;
  79218. /**
  79219. * Sets the value of a request header.
  79220. * @param name The name of the header whose value is to be set
  79221. * @param value The value to set as the body of the header
  79222. */
  79223. setRequestHeader(name: string, value: string): void;
  79224. /**
  79225. * Get the string containing the text of a particular header's value.
  79226. * @param name The name of the header
  79227. * @returns The string containing the text of the given header name
  79228. */
  79229. getResponseHeader(name: string): Nullable<string>;
  79230. }
  79231. }
  79232. declare module BABYLON {
  79233. /**
  79234. * File request interface
  79235. */
  79236. export interface IFileRequest {
  79237. /**
  79238. * Raised when the request is complete (success or error).
  79239. */
  79240. onCompleteObservable: Observable<IFileRequest>;
  79241. /**
  79242. * Aborts the request for a file.
  79243. */
  79244. abort: () => void;
  79245. }
  79246. }
  79247. declare module BABYLON {
  79248. /**
  79249. * Define options used to create a render target texture
  79250. */
  79251. export class RenderTargetCreationOptions {
  79252. /**
  79253. * Specifies is mipmaps must be generated
  79254. */
  79255. generateMipMaps?: boolean;
  79256. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  79257. generateDepthBuffer?: boolean;
  79258. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  79259. generateStencilBuffer?: boolean;
  79260. /** Defines texture type (int by default) */
  79261. type?: number;
  79262. /** Defines sampling mode (trilinear by default) */
  79263. samplingMode?: number;
  79264. /** Defines format (RGBA by default) */
  79265. format?: number;
  79266. }
  79267. }
  79268. declare module BABYLON {
  79269. /** Defines the cross module used constants to avoid circular dependncies */
  79270. export class Constants {
  79271. /** Defines that alpha blending is disabled */
  79272. static readonly ALPHA_DISABLE: number;
  79273. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  79274. static readonly ALPHA_ADD: number;
  79275. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  79276. static readonly ALPHA_COMBINE: number;
  79277. /** Defines that alpha blending is DEST - SRC * DEST */
  79278. static readonly ALPHA_SUBTRACT: number;
  79279. /** Defines that alpha blending is SRC * DEST */
  79280. static readonly ALPHA_MULTIPLY: number;
  79281. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  79282. static readonly ALPHA_MAXIMIZED: number;
  79283. /** Defines that alpha blending is SRC + DEST */
  79284. static readonly ALPHA_ONEONE: number;
  79285. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  79286. static readonly ALPHA_PREMULTIPLIED: number;
  79287. /**
  79288. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  79289. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  79290. */
  79291. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  79292. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  79293. static readonly ALPHA_INTERPOLATE: number;
  79294. /**
  79295. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  79296. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  79297. */
  79298. static readonly ALPHA_SCREENMODE: number;
  79299. /**
  79300. * Defines that alpha blending is SRC + DST
  79301. * Alpha will be set to SRC ALPHA + DST ALPHA
  79302. */
  79303. static readonly ALPHA_ONEONE_ONEONE: number;
  79304. /**
  79305. * Defines that alpha blending is SRC * DST ALPHA + DST
  79306. * Alpha will be set to 0
  79307. */
  79308. static readonly ALPHA_ALPHATOCOLOR: number;
  79309. /**
  79310. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79311. */
  79312. static readonly ALPHA_REVERSEONEMINUS: number;
  79313. /**
  79314. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  79315. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  79316. */
  79317. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  79318. /**
  79319. * Defines that alpha blending is SRC + DST
  79320. * Alpha will be set to SRC ALPHA
  79321. */
  79322. static readonly ALPHA_ONEONE_ONEZERO: number;
  79323. /**
  79324. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79325. * Alpha will be set to DST ALPHA
  79326. */
  79327. static readonly ALPHA_EXCLUSION: number;
  79328. /** Defines that alpha blending equation a SUM */
  79329. static readonly ALPHA_EQUATION_ADD: number;
  79330. /** Defines that alpha blending equation a SUBSTRACTION */
  79331. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  79332. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  79333. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  79334. /** Defines that alpha blending equation a MAX operation */
  79335. static readonly ALPHA_EQUATION_MAX: number;
  79336. /** Defines that alpha blending equation a MIN operation */
  79337. static readonly ALPHA_EQUATION_MIN: number;
  79338. /**
  79339. * Defines that alpha blending equation a DARKEN operation:
  79340. * It takes the min of the src and sums the alpha channels.
  79341. */
  79342. static readonly ALPHA_EQUATION_DARKEN: number;
  79343. /** Defines that the ressource is not delayed*/
  79344. static readonly DELAYLOADSTATE_NONE: number;
  79345. /** Defines that the ressource was successfully delay loaded */
  79346. static readonly DELAYLOADSTATE_LOADED: number;
  79347. /** Defines that the ressource is currently delay loading */
  79348. static readonly DELAYLOADSTATE_LOADING: number;
  79349. /** Defines that the ressource is delayed and has not started loading */
  79350. static readonly DELAYLOADSTATE_NOTLOADED: number;
  79351. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  79352. static readonly NEVER: number;
  79353. /** 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 */
  79354. static readonly ALWAYS: number;
  79355. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  79356. static readonly LESS: number;
  79357. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  79358. static readonly EQUAL: number;
  79359. /** 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 */
  79360. static readonly LEQUAL: number;
  79361. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  79362. static readonly GREATER: number;
  79363. /** 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 */
  79364. static readonly GEQUAL: number;
  79365. /** 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 */
  79366. static readonly NOTEQUAL: number;
  79367. /** Passed to stencilOperation to specify that stencil value must be kept */
  79368. static readonly KEEP: number;
  79369. /** Passed to stencilOperation to specify that stencil value must be replaced */
  79370. static readonly REPLACE: number;
  79371. /** Passed to stencilOperation to specify that stencil value must be incremented */
  79372. static readonly INCR: number;
  79373. /** Passed to stencilOperation to specify that stencil value must be decremented */
  79374. static readonly DECR: number;
  79375. /** Passed to stencilOperation to specify that stencil value must be inverted */
  79376. static readonly INVERT: number;
  79377. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  79378. static readonly INCR_WRAP: number;
  79379. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  79380. static readonly DECR_WRAP: number;
  79381. /** Texture is not repeating outside of 0..1 UVs */
  79382. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  79383. /** Texture is repeating outside of 0..1 UVs */
  79384. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  79385. /** Texture is repeating and mirrored */
  79386. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  79387. /** ALPHA */
  79388. static readonly TEXTUREFORMAT_ALPHA: number;
  79389. /** LUMINANCE */
  79390. static readonly TEXTUREFORMAT_LUMINANCE: number;
  79391. /** LUMINANCE_ALPHA */
  79392. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  79393. /** RGB */
  79394. static readonly TEXTUREFORMAT_RGB: number;
  79395. /** RGBA */
  79396. static readonly TEXTUREFORMAT_RGBA: number;
  79397. /** RED */
  79398. static readonly TEXTUREFORMAT_RED: number;
  79399. /** RED (2nd reference) */
  79400. static readonly TEXTUREFORMAT_R: number;
  79401. /** RG */
  79402. static readonly TEXTUREFORMAT_RG: number;
  79403. /** RED_INTEGER */
  79404. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  79405. /** RED_INTEGER (2nd reference) */
  79406. static readonly TEXTUREFORMAT_R_INTEGER: number;
  79407. /** RG_INTEGER */
  79408. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  79409. /** RGB_INTEGER */
  79410. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  79411. /** RGBA_INTEGER */
  79412. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  79413. /** UNSIGNED_BYTE */
  79414. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  79415. /** UNSIGNED_BYTE (2nd reference) */
  79416. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  79417. /** FLOAT */
  79418. static readonly TEXTURETYPE_FLOAT: number;
  79419. /** HALF_FLOAT */
  79420. static readonly TEXTURETYPE_HALF_FLOAT: number;
  79421. /** BYTE */
  79422. static readonly TEXTURETYPE_BYTE: number;
  79423. /** SHORT */
  79424. static readonly TEXTURETYPE_SHORT: number;
  79425. /** UNSIGNED_SHORT */
  79426. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  79427. /** INT */
  79428. static readonly TEXTURETYPE_INT: number;
  79429. /** UNSIGNED_INT */
  79430. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  79431. /** UNSIGNED_SHORT_4_4_4_4 */
  79432. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  79433. /** UNSIGNED_SHORT_5_5_5_1 */
  79434. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  79435. /** UNSIGNED_SHORT_5_6_5 */
  79436. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  79437. /** UNSIGNED_INT_2_10_10_10_REV */
  79438. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  79439. /** UNSIGNED_INT_24_8 */
  79440. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  79441. /** UNSIGNED_INT_10F_11F_11F_REV */
  79442. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  79443. /** UNSIGNED_INT_5_9_9_9_REV */
  79444. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  79445. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  79446. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  79447. /** nearest is mag = nearest and min = nearest and no mip */
  79448. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  79449. /** mag = nearest and min = nearest and mip = none */
  79450. static readonly TEXTURE_NEAREST_NEAREST: number;
  79451. /** Bilinear is mag = linear and min = linear and no mip */
  79452. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  79453. /** mag = linear and min = linear and mip = none */
  79454. static readonly TEXTURE_LINEAR_LINEAR: number;
  79455. /** Trilinear is mag = linear and min = linear and mip = linear */
  79456. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  79457. /** Trilinear is mag = linear and min = linear and mip = linear */
  79458. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  79459. /** mag = nearest and min = nearest and mip = nearest */
  79460. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  79461. /** mag = nearest and min = linear and mip = nearest */
  79462. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  79463. /** mag = nearest and min = linear and mip = linear */
  79464. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  79465. /** mag = nearest and min = linear and mip = none */
  79466. static readonly TEXTURE_NEAREST_LINEAR: number;
  79467. /** nearest is mag = nearest and min = nearest and mip = linear */
  79468. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  79469. /** mag = linear and min = nearest and mip = nearest */
  79470. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  79471. /** mag = linear and min = nearest and mip = linear */
  79472. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  79473. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79474. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  79475. /** mag = linear and min = nearest and mip = none */
  79476. static readonly TEXTURE_LINEAR_NEAREST: number;
  79477. /** Explicit coordinates mode */
  79478. static readonly TEXTURE_EXPLICIT_MODE: number;
  79479. /** Spherical coordinates mode */
  79480. static readonly TEXTURE_SPHERICAL_MODE: number;
  79481. /** Planar coordinates mode */
  79482. static readonly TEXTURE_PLANAR_MODE: number;
  79483. /** Cubic coordinates mode */
  79484. static readonly TEXTURE_CUBIC_MODE: number;
  79485. /** Projection coordinates mode */
  79486. static readonly TEXTURE_PROJECTION_MODE: number;
  79487. /** Skybox coordinates mode */
  79488. static readonly TEXTURE_SKYBOX_MODE: number;
  79489. /** Inverse Cubic coordinates mode */
  79490. static readonly TEXTURE_INVCUBIC_MODE: number;
  79491. /** Equirectangular coordinates mode */
  79492. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  79493. /** Equirectangular Fixed coordinates mode */
  79494. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  79495. /** Equirectangular Fixed Mirrored coordinates mode */
  79496. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79497. /** Offline (baking) quality for texture filtering */
  79498. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  79499. /** High quality for texture filtering */
  79500. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  79501. /** Medium quality for texture filtering */
  79502. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  79503. /** Low quality for texture filtering */
  79504. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  79505. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  79506. static readonly SCALEMODE_FLOOR: number;
  79507. /** Defines that texture rescaling will look for the nearest power of 2 size */
  79508. static readonly SCALEMODE_NEAREST: number;
  79509. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  79510. static readonly SCALEMODE_CEILING: number;
  79511. /**
  79512. * The dirty texture flag value
  79513. */
  79514. static readonly MATERIAL_TextureDirtyFlag: number;
  79515. /**
  79516. * The dirty light flag value
  79517. */
  79518. static readonly MATERIAL_LightDirtyFlag: number;
  79519. /**
  79520. * The dirty fresnel flag value
  79521. */
  79522. static readonly MATERIAL_FresnelDirtyFlag: number;
  79523. /**
  79524. * The dirty attribute flag value
  79525. */
  79526. static readonly MATERIAL_AttributesDirtyFlag: number;
  79527. /**
  79528. * The dirty misc flag value
  79529. */
  79530. static readonly MATERIAL_MiscDirtyFlag: number;
  79531. /**
  79532. * The all dirty flag value
  79533. */
  79534. static readonly MATERIAL_AllDirtyFlag: number;
  79535. /**
  79536. * Returns the triangle fill mode
  79537. */
  79538. static readonly MATERIAL_TriangleFillMode: number;
  79539. /**
  79540. * Returns the wireframe mode
  79541. */
  79542. static readonly MATERIAL_WireFrameFillMode: number;
  79543. /**
  79544. * Returns the point fill mode
  79545. */
  79546. static readonly MATERIAL_PointFillMode: number;
  79547. /**
  79548. * Returns the point list draw mode
  79549. */
  79550. static readonly MATERIAL_PointListDrawMode: number;
  79551. /**
  79552. * Returns the line list draw mode
  79553. */
  79554. static readonly MATERIAL_LineListDrawMode: number;
  79555. /**
  79556. * Returns the line loop draw mode
  79557. */
  79558. static readonly MATERIAL_LineLoopDrawMode: number;
  79559. /**
  79560. * Returns the line strip draw mode
  79561. */
  79562. static readonly MATERIAL_LineStripDrawMode: number;
  79563. /**
  79564. * Returns the triangle strip draw mode
  79565. */
  79566. static readonly MATERIAL_TriangleStripDrawMode: number;
  79567. /**
  79568. * Returns the triangle fan draw mode
  79569. */
  79570. static readonly MATERIAL_TriangleFanDrawMode: number;
  79571. /**
  79572. * Stores the clock-wise side orientation
  79573. */
  79574. static readonly MATERIAL_ClockWiseSideOrientation: number;
  79575. /**
  79576. * Stores the counter clock-wise side orientation
  79577. */
  79578. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  79579. /**
  79580. * Nothing
  79581. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79582. */
  79583. static readonly ACTION_NothingTrigger: number;
  79584. /**
  79585. * On pick
  79586. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79587. */
  79588. static readonly ACTION_OnPickTrigger: number;
  79589. /**
  79590. * On left pick
  79591. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79592. */
  79593. static readonly ACTION_OnLeftPickTrigger: number;
  79594. /**
  79595. * On right pick
  79596. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79597. */
  79598. static readonly ACTION_OnRightPickTrigger: number;
  79599. /**
  79600. * On center pick
  79601. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79602. */
  79603. static readonly ACTION_OnCenterPickTrigger: number;
  79604. /**
  79605. * On pick down
  79606. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79607. */
  79608. static readonly ACTION_OnPickDownTrigger: number;
  79609. /**
  79610. * On double pick
  79611. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79612. */
  79613. static readonly ACTION_OnDoublePickTrigger: number;
  79614. /**
  79615. * On pick up
  79616. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79617. */
  79618. static readonly ACTION_OnPickUpTrigger: number;
  79619. /**
  79620. * On pick out.
  79621. * This trigger will only be raised if you also declared a OnPickDown
  79622. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79623. */
  79624. static readonly ACTION_OnPickOutTrigger: number;
  79625. /**
  79626. * On long press
  79627. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79628. */
  79629. static readonly ACTION_OnLongPressTrigger: number;
  79630. /**
  79631. * On pointer over
  79632. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79633. */
  79634. static readonly ACTION_OnPointerOverTrigger: number;
  79635. /**
  79636. * On pointer out
  79637. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79638. */
  79639. static readonly ACTION_OnPointerOutTrigger: number;
  79640. /**
  79641. * On every frame
  79642. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79643. */
  79644. static readonly ACTION_OnEveryFrameTrigger: number;
  79645. /**
  79646. * On intersection enter
  79647. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79648. */
  79649. static readonly ACTION_OnIntersectionEnterTrigger: number;
  79650. /**
  79651. * On intersection exit
  79652. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79653. */
  79654. static readonly ACTION_OnIntersectionExitTrigger: number;
  79655. /**
  79656. * On key down
  79657. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79658. */
  79659. static readonly ACTION_OnKeyDownTrigger: number;
  79660. /**
  79661. * On key up
  79662. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79663. */
  79664. static readonly ACTION_OnKeyUpTrigger: number;
  79665. /**
  79666. * Billboard mode will only apply to Y axis
  79667. */
  79668. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  79669. /**
  79670. * Billboard mode will apply to all axes
  79671. */
  79672. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  79673. /**
  79674. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  79675. */
  79676. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  79677. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  79678. * Test order :
  79679. * Is the bounding sphere outside the frustum ?
  79680. * If not, are the bounding box vertices outside the frustum ?
  79681. * It not, then the cullable object is in the frustum.
  79682. */
  79683. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  79684. /** Culling strategy : Bounding Sphere Only.
  79685. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  79686. * It's also less accurate than the standard because some not visible objects can still be selected.
  79687. * Test : is the bounding sphere outside the frustum ?
  79688. * If not, then the cullable object is in the frustum.
  79689. */
  79690. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  79691. /** Culling strategy : Optimistic Inclusion.
  79692. * This in an inclusion test first, then the standard exclusion test.
  79693. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  79694. * 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.
  79695. * Anyway, it's as accurate as the standard strategy.
  79696. * Test :
  79697. * Is the cullable object bounding sphere center in the frustum ?
  79698. * If not, apply the default culling strategy.
  79699. */
  79700. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  79701. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  79702. * This in an inclusion test first, then the bounding sphere only exclusion test.
  79703. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  79704. * 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.
  79705. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  79706. * Test :
  79707. * Is the cullable object bounding sphere center in the frustum ?
  79708. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  79709. */
  79710. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  79711. /**
  79712. * No logging while loading
  79713. */
  79714. static readonly SCENELOADER_NO_LOGGING: number;
  79715. /**
  79716. * Minimal logging while loading
  79717. */
  79718. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  79719. /**
  79720. * Summary logging while loading
  79721. */
  79722. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  79723. /**
  79724. * Detailled logging while loading
  79725. */
  79726. static readonly SCENELOADER_DETAILED_LOGGING: number;
  79727. /**
  79728. * Prepass texture index for color
  79729. */
  79730. static readonly PREPASS_COLOR_INDEX: number;
  79731. /**
  79732. * Prepass texture index for irradiance
  79733. */
  79734. static readonly PREPASS_IRRADIANCE_INDEX: number;
  79735. /**
  79736. * Prepass texture index for depth + normal
  79737. */
  79738. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  79739. /**
  79740. * Prepass texture index for albedo
  79741. */
  79742. static readonly PREPASS_ALBEDO_INDEX: number;
  79743. }
  79744. }
  79745. declare module BABYLON {
  79746. /**
  79747. * This represents the required contract to create a new type of texture loader.
  79748. */
  79749. export interface IInternalTextureLoader {
  79750. /**
  79751. * Defines wether the loader supports cascade loading the different faces.
  79752. */
  79753. supportCascades: boolean;
  79754. /**
  79755. * This returns if the loader support the current file information.
  79756. * @param extension defines the file extension of the file being loaded
  79757. * @param mimeType defines the optional mime type of the file being loaded
  79758. * @returns true if the loader can load the specified file
  79759. */
  79760. canLoad(extension: string, mimeType?: string): boolean;
  79761. /**
  79762. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  79763. * @param data contains the texture data
  79764. * @param texture defines the BabylonJS internal texture
  79765. * @param createPolynomials will be true if polynomials have been requested
  79766. * @param onLoad defines the callback to trigger once the texture is ready
  79767. * @param onError defines the callback to trigger in case of error
  79768. */
  79769. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  79770. /**
  79771. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  79772. * @param data contains the texture data
  79773. * @param texture defines the BabylonJS internal texture
  79774. * @param callback defines the method to call once ready to upload
  79775. */
  79776. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  79777. }
  79778. }
  79779. declare module BABYLON {
  79780. /**
  79781. * Class used to store and describe the pipeline context associated with an effect
  79782. */
  79783. export interface IPipelineContext {
  79784. /**
  79785. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  79786. */
  79787. isAsync: boolean;
  79788. /**
  79789. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  79790. */
  79791. isReady: boolean;
  79792. /** @hidden */
  79793. _getVertexShaderCode(): string | null;
  79794. /** @hidden */
  79795. _getFragmentShaderCode(): string | null;
  79796. /** @hidden */
  79797. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  79798. }
  79799. }
  79800. declare module BABYLON {
  79801. /**
  79802. * Class used to store gfx data (like WebGLBuffer)
  79803. */
  79804. export class DataBuffer {
  79805. /**
  79806. * Gets or sets the number of objects referencing this buffer
  79807. */
  79808. references: number;
  79809. /** Gets or sets the size of the underlying buffer */
  79810. capacity: number;
  79811. /**
  79812. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  79813. */
  79814. is32Bits: boolean;
  79815. /**
  79816. * Gets the underlying buffer
  79817. */
  79818. get underlyingResource(): any;
  79819. }
  79820. }
  79821. declare module BABYLON {
  79822. /** @hidden */
  79823. export interface IShaderProcessor {
  79824. attributeProcessor?: (attribute: string) => string;
  79825. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  79826. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  79827. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  79828. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  79829. lineProcessor?: (line: string, isFragment: boolean) => string;
  79830. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  79831. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  79832. }
  79833. }
  79834. declare module BABYLON {
  79835. /** @hidden */
  79836. export interface ProcessingOptions {
  79837. defines: string[];
  79838. indexParameters: any;
  79839. isFragment: boolean;
  79840. shouldUseHighPrecisionShader: boolean;
  79841. supportsUniformBuffers: boolean;
  79842. shadersRepository: string;
  79843. includesShadersStore: {
  79844. [key: string]: string;
  79845. };
  79846. processor?: IShaderProcessor;
  79847. version: string;
  79848. platformName: string;
  79849. lookForClosingBracketForUniformBuffer?: boolean;
  79850. }
  79851. }
  79852. declare module BABYLON {
  79853. /** @hidden */
  79854. export class ShaderCodeNode {
  79855. line: string;
  79856. children: ShaderCodeNode[];
  79857. additionalDefineKey?: string;
  79858. additionalDefineValue?: string;
  79859. isValid(preprocessors: {
  79860. [key: string]: string;
  79861. }): boolean;
  79862. process(preprocessors: {
  79863. [key: string]: string;
  79864. }, options: ProcessingOptions): string;
  79865. }
  79866. }
  79867. declare module BABYLON {
  79868. /** @hidden */
  79869. export class ShaderCodeCursor {
  79870. private _lines;
  79871. lineIndex: number;
  79872. get currentLine(): string;
  79873. get canRead(): boolean;
  79874. set lines(value: string[]);
  79875. }
  79876. }
  79877. declare module BABYLON {
  79878. /** @hidden */
  79879. export class ShaderCodeConditionNode extends ShaderCodeNode {
  79880. process(preprocessors: {
  79881. [key: string]: string;
  79882. }, options: ProcessingOptions): string;
  79883. }
  79884. }
  79885. declare module BABYLON {
  79886. /** @hidden */
  79887. export class ShaderDefineExpression {
  79888. isTrue(preprocessors: {
  79889. [key: string]: string;
  79890. }): boolean;
  79891. private static _OperatorPriority;
  79892. private static _Stack;
  79893. static postfixToInfix(postfix: string[]): string;
  79894. static infixToPostfix(infix: string): string[];
  79895. }
  79896. }
  79897. declare module BABYLON {
  79898. /** @hidden */
  79899. export class ShaderCodeTestNode extends ShaderCodeNode {
  79900. testExpression: ShaderDefineExpression;
  79901. isValid(preprocessors: {
  79902. [key: string]: string;
  79903. }): boolean;
  79904. }
  79905. }
  79906. declare module BABYLON {
  79907. /** @hidden */
  79908. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  79909. define: string;
  79910. not: boolean;
  79911. constructor(define: string, not?: boolean);
  79912. isTrue(preprocessors: {
  79913. [key: string]: string;
  79914. }): boolean;
  79915. }
  79916. }
  79917. declare module BABYLON {
  79918. /** @hidden */
  79919. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  79920. leftOperand: ShaderDefineExpression;
  79921. rightOperand: ShaderDefineExpression;
  79922. isTrue(preprocessors: {
  79923. [key: string]: string;
  79924. }): boolean;
  79925. }
  79926. }
  79927. declare module BABYLON {
  79928. /** @hidden */
  79929. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  79930. leftOperand: ShaderDefineExpression;
  79931. rightOperand: ShaderDefineExpression;
  79932. isTrue(preprocessors: {
  79933. [key: string]: string;
  79934. }): boolean;
  79935. }
  79936. }
  79937. declare module BABYLON {
  79938. /** @hidden */
  79939. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  79940. define: string;
  79941. operand: string;
  79942. testValue: string;
  79943. constructor(define: string, operand: string, testValue: string);
  79944. isTrue(preprocessors: {
  79945. [key: string]: string;
  79946. }): boolean;
  79947. }
  79948. }
  79949. declare module BABYLON {
  79950. /**
  79951. * Class used to enable access to offline support
  79952. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  79953. */
  79954. export interface IOfflineProvider {
  79955. /**
  79956. * Gets a boolean indicating if scene must be saved in the database
  79957. */
  79958. enableSceneOffline: boolean;
  79959. /**
  79960. * Gets a boolean indicating if textures must be saved in the database
  79961. */
  79962. enableTexturesOffline: boolean;
  79963. /**
  79964. * Open the offline support and make it available
  79965. * @param successCallback defines the callback to call on success
  79966. * @param errorCallback defines the callback to call on error
  79967. */
  79968. open(successCallback: () => void, errorCallback: () => void): void;
  79969. /**
  79970. * Loads an image from the offline support
  79971. * @param url defines the url to load from
  79972. * @param image defines the target DOM image
  79973. */
  79974. loadImage(url: string, image: HTMLImageElement): void;
  79975. /**
  79976. * Loads a file from offline support
  79977. * @param url defines the URL to load from
  79978. * @param sceneLoaded defines a callback to call on success
  79979. * @param progressCallBack defines a callback to call when progress changed
  79980. * @param errorCallback defines a callback to call on error
  79981. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  79982. */
  79983. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  79984. }
  79985. }
  79986. declare module BABYLON {
  79987. /**
  79988. * Class used to help managing file picking and drag'n'drop
  79989. * File Storage
  79990. */
  79991. export class FilesInputStore {
  79992. /**
  79993. * List of files ready to be loaded
  79994. */
  79995. static FilesToLoad: {
  79996. [key: string]: File;
  79997. };
  79998. }
  79999. }
  80000. declare module BABYLON {
  80001. /**
  80002. * Class used to define a retry strategy when error happens while loading assets
  80003. */
  80004. export class RetryStrategy {
  80005. /**
  80006. * Function used to defines an exponential back off strategy
  80007. * @param maxRetries defines the maximum number of retries (3 by default)
  80008. * @param baseInterval defines the interval between retries
  80009. * @returns the strategy function to use
  80010. */
  80011. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  80012. }
  80013. }
  80014. declare module BABYLON {
  80015. /**
  80016. * @ignore
  80017. * Application error to support additional information when loading a file
  80018. */
  80019. export abstract class BaseError extends Error {
  80020. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  80021. }
  80022. }
  80023. declare module BABYLON {
  80024. /** @ignore */
  80025. export class LoadFileError extends BaseError {
  80026. request?: WebRequest;
  80027. file?: File;
  80028. /**
  80029. * Creates a new LoadFileError
  80030. * @param message defines the message of the error
  80031. * @param request defines the optional web request
  80032. * @param file defines the optional file
  80033. */
  80034. constructor(message: string, object?: WebRequest | File);
  80035. }
  80036. /** @ignore */
  80037. export class RequestFileError extends BaseError {
  80038. request: WebRequest;
  80039. /**
  80040. * Creates a new LoadFileError
  80041. * @param message defines the message of the error
  80042. * @param request defines the optional web request
  80043. */
  80044. constructor(message: string, request: WebRequest);
  80045. }
  80046. /** @ignore */
  80047. export class ReadFileError extends BaseError {
  80048. file: File;
  80049. /**
  80050. * Creates a new ReadFileError
  80051. * @param message defines the message of the error
  80052. * @param file defines the optional file
  80053. */
  80054. constructor(message: string, file: File);
  80055. }
  80056. /**
  80057. * @hidden
  80058. */
  80059. export class FileTools {
  80060. /**
  80061. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  80062. */
  80063. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  80064. /**
  80065. * Gets or sets the base URL to use to load assets
  80066. */
  80067. static BaseUrl: string;
  80068. /**
  80069. * Default behaviour for cors in the application.
  80070. * It can be a string if the expected behavior is identical in the entire app.
  80071. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  80072. */
  80073. static CorsBehavior: string | ((url: string | string[]) => string);
  80074. /**
  80075. * Gets or sets a function used to pre-process url before using them to load assets
  80076. */
  80077. static PreprocessUrl: (url: string) => string;
  80078. /**
  80079. * Removes unwanted characters from an url
  80080. * @param url defines the url to clean
  80081. * @returns the cleaned url
  80082. */
  80083. private static _CleanUrl;
  80084. /**
  80085. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  80086. * @param url define the url we are trying
  80087. * @param element define the dom element where to configure the cors policy
  80088. */
  80089. static SetCorsBehavior(url: string | string[], element: {
  80090. crossOrigin: string | null;
  80091. }): void;
  80092. /**
  80093. * Loads an image as an HTMLImageElement.
  80094. * @param input url string, ArrayBuffer, or Blob to load
  80095. * @param onLoad callback called when the image successfully loads
  80096. * @param onError callback called when the image fails to load
  80097. * @param offlineProvider offline provider for caching
  80098. * @param mimeType optional mime type
  80099. * @returns the HTMLImageElement of the loaded image
  80100. */
  80101. 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>;
  80102. /**
  80103. * Reads a file from a File object
  80104. * @param file defines the file to load
  80105. * @param onSuccess defines the callback to call when data is loaded
  80106. * @param onProgress defines the callback to call during loading process
  80107. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  80108. * @param onError defines the callback to call when an error occurs
  80109. * @returns a file request object
  80110. */
  80111. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  80112. /**
  80113. * Loads a file from a url
  80114. * @param url url to load
  80115. * @param onSuccess callback called when the file successfully loads
  80116. * @param onProgress callback called while file is loading (if the server supports this mode)
  80117. * @param offlineProvider defines the offline provider for caching
  80118. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80119. * @param onError callback called when the file fails to load
  80120. * @returns a file request object
  80121. */
  80122. 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;
  80123. /**
  80124. * Loads a file
  80125. * @param url url to load
  80126. * @param onSuccess callback called when the file successfully loads
  80127. * @param onProgress callback called while file is loading (if the server supports this mode)
  80128. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80129. * @param onError callback called when the file fails to load
  80130. * @param onOpened callback called when the web request is opened
  80131. * @returns a file request object
  80132. */
  80133. 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;
  80134. /**
  80135. * Checks if the loaded document was accessed via `file:`-Protocol.
  80136. * @returns boolean
  80137. */
  80138. static IsFileURL(): boolean;
  80139. }
  80140. }
  80141. declare module BABYLON {
  80142. /** @hidden */
  80143. export class ShaderProcessor {
  80144. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  80145. private static _ProcessPrecision;
  80146. private static _ExtractOperation;
  80147. private static _BuildSubExpression;
  80148. private static _BuildExpression;
  80149. private static _MoveCursorWithinIf;
  80150. private static _MoveCursor;
  80151. private static _EvaluatePreProcessors;
  80152. private static _PreparePreProcessors;
  80153. private static _ProcessShaderConversion;
  80154. private static _ProcessIncludes;
  80155. /**
  80156. * Loads a file from a url
  80157. * @param url url to load
  80158. * @param onSuccess callback called when the file successfully loads
  80159. * @param onProgress callback called while file is loading (if the server supports this mode)
  80160. * @param offlineProvider defines the offline provider for caching
  80161. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80162. * @param onError callback called when the file fails to load
  80163. * @returns a file request object
  80164. * @hidden
  80165. */
  80166. 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;
  80167. }
  80168. }
  80169. declare module BABYLON {
  80170. /**
  80171. * @hidden
  80172. */
  80173. export interface IColor4Like {
  80174. r: float;
  80175. g: float;
  80176. b: float;
  80177. a: float;
  80178. }
  80179. /**
  80180. * @hidden
  80181. */
  80182. export interface IColor3Like {
  80183. r: float;
  80184. g: float;
  80185. b: float;
  80186. }
  80187. /**
  80188. * @hidden
  80189. */
  80190. export interface IVector4Like {
  80191. x: float;
  80192. y: float;
  80193. z: float;
  80194. w: float;
  80195. }
  80196. /**
  80197. * @hidden
  80198. */
  80199. export interface IVector3Like {
  80200. x: float;
  80201. y: float;
  80202. z: float;
  80203. }
  80204. /**
  80205. * @hidden
  80206. */
  80207. export interface IVector2Like {
  80208. x: float;
  80209. y: float;
  80210. }
  80211. /**
  80212. * @hidden
  80213. */
  80214. export interface IMatrixLike {
  80215. toArray(): DeepImmutable<Float32Array | Array<number>>;
  80216. updateFlag: int;
  80217. }
  80218. /**
  80219. * @hidden
  80220. */
  80221. export interface IViewportLike {
  80222. x: float;
  80223. y: float;
  80224. width: float;
  80225. height: float;
  80226. }
  80227. /**
  80228. * @hidden
  80229. */
  80230. export interface IPlaneLike {
  80231. normal: IVector3Like;
  80232. d: float;
  80233. normalize(): void;
  80234. }
  80235. }
  80236. declare module BABYLON {
  80237. /**
  80238. * Interface used to define common properties for effect fallbacks
  80239. */
  80240. export interface IEffectFallbacks {
  80241. /**
  80242. * Removes the defines that should be removed when falling back.
  80243. * @param currentDefines defines the current define statements for the shader.
  80244. * @param effect defines the current effect we try to compile
  80245. * @returns The resulting defines with defines of the current rank removed.
  80246. */
  80247. reduce(currentDefines: string, effect: Effect): string;
  80248. /**
  80249. * Removes the fallback from the bound mesh.
  80250. */
  80251. unBindMesh(): void;
  80252. /**
  80253. * Checks to see if more fallbacks are still availible.
  80254. */
  80255. hasMoreFallbacks: boolean;
  80256. }
  80257. }
  80258. declare module BABYLON {
  80259. /**
  80260. * Class used to evalaute queries containing `and` and `or` operators
  80261. */
  80262. export class AndOrNotEvaluator {
  80263. /**
  80264. * Evaluate a query
  80265. * @param query defines the query to evaluate
  80266. * @param evaluateCallback defines the callback used to filter result
  80267. * @returns true if the query matches
  80268. */
  80269. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  80270. private static _HandleParenthesisContent;
  80271. private static _SimplifyNegation;
  80272. }
  80273. }
  80274. declare module BABYLON {
  80275. /**
  80276. * Class used to store custom tags
  80277. */
  80278. export class Tags {
  80279. /**
  80280. * Adds support for tags on the given object
  80281. * @param obj defines the object to use
  80282. */
  80283. static EnableFor(obj: any): void;
  80284. /**
  80285. * Removes tags support
  80286. * @param obj defines the object to use
  80287. */
  80288. static DisableFor(obj: any): void;
  80289. /**
  80290. * Gets a boolean indicating if the given object has tags
  80291. * @param obj defines the object to use
  80292. * @returns a boolean
  80293. */
  80294. static HasTags(obj: any): boolean;
  80295. /**
  80296. * Gets the tags available on a given object
  80297. * @param obj defines the object to use
  80298. * @param asString defines if the tags must be returned as a string instead of an array of strings
  80299. * @returns the tags
  80300. */
  80301. static GetTags(obj: any, asString?: boolean): any;
  80302. /**
  80303. * Adds tags to an object
  80304. * @param obj defines the object to use
  80305. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  80306. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  80307. */
  80308. static AddTagsTo(obj: any, tagsString: string): void;
  80309. /**
  80310. * @hidden
  80311. */
  80312. static _AddTagTo(obj: any, tag: string): void;
  80313. /**
  80314. * Removes specific tags from a specific object
  80315. * @param obj defines the object to use
  80316. * @param tagsString defines the tags to remove
  80317. */
  80318. static RemoveTagsFrom(obj: any, tagsString: string): void;
  80319. /**
  80320. * @hidden
  80321. */
  80322. static _RemoveTagFrom(obj: any, tag: string): void;
  80323. /**
  80324. * Defines if tags hosted on an object match a given query
  80325. * @param obj defines the object to use
  80326. * @param tagsQuery defines the tag query
  80327. * @returns a boolean
  80328. */
  80329. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  80330. }
  80331. }
  80332. declare module BABYLON {
  80333. /**
  80334. * Scalar computation library
  80335. */
  80336. export class Scalar {
  80337. /**
  80338. * Two pi constants convenient for computation.
  80339. */
  80340. static TwoPi: number;
  80341. /**
  80342. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80343. * @param a number
  80344. * @param b number
  80345. * @param epsilon (default = 1.401298E-45)
  80346. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80347. */
  80348. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80349. /**
  80350. * Returns a string : the upper case translation of the number i to hexadecimal.
  80351. * @param i number
  80352. * @returns the upper case translation of the number i to hexadecimal.
  80353. */
  80354. static ToHex(i: number): string;
  80355. /**
  80356. * Returns -1 if value is negative and +1 is value is positive.
  80357. * @param value the value
  80358. * @returns the value itself if it's equal to zero.
  80359. */
  80360. static Sign(value: number): number;
  80361. /**
  80362. * Returns the value itself if it's between min and max.
  80363. * Returns min if the value is lower than min.
  80364. * Returns max if the value is greater than max.
  80365. * @param value the value to clmap
  80366. * @param min the min value to clamp to (default: 0)
  80367. * @param max the max value to clamp to (default: 1)
  80368. * @returns the clamped value
  80369. */
  80370. static Clamp(value: number, min?: number, max?: number): number;
  80371. /**
  80372. * the log2 of value.
  80373. * @param value the value to compute log2 of
  80374. * @returns the log2 of value.
  80375. */
  80376. static Log2(value: number): number;
  80377. /**
  80378. * Loops the value, so that it is never larger than length and never smaller than 0.
  80379. *
  80380. * This is similar to the modulo operator but it works with floating point numbers.
  80381. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  80382. * With t = 5 and length = 2.5, the result would be 0.0.
  80383. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  80384. * @param value the value
  80385. * @param length the length
  80386. * @returns the looped value
  80387. */
  80388. static Repeat(value: number, length: number): number;
  80389. /**
  80390. * Normalize the value between 0.0 and 1.0 using min and max values
  80391. * @param value value to normalize
  80392. * @param min max to normalize between
  80393. * @param max min to normalize between
  80394. * @returns the normalized value
  80395. */
  80396. static Normalize(value: number, min: number, max: number): number;
  80397. /**
  80398. * Denormalize the value from 0.0 and 1.0 using min and max values
  80399. * @param normalized value to denormalize
  80400. * @param min max to denormalize between
  80401. * @param max min to denormalize between
  80402. * @returns the denormalized value
  80403. */
  80404. static Denormalize(normalized: number, min: number, max: number): number;
  80405. /**
  80406. * Calculates the shortest difference between two given angles given in degrees.
  80407. * @param current current angle in degrees
  80408. * @param target target angle in degrees
  80409. * @returns the delta
  80410. */
  80411. static DeltaAngle(current: number, target: number): number;
  80412. /**
  80413. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  80414. * @param tx value
  80415. * @param length length
  80416. * @returns The returned value will move back and forth between 0 and length
  80417. */
  80418. static PingPong(tx: number, length: number): number;
  80419. /**
  80420. * Interpolates between min and max with smoothing at the limits.
  80421. *
  80422. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  80423. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  80424. * @param from from
  80425. * @param to to
  80426. * @param tx value
  80427. * @returns the smooth stepped value
  80428. */
  80429. static SmoothStep(from: number, to: number, tx: number): number;
  80430. /**
  80431. * Moves a value current towards target.
  80432. *
  80433. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  80434. * Negative values of maxDelta pushes the value away from target.
  80435. * @param current current value
  80436. * @param target target value
  80437. * @param maxDelta max distance to move
  80438. * @returns resulting value
  80439. */
  80440. static MoveTowards(current: number, target: number, maxDelta: number): number;
  80441. /**
  80442. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80443. *
  80444. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  80445. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  80446. * @param current current value
  80447. * @param target target value
  80448. * @param maxDelta max distance to move
  80449. * @returns resulting angle
  80450. */
  80451. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  80452. /**
  80453. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  80454. * @param start start value
  80455. * @param end target value
  80456. * @param amount amount to lerp between
  80457. * @returns the lerped value
  80458. */
  80459. static Lerp(start: number, end: number, amount: number): number;
  80460. /**
  80461. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80462. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  80463. * @param start start value
  80464. * @param end target value
  80465. * @param amount amount to lerp between
  80466. * @returns the lerped value
  80467. */
  80468. static LerpAngle(start: number, end: number, amount: number): number;
  80469. /**
  80470. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  80471. * @param a start value
  80472. * @param b target value
  80473. * @param value value between a and b
  80474. * @returns the inverseLerp value
  80475. */
  80476. static InverseLerp(a: number, b: number, value: number): number;
  80477. /**
  80478. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  80479. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  80480. * @param value1 spline value
  80481. * @param tangent1 spline value
  80482. * @param value2 spline value
  80483. * @param tangent2 spline value
  80484. * @param amount input value
  80485. * @returns hermite result
  80486. */
  80487. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  80488. /**
  80489. * Returns a random float number between and min and max values
  80490. * @param min min value of random
  80491. * @param max max value of random
  80492. * @returns random value
  80493. */
  80494. static RandomRange(min: number, max: number): number;
  80495. /**
  80496. * This function returns percentage of a number in a given range.
  80497. *
  80498. * RangeToPercent(40,20,60) will return 0.5 (50%)
  80499. * RangeToPercent(34,0,100) will return 0.34 (34%)
  80500. * @param number to convert to percentage
  80501. * @param min min range
  80502. * @param max max range
  80503. * @returns the percentage
  80504. */
  80505. static RangeToPercent(number: number, min: number, max: number): number;
  80506. /**
  80507. * This function returns number that corresponds to the percentage in a given range.
  80508. *
  80509. * PercentToRange(0.34,0,100) will return 34.
  80510. * @param percent to convert to number
  80511. * @param min min range
  80512. * @param max max range
  80513. * @returns the number
  80514. */
  80515. static PercentToRange(percent: number, min: number, max: number): number;
  80516. /**
  80517. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  80518. * @param angle The angle to normalize in radian.
  80519. * @return The converted angle.
  80520. */
  80521. static NormalizeRadians(angle: number): number;
  80522. }
  80523. }
  80524. declare module BABYLON {
  80525. /**
  80526. * Constant used to convert a value to gamma space
  80527. * @ignorenaming
  80528. */
  80529. export const ToGammaSpace: number;
  80530. /**
  80531. * Constant used to convert a value to linear space
  80532. * @ignorenaming
  80533. */
  80534. export const ToLinearSpace = 2.2;
  80535. /**
  80536. * Constant used to define the minimal number value in Babylon.js
  80537. * @ignorenaming
  80538. */
  80539. let Epsilon: number;
  80540. }
  80541. declare module BABYLON {
  80542. /**
  80543. * Class used to represent a viewport on screen
  80544. */
  80545. export class Viewport {
  80546. /** viewport left coordinate */
  80547. x: number;
  80548. /** viewport top coordinate */
  80549. y: number;
  80550. /**viewport width */
  80551. width: number;
  80552. /** viewport height */
  80553. height: number;
  80554. /**
  80555. * Creates a Viewport object located at (x, y) and sized (width, height)
  80556. * @param x defines viewport left coordinate
  80557. * @param y defines viewport top coordinate
  80558. * @param width defines the viewport width
  80559. * @param height defines the viewport height
  80560. */
  80561. constructor(
  80562. /** viewport left coordinate */
  80563. x: number,
  80564. /** viewport top coordinate */
  80565. y: number,
  80566. /**viewport width */
  80567. width: number,
  80568. /** viewport height */
  80569. height: number);
  80570. /**
  80571. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  80572. * @param renderWidth defines the rendering width
  80573. * @param renderHeight defines the rendering height
  80574. * @returns a new Viewport
  80575. */
  80576. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  80577. /**
  80578. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  80579. * @param renderWidth defines the rendering width
  80580. * @param renderHeight defines the rendering height
  80581. * @param ref defines the target viewport
  80582. * @returns the current viewport
  80583. */
  80584. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  80585. /**
  80586. * Returns a new Viewport copied from the current one
  80587. * @returns a new Viewport
  80588. */
  80589. clone(): Viewport;
  80590. }
  80591. }
  80592. declare module BABYLON {
  80593. /**
  80594. * Class containing a set of static utilities functions for arrays.
  80595. */
  80596. export class ArrayTools {
  80597. /**
  80598. * Returns an array of the given size filled with element built from the given constructor and the paramters
  80599. * @param size the number of element to construct and put in the array
  80600. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  80601. * @returns a new array filled with new objects
  80602. */
  80603. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  80604. }
  80605. }
  80606. declare module BABYLON {
  80607. /**
  80608. * Represents a plane by the equation ax + by + cz + d = 0
  80609. */
  80610. export class Plane {
  80611. private static _TmpMatrix;
  80612. /**
  80613. * Normal of the plane (a,b,c)
  80614. */
  80615. normal: Vector3;
  80616. /**
  80617. * d component of the plane
  80618. */
  80619. d: number;
  80620. /**
  80621. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80622. * @param a a component of the plane
  80623. * @param b b component of the plane
  80624. * @param c c component of the plane
  80625. * @param d d component of the plane
  80626. */
  80627. constructor(a: number, b: number, c: number, d: number);
  80628. /**
  80629. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80630. */
  80631. asArray(): number[];
  80632. /**
  80633. * @returns a new plane copied from the current Plane.
  80634. */
  80635. clone(): Plane;
  80636. /**
  80637. * @returns the string "Plane".
  80638. */
  80639. getClassName(): string;
  80640. /**
  80641. * @returns the Plane hash code.
  80642. */
  80643. getHashCode(): number;
  80644. /**
  80645. * Normalize the current Plane in place.
  80646. * @returns the updated Plane.
  80647. */
  80648. normalize(): Plane;
  80649. /**
  80650. * Applies a transformation the plane and returns the result
  80651. * @param transformation the transformation matrix to be applied to the plane
  80652. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80653. */
  80654. transform(transformation: DeepImmutable<Matrix>): Plane;
  80655. /**
  80656. * Compute the dot product between the point and the plane normal
  80657. * @param point point to calculate the dot product with
  80658. * @returns the dot product (float) of the point coordinates and the plane normal.
  80659. */
  80660. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80661. /**
  80662. * Updates the current Plane from the plane defined by the three given points.
  80663. * @param point1 one of the points used to contruct the plane
  80664. * @param point2 one of the points used to contruct the plane
  80665. * @param point3 one of the points used to contruct the plane
  80666. * @returns the updated Plane.
  80667. */
  80668. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80669. /**
  80670. * Checks if the plane is facing a given direction
  80671. * @param direction the direction to check if the plane is facing
  80672. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80673. * @returns True is the vector "direction" is the same side than the plane normal.
  80674. */
  80675. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80676. /**
  80677. * Calculates the distance to a point
  80678. * @param point point to calculate distance to
  80679. * @returns the signed distance (float) from the given point to the Plane.
  80680. */
  80681. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80682. /**
  80683. * Creates a plane from an array
  80684. * @param array the array to create a plane from
  80685. * @returns a new Plane from the given array.
  80686. */
  80687. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80688. /**
  80689. * Creates a plane from three points
  80690. * @param point1 point used to create the plane
  80691. * @param point2 point used to create the plane
  80692. * @param point3 point used to create the plane
  80693. * @returns a new Plane defined by the three given points.
  80694. */
  80695. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80696. /**
  80697. * Creates a plane from an origin point and a normal
  80698. * @param origin origin of the plane to be constructed
  80699. * @param normal normal of the plane to be constructed
  80700. * @returns a new Plane the normal vector to this plane at the given origin point.
  80701. * Note : the vector "normal" is updated because normalized.
  80702. */
  80703. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  80704. /**
  80705. * Calculates the distance from a plane and a point
  80706. * @param origin origin of the plane to be constructed
  80707. * @param normal normal of the plane to be constructed
  80708. * @param point point to calculate distance to
  80709. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80710. */
  80711. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80712. }
  80713. }
  80714. declare module BABYLON {
  80715. /** @hidden */
  80716. export class PerformanceConfigurator {
  80717. /** @hidden */
  80718. static MatrixUse64Bits: boolean;
  80719. /** @hidden */
  80720. static MatrixTrackPrecisionChange: boolean;
  80721. /** @hidden */
  80722. static MatrixCurrentType: any;
  80723. /** @hidden */
  80724. static MatrixTrackedMatrices: Array<any> | null;
  80725. /** @hidden */
  80726. static SetMatrixPrecision(use64bits: boolean): void;
  80727. }
  80728. }
  80729. declare module BABYLON {
  80730. /**
  80731. * Class representing a vector containing 2 coordinates
  80732. */
  80733. export class Vector2 {
  80734. /** defines the first coordinate */
  80735. x: number;
  80736. /** defines the second coordinate */
  80737. y: number;
  80738. /**
  80739. * Creates a new Vector2 from the given x and y coordinates
  80740. * @param x defines the first coordinate
  80741. * @param y defines the second coordinate
  80742. */
  80743. constructor(
  80744. /** defines the first coordinate */
  80745. x?: number,
  80746. /** defines the second coordinate */
  80747. y?: number);
  80748. /**
  80749. * Gets a string with the Vector2 coordinates
  80750. * @returns a string with the Vector2 coordinates
  80751. */
  80752. toString(): string;
  80753. /**
  80754. * Gets class name
  80755. * @returns the string "Vector2"
  80756. */
  80757. getClassName(): string;
  80758. /**
  80759. * Gets current vector hash code
  80760. * @returns the Vector2 hash code as a number
  80761. */
  80762. getHashCode(): number;
  80763. /**
  80764. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  80765. * @param array defines the source array
  80766. * @param index defines the offset in source array
  80767. * @returns the current Vector2
  80768. */
  80769. toArray(array: FloatArray, index?: number): Vector2;
  80770. /**
  80771. * Update the current vector from an array
  80772. * @param array defines the destination array
  80773. * @param index defines the offset in the destination array
  80774. * @returns the current Vector3
  80775. */
  80776. fromArray(array: FloatArray, index?: number): Vector2;
  80777. /**
  80778. * Copy the current vector to an array
  80779. * @returns a new array with 2 elements: the Vector2 coordinates.
  80780. */
  80781. asArray(): number[];
  80782. /**
  80783. * Sets the Vector2 coordinates with the given Vector2 coordinates
  80784. * @param source defines the source Vector2
  80785. * @returns the current updated Vector2
  80786. */
  80787. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  80788. /**
  80789. * Sets the Vector2 coordinates with the given floats
  80790. * @param x defines the first coordinate
  80791. * @param y defines the second coordinate
  80792. * @returns the current updated Vector2
  80793. */
  80794. copyFromFloats(x: number, y: number): Vector2;
  80795. /**
  80796. * Sets the Vector2 coordinates with the given floats
  80797. * @param x defines the first coordinate
  80798. * @param y defines the second coordinate
  80799. * @returns the current updated Vector2
  80800. */
  80801. set(x: number, y: number): Vector2;
  80802. /**
  80803. * Add another vector with the current one
  80804. * @param otherVector defines the other vector
  80805. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  80806. */
  80807. add(otherVector: DeepImmutable<Vector2>): Vector2;
  80808. /**
  80809. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  80810. * @param otherVector defines the other vector
  80811. * @param result defines the target vector
  80812. * @returns the unmodified current Vector2
  80813. */
  80814. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80815. /**
  80816. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  80817. * @param otherVector defines the other vector
  80818. * @returns the current updated Vector2
  80819. */
  80820. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80821. /**
  80822. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  80823. * @param otherVector defines the other vector
  80824. * @returns a new Vector2
  80825. */
  80826. addVector3(otherVector: Vector3): Vector2;
  80827. /**
  80828. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  80829. * @param otherVector defines the other vector
  80830. * @returns a new Vector2
  80831. */
  80832. subtract(otherVector: Vector2): Vector2;
  80833. /**
  80834. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  80835. * @param otherVector defines the other vector
  80836. * @param result defines the target vector
  80837. * @returns the unmodified current Vector2
  80838. */
  80839. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80840. /**
  80841. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  80842. * @param otherVector defines the other vector
  80843. * @returns the current updated Vector2
  80844. */
  80845. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80846. /**
  80847. * Multiplies in place the current Vector2 coordinates by the given ones
  80848. * @param otherVector defines the other vector
  80849. * @returns the current updated Vector2
  80850. */
  80851. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80852. /**
  80853. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  80854. * @param otherVector defines the other vector
  80855. * @returns a new Vector2
  80856. */
  80857. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  80858. /**
  80859. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  80860. * @param otherVector defines the other vector
  80861. * @param result defines the target vector
  80862. * @returns the unmodified current Vector2
  80863. */
  80864. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80865. /**
  80866. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  80867. * @param x defines the first coordinate
  80868. * @param y defines the second coordinate
  80869. * @returns a new Vector2
  80870. */
  80871. multiplyByFloats(x: number, y: number): Vector2;
  80872. /**
  80873. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  80874. * @param otherVector defines the other vector
  80875. * @returns a new Vector2
  80876. */
  80877. divide(otherVector: Vector2): Vector2;
  80878. /**
  80879. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  80880. * @param otherVector defines the other vector
  80881. * @param result defines the target vector
  80882. * @returns the unmodified current Vector2
  80883. */
  80884. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80885. /**
  80886. * Divides the current Vector2 coordinates by the given ones
  80887. * @param otherVector defines the other vector
  80888. * @returns the current updated Vector2
  80889. */
  80890. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80891. /**
  80892. * Gets a new Vector2 with current Vector2 negated coordinates
  80893. * @returns a new Vector2
  80894. */
  80895. negate(): Vector2;
  80896. /**
  80897. * Negate this vector in place
  80898. * @returns this
  80899. */
  80900. negateInPlace(): Vector2;
  80901. /**
  80902. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  80903. * @param result defines the Vector3 object where to store the result
  80904. * @returns the current Vector2
  80905. */
  80906. negateToRef(result: Vector2): Vector2;
  80907. /**
  80908. * Multiply the Vector2 coordinates by scale
  80909. * @param scale defines the scaling factor
  80910. * @returns the current updated Vector2
  80911. */
  80912. scaleInPlace(scale: number): Vector2;
  80913. /**
  80914. * Returns a new Vector2 scaled by "scale" from the current Vector2
  80915. * @param scale defines the scaling factor
  80916. * @returns a new Vector2
  80917. */
  80918. scale(scale: number): Vector2;
  80919. /**
  80920. * Scale the current Vector2 values by a factor to a given Vector2
  80921. * @param scale defines the scale factor
  80922. * @param result defines the Vector2 object where to store the result
  80923. * @returns the unmodified current Vector2
  80924. */
  80925. scaleToRef(scale: number, result: Vector2): Vector2;
  80926. /**
  80927. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  80928. * @param scale defines the scale factor
  80929. * @param result defines the Vector2 object where to store the result
  80930. * @returns the unmodified current Vector2
  80931. */
  80932. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  80933. /**
  80934. * Gets a boolean if two vectors are equals
  80935. * @param otherVector defines the other vector
  80936. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  80937. */
  80938. equals(otherVector: DeepImmutable<Vector2>): boolean;
  80939. /**
  80940. * Gets a boolean if two vectors are equals (using an epsilon value)
  80941. * @param otherVector defines the other vector
  80942. * @param epsilon defines the minimal distance to consider equality
  80943. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  80944. */
  80945. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  80946. /**
  80947. * Gets a new Vector2 from current Vector2 floored values
  80948. * @returns a new Vector2
  80949. */
  80950. floor(): Vector2;
  80951. /**
  80952. * Gets a new Vector2 from current Vector2 floored values
  80953. * @returns a new Vector2
  80954. */
  80955. fract(): Vector2;
  80956. /**
  80957. * Gets the length of the vector
  80958. * @returns the vector length (float)
  80959. */
  80960. length(): number;
  80961. /**
  80962. * Gets the vector squared length
  80963. * @returns the vector squared length (float)
  80964. */
  80965. lengthSquared(): number;
  80966. /**
  80967. * Normalize the vector
  80968. * @returns the current updated Vector2
  80969. */
  80970. normalize(): Vector2;
  80971. /**
  80972. * Gets a new Vector2 copied from the Vector2
  80973. * @returns a new Vector2
  80974. */
  80975. clone(): Vector2;
  80976. /**
  80977. * Gets a new Vector2(0, 0)
  80978. * @returns a new Vector2
  80979. */
  80980. static Zero(): Vector2;
  80981. /**
  80982. * Gets a new Vector2(1, 1)
  80983. * @returns a new Vector2
  80984. */
  80985. static One(): Vector2;
  80986. /**
  80987. * Gets a new Vector2 set from the given index element of the given array
  80988. * @param array defines the data source
  80989. * @param offset defines the offset in the data source
  80990. * @returns a new Vector2
  80991. */
  80992. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  80993. /**
  80994. * Sets "result" from the given index element of the given array
  80995. * @param array defines the data source
  80996. * @param offset defines the offset in the data source
  80997. * @param result defines the target vector
  80998. */
  80999. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  81000. /**
  81001. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  81002. * @param value1 defines 1st point of control
  81003. * @param value2 defines 2nd point of control
  81004. * @param value3 defines 3rd point of control
  81005. * @param value4 defines 4th point of control
  81006. * @param amount defines the interpolation factor
  81007. * @returns a new Vector2
  81008. */
  81009. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  81010. /**
  81011. * 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".
  81012. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  81013. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  81014. * @param value defines the value to clamp
  81015. * @param min defines the lower limit
  81016. * @param max defines the upper limit
  81017. * @returns a new Vector2
  81018. */
  81019. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  81020. /**
  81021. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  81022. * @param value1 defines the 1st control point
  81023. * @param tangent1 defines the outgoing tangent
  81024. * @param value2 defines the 2nd control point
  81025. * @param tangent2 defines the incoming tangent
  81026. * @param amount defines the interpolation factor
  81027. * @returns a new Vector2
  81028. */
  81029. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  81030. /**
  81031. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  81032. * @param start defines the start vector
  81033. * @param end defines the end vector
  81034. * @param amount defines the interpolation factor
  81035. * @returns a new Vector2
  81036. */
  81037. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  81038. /**
  81039. * Gets the dot product of the vector "left" and the vector "right"
  81040. * @param left defines first vector
  81041. * @param right defines second vector
  81042. * @returns the dot product (float)
  81043. */
  81044. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  81045. /**
  81046. * Returns a new Vector2 equal to the normalized given vector
  81047. * @param vector defines the vector to normalize
  81048. * @returns a new Vector2
  81049. */
  81050. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  81051. /**
  81052. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  81053. * @param left defines 1st vector
  81054. * @param right defines 2nd vector
  81055. * @returns a new Vector2
  81056. */
  81057. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  81058. /**
  81059. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  81060. * @param left defines 1st vector
  81061. * @param right defines 2nd vector
  81062. * @returns a new Vector2
  81063. */
  81064. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  81065. /**
  81066. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  81067. * @param vector defines the vector to transform
  81068. * @param transformation defines the matrix to apply
  81069. * @returns a new Vector2
  81070. */
  81071. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  81072. /**
  81073. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  81074. * @param vector defines the vector to transform
  81075. * @param transformation defines the matrix to apply
  81076. * @param result defines the target vector
  81077. */
  81078. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  81079. /**
  81080. * Determines if a given vector is included in a triangle
  81081. * @param p defines the vector to test
  81082. * @param p0 defines 1st triangle point
  81083. * @param p1 defines 2nd triangle point
  81084. * @param p2 defines 3rd triangle point
  81085. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  81086. */
  81087. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  81088. /**
  81089. * Gets the distance between the vectors "value1" and "value2"
  81090. * @param value1 defines first vector
  81091. * @param value2 defines second vector
  81092. * @returns the distance between vectors
  81093. */
  81094. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  81095. /**
  81096. * Returns the squared distance between the vectors "value1" and "value2"
  81097. * @param value1 defines first vector
  81098. * @param value2 defines second vector
  81099. * @returns the squared distance between vectors
  81100. */
  81101. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  81102. /**
  81103. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  81104. * @param value1 defines first vector
  81105. * @param value2 defines second vector
  81106. * @returns a new Vector2
  81107. */
  81108. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  81109. /**
  81110. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  81111. * @param p defines the middle point
  81112. * @param segA defines one point of the segment
  81113. * @param segB defines the other point of the segment
  81114. * @returns the shortest distance
  81115. */
  81116. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  81117. }
  81118. /**
  81119. * Class used to store (x,y,z) vector representation
  81120. * A Vector3 is the main object used in 3D geometry
  81121. * It can represent etiher the coordinates of a point the space, either a direction
  81122. * Reminder: js uses a left handed forward facing system
  81123. */
  81124. export class Vector3 {
  81125. private static _UpReadOnly;
  81126. private static _ZeroReadOnly;
  81127. /** @hidden */
  81128. _x: number;
  81129. /** @hidden */
  81130. _y: number;
  81131. /** @hidden */
  81132. _z: number;
  81133. /** @hidden */
  81134. _isDirty: boolean;
  81135. /** Gets or sets the x coordinate */
  81136. get x(): number;
  81137. set x(value: number);
  81138. /** Gets or sets the y coordinate */
  81139. get y(): number;
  81140. set y(value: number);
  81141. /** Gets or sets the z coordinate */
  81142. get z(): number;
  81143. set z(value: number);
  81144. /**
  81145. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  81146. * @param x defines the first coordinates (on X axis)
  81147. * @param y defines the second coordinates (on Y axis)
  81148. * @param z defines the third coordinates (on Z axis)
  81149. */
  81150. constructor(x?: number, y?: number, z?: number);
  81151. /**
  81152. * Creates a string representation of the Vector3
  81153. * @returns a string with the Vector3 coordinates.
  81154. */
  81155. toString(): string;
  81156. /**
  81157. * Gets the class name
  81158. * @returns the string "Vector3"
  81159. */
  81160. getClassName(): string;
  81161. /**
  81162. * Creates the Vector3 hash code
  81163. * @returns a number which tends to be unique between Vector3 instances
  81164. */
  81165. getHashCode(): number;
  81166. /**
  81167. * Creates an array containing three elements : the coordinates of the Vector3
  81168. * @returns a new array of numbers
  81169. */
  81170. asArray(): number[];
  81171. /**
  81172. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  81173. * @param array defines the destination array
  81174. * @param index defines the offset in the destination array
  81175. * @returns the current Vector3
  81176. */
  81177. toArray(array: FloatArray, index?: number): Vector3;
  81178. /**
  81179. * Update the current vector from an array
  81180. * @param array defines the destination array
  81181. * @param index defines the offset in the destination array
  81182. * @returns the current Vector3
  81183. */
  81184. fromArray(array: FloatArray, index?: number): Vector3;
  81185. /**
  81186. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  81187. * @returns a new Quaternion object, computed from the Vector3 coordinates
  81188. */
  81189. toQuaternion(): Quaternion;
  81190. /**
  81191. * Adds the given vector to the current Vector3
  81192. * @param otherVector defines the second operand
  81193. * @returns the current updated Vector3
  81194. */
  81195. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81196. /**
  81197. * Adds the given coordinates to the current Vector3
  81198. * @param x defines the x coordinate of the operand
  81199. * @param y defines the y coordinate of the operand
  81200. * @param z defines the z coordinate of the operand
  81201. * @returns the current updated Vector3
  81202. */
  81203. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81204. /**
  81205. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  81206. * @param otherVector defines the second operand
  81207. * @returns the resulting Vector3
  81208. */
  81209. add(otherVector: DeepImmutable<Vector3>): Vector3;
  81210. /**
  81211. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  81212. * @param otherVector defines the second operand
  81213. * @param result defines the Vector3 object where to store the result
  81214. * @returns the current Vector3
  81215. */
  81216. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81217. /**
  81218. * Subtract the given vector from the current Vector3
  81219. * @param otherVector defines the second operand
  81220. * @returns the current updated Vector3
  81221. */
  81222. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81223. /**
  81224. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  81225. * @param otherVector defines the second operand
  81226. * @returns the resulting Vector3
  81227. */
  81228. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  81229. /**
  81230. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  81231. * @param otherVector defines the second operand
  81232. * @param result defines the Vector3 object where to store the result
  81233. * @returns the current Vector3
  81234. */
  81235. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81236. /**
  81237. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  81238. * @param x defines the x coordinate of the operand
  81239. * @param y defines the y coordinate of the operand
  81240. * @param z defines the z coordinate of the operand
  81241. * @returns the resulting Vector3
  81242. */
  81243. subtractFromFloats(x: number, y: number, z: number): Vector3;
  81244. /**
  81245. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  81246. * @param x defines the x coordinate of the operand
  81247. * @param y defines the y coordinate of the operand
  81248. * @param z defines the z coordinate of the operand
  81249. * @param result defines the Vector3 object where to store the result
  81250. * @returns the current Vector3
  81251. */
  81252. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  81253. /**
  81254. * Gets a new Vector3 set with the current Vector3 negated coordinates
  81255. * @returns a new Vector3
  81256. */
  81257. negate(): Vector3;
  81258. /**
  81259. * Negate this vector in place
  81260. * @returns this
  81261. */
  81262. negateInPlace(): Vector3;
  81263. /**
  81264. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  81265. * @param result defines the Vector3 object where to store the result
  81266. * @returns the current Vector3
  81267. */
  81268. negateToRef(result: Vector3): Vector3;
  81269. /**
  81270. * Multiplies the Vector3 coordinates by the float "scale"
  81271. * @param scale defines the multiplier factor
  81272. * @returns the current updated Vector3
  81273. */
  81274. scaleInPlace(scale: number): Vector3;
  81275. /**
  81276. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  81277. * @param scale defines the multiplier factor
  81278. * @returns a new Vector3
  81279. */
  81280. scale(scale: number): Vector3;
  81281. /**
  81282. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  81283. * @param scale defines the multiplier factor
  81284. * @param result defines the Vector3 object where to store the result
  81285. * @returns the current Vector3
  81286. */
  81287. scaleToRef(scale: number, result: Vector3): Vector3;
  81288. /**
  81289. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  81290. * @param scale defines the scale factor
  81291. * @param result defines the Vector3 object where to store the result
  81292. * @returns the unmodified current Vector3
  81293. */
  81294. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  81295. /**
  81296. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81297. * @param origin defines the origin of the projection ray
  81298. * @param plane defines the plane to project to
  81299. * @returns the projected vector3
  81300. */
  81301. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  81302. /**
  81303. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81304. * @param origin defines the origin of the projection ray
  81305. * @param plane defines the plane to project to
  81306. * @param result defines the Vector3 where to store the result
  81307. */
  81308. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  81309. /**
  81310. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  81311. * @param otherVector defines the second operand
  81312. * @returns true if both vectors are equals
  81313. */
  81314. equals(otherVector: DeepImmutable<Vector3>): boolean;
  81315. /**
  81316. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  81317. * @param otherVector defines the second operand
  81318. * @param epsilon defines the minimal distance to define values as equals
  81319. * @returns true if both vectors are distant less than epsilon
  81320. */
  81321. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  81322. /**
  81323. * Returns true if the current Vector3 coordinates equals the given floats
  81324. * @param x defines the x coordinate of the operand
  81325. * @param y defines the y coordinate of the operand
  81326. * @param z defines the z coordinate of the operand
  81327. * @returns true if both vectors are equals
  81328. */
  81329. equalsToFloats(x: number, y: number, z: number): boolean;
  81330. /**
  81331. * Multiplies the current Vector3 coordinates by the given ones
  81332. * @param otherVector defines the second operand
  81333. * @returns the current updated Vector3
  81334. */
  81335. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81336. /**
  81337. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  81338. * @param otherVector defines the second operand
  81339. * @returns the new Vector3
  81340. */
  81341. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  81342. /**
  81343. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  81344. * @param otherVector defines the second operand
  81345. * @param result defines the Vector3 object where to store the result
  81346. * @returns the current Vector3
  81347. */
  81348. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81349. /**
  81350. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  81351. * @param x defines the x coordinate of the operand
  81352. * @param y defines the y coordinate of the operand
  81353. * @param z defines the z coordinate of the operand
  81354. * @returns the new Vector3
  81355. */
  81356. multiplyByFloats(x: number, y: number, z: number): Vector3;
  81357. /**
  81358. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  81359. * @param otherVector defines the second operand
  81360. * @returns the new Vector3
  81361. */
  81362. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  81363. /**
  81364. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  81365. * @param otherVector defines the second operand
  81366. * @param result defines the Vector3 object where to store the result
  81367. * @returns the current Vector3
  81368. */
  81369. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81370. /**
  81371. * Divides the current Vector3 coordinates by the given ones.
  81372. * @param otherVector defines the second operand
  81373. * @returns the current updated Vector3
  81374. */
  81375. divideInPlace(otherVector: Vector3): Vector3;
  81376. /**
  81377. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  81378. * @param other defines the second operand
  81379. * @returns the current updated Vector3
  81380. */
  81381. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81382. /**
  81383. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  81384. * @param other defines the second operand
  81385. * @returns the current updated Vector3
  81386. */
  81387. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81388. /**
  81389. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  81390. * @param x defines the x coordinate of the operand
  81391. * @param y defines the y coordinate of the operand
  81392. * @param z defines the z coordinate of the operand
  81393. * @returns the current updated Vector3
  81394. */
  81395. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81396. /**
  81397. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  81398. * @param x defines the x coordinate of the operand
  81399. * @param y defines the y coordinate of the operand
  81400. * @param z defines the z coordinate of the operand
  81401. * @returns the current updated Vector3
  81402. */
  81403. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81404. /**
  81405. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  81406. * Check if is non uniform within a certain amount of decimal places to account for this
  81407. * @param epsilon the amount the values can differ
  81408. * @returns if the the vector is non uniform to a certain number of decimal places
  81409. */
  81410. isNonUniformWithinEpsilon(epsilon: number): boolean;
  81411. /**
  81412. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  81413. */
  81414. get isNonUniform(): boolean;
  81415. /**
  81416. * Gets a new Vector3 from current Vector3 floored values
  81417. * @returns a new Vector3
  81418. */
  81419. floor(): Vector3;
  81420. /**
  81421. * Gets a new Vector3 from current Vector3 floored values
  81422. * @returns a new Vector3
  81423. */
  81424. fract(): Vector3;
  81425. /**
  81426. * Gets the length of the Vector3
  81427. * @returns the length of the Vector3
  81428. */
  81429. length(): number;
  81430. /**
  81431. * Gets the squared length of the Vector3
  81432. * @returns squared length of the Vector3
  81433. */
  81434. lengthSquared(): number;
  81435. /**
  81436. * Normalize the current Vector3.
  81437. * Please note that this is an in place operation.
  81438. * @returns the current updated Vector3
  81439. */
  81440. normalize(): Vector3;
  81441. /**
  81442. * Reorders the x y z properties of the vector in place
  81443. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  81444. * @returns the current updated vector
  81445. */
  81446. reorderInPlace(order: string): this;
  81447. /**
  81448. * Rotates the vector around 0,0,0 by a quaternion
  81449. * @param quaternion the rotation quaternion
  81450. * @param result vector to store the result
  81451. * @returns the resulting vector
  81452. */
  81453. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  81454. /**
  81455. * Rotates a vector around a given point
  81456. * @param quaternion the rotation quaternion
  81457. * @param point the point to rotate around
  81458. * @param result vector to store the result
  81459. * @returns the resulting vector
  81460. */
  81461. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  81462. /**
  81463. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  81464. * The cross product is then orthogonal to both current and "other"
  81465. * @param other defines the right operand
  81466. * @returns the cross product
  81467. */
  81468. cross(other: Vector3): Vector3;
  81469. /**
  81470. * Normalize the current Vector3 with the given input length.
  81471. * Please note that this is an in place operation.
  81472. * @param len the length of the vector
  81473. * @returns the current updated Vector3
  81474. */
  81475. normalizeFromLength(len: number): Vector3;
  81476. /**
  81477. * Normalize the current Vector3 to a new vector
  81478. * @returns the new Vector3
  81479. */
  81480. normalizeToNew(): Vector3;
  81481. /**
  81482. * Normalize the current Vector3 to the reference
  81483. * @param reference define the Vector3 to update
  81484. * @returns the updated Vector3
  81485. */
  81486. normalizeToRef(reference: Vector3): Vector3;
  81487. /**
  81488. * Creates a new Vector3 copied from the current Vector3
  81489. * @returns the new Vector3
  81490. */
  81491. clone(): Vector3;
  81492. /**
  81493. * Copies the given vector coordinates to the current Vector3 ones
  81494. * @param source defines the source Vector3
  81495. * @returns the current updated Vector3
  81496. */
  81497. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  81498. /**
  81499. * Copies the given floats to the current Vector3 coordinates
  81500. * @param x defines the x coordinate of the operand
  81501. * @param y defines the y coordinate of the operand
  81502. * @param z defines the z coordinate of the operand
  81503. * @returns the current updated Vector3
  81504. */
  81505. copyFromFloats(x: number, y: number, z: number): Vector3;
  81506. /**
  81507. * Copies the given floats to the current Vector3 coordinates
  81508. * @param x defines the x coordinate of the operand
  81509. * @param y defines the y coordinate of the operand
  81510. * @param z defines the z coordinate of the operand
  81511. * @returns the current updated Vector3
  81512. */
  81513. set(x: number, y: number, z: number): Vector3;
  81514. /**
  81515. * Copies the given float to the current Vector3 coordinates
  81516. * @param v defines the x, y and z coordinates of the operand
  81517. * @returns the current updated Vector3
  81518. */
  81519. setAll(v: number): Vector3;
  81520. /**
  81521. * Get the clip factor between two vectors
  81522. * @param vector0 defines the first operand
  81523. * @param vector1 defines the second operand
  81524. * @param axis defines the axis to use
  81525. * @param size defines the size along the axis
  81526. * @returns the clip factor
  81527. */
  81528. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  81529. /**
  81530. * Get angle between two vectors
  81531. * @param vector0 angle between vector0 and vector1
  81532. * @param vector1 angle between vector0 and vector1
  81533. * @param normal direction of the normal
  81534. * @return the angle between vector0 and vector1
  81535. */
  81536. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  81537. /**
  81538. * Returns a new Vector3 set from the index "offset" of the given array
  81539. * @param array defines the source array
  81540. * @param offset defines the offset in the source array
  81541. * @returns the new Vector3
  81542. */
  81543. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  81544. /**
  81545. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  81546. * @param array defines the source array
  81547. * @param offset defines the offset in the source array
  81548. * @returns the new Vector3
  81549. * @deprecated Please use FromArray instead.
  81550. */
  81551. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  81552. /**
  81553. * Sets the given vector "result" with the element values from the index "offset" of the given array
  81554. * @param array defines the source array
  81555. * @param offset defines the offset in the source array
  81556. * @param result defines the Vector3 where to store the result
  81557. */
  81558. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  81559. /**
  81560. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  81561. * @param array defines the source array
  81562. * @param offset defines the offset in the source array
  81563. * @param result defines the Vector3 where to store the result
  81564. * @deprecated Please use FromArrayToRef instead.
  81565. */
  81566. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  81567. /**
  81568. * Sets the given vector "result" with the given floats.
  81569. * @param x defines the x coordinate of the source
  81570. * @param y defines the y coordinate of the source
  81571. * @param z defines the z coordinate of the source
  81572. * @param result defines the Vector3 where to store the result
  81573. */
  81574. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  81575. /**
  81576. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  81577. * @returns a new empty Vector3
  81578. */
  81579. static Zero(): Vector3;
  81580. /**
  81581. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  81582. * @returns a new unit Vector3
  81583. */
  81584. static One(): Vector3;
  81585. /**
  81586. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  81587. * @returns a new up Vector3
  81588. */
  81589. static Up(): Vector3;
  81590. /**
  81591. * Gets a up Vector3 that must not be updated
  81592. */
  81593. static get UpReadOnly(): DeepImmutable<Vector3>;
  81594. /**
  81595. * Gets a zero Vector3 that must not be updated
  81596. */
  81597. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  81598. /**
  81599. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  81600. * @returns a new down Vector3
  81601. */
  81602. static Down(): Vector3;
  81603. /**
  81604. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  81605. * @param rightHandedSystem is the scene right-handed (negative z)
  81606. * @returns a new forward Vector3
  81607. */
  81608. static Forward(rightHandedSystem?: boolean): Vector3;
  81609. /**
  81610. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  81611. * @param rightHandedSystem is the scene right-handed (negative-z)
  81612. * @returns a new forward Vector3
  81613. */
  81614. static Backward(rightHandedSystem?: boolean): Vector3;
  81615. /**
  81616. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  81617. * @returns a new right Vector3
  81618. */
  81619. static Right(): Vector3;
  81620. /**
  81621. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  81622. * @returns a new left Vector3
  81623. */
  81624. static Left(): Vector3;
  81625. /**
  81626. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  81627. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81628. * @param vector defines the Vector3 to transform
  81629. * @param transformation defines the transformation matrix
  81630. * @returns the transformed Vector3
  81631. */
  81632. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81633. /**
  81634. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  81635. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81636. * @param vector defines the Vector3 to transform
  81637. * @param transformation defines the transformation matrix
  81638. * @param result defines the Vector3 where to store the result
  81639. */
  81640. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81641. /**
  81642. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  81643. * This method computes tranformed coordinates only, not transformed direction vectors
  81644. * @param x define the x coordinate of the source vector
  81645. * @param y define the y coordinate of the source vector
  81646. * @param z define the z coordinate of the source vector
  81647. * @param transformation defines the transformation matrix
  81648. * @param result defines the Vector3 where to store the result
  81649. */
  81650. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81651. /**
  81652. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  81653. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81654. * @param vector defines the Vector3 to transform
  81655. * @param transformation defines the transformation matrix
  81656. * @returns the new Vector3
  81657. */
  81658. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81659. /**
  81660. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  81661. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81662. * @param vector defines the Vector3 to transform
  81663. * @param transformation defines the transformation matrix
  81664. * @param result defines the Vector3 where to store the result
  81665. */
  81666. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81667. /**
  81668. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  81669. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81670. * @param x define the x coordinate of the source vector
  81671. * @param y define the y coordinate of the source vector
  81672. * @param z define the z coordinate of the source vector
  81673. * @param transformation defines the transformation matrix
  81674. * @param result defines the Vector3 where to store the result
  81675. */
  81676. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81677. /**
  81678. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  81679. * @param value1 defines the first control point
  81680. * @param value2 defines the second control point
  81681. * @param value3 defines the third control point
  81682. * @param value4 defines the fourth control point
  81683. * @param amount defines the amount on the spline to use
  81684. * @returns the new Vector3
  81685. */
  81686. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  81687. /**
  81688. * 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"
  81689. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81690. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81691. * @param value defines the current value
  81692. * @param min defines the lower range value
  81693. * @param max defines the upper range value
  81694. * @returns the new Vector3
  81695. */
  81696. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  81697. /**
  81698. * 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"
  81699. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81700. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81701. * @param value defines the current value
  81702. * @param min defines the lower range value
  81703. * @param max defines the upper range value
  81704. * @param result defines the Vector3 where to store the result
  81705. */
  81706. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  81707. /**
  81708. * Checks if a given vector is inside a specific range
  81709. * @param v defines the vector to test
  81710. * @param min defines the minimum range
  81711. * @param max defines the maximum range
  81712. */
  81713. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  81714. /**
  81715. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  81716. * @param value1 defines the first control point
  81717. * @param tangent1 defines the first tangent vector
  81718. * @param value2 defines the second control point
  81719. * @param tangent2 defines the second tangent vector
  81720. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  81721. * @returns the new Vector3
  81722. */
  81723. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  81724. /**
  81725. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  81726. * @param start defines the start value
  81727. * @param end defines the end value
  81728. * @param amount max defines amount between both (between 0 and 1)
  81729. * @returns the new Vector3
  81730. */
  81731. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  81732. /**
  81733. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  81734. * @param start defines the start value
  81735. * @param end defines the end value
  81736. * @param amount max defines amount between both (between 0 and 1)
  81737. * @param result defines the Vector3 where to store the result
  81738. */
  81739. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  81740. /**
  81741. * Returns the dot product (float) between the vectors "left" and "right"
  81742. * @param left defines the left operand
  81743. * @param right defines the right operand
  81744. * @returns the dot product
  81745. */
  81746. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  81747. /**
  81748. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  81749. * The cross product is then orthogonal to both "left" and "right"
  81750. * @param left defines the left operand
  81751. * @param right defines the right operand
  81752. * @returns the cross product
  81753. */
  81754. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81755. /**
  81756. * Sets the given vector "result" with the cross product of "left" and "right"
  81757. * The cross product is then orthogonal to both "left" and "right"
  81758. * @param left defines the left operand
  81759. * @param right defines the right operand
  81760. * @param result defines the Vector3 where to store the result
  81761. */
  81762. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  81763. /**
  81764. * Returns a new Vector3 as the normalization of the given vector
  81765. * @param vector defines the Vector3 to normalize
  81766. * @returns the new Vector3
  81767. */
  81768. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  81769. /**
  81770. * Sets the given vector "result" with the normalization of the given first vector
  81771. * @param vector defines the Vector3 to normalize
  81772. * @param result defines the Vector3 where to store the result
  81773. */
  81774. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  81775. /**
  81776. * Project a Vector3 onto screen space
  81777. * @param vector defines the Vector3 to project
  81778. * @param world defines the world matrix to use
  81779. * @param transform defines the transform (view x projection) matrix to use
  81780. * @param viewport defines the screen viewport to use
  81781. * @returns the new Vector3
  81782. */
  81783. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  81784. /** @hidden */
  81785. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  81786. /**
  81787. * Unproject from screen space to object space
  81788. * @param source defines the screen space Vector3 to use
  81789. * @param viewportWidth defines the current width of the viewport
  81790. * @param viewportHeight defines the current height of the viewport
  81791. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81792. * @param transform defines the transform (view x projection) matrix to use
  81793. * @returns the new Vector3
  81794. */
  81795. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  81796. /**
  81797. * Unproject from screen space to object space
  81798. * @param source defines the screen space Vector3 to use
  81799. * @param viewportWidth defines the current width of the viewport
  81800. * @param viewportHeight defines the current height of the viewport
  81801. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81802. * @param view defines the view matrix to use
  81803. * @param projection defines the projection matrix to use
  81804. * @returns the new Vector3
  81805. */
  81806. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  81807. /**
  81808. * Unproject from screen space to object space
  81809. * @param source defines the screen space Vector3 to use
  81810. * @param viewportWidth defines the current width of the viewport
  81811. * @param viewportHeight defines the current height of the viewport
  81812. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81813. * @param view defines the view matrix to use
  81814. * @param projection defines the projection matrix to use
  81815. * @param result defines the Vector3 where to store the result
  81816. */
  81817. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  81818. /**
  81819. * Unproject from screen space to object space
  81820. * @param sourceX defines the screen space x coordinate to use
  81821. * @param sourceY defines the screen space y coordinate to use
  81822. * @param sourceZ defines the screen space z coordinate to use
  81823. * @param viewportWidth defines the current width of the viewport
  81824. * @param viewportHeight defines the current height of the viewport
  81825. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81826. * @param view defines the view matrix to use
  81827. * @param projection defines the projection matrix to use
  81828. * @param result defines the Vector3 where to store the result
  81829. */
  81830. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  81831. /**
  81832. * Gets the minimal coordinate values between two Vector3
  81833. * @param left defines the first operand
  81834. * @param right defines the second operand
  81835. * @returns the new Vector3
  81836. */
  81837. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81838. /**
  81839. * Gets the maximal coordinate values between two Vector3
  81840. * @param left defines the first operand
  81841. * @param right defines the second operand
  81842. * @returns the new Vector3
  81843. */
  81844. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81845. /**
  81846. * Returns the distance between the vectors "value1" and "value2"
  81847. * @param value1 defines the first operand
  81848. * @param value2 defines the second operand
  81849. * @returns the distance
  81850. */
  81851. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  81852. /**
  81853. * Returns the squared distance between the vectors "value1" and "value2"
  81854. * @param value1 defines the first operand
  81855. * @param value2 defines the second operand
  81856. * @returns the squared distance
  81857. */
  81858. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  81859. /**
  81860. * Returns a new Vector3 located at the center between "value1" and "value2"
  81861. * @param value1 defines the first operand
  81862. * @param value2 defines the second operand
  81863. * @returns the new Vector3
  81864. */
  81865. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  81866. /**
  81867. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  81868. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  81869. * to something in order to rotate it from its local system to the given target system
  81870. * Note: axis1, axis2 and axis3 are normalized during this operation
  81871. * @param axis1 defines the first axis
  81872. * @param axis2 defines the second axis
  81873. * @param axis3 defines the third axis
  81874. * @returns a new Vector3
  81875. */
  81876. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  81877. /**
  81878. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  81879. * @param axis1 defines the first axis
  81880. * @param axis2 defines the second axis
  81881. * @param axis3 defines the third axis
  81882. * @param ref defines the Vector3 where to store the result
  81883. */
  81884. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  81885. }
  81886. /**
  81887. * Vector4 class created for EulerAngle class conversion to Quaternion
  81888. */
  81889. export class Vector4 {
  81890. /** x value of the vector */
  81891. x: number;
  81892. /** y value of the vector */
  81893. y: number;
  81894. /** z value of the vector */
  81895. z: number;
  81896. /** w value of the vector */
  81897. w: number;
  81898. /**
  81899. * Creates a Vector4 object from the given floats.
  81900. * @param x x value of the vector
  81901. * @param y y value of the vector
  81902. * @param z z value of the vector
  81903. * @param w w value of the vector
  81904. */
  81905. constructor(
  81906. /** x value of the vector */
  81907. x: number,
  81908. /** y value of the vector */
  81909. y: number,
  81910. /** z value of the vector */
  81911. z: number,
  81912. /** w value of the vector */
  81913. w: number);
  81914. /**
  81915. * Returns the string with the Vector4 coordinates.
  81916. * @returns a string containing all the vector values
  81917. */
  81918. toString(): string;
  81919. /**
  81920. * Returns the string "Vector4".
  81921. * @returns "Vector4"
  81922. */
  81923. getClassName(): string;
  81924. /**
  81925. * Returns the Vector4 hash code.
  81926. * @returns a unique hash code
  81927. */
  81928. getHashCode(): number;
  81929. /**
  81930. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  81931. * @returns the resulting array
  81932. */
  81933. asArray(): number[];
  81934. /**
  81935. * Populates the given array from the given index with the Vector4 coordinates.
  81936. * @param array array to populate
  81937. * @param index index of the array to start at (default: 0)
  81938. * @returns the Vector4.
  81939. */
  81940. toArray(array: FloatArray, index?: number): Vector4;
  81941. /**
  81942. * Update the current vector from an array
  81943. * @param array defines the destination array
  81944. * @param index defines the offset in the destination array
  81945. * @returns the current Vector3
  81946. */
  81947. fromArray(array: FloatArray, index?: number): Vector4;
  81948. /**
  81949. * Adds the given vector to the current Vector4.
  81950. * @param otherVector the vector to add
  81951. * @returns the updated Vector4.
  81952. */
  81953. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81954. /**
  81955. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  81956. * @param otherVector the vector to add
  81957. * @returns the resulting vector
  81958. */
  81959. add(otherVector: DeepImmutable<Vector4>): Vector4;
  81960. /**
  81961. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  81962. * @param otherVector the vector to add
  81963. * @param result the vector to store the result
  81964. * @returns the current Vector4.
  81965. */
  81966. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81967. /**
  81968. * Subtract in place the given vector from the current Vector4.
  81969. * @param otherVector the vector to subtract
  81970. * @returns the updated Vector4.
  81971. */
  81972. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81973. /**
  81974. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  81975. * @param otherVector the vector to add
  81976. * @returns the new vector with the result
  81977. */
  81978. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  81979. /**
  81980. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  81981. * @param otherVector the vector to subtract
  81982. * @param result the vector to store the result
  81983. * @returns the current Vector4.
  81984. */
  81985. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81986. /**
  81987. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81988. */
  81989. /**
  81990. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81991. * @param x value to subtract
  81992. * @param y value to subtract
  81993. * @param z value to subtract
  81994. * @param w value to subtract
  81995. * @returns new vector containing the result
  81996. */
  81997. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81998. /**
  81999. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82000. * @param x value to subtract
  82001. * @param y value to subtract
  82002. * @param z value to subtract
  82003. * @param w value to subtract
  82004. * @param result the vector to store the result in
  82005. * @returns the current Vector4.
  82006. */
  82007. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  82008. /**
  82009. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  82010. * @returns a new vector with the negated values
  82011. */
  82012. negate(): Vector4;
  82013. /**
  82014. * Negate this vector in place
  82015. * @returns this
  82016. */
  82017. negateInPlace(): Vector4;
  82018. /**
  82019. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  82020. * @param result defines the Vector3 object where to store the result
  82021. * @returns the current Vector4
  82022. */
  82023. negateToRef(result: Vector4): Vector4;
  82024. /**
  82025. * Multiplies the current Vector4 coordinates by scale (float).
  82026. * @param scale the number to scale with
  82027. * @returns the updated Vector4.
  82028. */
  82029. scaleInPlace(scale: number): Vector4;
  82030. /**
  82031. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  82032. * @param scale the number to scale with
  82033. * @returns a new vector with the result
  82034. */
  82035. scale(scale: number): Vector4;
  82036. /**
  82037. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  82038. * @param scale the number to scale with
  82039. * @param result a vector to store the result in
  82040. * @returns the current Vector4.
  82041. */
  82042. scaleToRef(scale: number, result: Vector4): Vector4;
  82043. /**
  82044. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  82045. * @param scale defines the scale factor
  82046. * @param result defines the Vector4 object where to store the result
  82047. * @returns the unmodified current Vector4
  82048. */
  82049. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  82050. /**
  82051. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  82052. * @param otherVector the vector to compare against
  82053. * @returns true if they are equal
  82054. */
  82055. equals(otherVector: DeepImmutable<Vector4>): boolean;
  82056. /**
  82057. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  82058. * @param otherVector vector to compare against
  82059. * @param epsilon (Default: very small number)
  82060. * @returns true if they are equal
  82061. */
  82062. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  82063. /**
  82064. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  82065. * @param x x value to compare against
  82066. * @param y y value to compare against
  82067. * @param z z value to compare against
  82068. * @param w w value to compare against
  82069. * @returns true if equal
  82070. */
  82071. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  82072. /**
  82073. * Multiplies in place the current Vector4 by the given one.
  82074. * @param otherVector vector to multiple with
  82075. * @returns the updated Vector4.
  82076. */
  82077. multiplyInPlace(otherVector: Vector4): Vector4;
  82078. /**
  82079. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  82080. * @param otherVector vector to multiple with
  82081. * @returns resulting new vector
  82082. */
  82083. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  82084. /**
  82085. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  82086. * @param otherVector vector to multiple with
  82087. * @param result vector to store the result
  82088. * @returns the current Vector4.
  82089. */
  82090. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82091. /**
  82092. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  82093. * @param x x value multiply with
  82094. * @param y y value multiply with
  82095. * @param z z value multiply with
  82096. * @param w w value multiply with
  82097. * @returns resulting new vector
  82098. */
  82099. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  82100. /**
  82101. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  82102. * @param otherVector vector to devide with
  82103. * @returns resulting new vector
  82104. */
  82105. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  82106. /**
  82107. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  82108. * @param otherVector vector to devide with
  82109. * @param result vector to store the result
  82110. * @returns the current Vector4.
  82111. */
  82112. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82113. /**
  82114. * Divides the current Vector3 coordinates by the given ones.
  82115. * @param otherVector vector to devide with
  82116. * @returns the updated Vector3.
  82117. */
  82118. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82119. /**
  82120. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  82121. * @param other defines the second operand
  82122. * @returns the current updated Vector4
  82123. */
  82124. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  82125. /**
  82126. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  82127. * @param other defines the second operand
  82128. * @returns the current updated Vector4
  82129. */
  82130. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  82131. /**
  82132. * Gets a new Vector4 from current Vector4 floored values
  82133. * @returns a new Vector4
  82134. */
  82135. floor(): Vector4;
  82136. /**
  82137. * Gets a new Vector4 from current Vector3 floored values
  82138. * @returns a new Vector4
  82139. */
  82140. fract(): Vector4;
  82141. /**
  82142. * Returns the Vector4 length (float).
  82143. * @returns the length
  82144. */
  82145. length(): number;
  82146. /**
  82147. * Returns the Vector4 squared length (float).
  82148. * @returns the length squared
  82149. */
  82150. lengthSquared(): number;
  82151. /**
  82152. * Normalizes in place the Vector4.
  82153. * @returns the updated Vector4.
  82154. */
  82155. normalize(): Vector4;
  82156. /**
  82157. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  82158. * @returns this converted to a new vector3
  82159. */
  82160. toVector3(): Vector3;
  82161. /**
  82162. * Returns a new Vector4 copied from the current one.
  82163. * @returns the new cloned vector
  82164. */
  82165. clone(): Vector4;
  82166. /**
  82167. * Updates the current Vector4 with the given one coordinates.
  82168. * @param source the source vector to copy from
  82169. * @returns the updated Vector4.
  82170. */
  82171. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  82172. /**
  82173. * Updates the current Vector4 coordinates with the given floats.
  82174. * @param x float to copy from
  82175. * @param y float to copy from
  82176. * @param z float to copy from
  82177. * @param w float to copy from
  82178. * @returns the updated Vector4.
  82179. */
  82180. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  82181. /**
  82182. * Updates the current Vector4 coordinates with the given floats.
  82183. * @param x float to set from
  82184. * @param y float to set from
  82185. * @param z float to set from
  82186. * @param w float to set from
  82187. * @returns the updated Vector4.
  82188. */
  82189. set(x: number, y: number, z: number, w: number): Vector4;
  82190. /**
  82191. * Copies the given float to the current Vector3 coordinates
  82192. * @param v defines the x, y, z and w coordinates of the operand
  82193. * @returns the current updated Vector3
  82194. */
  82195. setAll(v: number): Vector4;
  82196. /**
  82197. * Returns a new Vector4 set from the starting index of the given array.
  82198. * @param array the array to pull values from
  82199. * @param offset the offset into the array to start at
  82200. * @returns the new vector
  82201. */
  82202. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  82203. /**
  82204. * Updates the given vector "result" from the starting index of the given array.
  82205. * @param array the array to pull values from
  82206. * @param offset the offset into the array to start at
  82207. * @param result the vector to store the result in
  82208. */
  82209. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  82210. /**
  82211. * Updates the given vector "result" from the starting index of the given Float32Array.
  82212. * @param array the array to pull values from
  82213. * @param offset the offset into the array to start at
  82214. * @param result the vector to store the result in
  82215. */
  82216. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  82217. /**
  82218. * Updates the given vector "result" coordinates from the given floats.
  82219. * @param x float to set from
  82220. * @param y float to set from
  82221. * @param z float to set from
  82222. * @param w float to set from
  82223. * @param result the vector to the floats in
  82224. */
  82225. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  82226. /**
  82227. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  82228. * @returns the new vector
  82229. */
  82230. static Zero(): Vector4;
  82231. /**
  82232. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  82233. * @returns the new vector
  82234. */
  82235. static One(): Vector4;
  82236. /**
  82237. * Returns a new normalized Vector4 from the given one.
  82238. * @param vector the vector to normalize
  82239. * @returns the vector
  82240. */
  82241. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  82242. /**
  82243. * Updates the given vector "result" from the normalization of the given one.
  82244. * @param vector the vector to normalize
  82245. * @param result the vector to store the result in
  82246. */
  82247. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  82248. /**
  82249. * Returns a vector with the minimum values from the left and right vectors
  82250. * @param left left vector to minimize
  82251. * @param right right vector to minimize
  82252. * @returns a new vector with the minimum of the left and right vector values
  82253. */
  82254. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82255. /**
  82256. * Returns a vector with the maximum values from the left and right vectors
  82257. * @param left left vector to maximize
  82258. * @param right right vector to maximize
  82259. * @returns a new vector with the maximum of the left and right vector values
  82260. */
  82261. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82262. /**
  82263. * Returns the distance (float) between the vectors "value1" and "value2".
  82264. * @param value1 value to calulate the distance between
  82265. * @param value2 value to calulate the distance between
  82266. * @return the distance between the two vectors
  82267. */
  82268. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82269. /**
  82270. * Returns the squared distance (float) between the vectors "value1" and "value2".
  82271. * @param value1 value to calulate the distance between
  82272. * @param value2 value to calulate the distance between
  82273. * @return the distance between the two vectors squared
  82274. */
  82275. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82276. /**
  82277. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  82278. * @param value1 value to calulate the center between
  82279. * @param value2 value to calulate the center between
  82280. * @return the center between the two vectors
  82281. */
  82282. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  82283. /**
  82284. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  82285. * This methods computes transformed normalized direction vectors only.
  82286. * @param vector the vector to transform
  82287. * @param transformation the transformation matrix to apply
  82288. * @returns the new vector
  82289. */
  82290. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  82291. /**
  82292. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  82293. * This methods computes transformed normalized direction vectors only.
  82294. * @param vector the vector to transform
  82295. * @param transformation the transformation matrix to apply
  82296. * @param result the vector to store the result in
  82297. */
  82298. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82299. /**
  82300. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  82301. * This methods computes transformed normalized direction vectors only.
  82302. * @param x value to transform
  82303. * @param y value to transform
  82304. * @param z value to transform
  82305. * @param w value to transform
  82306. * @param transformation the transformation matrix to apply
  82307. * @param result the vector to store the results in
  82308. */
  82309. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82310. /**
  82311. * Creates a new Vector4 from a Vector3
  82312. * @param source defines the source data
  82313. * @param w defines the 4th component (default is 0)
  82314. * @returns a new Vector4
  82315. */
  82316. static FromVector3(source: Vector3, w?: number): Vector4;
  82317. }
  82318. /**
  82319. * Class used to store quaternion data
  82320. * @see https://en.wikipedia.org/wiki/Quaternion
  82321. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  82322. */
  82323. export class Quaternion {
  82324. /** @hidden */
  82325. _x: number;
  82326. /** @hidden */
  82327. _y: number;
  82328. /** @hidden */
  82329. _z: number;
  82330. /** @hidden */
  82331. _w: number;
  82332. /** @hidden */
  82333. _isDirty: boolean;
  82334. /** Gets or sets the x coordinate */
  82335. get x(): number;
  82336. set x(value: number);
  82337. /** Gets or sets the y coordinate */
  82338. get y(): number;
  82339. set y(value: number);
  82340. /** Gets or sets the z coordinate */
  82341. get z(): number;
  82342. set z(value: number);
  82343. /** Gets or sets the w coordinate */
  82344. get w(): number;
  82345. set w(value: number);
  82346. /**
  82347. * Creates a new Quaternion from the given floats
  82348. * @param x defines the first component (0 by default)
  82349. * @param y defines the second component (0 by default)
  82350. * @param z defines the third component (0 by default)
  82351. * @param w defines the fourth component (1.0 by default)
  82352. */
  82353. constructor(x?: number, y?: number, z?: number, w?: number);
  82354. /**
  82355. * Gets a string representation for the current quaternion
  82356. * @returns a string with the Quaternion coordinates
  82357. */
  82358. toString(): string;
  82359. /**
  82360. * Gets the class name of the quaternion
  82361. * @returns the string "Quaternion"
  82362. */
  82363. getClassName(): string;
  82364. /**
  82365. * Gets a hash code for this quaternion
  82366. * @returns the quaternion hash code
  82367. */
  82368. getHashCode(): number;
  82369. /**
  82370. * Copy the quaternion to an array
  82371. * @returns a new array populated with 4 elements from the quaternion coordinates
  82372. */
  82373. asArray(): number[];
  82374. /**
  82375. * Check if two quaternions are equals
  82376. * @param otherQuaternion defines the second operand
  82377. * @return true if the current quaternion and the given one coordinates are strictly equals
  82378. */
  82379. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  82380. /**
  82381. * Gets a boolean if two quaternions are equals (using an epsilon value)
  82382. * @param otherQuaternion defines the other quaternion
  82383. * @param epsilon defines the minimal distance to consider equality
  82384. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  82385. */
  82386. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  82387. /**
  82388. * Clone the current quaternion
  82389. * @returns a new quaternion copied from the current one
  82390. */
  82391. clone(): Quaternion;
  82392. /**
  82393. * Copy a quaternion to the current one
  82394. * @param other defines the other quaternion
  82395. * @returns the updated current quaternion
  82396. */
  82397. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  82398. /**
  82399. * Updates the current quaternion with the given float coordinates
  82400. * @param x defines the x coordinate
  82401. * @param y defines the y coordinate
  82402. * @param z defines the z coordinate
  82403. * @param w defines the w coordinate
  82404. * @returns the updated current quaternion
  82405. */
  82406. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  82407. /**
  82408. * Updates the current quaternion from the given float coordinates
  82409. * @param x defines the x coordinate
  82410. * @param y defines the y coordinate
  82411. * @param z defines the z coordinate
  82412. * @param w defines the w coordinate
  82413. * @returns the updated current quaternion
  82414. */
  82415. set(x: number, y: number, z: number, w: number): Quaternion;
  82416. /**
  82417. * Adds two quaternions
  82418. * @param other defines the second operand
  82419. * @returns a new quaternion as the addition result of the given one and the current quaternion
  82420. */
  82421. add(other: DeepImmutable<Quaternion>): Quaternion;
  82422. /**
  82423. * Add a quaternion to the current one
  82424. * @param other defines the quaternion to add
  82425. * @returns the current quaternion
  82426. */
  82427. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  82428. /**
  82429. * Subtract two quaternions
  82430. * @param other defines the second operand
  82431. * @returns a new quaternion as the subtraction result of the given one from the current one
  82432. */
  82433. subtract(other: Quaternion): Quaternion;
  82434. /**
  82435. * Multiplies the current quaternion by a scale factor
  82436. * @param value defines the scale factor
  82437. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  82438. */
  82439. scale(value: number): Quaternion;
  82440. /**
  82441. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  82442. * @param scale defines the scale factor
  82443. * @param result defines the Quaternion object where to store the result
  82444. * @returns the unmodified current quaternion
  82445. */
  82446. scaleToRef(scale: number, result: Quaternion): Quaternion;
  82447. /**
  82448. * Multiplies in place the current quaternion by a scale factor
  82449. * @param value defines the scale factor
  82450. * @returns the current modified quaternion
  82451. */
  82452. scaleInPlace(value: number): Quaternion;
  82453. /**
  82454. * Scale the current quaternion values by a factor and add the result to a given quaternion
  82455. * @param scale defines the scale factor
  82456. * @param result defines the Quaternion object where to store the result
  82457. * @returns the unmodified current quaternion
  82458. */
  82459. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  82460. /**
  82461. * Multiplies two quaternions
  82462. * @param q1 defines the second operand
  82463. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  82464. */
  82465. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  82466. /**
  82467. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  82468. * @param q1 defines the second operand
  82469. * @param result defines the target quaternion
  82470. * @returns the current quaternion
  82471. */
  82472. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  82473. /**
  82474. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  82475. * @param q1 defines the second operand
  82476. * @returns the currentupdated quaternion
  82477. */
  82478. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  82479. /**
  82480. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  82481. * @param ref defines the target quaternion
  82482. * @returns the current quaternion
  82483. */
  82484. conjugateToRef(ref: Quaternion): Quaternion;
  82485. /**
  82486. * Conjugates in place (1-q) the current quaternion
  82487. * @returns the current updated quaternion
  82488. */
  82489. conjugateInPlace(): Quaternion;
  82490. /**
  82491. * Conjugates in place (1-q) the current quaternion
  82492. * @returns a new quaternion
  82493. */
  82494. conjugate(): Quaternion;
  82495. /**
  82496. * Gets length of current quaternion
  82497. * @returns the quaternion length (float)
  82498. */
  82499. length(): number;
  82500. /**
  82501. * Normalize in place the current quaternion
  82502. * @returns the current updated quaternion
  82503. */
  82504. normalize(): Quaternion;
  82505. /**
  82506. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  82507. * @param order is a reserved parameter and is ignore for now
  82508. * @returns a new Vector3 containing the Euler angles
  82509. */
  82510. toEulerAngles(order?: string): Vector3;
  82511. /**
  82512. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  82513. * @param result defines the vector which will be filled with the Euler angles
  82514. * @param order is a reserved parameter and is ignore for now
  82515. * @returns the current unchanged quaternion
  82516. */
  82517. toEulerAnglesToRef(result: Vector3): Quaternion;
  82518. /**
  82519. * Updates the given rotation matrix with the current quaternion values
  82520. * @param result defines the target matrix
  82521. * @returns the current unchanged quaternion
  82522. */
  82523. toRotationMatrix(result: Matrix): Quaternion;
  82524. /**
  82525. * Updates the current quaternion from the given rotation matrix values
  82526. * @param matrix defines the source matrix
  82527. * @returns the current updated quaternion
  82528. */
  82529. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82530. /**
  82531. * Creates a new quaternion from a rotation matrix
  82532. * @param matrix defines the source matrix
  82533. * @returns a new quaternion created from the given rotation matrix values
  82534. */
  82535. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82536. /**
  82537. * Updates the given quaternion with the given rotation matrix values
  82538. * @param matrix defines the source matrix
  82539. * @param result defines the target quaternion
  82540. */
  82541. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  82542. /**
  82543. * Returns the dot product (float) between the quaternions "left" and "right"
  82544. * @param left defines the left operand
  82545. * @param right defines the right operand
  82546. * @returns the dot product
  82547. */
  82548. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  82549. /**
  82550. * Checks if the two quaternions are close to each other
  82551. * @param quat0 defines the first quaternion to check
  82552. * @param quat1 defines the second quaternion to check
  82553. * @returns true if the two quaternions are close to each other
  82554. */
  82555. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  82556. /**
  82557. * Creates an empty quaternion
  82558. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  82559. */
  82560. static Zero(): Quaternion;
  82561. /**
  82562. * Inverse a given quaternion
  82563. * @param q defines the source quaternion
  82564. * @returns a new quaternion as the inverted current quaternion
  82565. */
  82566. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  82567. /**
  82568. * Inverse a given quaternion
  82569. * @param q defines the source quaternion
  82570. * @param result the quaternion the result will be stored in
  82571. * @returns the result quaternion
  82572. */
  82573. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  82574. /**
  82575. * Creates an identity quaternion
  82576. * @returns the identity quaternion
  82577. */
  82578. static Identity(): Quaternion;
  82579. /**
  82580. * Gets a boolean indicating if the given quaternion is identity
  82581. * @param quaternion defines the quaternion to check
  82582. * @returns true if the quaternion is identity
  82583. */
  82584. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  82585. /**
  82586. * Creates a quaternion from a rotation around an axis
  82587. * @param axis defines the axis to use
  82588. * @param angle defines the angle to use
  82589. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  82590. */
  82591. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  82592. /**
  82593. * Creates a rotation around an axis and stores it into the given quaternion
  82594. * @param axis defines the axis to use
  82595. * @param angle defines the angle to use
  82596. * @param result defines the target quaternion
  82597. * @returns the target quaternion
  82598. */
  82599. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  82600. /**
  82601. * Creates a new quaternion from data stored into an array
  82602. * @param array defines the data source
  82603. * @param offset defines the offset in the source array where the data starts
  82604. * @returns a new quaternion
  82605. */
  82606. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  82607. /**
  82608. * Updates the given quaternion "result" from the starting index of the given array.
  82609. * @param array the array to pull values from
  82610. * @param offset the offset into the array to start at
  82611. * @param result the quaternion to store the result in
  82612. */
  82613. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  82614. /**
  82615. * Create a quaternion from Euler rotation angles
  82616. * @param x Pitch
  82617. * @param y Yaw
  82618. * @param z Roll
  82619. * @returns the new Quaternion
  82620. */
  82621. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  82622. /**
  82623. * Updates a quaternion from Euler rotation angles
  82624. * @param x Pitch
  82625. * @param y Yaw
  82626. * @param z Roll
  82627. * @param result the quaternion to store the result
  82628. * @returns the updated quaternion
  82629. */
  82630. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  82631. /**
  82632. * Create a quaternion from Euler rotation vector
  82633. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82634. * @returns the new Quaternion
  82635. */
  82636. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  82637. /**
  82638. * Updates a quaternion from Euler rotation vector
  82639. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82640. * @param result the quaternion to store the result
  82641. * @returns the updated quaternion
  82642. */
  82643. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  82644. /**
  82645. * Creates a new quaternion from the given Euler float angles (y, x, z)
  82646. * @param yaw defines the rotation around Y axis
  82647. * @param pitch defines the rotation around X axis
  82648. * @param roll defines the rotation around Z axis
  82649. * @returns the new quaternion
  82650. */
  82651. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  82652. /**
  82653. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  82654. * @param yaw defines the rotation around Y axis
  82655. * @param pitch defines the rotation around X axis
  82656. * @param roll defines the rotation around Z axis
  82657. * @param result defines the target quaternion
  82658. */
  82659. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  82660. /**
  82661. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  82662. * @param alpha defines the rotation around first axis
  82663. * @param beta defines the rotation around second axis
  82664. * @param gamma defines the rotation around third axis
  82665. * @returns the new quaternion
  82666. */
  82667. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  82668. /**
  82669. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  82670. * @param alpha defines the rotation around first axis
  82671. * @param beta defines the rotation around second axis
  82672. * @param gamma defines the rotation around third axis
  82673. * @param result defines the target quaternion
  82674. */
  82675. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  82676. /**
  82677. * 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)
  82678. * @param axis1 defines the first axis
  82679. * @param axis2 defines the second axis
  82680. * @param axis3 defines the third axis
  82681. * @returns the new quaternion
  82682. */
  82683. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  82684. /**
  82685. * 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
  82686. * @param axis1 defines the first axis
  82687. * @param axis2 defines the second axis
  82688. * @param axis3 defines the third axis
  82689. * @param ref defines the target quaternion
  82690. */
  82691. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  82692. /**
  82693. * Interpolates between two quaternions
  82694. * @param left defines first quaternion
  82695. * @param right defines second quaternion
  82696. * @param amount defines the gradient to use
  82697. * @returns the new interpolated quaternion
  82698. */
  82699. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82700. /**
  82701. * Interpolates between two quaternions and stores it into a target quaternion
  82702. * @param left defines first quaternion
  82703. * @param right defines second quaternion
  82704. * @param amount defines the gradient to use
  82705. * @param result defines the target quaternion
  82706. */
  82707. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  82708. /**
  82709. * Interpolate between two quaternions using Hermite interpolation
  82710. * @param value1 defines first quaternion
  82711. * @param tangent1 defines the incoming tangent
  82712. * @param value2 defines second quaternion
  82713. * @param tangent2 defines the outgoing tangent
  82714. * @param amount defines the target quaternion
  82715. * @returns the new interpolated quaternion
  82716. */
  82717. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82718. }
  82719. /**
  82720. * Class used to store matrix data (4x4)
  82721. */
  82722. export class Matrix {
  82723. /**
  82724. * Gets the precision of matrix computations
  82725. */
  82726. static get Use64Bits(): boolean;
  82727. private static _updateFlagSeed;
  82728. private static _identityReadOnly;
  82729. private _isIdentity;
  82730. private _isIdentityDirty;
  82731. private _isIdentity3x2;
  82732. private _isIdentity3x2Dirty;
  82733. /**
  82734. * Gets the update flag of the matrix which is an unique number for the matrix.
  82735. * It will be incremented every time the matrix data change.
  82736. * You can use it to speed the comparison between two versions of the same matrix.
  82737. */
  82738. updateFlag: number;
  82739. private readonly _m;
  82740. /**
  82741. * Gets the internal data of the matrix
  82742. */
  82743. get m(): DeepImmutable<Float32Array | Array<number>>;
  82744. /** @hidden */
  82745. _markAsUpdated(): void;
  82746. /** @hidden */
  82747. private _updateIdentityStatus;
  82748. /**
  82749. * Creates an empty matrix (filled with zeros)
  82750. */
  82751. constructor();
  82752. /**
  82753. * Check if the current matrix is identity
  82754. * @returns true is the matrix is the identity matrix
  82755. */
  82756. isIdentity(): boolean;
  82757. /**
  82758. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  82759. * @returns true is the matrix is the identity matrix
  82760. */
  82761. isIdentityAs3x2(): boolean;
  82762. /**
  82763. * Gets the determinant of the matrix
  82764. * @returns the matrix determinant
  82765. */
  82766. determinant(): number;
  82767. /**
  82768. * Returns the matrix as a Float32Array or Array<number>
  82769. * @returns the matrix underlying array
  82770. */
  82771. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82772. /**
  82773. * Returns the matrix as a Float32Array or Array<number>
  82774. * @returns the matrix underlying array.
  82775. */
  82776. asArray(): DeepImmutable<Float32Array | Array<number>>;
  82777. /**
  82778. * Inverts the current matrix in place
  82779. * @returns the current inverted matrix
  82780. */
  82781. invert(): Matrix;
  82782. /**
  82783. * Sets all the matrix elements to zero
  82784. * @returns the current matrix
  82785. */
  82786. reset(): Matrix;
  82787. /**
  82788. * Adds the current matrix with a second one
  82789. * @param other defines the matrix to add
  82790. * @returns a new matrix as the addition of the current matrix and the given one
  82791. */
  82792. add(other: DeepImmutable<Matrix>): Matrix;
  82793. /**
  82794. * Sets the given matrix "result" to the addition of the current matrix and the given one
  82795. * @param other defines the matrix to add
  82796. * @param result defines the target matrix
  82797. * @returns the current matrix
  82798. */
  82799. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82800. /**
  82801. * Adds in place the given matrix to the current matrix
  82802. * @param other defines the second operand
  82803. * @returns the current updated matrix
  82804. */
  82805. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  82806. /**
  82807. * Sets the given matrix to the current inverted Matrix
  82808. * @param other defines the target matrix
  82809. * @returns the unmodified current matrix
  82810. */
  82811. invertToRef(other: Matrix): Matrix;
  82812. /**
  82813. * add a value at the specified position in the current Matrix
  82814. * @param index the index of the value within the matrix. between 0 and 15.
  82815. * @param value the value to be added
  82816. * @returns the current updated matrix
  82817. */
  82818. addAtIndex(index: number, value: number): Matrix;
  82819. /**
  82820. * mutiply the specified position in the current Matrix by a value
  82821. * @param index the index of the value within the matrix. between 0 and 15.
  82822. * @param value the value to be added
  82823. * @returns the current updated matrix
  82824. */
  82825. multiplyAtIndex(index: number, value: number): Matrix;
  82826. /**
  82827. * Inserts the translation vector (using 3 floats) in the current matrix
  82828. * @param x defines the 1st component of the translation
  82829. * @param y defines the 2nd component of the translation
  82830. * @param z defines the 3rd component of the translation
  82831. * @returns the current updated matrix
  82832. */
  82833. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  82834. /**
  82835. * Adds the translation vector (using 3 floats) in the current matrix
  82836. * @param x defines the 1st component of the translation
  82837. * @param y defines the 2nd component of the translation
  82838. * @param z defines the 3rd component of the translation
  82839. * @returns the current updated matrix
  82840. */
  82841. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  82842. /**
  82843. * Inserts the translation vector in the current matrix
  82844. * @param vector3 defines the translation to insert
  82845. * @returns the current updated matrix
  82846. */
  82847. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  82848. /**
  82849. * Gets the translation value of the current matrix
  82850. * @returns a new Vector3 as the extracted translation from the matrix
  82851. */
  82852. getTranslation(): Vector3;
  82853. /**
  82854. * Fill a Vector3 with the extracted translation from the matrix
  82855. * @param result defines the Vector3 where to store the translation
  82856. * @returns the current matrix
  82857. */
  82858. getTranslationToRef(result: Vector3): Matrix;
  82859. /**
  82860. * Remove rotation and scaling part from the matrix
  82861. * @returns the updated matrix
  82862. */
  82863. removeRotationAndScaling(): Matrix;
  82864. /**
  82865. * Multiply two matrices
  82866. * @param other defines the second operand
  82867. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  82868. */
  82869. multiply(other: DeepImmutable<Matrix>): Matrix;
  82870. /**
  82871. * Copy the current matrix from the given one
  82872. * @param other defines the source matrix
  82873. * @returns the current updated matrix
  82874. */
  82875. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  82876. /**
  82877. * Populates the given array from the starting index with the current matrix values
  82878. * @param array defines the target array
  82879. * @param offset defines the offset in the target array where to start storing values
  82880. * @returns the current matrix
  82881. */
  82882. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  82883. /**
  82884. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  82885. * @param other defines the second operand
  82886. * @param result defines the matrix where to store the multiplication
  82887. * @returns the current matrix
  82888. */
  82889. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82890. /**
  82891. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  82892. * @param other defines the second operand
  82893. * @param result defines the array where to store the multiplication
  82894. * @param offset defines the offset in the target array where to start storing values
  82895. * @returns the current matrix
  82896. */
  82897. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  82898. /**
  82899. * Check equality between this matrix and a second one
  82900. * @param value defines the second matrix to compare
  82901. * @returns true is the current matrix and the given one values are strictly equal
  82902. */
  82903. equals(value: DeepImmutable<Matrix>): boolean;
  82904. /**
  82905. * Clone the current matrix
  82906. * @returns a new matrix from the current matrix
  82907. */
  82908. clone(): Matrix;
  82909. /**
  82910. * Returns the name of the current matrix class
  82911. * @returns the string "Matrix"
  82912. */
  82913. getClassName(): string;
  82914. /**
  82915. * Gets the hash code of the current matrix
  82916. * @returns the hash code
  82917. */
  82918. getHashCode(): number;
  82919. /**
  82920. * Decomposes the current Matrix into a translation, rotation and scaling components
  82921. * @param scale defines the scale vector3 given as a reference to update
  82922. * @param rotation defines the rotation quaternion given as a reference to update
  82923. * @param translation defines the translation vector3 given as a reference to update
  82924. * @returns true if operation was successful
  82925. */
  82926. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  82927. /**
  82928. * Gets specific row of the matrix
  82929. * @param index defines the number of the row to get
  82930. * @returns the index-th row of the current matrix as a new Vector4
  82931. */
  82932. getRow(index: number): Nullable<Vector4>;
  82933. /**
  82934. * Sets the index-th row of the current matrix to the vector4 values
  82935. * @param index defines the number of the row to set
  82936. * @param row defines the target vector4
  82937. * @returns the updated current matrix
  82938. */
  82939. setRow(index: number, row: Vector4): Matrix;
  82940. /**
  82941. * Compute the transpose of the matrix
  82942. * @returns the new transposed matrix
  82943. */
  82944. transpose(): Matrix;
  82945. /**
  82946. * Compute the transpose of the matrix and store it in a given matrix
  82947. * @param result defines the target matrix
  82948. * @returns the current matrix
  82949. */
  82950. transposeToRef(result: Matrix): Matrix;
  82951. /**
  82952. * Sets the index-th row of the current matrix with the given 4 x float values
  82953. * @param index defines the row index
  82954. * @param x defines the x component to set
  82955. * @param y defines the y component to set
  82956. * @param z defines the z component to set
  82957. * @param w defines the w component to set
  82958. * @returns the updated current matrix
  82959. */
  82960. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  82961. /**
  82962. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  82963. * @param scale defines the scale factor
  82964. * @returns a new matrix
  82965. */
  82966. scale(scale: number): Matrix;
  82967. /**
  82968. * Scale the current matrix values by a factor to a given result matrix
  82969. * @param scale defines the scale factor
  82970. * @param result defines the matrix to store the result
  82971. * @returns the current matrix
  82972. */
  82973. scaleToRef(scale: number, result: Matrix): Matrix;
  82974. /**
  82975. * Scale the current matrix values by a factor and add the result to a given matrix
  82976. * @param scale defines the scale factor
  82977. * @param result defines the Matrix to store the result
  82978. * @returns the current matrix
  82979. */
  82980. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  82981. /**
  82982. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  82983. * @param ref matrix to store the result
  82984. */
  82985. toNormalMatrix(ref: Matrix): void;
  82986. /**
  82987. * Gets only rotation part of the current matrix
  82988. * @returns a new matrix sets to the extracted rotation matrix from the current one
  82989. */
  82990. getRotationMatrix(): Matrix;
  82991. /**
  82992. * Extracts the rotation matrix from the current one and sets it as the given "result"
  82993. * @param result defines the target matrix to store data to
  82994. * @returns the current matrix
  82995. */
  82996. getRotationMatrixToRef(result: Matrix): Matrix;
  82997. /**
  82998. * Toggles model matrix from being right handed to left handed in place and vice versa
  82999. */
  83000. toggleModelMatrixHandInPlace(): void;
  83001. /**
  83002. * Toggles projection matrix from being right handed to left handed in place and vice versa
  83003. */
  83004. toggleProjectionMatrixHandInPlace(): void;
  83005. /**
  83006. * Creates a matrix from an array
  83007. * @param array defines the source array
  83008. * @param offset defines an offset in the source array
  83009. * @returns a new Matrix set from the starting index of the given array
  83010. */
  83011. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  83012. /**
  83013. * Copy the content of an array into a given matrix
  83014. * @param array defines the source array
  83015. * @param offset defines an offset in the source array
  83016. * @param result defines the target matrix
  83017. */
  83018. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  83019. /**
  83020. * Stores an array into a matrix after having multiplied each component by a given factor
  83021. * @param array defines the source array
  83022. * @param offset defines the offset in the source array
  83023. * @param scale defines the scaling factor
  83024. * @param result defines the target matrix
  83025. */
  83026. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  83027. /**
  83028. * Gets an identity matrix that must not be updated
  83029. */
  83030. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  83031. /**
  83032. * Stores a list of values (16) inside a given matrix
  83033. * @param initialM11 defines 1st value of 1st row
  83034. * @param initialM12 defines 2nd value of 1st row
  83035. * @param initialM13 defines 3rd value of 1st row
  83036. * @param initialM14 defines 4th value of 1st row
  83037. * @param initialM21 defines 1st value of 2nd row
  83038. * @param initialM22 defines 2nd value of 2nd row
  83039. * @param initialM23 defines 3rd value of 2nd row
  83040. * @param initialM24 defines 4th value of 2nd row
  83041. * @param initialM31 defines 1st value of 3rd row
  83042. * @param initialM32 defines 2nd value of 3rd row
  83043. * @param initialM33 defines 3rd value of 3rd row
  83044. * @param initialM34 defines 4th value of 3rd row
  83045. * @param initialM41 defines 1st value of 4th row
  83046. * @param initialM42 defines 2nd value of 4th row
  83047. * @param initialM43 defines 3rd value of 4th row
  83048. * @param initialM44 defines 4th value of 4th row
  83049. * @param result defines the target matrix
  83050. */
  83051. 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;
  83052. /**
  83053. * Creates new matrix from a list of values (16)
  83054. * @param initialM11 defines 1st value of 1st row
  83055. * @param initialM12 defines 2nd value of 1st row
  83056. * @param initialM13 defines 3rd value of 1st row
  83057. * @param initialM14 defines 4th value of 1st row
  83058. * @param initialM21 defines 1st value of 2nd row
  83059. * @param initialM22 defines 2nd value of 2nd row
  83060. * @param initialM23 defines 3rd value of 2nd row
  83061. * @param initialM24 defines 4th value of 2nd row
  83062. * @param initialM31 defines 1st value of 3rd row
  83063. * @param initialM32 defines 2nd value of 3rd row
  83064. * @param initialM33 defines 3rd value of 3rd row
  83065. * @param initialM34 defines 4th value of 3rd row
  83066. * @param initialM41 defines 1st value of 4th row
  83067. * @param initialM42 defines 2nd value of 4th row
  83068. * @param initialM43 defines 3rd value of 4th row
  83069. * @param initialM44 defines 4th value of 4th row
  83070. * @returns the new matrix
  83071. */
  83072. 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;
  83073. /**
  83074. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  83075. * @param scale defines the scale vector3
  83076. * @param rotation defines the rotation quaternion
  83077. * @param translation defines the translation vector3
  83078. * @returns a new matrix
  83079. */
  83080. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  83081. /**
  83082. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  83083. * @param scale defines the scale vector3
  83084. * @param rotation defines the rotation quaternion
  83085. * @param translation defines the translation vector3
  83086. * @param result defines the target matrix
  83087. */
  83088. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  83089. /**
  83090. * Creates a new identity matrix
  83091. * @returns a new identity matrix
  83092. */
  83093. static Identity(): Matrix;
  83094. /**
  83095. * Creates a new identity matrix and stores the result in a given matrix
  83096. * @param result defines the target matrix
  83097. */
  83098. static IdentityToRef(result: Matrix): void;
  83099. /**
  83100. * Creates a new zero matrix
  83101. * @returns a new zero matrix
  83102. */
  83103. static Zero(): Matrix;
  83104. /**
  83105. * Creates a new rotation matrix for "angle" radians around the X axis
  83106. * @param angle defines the angle (in radians) to use
  83107. * @return the new matrix
  83108. */
  83109. static RotationX(angle: number): Matrix;
  83110. /**
  83111. * Creates a new matrix as the invert of a given matrix
  83112. * @param source defines the source matrix
  83113. * @returns the new matrix
  83114. */
  83115. static Invert(source: DeepImmutable<Matrix>): Matrix;
  83116. /**
  83117. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  83118. * @param angle defines the angle (in radians) to use
  83119. * @param result defines the target matrix
  83120. */
  83121. static RotationXToRef(angle: number, result: Matrix): void;
  83122. /**
  83123. * Creates a new rotation matrix for "angle" radians around the Y axis
  83124. * @param angle defines the angle (in radians) to use
  83125. * @return the new matrix
  83126. */
  83127. static RotationY(angle: number): Matrix;
  83128. /**
  83129. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  83130. * @param angle defines the angle (in radians) to use
  83131. * @param result defines the target matrix
  83132. */
  83133. static RotationYToRef(angle: number, result: Matrix): void;
  83134. /**
  83135. * Creates a new rotation matrix for "angle" radians around the Z axis
  83136. * @param angle defines the angle (in radians) to use
  83137. * @return the new matrix
  83138. */
  83139. static RotationZ(angle: number): Matrix;
  83140. /**
  83141. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  83142. * @param angle defines the angle (in radians) to use
  83143. * @param result defines the target matrix
  83144. */
  83145. static RotationZToRef(angle: number, result: Matrix): void;
  83146. /**
  83147. * Creates a new rotation matrix for "angle" radians around the given axis
  83148. * @param axis defines the axis to use
  83149. * @param angle defines the angle (in radians) to use
  83150. * @return the new matrix
  83151. */
  83152. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  83153. /**
  83154. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  83155. * @param axis defines the axis to use
  83156. * @param angle defines the angle (in radians) to use
  83157. * @param result defines the target matrix
  83158. */
  83159. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  83160. /**
  83161. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  83162. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  83163. * @param from defines the vector to align
  83164. * @param to defines the vector to align to
  83165. * @param result defines the target matrix
  83166. */
  83167. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  83168. /**
  83169. * Creates a rotation matrix
  83170. * @param yaw defines the yaw angle in radians (Y axis)
  83171. * @param pitch defines the pitch angle in radians (X axis)
  83172. * @param roll defines the roll angle in radians (Z axis)
  83173. * @returns the new rotation matrix
  83174. */
  83175. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  83176. /**
  83177. * Creates a rotation matrix and stores it in a given matrix
  83178. * @param yaw defines the yaw angle in radians (Y axis)
  83179. * @param pitch defines the pitch angle in radians (X axis)
  83180. * @param roll defines the roll angle in radians (Z axis)
  83181. * @param result defines the target matrix
  83182. */
  83183. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  83184. /**
  83185. * Creates a scaling matrix
  83186. * @param x defines the scale factor on X axis
  83187. * @param y defines the scale factor on Y axis
  83188. * @param z defines the scale factor on Z axis
  83189. * @returns the new matrix
  83190. */
  83191. static Scaling(x: number, y: number, z: number): Matrix;
  83192. /**
  83193. * Creates a scaling matrix and stores it in a given matrix
  83194. * @param x defines the scale factor on X axis
  83195. * @param y defines the scale factor on Y axis
  83196. * @param z defines the scale factor on Z axis
  83197. * @param result defines the target matrix
  83198. */
  83199. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  83200. /**
  83201. * Creates a translation matrix
  83202. * @param x defines the translation on X axis
  83203. * @param y defines the translation on Y axis
  83204. * @param z defines the translationon Z axis
  83205. * @returns the new matrix
  83206. */
  83207. static Translation(x: number, y: number, z: number): Matrix;
  83208. /**
  83209. * Creates a translation matrix and stores it in a given matrix
  83210. * @param x defines the translation on X axis
  83211. * @param y defines the translation on Y axis
  83212. * @param z defines the translationon Z axis
  83213. * @param result defines the target matrix
  83214. */
  83215. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  83216. /**
  83217. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83218. * @param startValue defines the start value
  83219. * @param endValue defines the end value
  83220. * @param gradient defines the gradient factor
  83221. * @returns the new matrix
  83222. */
  83223. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83224. /**
  83225. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83226. * @param startValue defines the start value
  83227. * @param endValue defines the end value
  83228. * @param gradient defines the gradient factor
  83229. * @param result defines the Matrix object where to store data
  83230. */
  83231. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83232. /**
  83233. * Builds a new matrix whose values are computed by:
  83234. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83235. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83236. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83237. * @param startValue defines the first matrix
  83238. * @param endValue defines the second matrix
  83239. * @param gradient defines the gradient between the two matrices
  83240. * @returns the new matrix
  83241. */
  83242. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83243. /**
  83244. * Update a matrix to values which are computed by:
  83245. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83246. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83247. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83248. * @param startValue defines the first matrix
  83249. * @param endValue defines the second matrix
  83250. * @param gradient defines the gradient between the two matrices
  83251. * @param result defines the target matrix
  83252. */
  83253. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83254. /**
  83255. * 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"
  83256. * This function works in left handed mode
  83257. * @param eye defines the final position of the entity
  83258. * @param target defines where the entity should look at
  83259. * @param up defines the up vector for the entity
  83260. * @returns the new matrix
  83261. */
  83262. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83263. /**
  83264. * 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".
  83265. * This function works in left handed mode
  83266. * @param eye defines the final position of the entity
  83267. * @param target defines where the entity should look at
  83268. * @param up defines the up vector for the entity
  83269. * @param result defines the target matrix
  83270. */
  83271. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83272. /**
  83273. * 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"
  83274. * This function works in right handed mode
  83275. * @param eye defines the final position of the entity
  83276. * @param target defines where the entity should look at
  83277. * @param up defines the up vector for the entity
  83278. * @returns the new matrix
  83279. */
  83280. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83281. /**
  83282. * 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".
  83283. * This function works in right handed mode
  83284. * @param eye defines the final position of the entity
  83285. * @param target defines where the entity should look at
  83286. * @param up defines the up vector for the entity
  83287. * @param result defines the target matrix
  83288. */
  83289. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83290. /**
  83291. * Create a left-handed orthographic projection matrix
  83292. * @param width defines the viewport width
  83293. * @param height defines the viewport height
  83294. * @param znear defines the near clip plane
  83295. * @param zfar defines the far clip plane
  83296. * @returns a new matrix as a left-handed orthographic projection matrix
  83297. */
  83298. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83299. /**
  83300. * Store a left-handed orthographic projection to a given matrix
  83301. * @param width defines the viewport width
  83302. * @param height defines the viewport height
  83303. * @param znear defines the near clip plane
  83304. * @param zfar defines the far clip plane
  83305. * @param result defines the target matrix
  83306. */
  83307. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  83308. /**
  83309. * Create a left-handed orthographic projection matrix
  83310. * @param left defines the viewport left coordinate
  83311. * @param right defines the viewport right coordinate
  83312. * @param bottom defines the viewport bottom coordinate
  83313. * @param top defines the viewport top coordinate
  83314. * @param znear defines the near clip plane
  83315. * @param zfar defines the far clip plane
  83316. * @returns a new matrix as a left-handed orthographic projection matrix
  83317. */
  83318. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83319. /**
  83320. * Stores a left-handed orthographic projection into a given matrix
  83321. * @param left defines the viewport left coordinate
  83322. * @param right defines the viewport right coordinate
  83323. * @param bottom defines the viewport bottom coordinate
  83324. * @param top defines the viewport top coordinate
  83325. * @param znear defines the near clip plane
  83326. * @param zfar defines the far clip plane
  83327. * @param result defines the target matrix
  83328. */
  83329. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83330. /**
  83331. * Creates a right-handed orthographic projection matrix
  83332. * @param left defines the viewport left coordinate
  83333. * @param right defines the viewport right coordinate
  83334. * @param bottom defines the viewport bottom coordinate
  83335. * @param top defines the viewport top coordinate
  83336. * @param znear defines the near clip plane
  83337. * @param zfar defines the far clip plane
  83338. * @returns a new matrix as a right-handed orthographic projection matrix
  83339. */
  83340. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83341. /**
  83342. * Stores a right-handed orthographic projection into a given matrix
  83343. * @param left defines the viewport left coordinate
  83344. * @param right defines the viewport right coordinate
  83345. * @param bottom defines the viewport bottom coordinate
  83346. * @param top defines the viewport top coordinate
  83347. * @param znear defines the near clip plane
  83348. * @param zfar defines the far clip plane
  83349. * @param result defines the target matrix
  83350. */
  83351. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83352. /**
  83353. * Creates a left-handed perspective projection matrix
  83354. * @param width defines the viewport width
  83355. * @param height defines the viewport height
  83356. * @param znear defines the near clip plane
  83357. * @param zfar defines the far clip plane
  83358. * @returns a new matrix as a left-handed perspective projection matrix
  83359. */
  83360. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83361. /**
  83362. * Creates a left-handed perspective projection matrix
  83363. * @param fov defines the horizontal field of view
  83364. * @param aspect defines the aspect ratio
  83365. * @param znear defines the near clip plane
  83366. * @param zfar defines the far clip plane
  83367. * @returns a new matrix as a left-handed perspective projection matrix
  83368. */
  83369. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83370. /**
  83371. * Stores a left-handed perspective projection into a given matrix
  83372. * @param fov defines the horizontal field of view
  83373. * @param aspect defines the aspect ratio
  83374. * @param znear defines the near clip plane
  83375. * @param zfar defines the far clip plane
  83376. * @param result defines the target matrix
  83377. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83378. */
  83379. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83380. /**
  83381. * Stores a left-handed perspective projection into a given matrix with depth reversed
  83382. * @param fov defines the horizontal field of view
  83383. * @param aspect defines the aspect ratio
  83384. * @param znear defines the near clip plane
  83385. * @param zfar not used as infinity is used as far clip
  83386. * @param result defines the target matrix
  83387. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83388. */
  83389. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83390. /**
  83391. * Creates a right-handed perspective projection matrix
  83392. * @param fov defines the horizontal field of view
  83393. * @param aspect defines the aspect ratio
  83394. * @param znear defines the near clip plane
  83395. * @param zfar defines the far clip plane
  83396. * @returns a new matrix as a right-handed perspective projection matrix
  83397. */
  83398. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83399. /**
  83400. * Stores a right-handed perspective projection into a given matrix
  83401. * @param fov defines the horizontal field of view
  83402. * @param aspect defines the aspect ratio
  83403. * @param znear defines the near clip plane
  83404. * @param zfar defines the far clip plane
  83405. * @param result defines the target matrix
  83406. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83407. */
  83408. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83409. /**
  83410. * Stores a right-handed perspective projection into a given matrix
  83411. * @param fov defines the horizontal field of view
  83412. * @param aspect defines the aspect ratio
  83413. * @param znear defines the near clip plane
  83414. * @param zfar not used as infinity is used as far clip
  83415. * @param result defines the target matrix
  83416. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83417. */
  83418. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83419. /**
  83420. * Stores a perspective projection for WebVR info a given matrix
  83421. * @param fov defines the field of view
  83422. * @param znear defines the near clip plane
  83423. * @param zfar defines the far clip plane
  83424. * @param result defines the target matrix
  83425. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  83426. */
  83427. static PerspectiveFovWebVRToRef(fov: {
  83428. upDegrees: number;
  83429. downDegrees: number;
  83430. leftDegrees: number;
  83431. rightDegrees: number;
  83432. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  83433. /**
  83434. * Computes a complete transformation matrix
  83435. * @param viewport defines the viewport to use
  83436. * @param world defines the world matrix
  83437. * @param view defines the view matrix
  83438. * @param projection defines the projection matrix
  83439. * @param zmin defines the near clip plane
  83440. * @param zmax defines the far clip plane
  83441. * @returns the transformation matrix
  83442. */
  83443. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  83444. /**
  83445. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  83446. * @param matrix defines the matrix to use
  83447. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  83448. */
  83449. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  83450. /**
  83451. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  83452. * @param matrix defines the matrix to use
  83453. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  83454. */
  83455. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  83456. /**
  83457. * Compute the transpose of a given matrix
  83458. * @param matrix defines the matrix to transpose
  83459. * @returns the new matrix
  83460. */
  83461. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  83462. /**
  83463. * Compute the transpose of a matrix and store it in a target matrix
  83464. * @param matrix defines the matrix to transpose
  83465. * @param result defines the target matrix
  83466. */
  83467. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  83468. /**
  83469. * Computes a reflection matrix from a plane
  83470. * @param plane defines the reflection plane
  83471. * @returns a new matrix
  83472. */
  83473. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  83474. /**
  83475. * Computes a reflection matrix from a plane
  83476. * @param plane defines the reflection plane
  83477. * @param result defines the target matrix
  83478. */
  83479. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  83480. /**
  83481. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  83482. * @param xaxis defines the value of the 1st axis
  83483. * @param yaxis defines the value of the 2nd axis
  83484. * @param zaxis defines the value of the 3rd axis
  83485. * @param result defines the target matrix
  83486. */
  83487. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  83488. /**
  83489. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  83490. * @param quat defines the quaternion to use
  83491. * @param result defines the target matrix
  83492. */
  83493. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  83494. }
  83495. /**
  83496. * @hidden
  83497. */
  83498. export class TmpVectors {
  83499. static Vector2: Vector2[];
  83500. static Vector3: Vector3[];
  83501. static Vector4: Vector4[];
  83502. static Quaternion: Quaternion[];
  83503. static Matrix: Matrix[];
  83504. }
  83505. }
  83506. declare module BABYLON {
  83507. /**
  83508. * Defines potential orientation for back face culling
  83509. */
  83510. export enum Orientation {
  83511. /**
  83512. * Clockwise
  83513. */
  83514. CW = 0,
  83515. /** Counter clockwise */
  83516. CCW = 1
  83517. }
  83518. /** Class used to represent a Bezier curve */
  83519. export class BezierCurve {
  83520. /**
  83521. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  83522. * @param t defines the time
  83523. * @param x1 defines the left coordinate on X axis
  83524. * @param y1 defines the left coordinate on Y axis
  83525. * @param x2 defines the right coordinate on X axis
  83526. * @param y2 defines the right coordinate on Y axis
  83527. * @returns the interpolated value
  83528. */
  83529. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  83530. }
  83531. /**
  83532. * Defines angle representation
  83533. */
  83534. export class Angle {
  83535. private _radians;
  83536. /**
  83537. * Creates an Angle object of "radians" radians (float).
  83538. * @param radians the angle in radians
  83539. */
  83540. constructor(radians: number);
  83541. /**
  83542. * Get value in degrees
  83543. * @returns the Angle value in degrees (float)
  83544. */
  83545. degrees(): number;
  83546. /**
  83547. * Get value in radians
  83548. * @returns the Angle value in radians (float)
  83549. */
  83550. radians(): number;
  83551. /**
  83552. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  83553. * @param a defines first point as the origin
  83554. * @param b defines point
  83555. * @returns a new Angle
  83556. */
  83557. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  83558. /**
  83559. * Gets a new Angle object from the given float in radians
  83560. * @param radians defines the angle value in radians
  83561. * @returns a new Angle
  83562. */
  83563. static FromRadians(radians: number): Angle;
  83564. /**
  83565. * Gets a new Angle object from the given float in degrees
  83566. * @param degrees defines the angle value in degrees
  83567. * @returns a new Angle
  83568. */
  83569. static FromDegrees(degrees: number): Angle;
  83570. }
  83571. /**
  83572. * This represents an arc in a 2d space.
  83573. */
  83574. export class Arc2 {
  83575. /** Defines the start point of the arc */
  83576. startPoint: Vector2;
  83577. /** Defines the mid point of the arc */
  83578. midPoint: Vector2;
  83579. /** Defines the end point of the arc */
  83580. endPoint: Vector2;
  83581. /**
  83582. * Defines the center point of the arc.
  83583. */
  83584. centerPoint: Vector2;
  83585. /**
  83586. * Defines the radius of the arc.
  83587. */
  83588. radius: number;
  83589. /**
  83590. * Defines the angle of the arc (from mid point to end point).
  83591. */
  83592. angle: Angle;
  83593. /**
  83594. * Defines the start angle of the arc (from start point to middle point).
  83595. */
  83596. startAngle: Angle;
  83597. /**
  83598. * Defines the orientation of the arc (clock wise/counter clock wise).
  83599. */
  83600. orientation: Orientation;
  83601. /**
  83602. * Creates an Arc object from the three given points : start, middle and end.
  83603. * @param startPoint Defines the start point of the arc
  83604. * @param midPoint Defines the midlle point of the arc
  83605. * @param endPoint Defines the end point of the arc
  83606. */
  83607. constructor(
  83608. /** Defines the start point of the arc */
  83609. startPoint: Vector2,
  83610. /** Defines the mid point of the arc */
  83611. midPoint: Vector2,
  83612. /** Defines the end point of the arc */
  83613. endPoint: Vector2);
  83614. }
  83615. /**
  83616. * Represents a 2D path made up of multiple 2D points
  83617. */
  83618. export class Path2 {
  83619. private _points;
  83620. private _length;
  83621. /**
  83622. * If the path start and end point are the same
  83623. */
  83624. closed: boolean;
  83625. /**
  83626. * Creates a Path2 object from the starting 2D coordinates x and y.
  83627. * @param x the starting points x value
  83628. * @param y the starting points y value
  83629. */
  83630. constructor(x: number, y: number);
  83631. /**
  83632. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  83633. * @param x the added points x value
  83634. * @param y the added points y value
  83635. * @returns the updated Path2.
  83636. */
  83637. addLineTo(x: number, y: number): Path2;
  83638. /**
  83639. * 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.
  83640. * @param midX middle point x value
  83641. * @param midY middle point y value
  83642. * @param endX end point x value
  83643. * @param endY end point y value
  83644. * @param numberOfSegments (default: 36)
  83645. * @returns the updated Path2.
  83646. */
  83647. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  83648. /**
  83649. * Closes the Path2.
  83650. * @returns the Path2.
  83651. */
  83652. close(): Path2;
  83653. /**
  83654. * Gets the sum of the distance between each sequential point in the path
  83655. * @returns the Path2 total length (float).
  83656. */
  83657. length(): number;
  83658. /**
  83659. * Gets the points which construct the path
  83660. * @returns the Path2 internal array of points.
  83661. */
  83662. getPoints(): Vector2[];
  83663. /**
  83664. * Retreives the point at the distance aways from the starting point
  83665. * @param normalizedLengthPosition the length along the path to retreive the point from
  83666. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  83667. */
  83668. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  83669. /**
  83670. * Creates a new path starting from an x and y position
  83671. * @param x starting x value
  83672. * @param y starting y value
  83673. * @returns a new Path2 starting at the coordinates (x, y).
  83674. */
  83675. static StartingAt(x: number, y: number): Path2;
  83676. }
  83677. /**
  83678. * Represents a 3D path made up of multiple 3D points
  83679. */
  83680. export class Path3D {
  83681. /**
  83682. * an array of Vector3, the curve axis of the Path3D
  83683. */
  83684. path: Vector3[];
  83685. private _curve;
  83686. private _distances;
  83687. private _tangents;
  83688. private _normals;
  83689. private _binormals;
  83690. private _raw;
  83691. private _alignTangentsWithPath;
  83692. private readonly _pointAtData;
  83693. /**
  83694. * new Path3D(path, normal, raw)
  83695. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  83696. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  83697. * @param path an array of Vector3, the curve axis of the Path3D
  83698. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  83699. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  83700. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  83701. */
  83702. constructor(
  83703. /**
  83704. * an array of Vector3, the curve axis of the Path3D
  83705. */
  83706. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  83707. /**
  83708. * Returns the Path3D array of successive Vector3 designing its curve.
  83709. * @returns the Path3D array of successive Vector3 designing its curve.
  83710. */
  83711. getCurve(): Vector3[];
  83712. /**
  83713. * Returns the Path3D array of successive Vector3 designing its curve.
  83714. * @returns the Path3D array of successive Vector3 designing its curve.
  83715. */
  83716. getPoints(): Vector3[];
  83717. /**
  83718. * @returns the computed length (float) of the path.
  83719. */
  83720. length(): number;
  83721. /**
  83722. * Returns an array populated with tangent vectors on each Path3D curve point.
  83723. * @returns an array populated with tangent vectors on each Path3D curve point.
  83724. */
  83725. getTangents(): Vector3[];
  83726. /**
  83727. * Returns an array populated with normal vectors on each Path3D curve point.
  83728. * @returns an array populated with normal vectors on each Path3D curve point.
  83729. */
  83730. getNormals(): Vector3[];
  83731. /**
  83732. * Returns an array populated with binormal vectors on each Path3D curve point.
  83733. * @returns an array populated with binormal vectors on each Path3D curve point.
  83734. */
  83735. getBinormals(): Vector3[];
  83736. /**
  83737. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  83738. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  83739. */
  83740. getDistances(): number[];
  83741. /**
  83742. * Returns an interpolated point along this path
  83743. * @param position the position of the point along this path, from 0.0 to 1.0
  83744. * @returns a new Vector3 as the point
  83745. */
  83746. getPointAt(position: number): Vector3;
  83747. /**
  83748. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83749. * @param position the position of the point along this path, from 0.0 to 1.0
  83750. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  83751. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  83752. */
  83753. getTangentAt(position: number, interpolated?: boolean): Vector3;
  83754. /**
  83755. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83756. * @param position the position of the point along this path, from 0.0 to 1.0
  83757. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  83758. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  83759. */
  83760. getNormalAt(position: number, interpolated?: boolean): Vector3;
  83761. /**
  83762. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  83763. * @param position the position of the point along this path, from 0.0 to 1.0
  83764. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  83765. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  83766. */
  83767. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  83768. /**
  83769. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  83770. * @param position the position of the point along this path, from 0.0 to 1.0
  83771. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  83772. */
  83773. getDistanceAt(position: number): number;
  83774. /**
  83775. * Returns the array index of the previous point of an interpolated point along this path
  83776. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83777. * @returns the array index
  83778. */
  83779. getPreviousPointIndexAt(position: number): number;
  83780. /**
  83781. * 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)
  83782. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83783. * @returns the sub position
  83784. */
  83785. getSubPositionAt(position: number): number;
  83786. /**
  83787. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  83788. * @param target the vector of which to get the closest position to
  83789. * @returns the position of the closest virtual point on this path to the target vector
  83790. */
  83791. getClosestPositionTo(target: Vector3): number;
  83792. /**
  83793. * Returns a sub path (slice) of this path
  83794. * @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
  83795. * @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
  83796. * @returns a sub path (slice) of this path
  83797. */
  83798. slice(start?: number, end?: number): Path3D;
  83799. /**
  83800. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  83801. * @param path path which all values are copied into the curves points
  83802. * @param firstNormal which should be projected onto the curve
  83803. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  83804. * @returns the same object updated.
  83805. */
  83806. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  83807. private _compute;
  83808. private _getFirstNonNullVector;
  83809. private _getLastNonNullVector;
  83810. private _normalVector;
  83811. /**
  83812. * Updates the point at data for an interpolated point along this curve
  83813. * @param position the position of the point along this curve, from 0.0 to 1.0
  83814. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  83815. * @returns the (updated) point at data
  83816. */
  83817. private _updatePointAtData;
  83818. /**
  83819. * Updates the point at data from the specified parameters
  83820. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  83821. * @param point the interpolated point
  83822. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  83823. */
  83824. private _setPointAtData;
  83825. /**
  83826. * Updates the point at interpolation matrix for the tangents, normals and binormals
  83827. */
  83828. private _updateInterpolationMatrix;
  83829. }
  83830. /**
  83831. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  83832. * A Curve3 is designed from a series of successive Vector3.
  83833. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  83834. */
  83835. export class Curve3 {
  83836. private _points;
  83837. private _length;
  83838. /**
  83839. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  83840. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  83841. * @param v1 (Vector3) the control point
  83842. * @param v2 (Vector3) the end point of the Quadratic Bezier
  83843. * @param nbPoints (integer) the wanted number of points in the curve
  83844. * @returns the created Curve3
  83845. */
  83846. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83847. /**
  83848. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  83849. * @param v0 (Vector3) the origin point of the Cubic Bezier
  83850. * @param v1 (Vector3) the first control point
  83851. * @param v2 (Vector3) the second control point
  83852. * @param v3 (Vector3) the end point of the Cubic Bezier
  83853. * @param nbPoints (integer) the wanted number of points in the curve
  83854. * @returns the created Curve3
  83855. */
  83856. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83857. /**
  83858. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  83859. * @param p1 (Vector3) the origin point of the Hermite Spline
  83860. * @param t1 (Vector3) the tangent vector at the origin point
  83861. * @param p2 (Vector3) the end point of the Hermite Spline
  83862. * @param t2 (Vector3) the tangent vector at the end point
  83863. * @param nbPoints (integer) the wanted number of points in the curve
  83864. * @returns the created Curve3
  83865. */
  83866. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83867. /**
  83868. * Returns a Curve3 object along a CatmullRom Spline curve :
  83869. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  83870. * @param nbPoints (integer) the wanted number of points between each curve control points
  83871. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  83872. * @returns the created Curve3
  83873. */
  83874. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  83875. /**
  83876. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  83877. * A Curve3 is designed from a series of successive Vector3.
  83878. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  83879. * @param points points which make up the curve
  83880. */
  83881. constructor(points: Vector3[]);
  83882. /**
  83883. * @returns the Curve3 stored array of successive Vector3
  83884. */
  83885. getPoints(): Vector3[];
  83886. /**
  83887. * @returns the computed length (float) of the curve.
  83888. */
  83889. length(): number;
  83890. /**
  83891. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  83892. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  83893. * curveA and curveB keep unchanged.
  83894. * @param curve the curve to continue from this curve
  83895. * @returns the newly constructed curve
  83896. */
  83897. continue(curve: DeepImmutable<Curve3>): Curve3;
  83898. private _computeLength;
  83899. }
  83900. }
  83901. declare module BABYLON {
  83902. /**
  83903. * This represents the main contract an easing function should follow.
  83904. * Easing functions are used throughout the animation system.
  83905. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83906. */
  83907. export interface IEasingFunction {
  83908. /**
  83909. * Given an input gradient between 0 and 1, this returns the corrseponding value
  83910. * of the easing function.
  83911. * The link below provides some of the most common examples of easing functions.
  83912. * @see https://easings.net/
  83913. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83914. * @returns the corresponding value on the curve defined by the easing function
  83915. */
  83916. ease(gradient: number): number;
  83917. }
  83918. /**
  83919. * Base class used for every default easing function.
  83920. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83921. */
  83922. export class EasingFunction implements IEasingFunction {
  83923. /**
  83924. * Interpolation follows the mathematical formula associated with the easing function.
  83925. */
  83926. static readonly EASINGMODE_EASEIN: number;
  83927. /**
  83928. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  83929. */
  83930. static readonly EASINGMODE_EASEOUT: number;
  83931. /**
  83932. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  83933. */
  83934. static readonly EASINGMODE_EASEINOUT: number;
  83935. private _easingMode;
  83936. /**
  83937. * Sets the easing mode of the current function.
  83938. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  83939. */
  83940. setEasingMode(easingMode: number): void;
  83941. /**
  83942. * Gets the current easing mode.
  83943. * @returns the easing mode
  83944. */
  83945. getEasingMode(): number;
  83946. /**
  83947. * @hidden
  83948. */
  83949. easeInCore(gradient: number): number;
  83950. /**
  83951. * Given an input gradient between 0 and 1, this returns the corresponding value
  83952. * of the easing function.
  83953. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83954. * @returns the corresponding value on the curve defined by the easing function
  83955. */
  83956. ease(gradient: number): number;
  83957. }
  83958. /**
  83959. * Easing function with a circle shape (see link below).
  83960. * @see https://easings.net/#easeInCirc
  83961. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83962. */
  83963. export class CircleEase extends EasingFunction implements IEasingFunction {
  83964. /** @hidden */
  83965. easeInCore(gradient: number): number;
  83966. }
  83967. /**
  83968. * Easing function with a ease back shape (see link below).
  83969. * @see https://easings.net/#easeInBack
  83970. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83971. */
  83972. export class BackEase extends EasingFunction implements IEasingFunction {
  83973. /** Defines the amplitude of the function */
  83974. amplitude: number;
  83975. /**
  83976. * Instantiates a back ease easing
  83977. * @see https://easings.net/#easeInBack
  83978. * @param amplitude Defines the amplitude of the function
  83979. */
  83980. constructor(
  83981. /** Defines the amplitude of the function */
  83982. amplitude?: number);
  83983. /** @hidden */
  83984. easeInCore(gradient: number): number;
  83985. }
  83986. /**
  83987. * Easing function with a bouncing shape (see link below).
  83988. * @see https://easings.net/#easeInBounce
  83989. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83990. */
  83991. export class BounceEase extends EasingFunction implements IEasingFunction {
  83992. /** Defines the number of bounces */
  83993. bounces: number;
  83994. /** Defines the amplitude of the bounce */
  83995. bounciness: number;
  83996. /**
  83997. * Instantiates a bounce easing
  83998. * @see https://easings.net/#easeInBounce
  83999. * @param bounces Defines the number of bounces
  84000. * @param bounciness Defines the amplitude of the bounce
  84001. */
  84002. constructor(
  84003. /** Defines the number of bounces */
  84004. bounces?: number,
  84005. /** Defines the amplitude of the bounce */
  84006. bounciness?: number);
  84007. /** @hidden */
  84008. easeInCore(gradient: number): number;
  84009. }
  84010. /**
  84011. * Easing function with a power of 3 shape (see link below).
  84012. * @see https://easings.net/#easeInCubic
  84013. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84014. */
  84015. export class CubicEase extends EasingFunction implements IEasingFunction {
  84016. /** @hidden */
  84017. easeInCore(gradient: number): number;
  84018. }
  84019. /**
  84020. * Easing function with an elastic shape (see link below).
  84021. * @see https://easings.net/#easeInElastic
  84022. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84023. */
  84024. export class ElasticEase extends EasingFunction implements IEasingFunction {
  84025. /** Defines the number of oscillations*/
  84026. oscillations: number;
  84027. /** Defines the amplitude of the oscillations*/
  84028. springiness: number;
  84029. /**
  84030. * Instantiates an elastic easing function
  84031. * @see https://easings.net/#easeInElastic
  84032. * @param oscillations Defines the number of oscillations
  84033. * @param springiness Defines the amplitude of the oscillations
  84034. */
  84035. constructor(
  84036. /** Defines the number of oscillations*/
  84037. oscillations?: number,
  84038. /** Defines the amplitude of the oscillations*/
  84039. springiness?: number);
  84040. /** @hidden */
  84041. easeInCore(gradient: number): number;
  84042. }
  84043. /**
  84044. * Easing function with an exponential shape (see link below).
  84045. * @see https://easings.net/#easeInExpo
  84046. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84047. */
  84048. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  84049. /** Defines the exponent of the function */
  84050. exponent: number;
  84051. /**
  84052. * Instantiates an exponential easing function
  84053. * @see https://easings.net/#easeInExpo
  84054. * @param exponent Defines the exponent of the function
  84055. */
  84056. constructor(
  84057. /** Defines the exponent of the function */
  84058. exponent?: number);
  84059. /** @hidden */
  84060. easeInCore(gradient: number): number;
  84061. }
  84062. /**
  84063. * Easing function with a power shape (see link below).
  84064. * @see https://easings.net/#easeInQuad
  84065. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84066. */
  84067. export class PowerEase extends EasingFunction implements IEasingFunction {
  84068. /** Defines the power of the function */
  84069. power: number;
  84070. /**
  84071. * Instantiates an power base easing function
  84072. * @see https://easings.net/#easeInQuad
  84073. * @param power Defines the power of the function
  84074. */
  84075. constructor(
  84076. /** Defines the power of the function */
  84077. power?: number);
  84078. /** @hidden */
  84079. easeInCore(gradient: number): number;
  84080. }
  84081. /**
  84082. * Easing function with a power of 2 shape (see link below).
  84083. * @see https://easings.net/#easeInQuad
  84084. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84085. */
  84086. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  84087. /** @hidden */
  84088. easeInCore(gradient: number): number;
  84089. }
  84090. /**
  84091. * Easing function with a power of 4 shape (see link below).
  84092. * @see https://easings.net/#easeInQuart
  84093. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84094. */
  84095. export class QuarticEase extends EasingFunction implements IEasingFunction {
  84096. /** @hidden */
  84097. easeInCore(gradient: number): number;
  84098. }
  84099. /**
  84100. * Easing function with a power of 5 shape (see link below).
  84101. * @see https://easings.net/#easeInQuint
  84102. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84103. */
  84104. export class QuinticEase extends EasingFunction implements IEasingFunction {
  84105. /** @hidden */
  84106. easeInCore(gradient: number): number;
  84107. }
  84108. /**
  84109. * Easing function with a sin shape (see link below).
  84110. * @see https://easings.net/#easeInSine
  84111. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84112. */
  84113. export class SineEase extends EasingFunction implements IEasingFunction {
  84114. /** @hidden */
  84115. easeInCore(gradient: number): number;
  84116. }
  84117. /**
  84118. * Easing function with a bezier shape (see link below).
  84119. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  84120. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84121. */
  84122. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  84123. /** Defines the x component of the start tangent in the bezier curve */
  84124. x1: number;
  84125. /** Defines the y component of the start tangent in the bezier curve */
  84126. y1: number;
  84127. /** Defines the x component of the end tangent in the bezier curve */
  84128. x2: number;
  84129. /** Defines the y component of the end tangent in the bezier curve */
  84130. y2: number;
  84131. /**
  84132. * Instantiates a bezier function
  84133. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  84134. * @param x1 Defines the x component of the start tangent in the bezier curve
  84135. * @param y1 Defines the y component of the start tangent in the bezier curve
  84136. * @param x2 Defines the x component of the end tangent in the bezier curve
  84137. * @param y2 Defines the y component of the end tangent in the bezier curve
  84138. */
  84139. constructor(
  84140. /** Defines the x component of the start tangent in the bezier curve */
  84141. x1?: number,
  84142. /** Defines the y component of the start tangent in the bezier curve */
  84143. y1?: number,
  84144. /** Defines the x component of the end tangent in the bezier curve */
  84145. x2?: number,
  84146. /** Defines the y component of the end tangent in the bezier curve */
  84147. y2?: number);
  84148. /** @hidden */
  84149. easeInCore(gradient: number): number;
  84150. }
  84151. }
  84152. declare module BABYLON {
  84153. /**
  84154. * Class used to hold a RBG color
  84155. */
  84156. export class Color3 {
  84157. /**
  84158. * Defines the red component (between 0 and 1, default is 0)
  84159. */
  84160. r: number;
  84161. /**
  84162. * Defines the green component (between 0 and 1, default is 0)
  84163. */
  84164. g: number;
  84165. /**
  84166. * Defines the blue component (between 0 and 1, default is 0)
  84167. */
  84168. b: number;
  84169. /**
  84170. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  84171. * @param r defines the red component (between 0 and 1, default is 0)
  84172. * @param g defines the green component (between 0 and 1, default is 0)
  84173. * @param b defines the blue component (between 0 and 1, default is 0)
  84174. */
  84175. constructor(
  84176. /**
  84177. * Defines the red component (between 0 and 1, default is 0)
  84178. */
  84179. r?: number,
  84180. /**
  84181. * Defines the green component (between 0 and 1, default is 0)
  84182. */
  84183. g?: number,
  84184. /**
  84185. * Defines the blue component (between 0 and 1, default is 0)
  84186. */
  84187. b?: number);
  84188. /**
  84189. * Creates a string with the Color3 current values
  84190. * @returns the string representation of the Color3 object
  84191. */
  84192. toString(): string;
  84193. /**
  84194. * Returns the string "Color3"
  84195. * @returns "Color3"
  84196. */
  84197. getClassName(): string;
  84198. /**
  84199. * Compute the Color3 hash code
  84200. * @returns an unique number that can be used to hash Color3 objects
  84201. */
  84202. getHashCode(): number;
  84203. /**
  84204. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  84205. * @param array defines the array where to store the r,g,b components
  84206. * @param index defines an optional index in the target array to define where to start storing values
  84207. * @returns the current Color3 object
  84208. */
  84209. toArray(array: FloatArray, index?: number): Color3;
  84210. /**
  84211. * Update the current color with values stored in an array from the starting index of the given array
  84212. * @param array defines the source array
  84213. * @param offset defines an offset in the source array
  84214. * @returns the current Color3 object
  84215. */
  84216. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84217. /**
  84218. * Returns a new Color4 object from the current Color3 and the given alpha
  84219. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  84220. * @returns a new Color4 object
  84221. */
  84222. toColor4(alpha?: number): Color4;
  84223. /**
  84224. * Returns a new array populated with 3 numeric elements : red, green and blue values
  84225. * @returns the new array
  84226. */
  84227. asArray(): number[];
  84228. /**
  84229. * Returns the luminance value
  84230. * @returns a float value
  84231. */
  84232. toLuminance(): number;
  84233. /**
  84234. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  84235. * @param otherColor defines the second operand
  84236. * @returns the new Color3 object
  84237. */
  84238. multiply(otherColor: DeepImmutable<Color3>): Color3;
  84239. /**
  84240. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  84241. * @param otherColor defines the second operand
  84242. * @param result defines the Color3 object where to store the result
  84243. * @returns the current Color3
  84244. */
  84245. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84246. /**
  84247. * Determines equality between Color3 objects
  84248. * @param otherColor defines the second operand
  84249. * @returns true if the rgb values are equal to the given ones
  84250. */
  84251. equals(otherColor: DeepImmutable<Color3>): boolean;
  84252. /**
  84253. * Determines equality between the current Color3 object and a set of r,b,g values
  84254. * @param r defines the red component to check
  84255. * @param g defines the green component to check
  84256. * @param b defines the blue component to check
  84257. * @returns true if the rgb values are equal to the given ones
  84258. */
  84259. equalsFloats(r: number, g: number, b: number): boolean;
  84260. /**
  84261. * Multiplies in place each rgb value by scale
  84262. * @param scale defines the scaling factor
  84263. * @returns the updated Color3
  84264. */
  84265. scale(scale: number): Color3;
  84266. /**
  84267. * Multiplies the rgb values by scale and stores the result into "result"
  84268. * @param scale defines the scaling factor
  84269. * @param result defines the Color3 object where to store the result
  84270. * @returns the unmodified current Color3
  84271. */
  84272. scaleToRef(scale: number, result: Color3): Color3;
  84273. /**
  84274. * Scale the current Color3 values by a factor and add the result to a given Color3
  84275. * @param scale defines the scale factor
  84276. * @param result defines color to store the result into
  84277. * @returns the unmodified current Color3
  84278. */
  84279. scaleAndAddToRef(scale: number, result: Color3): Color3;
  84280. /**
  84281. * Clamps the rgb values by the min and max values and stores the result into "result"
  84282. * @param min defines minimum clamping value (default is 0)
  84283. * @param max defines maximum clamping value (default is 1)
  84284. * @param result defines color to store the result into
  84285. * @returns the original Color3
  84286. */
  84287. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  84288. /**
  84289. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  84290. * @param otherColor defines the second operand
  84291. * @returns the new Color3
  84292. */
  84293. add(otherColor: DeepImmutable<Color3>): Color3;
  84294. /**
  84295. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  84296. * @param otherColor defines the second operand
  84297. * @param result defines Color3 object to store the result into
  84298. * @returns the unmodified current Color3
  84299. */
  84300. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84301. /**
  84302. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  84303. * @param otherColor defines the second operand
  84304. * @returns the new Color3
  84305. */
  84306. subtract(otherColor: DeepImmutable<Color3>): Color3;
  84307. /**
  84308. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  84309. * @param otherColor defines the second operand
  84310. * @param result defines Color3 object to store the result into
  84311. * @returns the unmodified current Color3
  84312. */
  84313. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84314. /**
  84315. * Copy the current object
  84316. * @returns a new Color3 copied the current one
  84317. */
  84318. clone(): Color3;
  84319. /**
  84320. * Copies the rgb values from the source in the current Color3
  84321. * @param source defines the source Color3 object
  84322. * @returns the updated Color3 object
  84323. */
  84324. copyFrom(source: DeepImmutable<Color3>): Color3;
  84325. /**
  84326. * Updates the Color3 rgb values from the given floats
  84327. * @param r defines the red component to read from
  84328. * @param g defines the green component to read from
  84329. * @param b defines the blue component to read from
  84330. * @returns the current Color3 object
  84331. */
  84332. copyFromFloats(r: number, g: number, b: number): Color3;
  84333. /**
  84334. * Updates the Color3 rgb values from the given floats
  84335. * @param r defines the red component to read from
  84336. * @param g defines the green component to read from
  84337. * @param b defines the blue component to read from
  84338. * @returns the current Color3 object
  84339. */
  84340. set(r: number, g: number, b: number): Color3;
  84341. /**
  84342. * Compute the Color3 hexadecimal code as a string
  84343. * @returns a string containing the hexadecimal representation of the Color3 object
  84344. */
  84345. toHexString(): string;
  84346. /**
  84347. * Computes a new Color3 converted from the current one to linear space
  84348. * @returns a new Color3 object
  84349. */
  84350. toLinearSpace(): Color3;
  84351. /**
  84352. * Converts current color in rgb space to HSV values
  84353. * @returns a new color3 representing the HSV values
  84354. */
  84355. toHSV(): Color3;
  84356. /**
  84357. * Converts current color in rgb space to HSV values
  84358. * @param result defines the Color3 where to store the HSV values
  84359. */
  84360. toHSVToRef(result: Color3): void;
  84361. /**
  84362. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  84363. * @param convertedColor defines the Color3 object where to store the linear space version
  84364. * @returns the unmodified Color3
  84365. */
  84366. toLinearSpaceToRef(convertedColor: Color3): Color3;
  84367. /**
  84368. * Computes a new Color3 converted from the current one to gamma space
  84369. * @returns a new Color3 object
  84370. */
  84371. toGammaSpace(): Color3;
  84372. /**
  84373. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  84374. * @param convertedColor defines the Color3 object where to store the gamma space version
  84375. * @returns the unmodified Color3
  84376. */
  84377. toGammaSpaceToRef(convertedColor: Color3): Color3;
  84378. private static _BlackReadOnly;
  84379. /**
  84380. * Convert Hue, saturation and value to a Color3 (RGB)
  84381. * @param hue defines the hue
  84382. * @param saturation defines the saturation
  84383. * @param value defines the value
  84384. * @param result defines the Color3 where to store the RGB values
  84385. */
  84386. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  84387. /**
  84388. * Creates a new Color3 from the string containing valid hexadecimal values
  84389. * @param hex defines a string containing valid hexadecimal values
  84390. * @returns a new Color3 object
  84391. */
  84392. static FromHexString(hex: string): Color3;
  84393. /**
  84394. * Creates a new Color3 from the starting index of the given array
  84395. * @param array defines the source array
  84396. * @param offset defines an offset in the source array
  84397. * @returns a new Color3 object
  84398. */
  84399. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84400. /**
  84401. * Creates a new Color3 from the starting index element of the given array
  84402. * @param array defines the source array to read from
  84403. * @param offset defines the offset in the source array
  84404. * @param result defines the target Color3 object
  84405. */
  84406. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  84407. /**
  84408. * Creates a new Color3 from integer values (< 256)
  84409. * @param r defines the red component to read from (value between 0 and 255)
  84410. * @param g defines the green component to read from (value between 0 and 255)
  84411. * @param b defines the blue component to read from (value between 0 and 255)
  84412. * @returns a new Color3 object
  84413. */
  84414. static FromInts(r: number, g: number, b: number): Color3;
  84415. /**
  84416. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84417. * @param start defines the start Color3 value
  84418. * @param end defines the end Color3 value
  84419. * @param amount defines the gradient value between start and end
  84420. * @returns a new Color3 object
  84421. */
  84422. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  84423. /**
  84424. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84425. * @param left defines the start value
  84426. * @param right defines the end value
  84427. * @param amount defines the gradient factor
  84428. * @param result defines the Color3 object where to store the result
  84429. */
  84430. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  84431. /**
  84432. * Returns a Color3 value containing a red color
  84433. * @returns a new Color3 object
  84434. */
  84435. static Red(): Color3;
  84436. /**
  84437. * Returns a Color3 value containing a green color
  84438. * @returns a new Color3 object
  84439. */
  84440. static Green(): Color3;
  84441. /**
  84442. * Returns a Color3 value containing a blue color
  84443. * @returns a new Color3 object
  84444. */
  84445. static Blue(): Color3;
  84446. /**
  84447. * Returns a Color3 value containing a black color
  84448. * @returns a new Color3 object
  84449. */
  84450. static Black(): Color3;
  84451. /**
  84452. * Gets a Color3 value containing a black color that must not be updated
  84453. */
  84454. static get BlackReadOnly(): DeepImmutable<Color3>;
  84455. /**
  84456. * Returns a Color3 value containing a white color
  84457. * @returns a new Color3 object
  84458. */
  84459. static White(): Color3;
  84460. /**
  84461. * Returns a Color3 value containing a purple color
  84462. * @returns a new Color3 object
  84463. */
  84464. static Purple(): Color3;
  84465. /**
  84466. * Returns a Color3 value containing a magenta color
  84467. * @returns a new Color3 object
  84468. */
  84469. static Magenta(): Color3;
  84470. /**
  84471. * Returns a Color3 value containing a yellow color
  84472. * @returns a new Color3 object
  84473. */
  84474. static Yellow(): Color3;
  84475. /**
  84476. * Returns a Color3 value containing a gray color
  84477. * @returns a new Color3 object
  84478. */
  84479. static Gray(): Color3;
  84480. /**
  84481. * Returns a Color3 value containing a teal color
  84482. * @returns a new Color3 object
  84483. */
  84484. static Teal(): Color3;
  84485. /**
  84486. * Returns a Color3 value containing a random color
  84487. * @returns a new Color3 object
  84488. */
  84489. static Random(): Color3;
  84490. }
  84491. /**
  84492. * Class used to hold a RBGA color
  84493. */
  84494. export class Color4 {
  84495. /**
  84496. * Defines the red component (between 0 and 1, default is 0)
  84497. */
  84498. r: number;
  84499. /**
  84500. * Defines the green component (between 0 and 1, default is 0)
  84501. */
  84502. g: number;
  84503. /**
  84504. * Defines the blue component (between 0 and 1, default is 0)
  84505. */
  84506. b: number;
  84507. /**
  84508. * Defines the alpha component (between 0 and 1, default is 1)
  84509. */
  84510. a: number;
  84511. /**
  84512. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  84513. * @param r defines the red component (between 0 and 1, default is 0)
  84514. * @param g defines the green component (between 0 and 1, default is 0)
  84515. * @param b defines the blue component (between 0 and 1, default is 0)
  84516. * @param a defines the alpha component (between 0 and 1, default is 1)
  84517. */
  84518. constructor(
  84519. /**
  84520. * Defines the red component (between 0 and 1, default is 0)
  84521. */
  84522. r?: number,
  84523. /**
  84524. * Defines the green component (between 0 and 1, default is 0)
  84525. */
  84526. g?: number,
  84527. /**
  84528. * Defines the blue component (between 0 and 1, default is 0)
  84529. */
  84530. b?: number,
  84531. /**
  84532. * Defines the alpha component (between 0 and 1, default is 1)
  84533. */
  84534. a?: number);
  84535. /**
  84536. * Adds in place the given Color4 values to the current Color4 object
  84537. * @param right defines the second operand
  84538. * @returns the current updated Color4 object
  84539. */
  84540. addInPlace(right: DeepImmutable<Color4>): Color4;
  84541. /**
  84542. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  84543. * @returns the new array
  84544. */
  84545. asArray(): number[];
  84546. /**
  84547. * Stores from the starting index in the given array the Color4 successive values
  84548. * @param array defines the array where to store the r,g,b components
  84549. * @param index defines an optional index in the target array to define where to start storing values
  84550. * @returns the current Color4 object
  84551. */
  84552. toArray(array: number[], index?: number): Color4;
  84553. /**
  84554. * Update the current color with values stored in an array from the starting index of the given array
  84555. * @param array defines the source array
  84556. * @param offset defines an offset in the source array
  84557. * @returns the current Color4 object
  84558. */
  84559. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84560. /**
  84561. * Determines equality between Color4 objects
  84562. * @param otherColor defines the second operand
  84563. * @returns true if the rgba values are equal to the given ones
  84564. */
  84565. equals(otherColor: DeepImmutable<Color4>): boolean;
  84566. /**
  84567. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  84568. * @param right defines the second operand
  84569. * @returns a new Color4 object
  84570. */
  84571. add(right: DeepImmutable<Color4>): Color4;
  84572. /**
  84573. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  84574. * @param right defines the second operand
  84575. * @returns a new Color4 object
  84576. */
  84577. subtract(right: DeepImmutable<Color4>): Color4;
  84578. /**
  84579. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  84580. * @param right defines the second operand
  84581. * @param result defines the Color4 object where to store the result
  84582. * @returns the current Color4 object
  84583. */
  84584. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  84585. /**
  84586. * Creates a new Color4 with the current Color4 values multiplied by scale
  84587. * @param scale defines the scaling factor to apply
  84588. * @returns a new Color4 object
  84589. */
  84590. scale(scale: number): Color4;
  84591. /**
  84592. * Multiplies the current Color4 values by scale and stores the result in "result"
  84593. * @param scale defines the scaling factor to apply
  84594. * @param result defines the Color4 object where to store the result
  84595. * @returns the current unmodified Color4
  84596. */
  84597. scaleToRef(scale: number, result: Color4): Color4;
  84598. /**
  84599. * Scale the current Color4 values by a factor and add the result to a given Color4
  84600. * @param scale defines the scale factor
  84601. * @param result defines the Color4 object where to store the result
  84602. * @returns the unmodified current Color4
  84603. */
  84604. scaleAndAddToRef(scale: number, result: Color4): Color4;
  84605. /**
  84606. * Clamps the rgb values by the min and max values and stores the result into "result"
  84607. * @param min defines minimum clamping value (default is 0)
  84608. * @param max defines maximum clamping value (default is 1)
  84609. * @param result defines color to store the result into.
  84610. * @returns the cuurent Color4
  84611. */
  84612. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  84613. /**
  84614. * Multipy an Color4 value by another and return a new Color4 object
  84615. * @param color defines the Color4 value to multiply by
  84616. * @returns a new Color4 object
  84617. */
  84618. multiply(color: Color4): Color4;
  84619. /**
  84620. * Multipy a Color4 value by another and push the result in a reference value
  84621. * @param color defines the Color4 value to multiply by
  84622. * @param result defines the Color4 to fill the result in
  84623. * @returns the result Color4
  84624. */
  84625. multiplyToRef(color: Color4, result: Color4): Color4;
  84626. /**
  84627. * Creates a string with the Color4 current values
  84628. * @returns the string representation of the Color4 object
  84629. */
  84630. toString(): string;
  84631. /**
  84632. * Returns the string "Color4"
  84633. * @returns "Color4"
  84634. */
  84635. getClassName(): string;
  84636. /**
  84637. * Compute the Color4 hash code
  84638. * @returns an unique number that can be used to hash Color4 objects
  84639. */
  84640. getHashCode(): number;
  84641. /**
  84642. * Creates a new Color4 copied from the current one
  84643. * @returns a new Color4 object
  84644. */
  84645. clone(): Color4;
  84646. /**
  84647. * Copies the given Color4 values into the current one
  84648. * @param source defines the source Color4 object
  84649. * @returns the current updated Color4 object
  84650. */
  84651. copyFrom(source: Color4): Color4;
  84652. /**
  84653. * Copies the given float values into the current one
  84654. * @param r defines the red component to read from
  84655. * @param g defines the green component to read from
  84656. * @param b defines the blue component to read from
  84657. * @param a defines the alpha component to read from
  84658. * @returns the current updated Color4 object
  84659. */
  84660. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  84661. /**
  84662. * Copies the given float values into the current one
  84663. * @param r defines the red component to read from
  84664. * @param g defines the green component to read from
  84665. * @param b defines the blue component to read from
  84666. * @param a defines the alpha component to read from
  84667. * @returns the current updated Color4 object
  84668. */
  84669. set(r: number, g: number, b: number, a: number): Color4;
  84670. /**
  84671. * Compute the Color4 hexadecimal code as a string
  84672. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  84673. * @returns a string containing the hexadecimal representation of the Color4 object
  84674. */
  84675. toHexString(returnAsColor3?: boolean): string;
  84676. /**
  84677. * Computes a new Color4 converted from the current one to linear space
  84678. * @returns a new Color4 object
  84679. */
  84680. toLinearSpace(): Color4;
  84681. /**
  84682. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  84683. * @param convertedColor defines the Color4 object where to store the linear space version
  84684. * @returns the unmodified Color4
  84685. */
  84686. toLinearSpaceToRef(convertedColor: Color4): Color4;
  84687. /**
  84688. * Computes a new Color4 converted from the current one to gamma space
  84689. * @returns a new Color4 object
  84690. */
  84691. toGammaSpace(): Color4;
  84692. /**
  84693. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  84694. * @param convertedColor defines the Color4 object where to store the gamma space version
  84695. * @returns the unmodified Color4
  84696. */
  84697. toGammaSpaceToRef(convertedColor: Color4): Color4;
  84698. /**
  84699. * Creates a new Color4 from the string containing valid hexadecimal values
  84700. * @param hex defines a string containing valid hexadecimal values
  84701. * @returns a new Color4 object
  84702. */
  84703. static FromHexString(hex: string): Color4;
  84704. /**
  84705. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84706. * @param left defines the start value
  84707. * @param right defines the end value
  84708. * @param amount defines the gradient factor
  84709. * @returns a new Color4 object
  84710. */
  84711. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  84712. /**
  84713. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84714. * @param left defines the start value
  84715. * @param right defines the end value
  84716. * @param amount defines the gradient factor
  84717. * @param result defines the Color4 object where to store data
  84718. */
  84719. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  84720. /**
  84721. * Creates a new Color4 from a Color3 and an alpha value
  84722. * @param color3 defines the source Color3 to read from
  84723. * @param alpha defines the alpha component (1.0 by default)
  84724. * @returns a new Color4 object
  84725. */
  84726. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  84727. /**
  84728. * Creates a new Color4 from the starting index element of the given array
  84729. * @param array defines the source array to read from
  84730. * @param offset defines the offset in the source array
  84731. * @returns a new Color4 object
  84732. */
  84733. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84734. /**
  84735. * Creates a new Color4 from the starting index element of the given array
  84736. * @param array defines the source array to read from
  84737. * @param offset defines the offset in the source array
  84738. * @param result defines the target Color4 object
  84739. */
  84740. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  84741. /**
  84742. * Creates a new Color3 from integer values (< 256)
  84743. * @param r defines the red component to read from (value between 0 and 255)
  84744. * @param g defines the green component to read from (value between 0 and 255)
  84745. * @param b defines the blue component to read from (value between 0 and 255)
  84746. * @param a defines the alpha component to read from (value between 0 and 255)
  84747. * @returns a new Color3 object
  84748. */
  84749. static FromInts(r: number, g: number, b: number, a: number): Color4;
  84750. /**
  84751. * Check the content of a given array and convert it to an array containing RGBA data
  84752. * If the original array was already containing count * 4 values then it is returned directly
  84753. * @param colors defines the array to check
  84754. * @param count defines the number of RGBA data to expect
  84755. * @returns an array containing count * 4 values (RGBA)
  84756. */
  84757. static CheckColors4(colors: number[], count: number): number[];
  84758. }
  84759. /**
  84760. * @hidden
  84761. */
  84762. export class TmpColors {
  84763. static Color3: Color3[];
  84764. static Color4: Color4[];
  84765. }
  84766. }
  84767. declare module BABYLON {
  84768. /**
  84769. * Defines an interface which represents an animation key frame
  84770. */
  84771. export interface IAnimationKey {
  84772. /**
  84773. * Frame of the key frame
  84774. */
  84775. frame: number;
  84776. /**
  84777. * Value at the specifies key frame
  84778. */
  84779. value: any;
  84780. /**
  84781. * The input tangent for the cubic hermite spline
  84782. */
  84783. inTangent?: any;
  84784. /**
  84785. * The output tangent for the cubic hermite spline
  84786. */
  84787. outTangent?: any;
  84788. /**
  84789. * The animation interpolation type
  84790. */
  84791. interpolation?: AnimationKeyInterpolation;
  84792. }
  84793. /**
  84794. * Enum for the animation key frame interpolation type
  84795. */
  84796. export enum AnimationKeyInterpolation {
  84797. /**
  84798. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  84799. */
  84800. STEP = 1
  84801. }
  84802. }
  84803. declare module BABYLON {
  84804. /**
  84805. * Represents the range of an animation
  84806. */
  84807. export class AnimationRange {
  84808. /**The name of the animation range**/
  84809. name: string;
  84810. /**The starting frame of the animation */
  84811. from: number;
  84812. /**The ending frame of the animation*/
  84813. to: number;
  84814. /**
  84815. * Initializes the range of an animation
  84816. * @param name The name of the animation range
  84817. * @param from The starting frame of the animation
  84818. * @param to The ending frame of the animation
  84819. */
  84820. constructor(
  84821. /**The name of the animation range**/
  84822. name: string,
  84823. /**The starting frame of the animation */
  84824. from: number,
  84825. /**The ending frame of the animation*/
  84826. to: number);
  84827. /**
  84828. * Makes a copy of the animation range
  84829. * @returns A copy of the animation range
  84830. */
  84831. clone(): AnimationRange;
  84832. }
  84833. }
  84834. declare module BABYLON {
  84835. /**
  84836. * Composed of a frame, and an action function
  84837. */
  84838. export class AnimationEvent {
  84839. /** The frame for which the event is triggered **/
  84840. frame: number;
  84841. /** The event to perform when triggered **/
  84842. action: (currentFrame: number) => void;
  84843. /** Specifies if the event should be triggered only once**/
  84844. onlyOnce?: boolean | undefined;
  84845. /**
  84846. * Specifies if the animation event is done
  84847. */
  84848. isDone: boolean;
  84849. /**
  84850. * Initializes the animation event
  84851. * @param frame The frame for which the event is triggered
  84852. * @param action The event to perform when triggered
  84853. * @param onlyOnce Specifies if the event should be triggered only once
  84854. */
  84855. constructor(
  84856. /** The frame for which the event is triggered **/
  84857. frame: number,
  84858. /** The event to perform when triggered **/
  84859. action: (currentFrame: number) => void,
  84860. /** Specifies if the event should be triggered only once**/
  84861. onlyOnce?: boolean | undefined);
  84862. /** @hidden */
  84863. _clone(): AnimationEvent;
  84864. }
  84865. }
  84866. declare module BABYLON {
  84867. /**
  84868. * Interface used to define a behavior
  84869. */
  84870. export interface Behavior<T> {
  84871. /** gets or sets behavior's name */
  84872. name: string;
  84873. /**
  84874. * Function called when the behavior needs to be initialized (after attaching it to a target)
  84875. */
  84876. init(): void;
  84877. /**
  84878. * Called when the behavior is attached to a target
  84879. * @param target defines the target where the behavior is attached to
  84880. */
  84881. attach(target: T): void;
  84882. /**
  84883. * Called when the behavior is detached from its target
  84884. */
  84885. detach(): void;
  84886. }
  84887. /**
  84888. * Interface implemented by classes supporting behaviors
  84889. */
  84890. export interface IBehaviorAware<T> {
  84891. /**
  84892. * Attach a behavior
  84893. * @param behavior defines the behavior to attach
  84894. * @returns the current host
  84895. */
  84896. addBehavior(behavior: Behavior<T>): T;
  84897. /**
  84898. * Remove a behavior from the current object
  84899. * @param behavior defines the behavior to detach
  84900. * @returns the current host
  84901. */
  84902. removeBehavior(behavior: Behavior<T>): T;
  84903. /**
  84904. * Gets a behavior using its name to search
  84905. * @param name defines the name to search
  84906. * @returns the behavior or null if not found
  84907. */
  84908. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  84909. }
  84910. }
  84911. declare module BABYLON {
  84912. /**
  84913. * Defines an array and its length.
  84914. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  84915. */
  84916. export interface ISmartArrayLike<T> {
  84917. /**
  84918. * The data of the array.
  84919. */
  84920. data: Array<T>;
  84921. /**
  84922. * The active length of the array.
  84923. */
  84924. length: number;
  84925. }
  84926. /**
  84927. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84928. */
  84929. export class SmartArray<T> implements ISmartArrayLike<T> {
  84930. /**
  84931. * The full set of data from the array.
  84932. */
  84933. data: Array<T>;
  84934. /**
  84935. * The active length of the array.
  84936. */
  84937. length: number;
  84938. protected _id: number;
  84939. /**
  84940. * Instantiates a Smart Array.
  84941. * @param capacity defines the default capacity of the array.
  84942. */
  84943. constructor(capacity: number);
  84944. /**
  84945. * Pushes a value at the end of the active data.
  84946. * @param value defines the object to push in the array.
  84947. */
  84948. push(value: T): void;
  84949. /**
  84950. * Iterates over the active data and apply the lambda to them.
  84951. * @param func defines the action to apply on each value.
  84952. */
  84953. forEach(func: (content: T) => void): void;
  84954. /**
  84955. * Sorts the full sets of data.
  84956. * @param compareFn defines the comparison function to apply.
  84957. */
  84958. sort(compareFn: (a: T, b: T) => number): void;
  84959. /**
  84960. * Resets the active data to an empty array.
  84961. */
  84962. reset(): void;
  84963. /**
  84964. * Releases all the data from the array as well as the array.
  84965. */
  84966. dispose(): void;
  84967. /**
  84968. * Concats the active data with a given array.
  84969. * @param array defines the data to concatenate with.
  84970. */
  84971. concat(array: any): void;
  84972. /**
  84973. * Returns the position of a value in the active data.
  84974. * @param value defines the value to find the index for
  84975. * @returns the index if found in the active data otherwise -1
  84976. */
  84977. indexOf(value: T): number;
  84978. /**
  84979. * Returns whether an element is part of the active data.
  84980. * @param value defines the value to look for
  84981. * @returns true if found in the active data otherwise false
  84982. */
  84983. contains(value: T): boolean;
  84984. private static _GlobalId;
  84985. }
  84986. /**
  84987. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84988. * The data in this array can only be present once
  84989. */
  84990. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  84991. private _duplicateId;
  84992. /**
  84993. * Pushes a value at the end of the active data.
  84994. * THIS DOES NOT PREVENT DUPPLICATE DATA
  84995. * @param value defines the object to push in the array.
  84996. */
  84997. push(value: T): void;
  84998. /**
  84999. * Pushes a value at the end of the active data.
  85000. * If the data is already present, it won t be added again
  85001. * @param value defines the object to push in the array.
  85002. * @returns true if added false if it was already present
  85003. */
  85004. pushNoDuplicate(value: T): boolean;
  85005. /**
  85006. * Resets the active data to an empty array.
  85007. */
  85008. reset(): void;
  85009. /**
  85010. * Concats the active data with a given array.
  85011. * This ensures no dupplicate will be present in the result.
  85012. * @param array defines the data to concatenate with.
  85013. */
  85014. concatWithNoDuplicate(array: any): void;
  85015. }
  85016. }
  85017. declare module BABYLON {
  85018. /**
  85019. * @ignore
  85020. * This is a list of all the different input types that are available in the application.
  85021. * Fo instance: ArcRotateCameraGamepadInput...
  85022. */
  85023. export var CameraInputTypes: {};
  85024. /**
  85025. * This is the contract to implement in order to create a new input class.
  85026. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  85027. */
  85028. export interface ICameraInput<TCamera extends Camera> {
  85029. /**
  85030. * Defines the camera the input is attached to.
  85031. */
  85032. camera: Nullable<TCamera>;
  85033. /**
  85034. * Gets the class name of the current intput.
  85035. * @returns the class name
  85036. */
  85037. getClassName(): string;
  85038. /**
  85039. * Get the friendly name associated with the input class.
  85040. * @returns the input friendly name
  85041. */
  85042. getSimpleName(): string;
  85043. /**
  85044. * Attach the input controls to a specific dom element to get the input from.
  85045. * @param element Defines the element the controls should be listened from
  85046. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85047. */
  85048. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85049. /**
  85050. * Detach the current controls from the specified dom element.
  85051. * @param element Defines the element to stop listening the inputs from
  85052. */
  85053. detachControl(element: Nullable<HTMLElement>): void;
  85054. /**
  85055. * Update the current camera state depending on the inputs that have been used this frame.
  85056. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85057. */
  85058. checkInputs?: () => void;
  85059. }
  85060. /**
  85061. * Represents a map of input types to input instance or input index to input instance.
  85062. */
  85063. export interface CameraInputsMap<TCamera extends Camera> {
  85064. /**
  85065. * Accessor to the input by input type.
  85066. */
  85067. [name: string]: ICameraInput<TCamera>;
  85068. /**
  85069. * Accessor to the input by input index.
  85070. */
  85071. [idx: number]: ICameraInput<TCamera>;
  85072. }
  85073. /**
  85074. * This represents the input manager used within a camera.
  85075. * It helps dealing with all the different kind of input attached to a camera.
  85076. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  85077. */
  85078. export class CameraInputsManager<TCamera extends Camera> {
  85079. /**
  85080. * Defines the list of inputs attahed to the camera.
  85081. */
  85082. attached: CameraInputsMap<TCamera>;
  85083. /**
  85084. * Defines the dom element the camera is collecting inputs from.
  85085. * This is null if the controls have not been attached.
  85086. */
  85087. attachedElement: Nullable<HTMLElement>;
  85088. /**
  85089. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85090. */
  85091. noPreventDefault: boolean;
  85092. /**
  85093. * Defined the camera the input manager belongs to.
  85094. */
  85095. camera: TCamera;
  85096. /**
  85097. * Update the current camera state depending on the inputs that have been used this frame.
  85098. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85099. */
  85100. checkInputs: () => void;
  85101. /**
  85102. * Instantiate a new Camera Input Manager.
  85103. * @param camera Defines the camera the input manager blongs to
  85104. */
  85105. constructor(camera: TCamera);
  85106. /**
  85107. * Add an input method to a camera
  85108. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  85109. * @param input camera input method
  85110. */
  85111. add(input: ICameraInput<TCamera>): void;
  85112. /**
  85113. * Remove a specific input method from a camera
  85114. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  85115. * @param inputToRemove camera input method
  85116. */
  85117. remove(inputToRemove: ICameraInput<TCamera>): void;
  85118. /**
  85119. * Remove a specific input type from a camera
  85120. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  85121. * @param inputType the type of the input to remove
  85122. */
  85123. removeByType(inputType: string): void;
  85124. private _addCheckInputs;
  85125. /**
  85126. * Attach the input controls to the currently attached dom element to listen the events from.
  85127. * @param input Defines the input to attach
  85128. */
  85129. attachInput(input: ICameraInput<TCamera>): void;
  85130. /**
  85131. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  85132. * @param element Defines the dom element to collect the events from
  85133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85134. */
  85135. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  85136. /**
  85137. * Detach the current manager inputs controls from a specific dom element.
  85138. * @param element Defines the dom element to collect the events from
  85139. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  85140. */
  85141. detachElement(element: HTMLElement, disconnect?: boolean): void;
  85142. /**
  85143. * Rebuild the dynamic inputCheck function from the current list of
  85144. * defined inputs in the manager.
  85145. */
  85146. rebuildInputCheck(): void;
  85147. /**
  85148. * Remove all attached input methods from a camera
  85149. */
  85150. clear(): void;
  85151. /**
  85152. * Serialize the current input manager attached to a camera.
  85153. * This ensures than once parsed,
  85154. * the input associated to the camera will be identical to the current ones
  85155. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  85156. */
  85157. serialize(serializedCamera: any): void;
  85158. /**
  85159. * Parses an input manager serialized JSON to restore the previous list of inputs
  85160. * and states associated to a camera.
  85161. * @param parsedCamera Defines the JSON to parse
  85162. */
  85163. parse(parsedCamera: any): void;
  85164. }
  85165. }
  85166. declare module BABYLON {
  85167. /**
  85168. * Class used to store data that will be store in GPU memory
  85169. */
  85170. export class Buffer {
  85171. private _engine;
  85172. private _buffer;
  85173. /** @hidden */
  85174. _data: Nullable<DataArray>;
  85175. private _updatable;
  85176. private _instanced;
  85177. private _divisor;
  85178. /**
  85179. * Gets the byte stride.
  85180. */
  85181. readonly byteStride: number;
  85182. /**
  85183. * Constructor
  85184. * @param engine the engine
  85185. * @param data the data to use for this buffer
  85186. * @param updatable whether the data is updatable
  85187. * @param stride the stride (optional)
  85188. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85189. * @param instanced whether the buffer is instanced (optional)
  85190. * @param useBytes set to true if the stride in in bytes (optional)
  85191. * @param divisor sets an optional divisor for instances (1 by default)
  85192. */
  85193. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  85194. /**
  85195. * Create a new VertexBuffer based on the current buffer
  85196. * @param kind defines the vertex buffer kind (position, normal, etc.)
  85197. * @param offset defines offset in the buffer (0 by default)
  85198. * @param size defines the size in floats of attributes (position is 3 for instance)
  85199. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  85200. * @param instanced defines if the vertex buffer contains indexed data
  85201. * @param useBytes defines if the offset and stride are in bytes *
  85202. * @param divisor sets an optional divisor for instances (1 by default)
  85203. * @returns the new vertex buffer
  85204. */
  85205. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  85206. /**
  85207. * Gets a boolean indicating if the Buffer is updatable?
  85208. * @returns true if the buffer is updatable
  85209. */
  85210. isUpdatable(): boolean;
  85211. /**
  85212. * Gets current buffer's data
  85213. * @returns a DataArray or null
  85214. */
  85215. getData(): Nullable<DataArray>;
  85216. /**
  85217. * Gets underlying native buffer
  85218. * @returns underlying native buffer
  85219. */
  85220. getBuffer(): Nullable<DataBuffer>;
  85221. /**
  85222. * Gets the stride in float32 units (i.e. byte stride / 4).
  85223. * May not be an integer if the byte stride is not divisible by 4.
  85224. * @returns the stride in float32 units
  85225. * @deprecated Please use byteStride instead.
  85226. */
  85227. getStrideSize(): number;
  85228. /**
  85229. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85230. * @param data defines the data to store
  85231. */
  85232. create(data?: Nullable<DataArray>): void;
  85233. /** @hidden */
  85234. _rebuild(): void;
  85235. /**
  85236. * Update current buffer data
  85237. * @param data defines the data to store
  85238. */
  85239. update(data: DataArray): void;
  85240. /**
  85241. * Updates the data directly.
  85242. * @param data the new data
  85243. * @param offset the new offset
  85244. * @param vertexCount the vertex count (optional)
  85245. * @param useBytes set to true if the offset is in bytes
  85246. */
  85247. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  85248. /**
  85249. * Release all resources
  85250. */
  85251. dispose(): void;
  85252. }
  85253. /**
  85254. * Specialized buffer used to store vertex data
  85255. */
  85256. export class VertexBuffer {
  85257. /** @hidden */
  85258. _buffer: Buffer;
  85259. private _kind;
  85260. private _size;
  85261. private _ownsBuffer;
  85262. private _instanced;
  85263. private _instanceDivisor;
  85264. /**
  85265. * The byte type.
  85266. */
  85267. static readonly BYTE: number;
  85268. /**
  85269. * The unsigned byte type.
  85270. */
  85271. static readonly UNSIGNED_BYTE: number;
  85272. /**
  85273. * The short type.
  85274. */
  85275. static readonly SHORT: number;
  85276. /**
  85277. * The unsigned short type.
  85278. */
  85279. static readonly UNSIGNED_SHORT: number;
  85280. /**
  85281. * The integer type.
  85282. */
  85283. static readonly INT: number;
  85284. /**
  85285. * The unsigned integer type.
  85286. */
  85287. static readonly UNSIGNED_INT: number;
  85288. /**
  85289. * The float type.
  85290. */
  85291. static readonly FLOAT: number;
  85292. /**
  85293. * Gets or sets the instance divisor when in instanced mode
  85294. */
  85295. get instanceDivisor(): number;
  85296. set instanceDivisor(value: number);
  85297. /**
  85298. * Gets the byte stride.
  85299. */
  85300. readonly byteStride: number;
  85301. /**
  85302. * Gets the byte offset.
  85303. */
  85304. readonly byteOffset: number;
  85305. /**
  85306. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  85307. */
  85308. readonly normalized: boolean;
  85309. /**
  85310. * Gets the data type of each component in the array.
  85311. */
  85312. readonly type: number;
  85313. /**
  85314. * Constructor
  85315. * @param engine the engine
  85316. * @param data the data to use for this vertex buffer
  85317. * @param kind the vertex buffer kind
  85318. * @param updatable whether the data is updatable
  85319. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85320. * @param stride the stride (optional)
  85321. * @param instanced whether the buffer is instanced (optional)
  85322. * @param offset the offset of the data (optional)
  85323. * @param size the number of components (optional)
  85324. * @param type the type of the component (optional)
  85325. * @param normalized whether the data contains normalized data (optional)
  85326. * @param useBytes set to true if stride and offset are in bytes (optional)
  85327. * @param divisor defines the instance divisor to use (1 by default)
  85328. */
  85329. 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);
  85330. /** @hidden */
  85331. _rebuild(): void;
  85332. /**
  85333. * Returns the kind of the VertexBuffer (string)
  85334. * @returns a string
  85335. */
  85336. getKind(): string;
  85337. /**
  85338. * Gets a boolean indicating if the VertexBuffer is updatable?
  85339. * @returns true if the buffer is updatable
  85340. */
  85341. isUpdatable(): boolean;
  85342. /**
  85343. * Gets current buffer's data
  85344. * @returns a DataArray or null
  85345. */
  85346. getData(): Nullable<DataArray>;
  85347. /**
  85348. * Gets underlying native buffer
  85349. * @returns underlying native buffer
  85350. */
  85351. getBuffer(): Nullable<DataBuffer>;
  85352. /**
  85353. * Gets the stride in float32 units (i.e. byte stride / 4).
  85354. * May not be an integer if the byte stride is not divisible by 4.
  85355. * @returns the stride in float32 units
  85356. * @deprecated Please use byteStride instead.
  85357. */
  85358. getStrideSize(): number;
  85359. /**
  85360. * Returns the offset as a multiple of the type byte length.
  85361. * @returns the offset in bytes
  85362. * @deprecated Please use byteOffset instead.
  85363. */
  85364. getOffset(): number;
  85365. /**
  85366. * Returns the number of components per vertex attribute (integer)
  85367. * @returns the size in float
  85368. */
  85369. getSize(): number;
  85370. /**
  85371. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  85372. * @returns true if this buffer is instanced
  85373. */
  85374. getIsInstanced(): boolean;
  85375. /**
  85376. * Returns the instancing divisor, zero for non-instanced (integer).
  85377. * @returns a number
  85378. */
  85379. getInstanceDivisor(): number;
  85380. /**
  85381. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85382. * @param data defines the data to store
  85383. */
  85384. create(data?: DataArray): void;
  85385. /**
  85386. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  85387. * This function will create a new buffer if the current one is not updatable
  85388. * @param data defines the data to store
  85389. */
  85390. update(data: DataArray): void;
  85391. /**
  85392. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  85393. * Returns the directly updated WebGLBuffer.
  85394. * @param data the new data
  85395. * @param offset the new offset
  85396. * @param useBytes set to true if the offset is in bytes
  85397. */
  85398. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  85399. /**
  85400. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  85401. */
  85402. dispose(): void;
  85403. /**
  85404. * Enumerates each value of this vertex buffer as numbers.
  85405. * @param count the number of values to enumerate
  85406. * @param callback the callback function called for each value
  85407. */
  85408. forEach(count: number, callback: (value: number, index: number) => void): void;
  85409. /**
  85410. * Positions
  85411. */
  85412. static readonly PositionKind: string;
  85413. /**
  85414. * Normals
  85415. */
  85416. static readonly NormalKind: string;
  85417. /**
  85418. * Tangents
  85419. */
  85420. static readonly TangentKind: string;
  85421. /**
  85422. * Texture coordinates
  85423. */
  85424. static readonly UVKind: string;
  85425. /**
  85426. * Texture coordinates 2
  85427. */
  85428. static readonly UV2Kind: string;
  85429. /**
  85430. * Texture coordinates 3
  85431. */
  85432. static readonly UV3Kind: string;
  85433. /**
  85434. * Texture coordinates 4
  85435. */
  85436. static readonly UV4Kind: string;
  85437. /**
  85438. * Texture coordinates 5
  85439. */
  85440. static readonly UV5Kind: string;
  85441. /**
  85442. * Texture coordinates 6
  85443. */
  85444. static readonly UV6Kind: string;
  85445. /**
  85446. * Colors
  85447. */
  85448. static readonly ColorKind: string;
  85449. /**
  85450. * Matrix indices (for bones)
  85451. */
  85452. static readonly MatricesIndicesKind: string;
  85453. /**
  85454. * Matrix weights (for bones)
  85455. */
  85456. static readonly MatricesWeightsKind: string;
  85457. /**
  85458. * Additional matrix indices (for bones)
  85459. */
  85460. static readonly MatricesIndicesExtraKind: string;
  85461. /**
  85462. * Additional matrix weights (for bones)
  85463. */
  85464. static readonly MatricesWeightsExtraKind: string;
  85465. /**
  85466. * Deduces the stride given a kind.
  85467. * @param kind The kind string to deduce
  85468. * @returns The deduced stride
  85469. */
  85470. static DeduceStride(kind: string): number;
  85471. /**
  85472. * Gets the byte length of the given type.
  85473. * @param type the type
  85474. * @returns the number of bytes
  85475. */
  85476. static GetTypeByteLength(type: number): number;
  85477. /**
  85478. * Enumerates each value of the given parameters as numbers.
  85479. * @param data the data to enumerate
  85480. * @param byteOffset the byte offset of the data
  85481. * @param byteStride the byte stride of the data
  85482. * @param componentCount the number of components per element
  85483. * @param componentType the type of the component
  85484. * @param count the number of values to enumerate
  85485. * @param normalized whether the data is normalized
  85486. * @param callback the callback function called for each value
  85487. */
  85488. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  85489. private static _GetFloatValue;
  85490. }
  85491. }
  85492. declare module BABYLON {
  85493. /**
  85494. * @hidden
  85495. */
  85496. export class IntersectionInfo {
  85497. bu: Nullable<number>;
  85498. bv: Nullable<number>;
  85499. distance: number;
  85500. faceId: number;
  85501. subMeshId: number;
  85502. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  85503. }
  85504. }
  85505. declare module BABYLON {
  85506. /**
  85507. * Class used to store bounding sphere information
  85508. */
  85509. export class BoundingSphere {
  85510. /**
  85511. * Gets the center of the bounding sphere in local space
  85512. */
  85513. readonly center: Vector3;
  85514. /**
  85515. * Radius of the bounding sphere in local space
  85516. */
  85517. radius: number;
  85518. /**
  85519. * Gets the center of the bounding sphere in world space
  85520. */
  85521. readonly centerWorld: Vector3;
  85522. /**
  85523. * Radius of the bounding sphere in world space
  85524. */
  85525. radiusWorld: number;
  85526. /**
  85527. * Gets the minimum vector in local space
  85528. */
  85529. readonly minimum: Vector3;
  85530. /**
  85531. * Gets the maximum vector in local space
  85532. */
  85533. readonly maximum: Vector3;
  85534. private _worldMatrix;
  85535. private static readonly TmpVector3;
  85536. /**
  85537. * Creates a new bounding sphere
  85538. * @param min defines the minimum vector (in local space)
  85539. * @param max defines the maximum vector (in local space)
  85540. * @param worldMatrix defines the new world matrix
  85541. */
  85542. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85543. /**
  85544. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  85545. * @param min defines the new minimum vector (in local space)
  85546. * @param max defines the new maximum vector (in local space)
  85547. * @param worldMatrix defines the new world matrix
  85548. */
  85549. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85550. /**
  85551. * Scale the current bounding sphere by applying a scale factor
  85552. * @param factor defines the scale factor to apply
  85553. * @returns the current bounding box
  85554. */
  85555. scale(factor: number): BoundingSphere;
  85556. /**
  85557. * Gets the world matrix of the bounding box
  85558. * @returns a matrix
  85559. */
  85560. getWorldMatrix(): DeepImmutable<Matrix>;
  85561. /** @hidden */
  85562. _update(worldMatrix: DeepImmutable<Matrix>): void;
  85563. /**
  85564. * Tests if the bounding sphere is intersecting the frustum planes
  85565. * @param frustumPlanes defines the frustum planes to test
  85566. * @returns true if there is an intersection
  85567. */
  85568. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85569. /**
  85570. * Tests if the bounding sphere center is in between the frustum planes.
  85571. * Used for optimistic fast inclusion.
  85572. * @param frustumPlanes defines the frustum planes to test
  85573. * @returns true if the sphere center is in between the frustum planes
  85574. */
  85575. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85576. /**
  85577. * Tests if a point is inside the bounding sphere
  85578. * @param point defines the point to test
  85579. * @returns true if the point is inside the bounding sphere
  85580. */
  85581. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85582. /**
  85583. * Checks if two sphere intersct
  85584. * @param sphere0 sphere 0
  85585. * @param sphere1 sphere 1
  85586. * @returns true if the speres intersect
  85587. */
  85588. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  85589. }
  85590. }
  85591. declare module BABYLON {
  85592. /**
  85593. * Class used to store bounding box information
  85594. */
  85595. export class BoundingBox implements ICullable {
  85596. /**
  85597. * Gets the 8 vectors representing the bounding box in local space
  85598. */
  85599. readonly vectors: Vector3[];
  85600. /**
  85601. * Gets the center of the bounding box in local space
  85602. */
  85603. readonly center: Vector3;
  85604. /**
  85605. * Gets the center of the bounding box in world space
  85606. */
  85607. readonly centerWorld: Vector3;
  85608. /**
  85609. * Gets the extend size in local space
  85610. */
  85611. readonly extendSize: Vector3;
  85612. /**
  85613. * Gets the extend size in world space
  85614. */
  85615. readonly extendSizeWorld: Vector3;
  85616. /**
  85617. * Gets the OBB (object bounding box) directions
  85618. */
  85619. readonly directions: Vector3[];
  85620. /**
  85621. * Gets the 8 vectors representing the bounding box in world space
  85622. */
  85623. readonly vectorsWorld: Vector3[];
  85624. /**
  85625. * Gets the minimum vector in world space
  85626. */
  85627. readonly minimumWorld: Vector3;
  85628. /**
  85629. * Gets the maximum vector in world space
  85630. */
  85631. readonly maximumWorld: Vector3;
  85632. /**
  85633. * Gets the minimum vector in local space
  85634. */
  85635. readonly minimum: Vector3;
  85636. /**
  85637. * Gets the maximum vector in local space
  85638. */
  85639. readonly maximum: Vector3;
  85640. private _worldMatrix;
  85641. private static readonly TmpVector3;
  85642. /**
  85643. * @hidden
  85644. */
  85645. _tag: number;
  85646. /**
  85647. * Creates a new bounding box
  85648. * @param min defines the minimum vector (in local space)
  85649. * @param max defines the maximum vector (in local space)
  85650. * @param worldMatrix defines the new world matrix
  85651. */
  85652. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85653. /**
  85654. * Recreates the entire bounding box from scratch as if we call the constructor in place
  85655. * @param min defines the new minimum vector (in local space)
  85656. * @param max defines the new maximum vector (in local space)
  85657. * @param worldMatrix defines the new world matrix
  85658. */
  85659. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85660. /**
  85661. * Scale the current bounding box by applying a scale factor
  85662. * @param factor defines the scale factor to apply
  85663. * @returns the current bounding box
  85664. */
  85665. scale(factor: number): BoundingBox;
  85666. /**
  85667. * Gets the world matrix of the bounding box
  85668. * @returns a matrix
  85669. */
  85670. getWorldMatrix(): DeepImmutable<Matrix>;
  85671. /** @hidden */
  85672. _update(world: DeepImmutable<Matrix>): void;
  85673. /**
  85674. * Tests if the bounding box is intersecting the frustum planes
  85675. * @param frustumPlanes defines the frustum planes to test
  85676. * @returns true if there is an intersection
  85677. */
  85678. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85679. /**
  85680. * Tests if the bounding box is entirely inside the frustum planes
  85681. * @param frustumPlanes defines the frustum planes to test
  85682. * @returns true if there is an inclusion
  85683. */
  85684. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85685. /**
  85686. * Tests if a point is inside the bounding box
  85687. * @param point defines the point to test
  85688. * @returns true if the point is inside the bounding box
  85689. */
  85690. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85691. /**
  85692. * Tests if the bounding box intersects with a bounding sphere
  85693. * @param sphere defines the sphere to test
  85694. * @returns true if there is an intersection
  85695. */
  85696. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  85697. /**
  85698. * Tests if the bounding box intersects with a box defined by a min and max vectors
  85699. * @param min defines the min vector to use
  85700. * @param max defines the max vector to use
  85701. * @returns true if there is an intersection
  85702. */
  85703. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  85704. /**
  85705. * Tests if two bounding boxes are intersections
  85706. * @param box0 defines the first box to test
  85707. * @param box1 defines the second box to test
  85708. * @returns true if there is an intersection
  85709. */
  85710. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  85711. /**
  85712. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  85713. * @param minPoint defines the minimum vector of the bounding box
  85714. * @param maxPoint defines the maximum vector of the bounding box
  85715. * @param sphereCenter defines the sphere center
  85716. * @param sphereRadius defines the sphere radius
  85717. * @returns true if there is an intersection
  85718. */
  85719. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  85720. /**
  85721. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  85722. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85723. * @param frustumPlanes defines the frustum planes to test
  85724. * @return true if there is an inclusion
  85725. */
  85726. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85727. /**
  85728. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  85729. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85730. * @param frustumPlanes defines the frustum planes to test
  85731. * @return true if there is an intersection
  85732. */
  85733. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85734. }
  85735. }
  85736. declare module BABYLON {
  85737. /** @hidden */
  85738. export class Collider {
  85739. /** Define if a collision was found */
  85740. collisionFound: boolean;
  85741. /**
  85742. * Define last intersection point in local space
  85743. */
  85744. intersectionPoint: Vector3;
  85745. /**
  85746. * Define last collided mesh
  85747. */
  85748. collidedMesh: Nullable<AbstractMesh>;
  85749. private _collisionPoint;
  85750. private _planeIntersectionPoint;
  85751. private _tempVector;
  85752. private _tempVector2;
  85753. private _tempVector3;
  85754. private _tempVector4;
  85755. private _edge;
  85756. private _baseToVertex;
  85757. private _destinationPoint;
  85758. private _slidePlaneNormal;
  85759. private _displacementVector;
  85760. /** @hidden */
  85761. _radius: Vector3;
  85762. /** @hidden */
  85763. _retry: number;
  85764. private _velocity;
  85765. private _basePoint;
  85766. private _epsilon;
  85767. /** @hidden */
  85768. _velocityWorldLength: number;
  85769. /** @hidden */
  85770. _basePointWorld: Vector3;
  85771. private _velocityWorld;
  85772. private _normalizedVelocity;
  85773. /** @hidden */
  85774. _initialVelocity: Vector3;
  85775. /** @hidden */
  85776. _initialPosition: Vector3;
  85777. private _nearestDistance;
  85778. private _collisionMask;
  85779. get collisionMask(): number;
  85780. set collisionMask(mask: number);
  85781. /**
  85782. * Gets the plane normal used to compute the sliding response (in local space)
  85783. */
  85784. get slidePlaneNormal(): Vector3;
  85785. /** @hidden */
  85786. _initialize(source: Vector3, dir: Vector3, e: number): void;
  85787. /** @hidden */
  85788. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  85789. /** @hidden */
  85790. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  85791. /** @hidden */
  85792. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85793. /** @hidden */
  85794. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85795. /** @hidden */
  85796. _getResponse(pos: Vector3, vel: Vector3): void;
  85797. }
  85798. }
  85799. declare module BABYLON {
  85800. /**
  85801. * Interface for cullable objects
  85802. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  85803. */
  85804. export interface ICullable {
  85805. /**
  85806. * Checks if the object or part of the object is in the frustum
  85807. * @param frustumPlanes Camera near/planes
  85808. * @returns true if the object is in frustum otherwise false
  85809. */
  85810. isInFrustum(frustumPlanes: Plane[]): boolean;
  85811. /**
  85812. * Checks if a cullable object (mesh...) is in the camera frustum
  85813. * Unlike isInFrustum this cheks the full bounding box
  85814. * @param frustumPlanes Camera near/planes
  85815. * @returns true if the object is in frustum otherwise false
  85816. */
  85817. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85818. }
  85819. /**
  85820. * Info for a bounding data of a mesh
  85821. */
  85822. export class BoundingInfo implements ICullable {
  85823. /**
  85824. * Bounding box for the mesh
  85825. */
  85826. readonly boundingBox: BoundingBox;
  85827. /**
  85828. * Bounding sphere for the mesh
  85829. */
  85830. readonly boundingSphere: BoundingSphere;
  85831. private _isLocked;
  85832. private static readonly TmpVector3;
  85833. /**
  85834. * Constructs bounding info
  85835. * @param minimum min vector of the bounding box/sphere
  85836. * @param maximum max vector of the bounding box/sphere
  85837. * @param worldMatrix defines the new world matrix
  85838. */
  85839. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85840. /**
  85841. * Recreates the entire bounding info from scratch as if we call the constructor in place
  85842. * @param min defines the new minimum vector (in local space)
  85843. * @param max defines the new maximum vector (in local space)
  85844. * @param worldMatrix defines the new world matrix
  85845. */
  85846. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85847. /**
  85848. * min vector of the bounding box/sphere
  85849. */
  85850. get minimum(): Vector3;
  85851. /**
  85852. * max vector of the bounding box/sphere
  85853. */
  85854. get maximum(): Vector3;
  85855. /**
  85856. * If the info is locked and won't be updated to avoid perf overhead
  85857. */
  85858. get isLocked(): boolean;
  85859. set isLocked(value: boolean);
  85860. /**
  85861. * Updates the bounding sphere and box
  85862. * @param world world matrix to be used to update
  85863. */
  85864. update(world: DeepImmutable<Matrix>): void;
  85865. /**
  85866. * Recreate the bounding info to be centered around a specific point given a specific extend.
  85867. * @param center New center of the bounding info
  85868. * @param extend New extend of the bounding info
  85869. * @returns the current bounding info
  85870. */
  85871. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  85872. /**
  85873. * Scale the current bounding info by applying a scale factor
  85874. * @param factor defines the scale factor to apply
  85875. * @returns the current bounding info
  85876. */
  85877. scale(factor: number): BoundingInfo;
  85878. /**
  85879. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  85880. * @param frustumPlanes defines the frustum to test
  85881. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  85882. * @returns true if the bounding info is in the frustum planes
  85883. */
  85884. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  85885. /**
  85886. * Gets the world distance between the min and max points of the bounding box
  85887. */
  85888. get diagonalLength(): number;
  85889. /**
  85890. * Checks if a cullable object (mesh...) is in the camera frustum
  85891. * Unlike isInFrustum this cheks the full bounding box
  85892. * @param frustumPlanes Camera near/planes
  85893. * @returns true if the object is in frustum otherwise false
  85894. */
  85895. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85896. /** @hidden */
  85897. _checkCollision(collider: Collider): boolean;
  85898. /**
  85899. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  85900. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  85901. * @param point the point to check intersection with
  85902. * @returns if the point intersects
  85903. */
  85904. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85905. /**
  85906. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  85907. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  85908. * @param boundingInfo the bounding info to check intersection with
  85909. * @param precise if the intersection should be done using OBB
  85910. * @returns if the bounding info intersects
  85911. */
  85912. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  85913. }
  85914. }
  85915. declare module BABYLON {
  85916. /**
  85917. * Extracts minimum and maximum values from a list of indexed positions
  85918. * @param positions defines the positions to use
  85919. * @param indices defines the indices to the positions
  85920. * @param indexStart defines the start index
  85921. * @param indexCount defines the end index
  85922. * @param bias defines bias value to add to the result
  85923. * @return minimum and maximum values
  85924. */
  85925. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  85926. minimum: Vector3;
  85927. maximum: Vector3;
  85928. };
  85929. /**
  85930. * Extracts minimum and maximum values from a list of positions
  85931. * @param positions defines the positions to use
  85932. * @param start defines the start index in the positions array
  85933. * @param count defines the number of positions to handle
  85934. * @param bias defines bias value to add to the result
  85935. * @param stride defines the stride size to use (distance between two positions in the positions array)
  85936. * @return minimum and maximum values
  85937. */
  85938. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  85939. minimum: Vector3;
  85940. maximum: Vector3;
  85941. };
  85942. }
  85943. declare module BABYLON {
  85944. /** @hidden */
  85945. export class WebGLDataBuffer extends DataBuffer {
  85946. private _buffer;
  85947. constructor(resource: WebGLBuffer);
  85948. get underlyingResource(): any;
  85949. }
  85950. }
  85951. declare module BABYLON {
  85952. /** @hidden */
  85953. export class WebGLPipelineContext implements IPipelineContext {
  85954. engine: ThinEngine;
  85955. program: Nullable<WebGLProgram>;
  85956. context?: WebGLRenderingContext;
  85957. vertexShader?: WebGLShader;
  85958. fragmentShader?: WebGLShader;
  85959. isParallelCompiled: boolean;
  85960. onCompiled?: () => void;
  85961. transformFeedback?: WebGLTransformFeedback | null;
  85962. vertexCompilationError: Nullable<string>;
  85963. fragmentCompilationError: Nullable<string>;
  85964. programLinkError: Nullable<string>;
  85965. programValidationError: Nullable<string>;
  85966. get isAsync(): boolean;
  85967. get isReady(): boolean;
  85968. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  85969. _getVertexShaderCode(): string | null;
  85970. _getFragmentShaderCode(): string | null;
  85971. }
  85972. }
  85973. declare module BABYLON {
  85974. interface ThinEngine {
  85975. /**
  85976. * Create an uniform buffer
  85977. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85978. * @param elements defines the content of the uniform buffer
  85979. * @returns the webGL uniform buffer
  85980. */
  85981. createUniformBuffer(elements: FloatArray): DataBuffer;
  85982. /**
  85983. * Create a dynamic uniform buffer
  85984. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85985. * @param elements defines the content of the uniform buffer
  85986. * @returns the webGL uniform buffer
  85987. */
  85988. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  85989. /**
  85990. * Update an existing uniform buffer
  85991. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85992. * @param uniformBuffer defines the target uniform buffer
  85993. * @param elements defines the content to update
  85994. * @param offset defines the offset in the uniform buffer where update should start
  85995. * @param count defines the size of the data to update
  85996. */
  85997. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  85998. /**
  85999. * Bind an uniform buffer to the current webGL context
  86000. * @param buffer defines the buffer to bind
  86001. */
  86002. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  86003. /**
  86004. * Bind a buffer to the current webGL context at a given location
  86005. * @param buffer defines the buffer to bind
  86006. * @param location defines the index where to bind the buffer
  86007. */
  86008. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  86009. /**
  86010. * Bind a specific block at a given index in a specific shader program
  86011. * @param pipelineContext defines the pipeline context to use
  86012. * @param blockName defines the block name
  86013. * @param index defines the index where to bind the block
  86014. */
  86015. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  86016. }
  86017. }
  86018. declare module BABYLON {
  86019. /**
  86020. * Uniform buffer objects.
  86021. *
  86022. * Handles blocks of uniform on the GPU.
  86023. *
  86024. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86025. *
  86026. * For more information, please refer to :
  86027. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86028. */
  86029. export class UniformBuffer {
  86030. private _engine;
  86031. private _buffer;
  86032. private _data;
  86033. private _bufferData;
  86034. private _dynamic?;
  86035. private _uniformLocations;
  86036. private _uniformSizes;
  86037. private _uniformLocationPointer;
  86038. private _needSync;
  86039. private _noUBO;
  86040. private _currentEffect;
  86041. /** @hidden */
  86042. _alreadyBound: boolean;
  86043. private static _MAX_UNIFORM_SIZE;
  86044. private static _tempBuffer;
  86045. /**
  86046. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86047. * This is dynamic to allow compat with webgl 1 and 2.
  86048. * You will need to pass the name of the uniform as well as the value.
  86049. */
  86050. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86051. /**
  86052. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86053. * This is dynamic to allow compat with webgl 1 and 2.
  86054. * You will need to pass the name of the uniform as well as the value.
  86055. */
  86056. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86057. /**
  86058. * Lambda to Update a single float in a uniform buffer.
  86059. * This is dynamic to allow compat with webgl 1 and 2.
  86060. * You will need to pass the name of the uniform as well as the value.
  86061. */
  86062. updateFloat: (name: string, x: number) => void;
  86063. /**
  86064. * Lambda to Update a vec2 of float in a uniform buffer.
  86065. * This is dynamic to allow compat with webgl 1 and 2.
  86066. * You will need to pass the name of the uniform as well as the value.
  86067. */
  86068. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86069. /**
  86070. * Lambda to Update a vec3 of float in a uniform buffer.
  86071. * This is dynamic to allow compat with webgl 1 and 2.
  86072. * You will need to pass the name of the uniform as well as the value.
  86073. */
  86074. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86075. /**
  86076. * Lambda to Update a vec4 of float in a uniform buffer.
  86077. * This is dynamic to allow compat with webgl 1 and 2.
  86078. * You will need to pass the name of the uniform as well as the value.
  86079. */
  86080. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86081. /**
  86082. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86083. * This is dynamic to allow compat with webgl 1 and 2.
  86084. * You will need to pass the name of the uniform as well as the value.
  86085. */
  86086. updateMatrix: (name: string, mat: Matrix) => void;
  86087. /**
  86088. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86089. * This is dynamic to allow compat with webgl 1 and 2.
  86090. * You will need to pass the name of the uniform as well as the value.
  86091. */
  86092. updateVector3: (name: string, vector: Vector3) => void;
  86093. /**
  86094. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86095. * This is dynamic to allow compat with webgl 1 and 2.
  86096. * You will need to pass the name of the uniform as well as the value.
  86097. */
  86098. updateVector4: (name: string, vector: Vector4) => void;
  86099. /**
  86100. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86101. * This is dynamic to allow compat with webgl 1 and 2.
  86102. * You will need to pass the name of the uniform as well as the value.
  86103. */
  86104. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86105. /**
  86106. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86107. * This is dynamic to allow compat with webgl 1 and 2.
  86108. * You will need to pass the name of the uniform as well as the value.
  86109. */
  86110. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86111. /**
  86112. * Instantiates a new Uniform buffer objects.
  86113. *
  86114. * Handles blocks of uniform on the GPU.
  86115. *
  86116. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86117. *
  86118. * For more information, please refer to :
  86119. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86120. * @param engine Define the engine the buffer is associated with
  86121. * @param data Define the data contained in the buffer
  86122. * @param dynamic Define if the buffer is updatable
  86123. */
  86124. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86125. /**
  86126. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86127. * or just falling back on setUniformXXX calls.
  86128. */
  86129. get useUbo(): boolean;
  86130. /**
  86131. * Indicates if the WebGL underlying uniform buffer is in sync
  86132. * with the javascript cache data.
  86133. */
  86134. get isSync(): boolean;
  86135. /**
  86136. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86137. * Also, a dynamic UniformBuffer will disable cache verification and always
  86138. * update the underlying WebGL uniform buffer to the GPU.
  86139. * @returns if Dynamic, otherwise false
  86140. */
  86141. isDynamic(): boolean;
  86142. /**
  86143. * The data cache on JS side.
  86144. * @returns the underlying data as a float array
  86145. */
  86146. getData(): Float32Array;
  86147. /**
  86148. * The underlying WebGL Uniform buffer.
  86149. * @returns the webgl buffer
  86150. */
  86151. getBuffer(): Nullable<DataBuffer>;
  86152. /**
  86153. * std140 layout specifies how to align data within an UBO structure.
  86154. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86155. * for specs.
  86156. */
  86157. private _fillAlignment;
  86158. /**
  86159. * Adds an uniform in the buffer.
  86160. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86161. * for the layout to be correct !
  86162. * @param name Name of the uniform, as used in the uniform block in the shader.
  86163. * @param size Data size, or data directly.
  86164. */
  86165. addUniform(name: string, size: number | number[]): void;
  86166. /**
  86167. * Adds a Matrix 4x4 to the uniform buffer.
  86168. * @param name Name of the uniform, as used in the uniform block in the shader.
  86169. * @param mat A 4x4 matrix.
  86170. */
  86171. addMatrix(name: string, mat: Matrix): void;
  86172. /**
  86173. * Adds a vec2 to the uniform buffer.
  86174. * @param name Name of the uniform, as used in the uniform block in the shader.
  86175. * @param x Define the x component value of the vec2
  86176. * @param y Define the y component value of the vec2
  86177. */
  86178. addFloat2(name: string, x: number, y: number): void;
  86179. /**
  86180. * Adds a vec3 to the uniform buffer.
  86181. * @param name Name of the uniform, as used in the uniform block in the shader.
  86182. * @param x Define the x component value of the vec3
  86183. * @param y Define the y component value of the vec3
  86184. * @param z Define the z component value of the vec3
  86185. */
  86186. addFloat3(name: string, x: number, y: number, z: number): void;
  86187. /**
  86188. * Adds a vec3 to the uniform buffer.
  86189. * @param name Name of the uniform, as used in the uniform block in the shader.
  86190. * @param color Define the vec3 from a Color
  86191. */
  86192. addColor3(name: string, color: Color3): void;
  86193. /**
  86194. * Adds a vec4 to the uniform buffer.
  86195. * @param name Name of the uniform, as used in the uniform block in the shader.
  86196. * @param color Define the rgb components from a Color
  86197. * @param alpha Define the a component of the vec4
  86198. */
  86199. addColor4(name: string, color: Color3, alpha: number): void;
  86200. /**
  86201. * Adds a vec3 to the uniform buffer.
  86202. * @param name Name of the uniform, as used in the uniform block in the shader.
  86203. * @param vector Define the vec3 components from a Vector
  86204. */
  86205. addVector3(name: string, vector: Vector3): void;
  86206. /**
  86207. * Adds a Matrix 3x3 to the uniform buffer.
  86208. * @param name Name of the uniform, as used in the uniform block in the shader.
  86209. */
  86210. addMatrix3x3(name: string): void;
  86211. /**
  86212. * Adds a Matrix 2x2 to the uniform buffer.
  86213. * @param name Name of the uniform, as used in the uniform block in the shader.
  86214. */
  86215. addMatrix2x2(name: string): void;
  86216. /**
  86217. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86218. */
  86219. create(): void;
  86220. /** @hidden */
  86221. _rebuild(): void;
  86222. /**
  86223. * Updates the WebGL Uniform Buffer on the GPU.
  86224. * If the `dynamic` flag is set to true, no cache comparison is done.
  86225. * Otherwise, the buffer will be updated only if the cache differs.
  86226. */
  86227. update(): void;
  86228. /**
  86229. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86230. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86231. * @param data Define the flattened data
  86232. * @param size Define the size of the data.
  86233. */
  86234. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86235. private _valueCache;
  86236. private _cacheMatrix;
  86237. private _updateMatrix3x3ForUniform;
  86238. private _updateMatrix3x3ForEffect;
  86239. private _updateMatrix2x2ForEffect;
  86240. private _updateMatrix2x2ForUniform;
  86241. private _updateFloatForEffect;
  86242. private _updateFloatForUniform;
  86243. private _updateFloat2ForEffect;
  86244. private _updateFloat2ForUniform;
  86245. private _updateFloat3ForEffect;
  86246. private _updateFloat3ForUniform;
  86247. private _updateFloat4ForEffect;
  86248. private _updateFloat4ForUniform;
  86249. private _updateMatrixForEffect;
  86250. private _updateMatrixForUniform;
  86251. private _updateVector3ForEffect;
  86252. private _updateVector3ForUniform;
  86253. private _updateVector4ForEffect;
  86254. private _updateVector4ForUniform;
  86255. private _updateColor3ForEffect;
  86256. private _updateColor3ForUniform;
  86257. private _updateColor4ForEffect;
  86258. private _updateColor4ForUniform;
  86259. /**
  86260. * Sets a sampler uniform on the effect.
  86261. * @param name Define the name of the sampler.
  86262. * @param texture Define the texture to set in the sampler
  86263. */
  86264. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86265. /**
  86266. * Directly updates the value of the uniform in the cache AND on the GPU.
  86267. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86268. * @param data Define the flattened data
  86269. */
  86270. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86271. /**
  86272. * Binds this uniform buffer to an effect.
  86273. * @param effect Define the effect to bind the buffer to
  86274. * @param name Name of the uniform block in the shader.
  86275. */
  86276. bindToEffect(effect: Effect, name: string): void;
  86277. /**
  86278. * Disposes the uniform buffer.
  86279. */
  86280. dispose(): void;
  86281. }
  86282. }
  86283. declare module BABYLON {
  86284. /**
  86285. * Enum that determines the text-wrapping mode to use.
  86286. */
  86287. export enum InspectableType {
  86288. /**
  86289. * Checkbox for booleans
  86290. */
  86291. Checkbox = 0,
  86292. /**
  86293. * Sliders for numbers
  86294. */
  86295. Slider = 1,
  86296. /**
  86297. * Vector3
  86298. */
  86299. Vector3 = 2,
  86300. /**
  86301. * Quaternions
  86302. */
  86303. Quaternion = 3,
  86304. /**
  86305. * Color3
  86306. */
  86307. Color3 = 4,
  86308. /**
  86309. * String
  86310. */
  86311. String = 5
  86312. }
  86313. /**
  86314. * Interface used to define custom inspectable properties.
  86315. * This interface is used by the inspector to display custom property grids
  86316. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86317. */
  86318. export interface IInspectable {
  86319. /**
  86320. * Gets the label to display
  86321. */
  86322. label: string;
  86323. /**
  86324. * Gets the name of the property to edit
  86325. */
  86326. propertyName: string;
  86327. /**
  86328. * Gets the type of the editor to use
  86329. */
  86330. type: InspectableType;
  86331. /**
  86332. * Gets the minimum value of the property when using in "slider" mode
  86333. */
  86334. min?: number;
  86335. /**
  86336. * Gets the maximum value of the property when using in "slider" mode
  86337. */
  86338. max?: number;
  86339. /**
  86340. * Gets the setp to use when using in "slider" mode
  86341. */
  86342. step?: number;
  86343. }
  86344. }
  86345. declare module BABYLON {
  86346. /**
  86347. * Class used to provide helper for timing
  86348. */
  86349. export class TimingTools {
  86350. /**
  86351. * Polyfill for setImmediate
  86352. * @param action defines the action to execute after the current execution block
  86353. */
  86354. static SetImmediate(action: () => void): void;
  86355. }
  86356. }
  86357. declare module BABYLON {
  86358. /**
  86359. * Class used to enable instatition of objects by class name
  86360. */
  86361. export class InstantiationTools {
  86362. /**
  86363. * Use this object to register external classes like custom textures or material
  86364. * to allow the laoders to instantiate them
  86365. */
  86366. static RegisteredExternalClasses: {
  86367. [key: string]: Object;
  86368. };
  86369. /**
  86370. * Tries to instantiate a new object from a given class name
  86371. * @param className defines the class name to instantiate
  86372. * @returns the new object or null if the system was not able to do the instantiation
  86373. */
  86374. static Instantiate(className: string): any;
  86375. }
  86376. }
  86377. declare module BABYLON {
  86378. /**
  86379. * Define options used to create a depth texture
  86380. */
  86381. export class DepthTextureCreationOptions {
  86382. /** Specifies whether or not a stencil should be allocated in the texture */
  86383. generateStencil?: boolean;
  86384. /** Specifies whether or not bilinear filtering is enable on the texture */
  86385. bilinearFiltering?: boolean;
  86386. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86387. comparisonFunction?: number;
  86388. /** Specifies if the created texture is a cube texture */
  86389. isCube?: boolean;
  86390. }
  86391. }
  86392. declare module BABYLON {
  86393. interface ThinEngine {
  86394. /**
  86395. * Creates a depth stencil cube texture.
  86396. * This is only available in WebGL 2.
  86397. * @param size The size of face edge in the cube texture.
  86398. * @param options The options defining the cube texture.
  86399. * @returns The cube texture
  86400. */
  86401. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  86402. /**
  86403. * Creates a cube texture
  86404. * @param rootUrl defines the url where the files to load is located
  86405. * @param scene defines the current scene
  86406. * @param files defines the list of files to load (1 per face)
  86407. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86408. * @param onLoad defines an optional callback raised when the texture is loaded
  86409. * @param onError defines an optional callback raised if there is an issue to load the texture
  86410. * @param format defines the format of the data
  86411. * @param forcedExtension defines the extension to use to pick the right loader
  86412. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86413. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86414. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86415. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  86416. * @returns the cube texture as an InternalTexture
  86417. */
  86418. 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;
  86419. /**
  86420. * Creates a cube texture
  86421. * @param rootUrl defines the url where the files to load is located
  86422. * @param scene defines the current scene
  86423. * @param files defines the list of files to load (1 per face)
  86424. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86425. * @param onLoad defines an optional callback raised when the texture is loaded
  86426. * @param onError defines an optional callback raised if there is an issue to load the texture
  86427. * @param format defines the format of the data
  86428. * @param forcedExtension defines the extension to use to pick the right loader
  86429. * @returns the cube texture as an InternalTexture
  86430. */
  86431. 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;
  86432. /**
  86433. * Creates a cube texture
  86434. * @param rootUrl defines the url where the files to load is located
  86435. * @param scene defines the current scene
  86436. * @param files defines the list of files to load (1 per face)
  86437. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86438. * @param onLoad defines an optional callback raised when the texture is loaded
  86439. * @param onError defines an optional callback raised if there is an issue to load the texture
  86440. * @param format defines the format of the data
  86441. * @param forcedExtension defines the extension to use to pick the right loader
  86442. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86443. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86444. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86445. * @returns the cube texture as an InternalTexture
  86446. */
  86447. 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;
  86448. /** @hidden */
  86449. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  86450. /** @hidden */
  86451. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  86452. /** @hidden */
  86453. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86454. /** @hidden */
  86455. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86456. /**
  86457. * @hidden
  86458. */
  86459. _setCubeMapTextureParams(loadMipmap: boolean): void;
  86460. }
  86461. }
  86462. declare module BABYLON {
  86463. /**
  86464. * Class for creating a cube texture
  86465. */
  86466. export class CubeTexture extends BaseTexture {
  86467. private _delayedOnLoad;
  86468. /**
  86469. * Observable triggered once the texture has been loaded.
  86470. */
  86471. onLoadObservable: Observable<CubeTexture>;
  86472. /**
  86473. * The url of the texture
  86474. */
  86475. url: string;
  86476. /**
  86477. * Gets or sets the center of the bounding box associated with the cube texture.
  86478. * It must define where the camera used to render the texture was set
  86479. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86480. */
  86481. boundingBoxPosition: Vector3;
  86482. private _boundingBoxSize;
  86483. /**
  86484. * Gets or sets the size of the bounding box associated with the cube texture
  86485. * When defined, the cubemap will switch to local mode
  86486. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86487. * @example https://www.babylonjs-playground.com/#RNASML
  86488. */
  86489. set boundingBoxSize(value: Vector3);
  86490. /**
  86491. * Returns the bounding box size
  86492. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86493. */
  86494. get boundingBoxSize(): Vector3;
  86495. protected _rotationY: number;
  86496. /**
  86497. * Sets texture matrix rotation angle around Y axis in radians.
  86498. */
  86499. set rotationY(value: number);
  86500. /**
  86501. * Gets texture matrix rotation angle around Y axis radians.
  86502. */
  86503. get rotationY(): number;
  86504. /**
  86505. * Are mip maps generated for this texture or not.
  86506. */
  86507. get noMipmap(): boolean;
  86508. private _noMipmap;
  86509. private _files;
  86510. protected _forcedExtension: Nullable<string>;
  86511. private _extensions;
  86512. private _textureMatrix;
  86513. private _format;
  86514. private _createPolynomials;
  86515. /**
  86516. * Creates a cube texture from an array of image urls
  86517. * @param files defines an array of image urls
  86518. * @param scene defines the hosting scene
  86519. * @param noMipmap specifies if mip maps are not used
  86520. * @returns a cube texture
  86521. */
  86522. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  86523. /**
  86524. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  86525. * @param url defines the url of the prefiltered texture
  86526. * @param scene defines the scene the texture is attached to
  86527. * @param forcedExtension defines the extension of the file if different from the url
  86528. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86529. * @return the prefiltered texture
  86530. */
  86531. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  86532. /**
  86533. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  86534. * as prefiltered data.
  86535. * @param rootUrl defines the url of the texture or the root name of the six images
  86536. * @param null defines the scene or engine the texture is attached to
  86537. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  86538. * @param noMipmap defines if mipmaps should be created or not
  86539. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  86540. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  86541. * @param onError defines a callback triggered in case of error during load
  86542. * @param format defines the internal format to use for the texture once loaded
  86543. * @param prefiltered defines whether or not the texture is created from prefiltered data
  86544. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  86545. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86546. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86547. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86548. * @return the cube texture
  86549. */
  86550. 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);
  86551. /**
  86552. * Get the current class name of the texture useful for serialization or dynamic coding.
  86553. * @returns "CubeTexture"
  86554. */
  86555. getClassName(): string;
  86556. /**
  86557. * Update the url (and optional buffer) of this texture if url was null during construction.
  86558. * @param url the url of the texture
  86559. * @param forcedExtension defines the extension to use
  86560. * @param onLoad callback called when the texture is loaded (defaults to null)
  86561. * @param prefiltered Defines whether the updated texture is prefiltered or not
  86562. */
  86563. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  86564. /**
  86565. * Delays loading of the cube texture
  86566. * @param forcedExtension defines the extension to use
  86567. */
  86568. delayLoad(forcedExtension?: string): void;
  86569. /**
  86570. * Returns the reflection texture matrix
  86571. * @returns the reflection texture matrix
  86572. */
  86573. getReflectionTextureMatrix(): Matrix;
  86574. /**
  86575. * Sets the reflection texture matrix
  86576. * @param value Reflection texture matrix
  86577. */
  86578. setReflectionTextureMatrix(value: Matrix): void;
  86579. /**
  86580. * Parses text to create a cube texture
  86581. * @param parsedTexture define the serialized text to read from
  86582. * @param scene defines the hosting scene
  86583. * @param rootUrl defines the root url of the cube texture
  86584. * @returns a cube texture
  86585. */
  86586. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  86587. /**
  86588. * Makes a clone, or deep copy, of the cube texture
  86589. * @returns a new cube texture
  86590. */
  86591. clone(): CubeTexture;
  86592. }
  86593. }
  86594. declare module BABYLON {
  86595. /**
  86596. * Manages the defines for the Material
  86597. */
  86598. export class MaterialDefines {
  86599. /** @hidden */
  86600. protected _keys: string[];
  86601. private _isDirty;
  86602. /** @hidden */
  86603. _renderId: number;
  86604. /** @hidden */
  86605. _areLightsDirty: boolean;
  86606. /** @hidden */
  86607. _areLightsDisposed: boolean;
  86608. /** @hidden */
  86609. _areAttributesDirty: boolean;
  86610. /** @hidden */
  86611. _areTexturesDirty: boolean;
  86612. /** @hidden */
  86613. _areFresnelDirty: boolean;
  86614. /** @hidden */
  86615. _areMiscDirty: boolean;
  86616. /** @hidden */
  86617. _areImageProcessingDirty: boolean;
  86618. /** @hidden */
  86619. _normals: boolean;
  86620. /** @hidden */
  86621. _uvs: boolean;
  86622. /** @hidden */
  86623. _needNormals: boolean;
  86624. /** @hidden */
  86625. _needUVs: boolean;
  86626. [id: string]: any;
  86627. /**
  86628. * Specifies if the material needs to be re-calculated
  86629. */
  86630. get isDirty(): boolean;
  86631. /**
  86632. * Marks the material to indicate that it has been re-calculated
  86633. */
  86634. markAsProcessed(): void;
  86635. /**
  86636. * Marks the material to indicate that it needs to be re-calculated
  86637. */
  86638. markAsUnprocessed(): void;
  86639. /**
  86640. * Marks the material to indicate all of its defines need to be re-calculated
  86641. */
  86642. markAllAsDirty(): void;
  86643. /**
  86644. * Marks the material to indicate that image processing needs to be re-calculated
  86645. */
  86646. markAsImageProcessingDirty(): void;
  86647. /**
  86648. * Marks the material to indicate the lights need to be re-calculated
  86649. * @param disposed Defines whether the light is dirty due to dispose or not
  86650. */
  86651. markAsLightDirty(disposed?: boolean): void;
  86652. /**
  86653. * Marks the attribute state as changed
  86654. */
  86655. markAsAttributesDirty(): void;
  86656. /**
  86657. * Marks the texture state as changed
  86658. */
  86659. markAsTexturesDirty(): void;
  86660. /**
  86661. * Marks the fresnel state as changed
  86662. */
  86663. markAsFresnelDirty(): void;
  86664. /**
  86665. * Marks the misc state as changed
  86666. */
  86667. markAsMiscDirty(): void;
  86668. /**
  86669. * Rebuilds the material defines
  86670. */
  86671. rebuild(): void;
  86672. /**
  86673. * Specifies if two material defines are equal
  86674. * @param other - A material define instance to compare to
  86675. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  86676. */
  86677. isEqual(other: MaterialDefines): boolean;
  86678. /**
  86679. * Clones this instance's defines to another instance
  86680. * @param other - material defines to clone values to
  86681. */
  86682. cloneTo(other: MaterialDefines): void;
  86683. /**
  86684. * Resets the material define values
  86685. */
  86686. reset(): void;
  86687. /**
  86688. * Converts the material define values to a string
  86689. * @returns - String of material define information
  86690. */
  86691. toString(): string;
  86692. }
  86693. }
  86694. declare module BABYLON {
  86695. /**
  86696. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86697. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86698. * 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;
  86699. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86700. */
  86701. export class ColorCurves {
  86702. private _dirty;
  86703. private _tempColor;
  86704. private _globalCurve;
  86705. private _highlightsCurve;
  86706. private _midtonesCurve;
  86707. private _shadowsCurve;
  86708. private _positiveCurve;
  86709. private _negativeCurve;
  86710. private _globalHue;
  86711. private _globalDensity;
  86712. private _globalSaturation;
  86713. private _globalExposure;
  86714. /**
  86715. * Gets the global Hue value.
  86716. * 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).
  86717. */
  86718. get globalHue(): number;
  86719. /**
  86720. * Sets the global Hue value.
  86721. * 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).
  86722. */
  86723. set globalHue(value: number);
  86724. /**
  86725. * Gets the global Density value.
  86726. * 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.
  86727. * Values less than zero provide a filter of opposite hue.
  86728. */
  86729. get globalDensity(): number;
  86730. /**
  86731. * Sets the global Density value.
  86732. * 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.
  86733. * Values less than zero provide a filter of opposite hue.
  86734. */
  86735. set globalDensity(value: number);
  86736. /**
  86737. * Gets the global Saturation value.
  86738. * 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.
  86739. */
  86740. get globalSaturation(): number;
  86741. /**
  86742. * Sets the global Saturation value.
  86743. * 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.
  86744. */
  86745. set globalSaturation(value: number);
  86746. /**
  86747. * Gets the global Exposure value.
  86748. * 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.
  86749. */
  86750. get globalExposure(): number;
  86751. /**
  86752. * Sets the global Exposure value.
  86753. * 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.
  86754. */
  86755. set globalExposure(value: number);
  86756. private _highlightsHue;
  86757. private _highlightsDensity;
  86758. private _highlightsSaturation;
  86759. private _highlightsExposure;
  86760. /**
  86761. * Gets the highlights Hue value.
  86762. * 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).
  86763. */
  86764. get highlightsHue(): number;
  86765. /**
  86766. * Sets the highlights Hue value.
  86767. * 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).
  86768. */
  86769. set highlightsHue(value: number);
  86770. /**
  86771. * Gets the highlights Density value.
  86772. * 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.
  86773. * Values less than zero provide a filter of opposite hue.
  86774. */
  86775. get highlightsDensity(): number;
  86776. /**
  86777. * Sets the highlights Density value.
  86778. * 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.
  86779. * Values less than zero provide a filter of opposite hue.
  86780. */
  86781. set highlightsDensity(value: number);
  86782. /**
  86783. * Gets the highlights Saturation value.
  86784. * 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.
  86785. */
  86786. get highlightsSaturation(): number;
  86787. /**
  86788. * Sets the highlights Saturation value.
  86789. * 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.
  86790. */
  86791. set highlightsSaturation(value: number);
  86792. /**
  86793. * Gets the highlights Exposure value.
  86794. * 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.
  86795. */
  86796. get highlightsExposure(): number;
  86797. /**
  86798. * Sets the highlights Exposure value.
  86799. * 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.
  86800. */
  86801. set highlightsExposure(value: number);
  86802. private _midtonesHue;
  86803. private _midtonesDensity;
  86804. private _midtonesSaturation;
  86805. private _midtonesExposure;
  86806. /**
  86807. * Gets the midtones Hue value.
  86808. * 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).
  86809. */
  86810. get midtonesHue(): number;
  86811. /**
  86812. * Sets the midtones Hue value.
  86813. * 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).
  86814. */
  86815. set midtonesHue(value: number);
  86816. /**
  86817. * Gets the midtones Density value.
  86818. * 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.
  86819. * Values less than zero provide a filter of opposite hue.
  86820. */
  86821. get midtonesDensity(): number;
  86822. /**
  86823. * Sets the midtones Density value.
  86824. * 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.
  86825. * Values less than zero provide a filter of opposite hue.
  86826. */
  86827. set midtonesDensity(value: number);
  86828. /**
  86829. * Gets the midtones Saturation value.
  86830. * 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.
  86831. */
  86832. get midtonesSaturation(): number;
  86833. /**
  86834. * Sets the midtones Saturation value.
  86835. * 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.
  86836. */
  86837. set midtonesSaturation(value: number);
  86838. /**
  86839. * Gets the midtones Exposure value.
  86840. * 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.
  86841. */
  86842. get midtonesExposure(): number;
  86843. /**
  86844. * Sets the midtones Exposure value.
  86845. * 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.
  86846. */
  86847. set midtonesExposure(value: number);
  86848. private _shadowsHue;
  86849. private _shadowsDensity;
  86850. private _shadowsSaturation;
  86851. private _shadowsExposure;
  86852. /**
  86853. * Gets the shadows Hue value.
  86854. * 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).
  86855. */
  86856. get shadowsHue(): number;
  86857. /**
  86858. * Sets the shadows Hue value.
  86859. * 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).
  86860. */
  86861. set shadowsHue(value: number);
  86862. /**
  86863. * Gets the shadows Density value.
  86864. * 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.
  86865. * Values less than zero provide a filter of opposite hue.
  86866. */
  86867. get shadowsDensity(): number;
  86868. /**
  86869. * Sets the shadows Density value.
  86870. * 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.
  86871. * Values less than zero provide a filter of opposite hue.
  86872. */
  86873. set shadowsDensity(value: number);
  86874. /**
  86875. * Gets the shadows Saturation value.
  86876. * 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.
  86877. */
  86878. get shadowsSaturation(): number;
  86879. /**
  86880. * Sets the shadows Saturation value.
  86881. * 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.
  86882. */
  86883. set shadowsSaturation(value: number);
  86884. /**
  86885. * Gets the shadows Exposure value.
  86886. * 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.
  86887. */
  86888. get shadowsExposure(): number;
  86889. /**
  86890. * Sets the shadows Exposure value.
  86891. * 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.
  86892. */
  86893. set shadowsExposure(value: number);
  86894. /**
  86895. * Returns the class name
  86896. * @returns The class name
  86897. */
  86898. getClassName(): string;
  86899. /**
  86900. * Binds the color curves to the shader.
  86901. * @param colorCurves The color curve to bind
  86902. * @param effect The effect to bind to
  86903. * @param positiveUniform The positive uniform shader parameter
  86904. * @param neutralUniform The neutral uniform shader parameter
  86905. * @param negativeUniform The negative uniform shader parameter
  86906. */
  86907. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86908. /**
  86909. * Prepare the list of uniforms associated with the ColorCurves effects.
  86910. * @param uniformsList The list of uniforms used in the effect
  86911. */
  86912. static PrepareUniforms(uniformsList: string[]): void;
  86913. /**
  86914. * Returns color grading data based on a hue, density, saturation and exposure value.
  86915. * @param filterHue The hue of the color filter.
  86916. * @param filterDensity The density of the color filter.
  86917. * @param saturation The saturation.
  86918. * @param exposure The exposure.
  86919. * @param result The result data container.
  86920. */
  86921. private getColorGradingDataToRef;
  86922. /**
  86923. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86924. * @param value The input slider value in range [-100,100].
  86925. * @returns Adjusted value.
  86926. */
  86927. private static applyColorGradingSliderNonlinear;
  86928. /**
  86929. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86930. * @param hue The hue (H) input.
  86931. * @param saturation The saturation (S) input.
  86932. * @param brightness The brightness (B) input.
  86933. * @result An RGBA color represented as Vector4.
  86934. */
  86935. private static fromHSBToRef;
  86936. /**
  86937. * Returns a value clamped between min and max
  86938. * @param value The value to clamp
  86939. * @param min The minimum of value
  86940. * @param max The maximum of value
  86941. * @returns The clamped value.
  86942. */
  86943. private static clamp;
  86944. /**
  86945. * Clones the current color curve instance.
  86946. * @return The cloned curves
  86947. */
  86948. clone(): ColorCurves;
  86949. /**
  86950. * Serializes the current color curve instance to a json representation.
  86951. * @return a JSON representation
  86952. */
  86953. serialize(): any;
  86954. /**
  86955. * Parses the color curve from a json representation.
  86956. * @param source the JSON source to parse
  86957. * @return The parsed curves
  86958. */
  86959. static Parse(source: any): ColorCurves;
  86960. }
  86961. }
  86962. declare module BABYLON {
  86963. /**
  86964. * Interface to follow in your material defines to integrate easily the
  86965. * Image proccessing functions.
  86966. * @hidden
  86967. */
  86968. export interface IImageProcessingConfigurationDefines {
  86969. IMAGEPROCESSING: boolean;
  86970. VIGNETTE: boolean;
  86971. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86972. VIGNETTEBLENDMODEOPAQUE: boolean;
  86973. TONEMAPPING: boolean;
  86974. TONEMAPPING_ACES: boolean;
  86975. CONTRAST: boolean;
  86976. EXPOSURE: boolean;
  86977. COLORCURVES: boolean;
  86978. COLORGRADING: boolean;
  86979. COLORGRADING3D: boolean;
  86980. SAMPLER3DGREENDEPTH: boolean;
  86981. SAMPLER3DBGRMAP: boolean;
  86982. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86983. }
  86984. /**
  86985. * @hidden
  86986. */
  86987. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86988. IMAGEPROCESSING: boolean;
  86989. VIGNETTE: boolean;
  86990. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86991. VIGNETTEBLENDMODEOPAQUE: boolean;
  86992. TONEMAPPING: boolean;
  86993. TONEMAPPING_ACES: boolean;
  86994. CONTRAST: boolean;
  86995. COLORCURVES: boolean;
  86996. COLORGRADING: boolean;
  86997. COLORGRADING3D: boolean;
  86998. SAMPLER3DGREENDEPTH: boolean;
  86999. SAMPLER3DBGRMAP: boolean;
  87000. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87001. EXPOSURE: boolean;
  87002. constructor();
  87003. }
  87004. /**
  87005. * This groups together the common properties used for image processing either in direct forward pass
  87006. * or through post processing effect depending on the use of the image processing pipeline in your scene
  87007. * or not.
  87008. */
  87009. export class ImageProcessingConfiguration {
  87010. /**
  87011. * Default tone mapping applied in BabylonJS.
  87012. */
  87013. static readonly TONEMAPPING_STANDARD: number;
  87014. /**
  87015. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  87016. * to other engines rendering to increase portability.
  87017. */
  87018. static readonly TONEMAPPING_ACES: number;
  87019. /**
  87020. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  87021. */
  87022. colorCurves: Nullable<ColorCurves>;
  87023. private _colorCurvesEnabled;
  87024. /**
  87025. * Gets wether the color curves effect is enabled.
  87026. */
  87027. get colorCurvesEnabled(): boolean;
  87028. /**
  87029. * Sets wether the color curves effect is enabled.
  87030. */
  87031. set colorCurvesEnabled(value: boolean);
  87032. private _colorGradingTexture;
  87033. /**
  87034. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87035. */
  87036. get colorGradingTexture(): Nullable<BaseTexture>;
  87037. /**
  87038. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87039. */
  87040. set colorGradingTexture(value: Nullable<BaseTexture>);
  87041. private _colorGradingEnabled;
  87042. /**
  87043. * Gets wether the color grading effect is enabled.
  87044. */
  87045. get colorGradingEnabled(): boolean;
  87046. /**
  87047. * Sets wether the color grading effect is enabled.
  87048. */
  87049. set colorGradingEnabled(value: boolean);
  87050. private _colorGradingWithGreenDepth;
  87051. /**
  87052. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  87053. */
  87054. get colorGradingWithGreenDepth(): boolean;
  87055. /**
  87056. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  87057. */
  87058. set colorGradingWithGreenDepth(value: boolean);
  87059. private _colorGradingBGR;
  87060. /**
  87061. * Gets wether the color grading texture contains BGR values.
  87062. */
  87063. get colorGradingBGR(): boolean;
  87064. /**
  87065. * Sets wether the color grading texture contains BGR values.
  87066. */
  87067. set colorGradingBGR(value: boolean);
  87068. /** @hidden */
  87069. _exposure: number;
  87070. /**
  87071. * Gets the Exposure used in the effect.
  87072. */
  87073. get exposure(): number;
  87074. /**
  87075. * Sets the Exposure used in the effect.
  87076. */
  87077. set exposure(value: number);
  87078. private _toneMappingEnabled;
  87079. /**
  87080. * Gets wether the tone mapping effect is enabled.
  87081. */
  87082. get toneMappingEnabled(): boolean;
  87083. /**
  87084. * Sets wether the tone mapping effect is enabled.
  87085. */
  87086. set toneMappingEnabled(value: boolean);
  87087. private _toneMappingType;
  87088. /**
  87089. * Gets the type of tone mapping effect.
  87090. */
  87091. get toneMappingType(): number;
  87092. /**
  87093. * Sets the type of tone mapping effect used in BabylonJS.
  87094. */
  87095. set toneMappingType(value: number);
  87096. protected _contrast: number;
  87097. /**
  87098. * Gets the contrast used in the effect.
  87099. */
  87100. get contrast(): number;
  87101. /**
  87102. * Sets the contrast used in the effect.
  87103. */
  87104. set contrast(value: number);
  87105. /**
  87106. * Vignette stretch size.
  87107. */
  87108. vignetteStretch: number;
  87109. /**
  87110. * Vignette centre X Offset.
  87111. */
  87112. vignetteCentreX: number;
  87113. /**
  87114. * Vignette centre Y Offset.
  87115. */
  87116. vignetteCentreY: number;
  87117. /**
  87118. * Vignette weight or intensity of the vignette effect.
  87119. */
  87120. vignetteWeight: number;
  87121. /**
  87122. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  87123. * if vignetteEnabled is set to true.
  87124. */
  87125. vignetteColor: Color4;
  87126. /**
  87127. * Camera field of view used by the Vignette effect.
  87128. */
  87129. vignetteCameraFov: number;
  87130. private _vignetteBlendMode;
  87131. /**
  87132. * Gets the vignette blend mode allowing different kind of effect.
  87133. */
  87134. get vignetteBlendMode(): number;
  87135. /**
  87136. * Sets the vignette blend mode allowing different kind of effect.
  87137. */
  87138. set vignetteBlendMode(value: number);
  87139. private _vignetteEnabled;
  87140. /**
  87141. * Gets wether the vignette effect is enabled.
  87142. */
  87143. get vignetteEnabled(): boolean;
  87144. /**
  87145. * Sets wether the vignette effect is enabled.
  87146. */
  87147. set vignetteEnabled(value: boolean);
  87148. private _applyByPostProcess;
  87149. /**
  87150. * Gets wether the image processing is applied through a post process or not.
  87151. */
  87152. get applyByPostProcess(): boolean;
  87153. /**
  87154. * Sets wether the image processing is applied through a post process or not.
  87155. */
  87156. set applyByPostProcess(value: boolean);
  87157. private _isEnabled;
  87158. /**
  87159. * Gets wether the image processing is enabled or not.
  87160. */
  87161. get isEnabled(): boolean;
  87162. /**
  87163. * Sets wether the image processing is enabled or not.
  87164. */
  87165. set isEnabled(value: boolean);
  87166. /**
  87167. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  87168. */
  87169. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  87170. /**
  87171. * Method called each time the image processing information changes requires to recompile the effect.
  87172. */
  87173. protected _updateParameters(): void;
  87174. /**
  87175. * Gets the current class name.
  87176. * @return "ImageProcessingConfiguration"
  87177. */
  87178. getClassName(): string;
  87179. /**
  87180. * Prepare the list of uniforms associated with the Image Processing effects.
  87181. * @param uniforms The list of uniforms used in the effect
  87182. * @param defines the list of defines currently in use
  87183. */
  87184. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  87185. /**
  87186. * Prepare the list of samplers associated with the Image Processing effects.
  87187. * @param samplersList The list of uniforms used in the effect
  87188. * @param defines the list of defines currently in use
  87189. */
  87190. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  87191. /**
  87192. * Prepare the list of defines associated to the shader.
  87193. * @param defines the list of defines to complete
  87194. * @param forPostProcess Define if we are currently in post process mode or not
  87195. */
  87196. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  87197. /**
  87198. * Returns true if all the image processing information are ready.
  87199. * @returns True if ready, otherwise, false
  87200. */
  87201. isReady(): boolean;
  87202. /**
  87203. * Binds the image processing to the shader.
  87204. * @param effect The effect to bind to
  87205. * @param overrideAspectRatio Override the aspect ratio of the effect
  87206. */
  87207. bind(effect: Effect, overrideAspectRatio?: number): void;
  87208. /**
  87209. * Clones the current image processing instance.
  87210. * @return The cloned image processing
  87211. */
  87212. clone(): ImageProcessingConfiguration;
  87213. /**
  87214. * Serializes the current image processing instance to a json representation.
  87215. * @return a JSON representation
  87216. */
  87217. serialize(): any;
  87218. /**
  87219. * Parses the image processing from a json representation.
  87220. * @param source the JSON source to parse
  87221. * @return The parsed image processing
  87222. */
  87223. static Parse(source: any): ImageProcessingConfiguration;
  87224. private static _VIGNETTEMODE_MULTIPLY;
  87225. private static _VIGNETTEMODE_OPAQUE;
  87226. /**
  87227. * Used to apply the vignette as a mix with the pixel color.
  87228. */
  87229. static get VIGNETTEMODE_MULTIPLY(): number;
  87230. /**
  87231. * Used to apply the vignette as a replacement of the pixel color.
  87232. */
  87233. static get VIGNETTEMODE_OPAQUE(): number;
  87234. }
  87235. }
  87236. declare module BABYLON {
  87237. /** @hidden */
  87238. export var postprocessVertexShader: {
  87239. name: string;
  87240. shader: string;
  87241. };
  87242. }
  87243. declare module BABYLON {
  87244. interface ThinEngine {
  87245. /**
  87246. * Creates a new render target texture
  87247. * @param size defines the size of the texture
  87248. * @param options defines the options used to create the texture
  87249. * @returns a new render target texture stored in an InternalTexture
  87250. */
  87251. createRenderTargetTexture(size: number | {
  87252. width: number;
  87253. height: number;
  87254. layers?: number;
  87255. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87256. /**
  87257. * Creates a depth stencil texture.
  87258. * This is only available in WebGL 2 or with the depth texture extension available.
  87259. * @param size The size of face edge in the texture.
  87260. * @param options The options defining the texture.
  87261. * @returns The texture
  87262. */
  87263. createDepthStencilTexture(size: number | {
  87264. width: number;
  87265. height: number;
  87266. layers?: number;
  87267. }, options: DepthTextureCreationOptions): InternalTexture;
  87268. /** @hidden */
  87269. _createDepthStencilTexture(size: number | {
  87270. width: number;
  87271. height: number;
  87272. layers?: number;
  87273. }, options: DepthTextureCreationOptions): InternalTexture;
  87274. }
  87275. }
  87276. declare module BABYLON {
  87277. /**
  87278. * Defines the kind of connection point for node based material
  87279. */
  87280. export enum NodeMaterialBlockConnectionPointTypes {
  87281. /** Float */
  87282. Float = 1,
  87283. /** Int */
  87284. Int = 2,
  87285. /** Vector2 */
  87286. Vector2 = 4,
  87287. /** Vector3 */
  87288. Vector3 = 8,
  87289. /** Vector4 */
  87290. Vector4 = 16,
  87291. /** Color3 */
  87292. Color3 = 32,
  87293. /** Color4 */
  87294. Color4 = 64,
  87295. /** Matrix */
  87296. Matrix = 128,
  87297. /** Custom object */
  87298. Object = 256,
  87299. /** Detect type based on connection */
  87300. AutoDetect = 1024,
  87301. /** Output type that will be defined by input type */
  87302. BasedOnInput = 2048
  87303. }
  87304. }
  87305. declare module BABYLON {
  87306. /**
  87307. * Enum used to define the target of a block
  87308. */
  87309. export enum NodeMaterialBlockTargets {
  87310. /** Vertex shader */
  87311. Vertex = 1,
  87312. /** Fragment shader */
  87313. Fragment = 2,
  87314. /** Neutral */
  87315. Neutral = 4,
  87316. /** Vertex and Fragment */
  87317. VertexAndFragment = 3
  87318. }
  87319. }
  87320. declare module BABYLON {
  87321. /**
  87322. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  87323. */
  87324. export enum NodeMaterialBlockConnectionPointMode {
  87325. /** Value is an uniform */
  87326. Uniform = 0,
  87327. /** Value is a mesh attribute */
  87328. Attribute = 1,
  87329. /** Value is a varying between vertex and fragment shaders */
  87330. Varying = 2,
  87331. /** Mode is undefined */
  87332. Undefined = 3
  87333. }
  87334. }
  87335. declare module BABYLON {
  87336. /**
  87337. * Enum used to define system values e.g. values automatically provided by the system
  87338. */
  87339. export enum NodeMaterialSystemValues {
  87340. /** World */
  87341. World = 1,
  87342. /** View */
  87343. View = 2,
  87344. /** Projection */
  87345. Projection = 3,
  87346. /** ViewProjection */
  87347. ViewProjection = 4,
  87348. /** WorldView */
  87349. WorldView = 5,
  87350. /** WorldViewProjection */
  87351. WorldViewProjection = 6,
  87352. /** CameraPosition */
  87353. CameraPosition = 7,
  87354. /** Fog Color */
  87355. FogColor = 8,
  87356. /** Delta time */
  87357. DeltaTime = 9
  87358. }
  87359. }
  87360. declare module BABYLON {
  87361. /** Defines supported spaces */
  87362. export enum Space {
  87363. /** Local (object) space */
  87364. LOCAL = 0,
  87365. /** World space */
  87366. WORLD = 1,
  87367. /** Bone space */
  87368. BONE = 2
  87369. }
  87370. /** Defines the 3 main axes */
  87371. export class Axis {
  87372. /** X axis */
  87373. static X: Vector3;
  87374. /** Y axis */
  87375. static Y: Vector3;
  87376. /** Z axis */
  87377. static Z: Vector3;
  87378. }
  87379. }
  87380. declare module BABYLON {
  87381. /**
  87382. * Represents a camera frustum
  87383. */
  87384. export class Frustum {
  87385. /**
  87386. * Gets the planes representing the frustum
  87387. * @param transform matrix to be applied to the returned planes
  87388. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  87389. */
  87390. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  87391. /**
  87392. * Gets the near frustum plane transformed by the transform matrix
  87393. * @param transform transformation matrix to be applied to the resulting frustum plane
  87394. * @param frustumPlane the resuling frustum plane
  87395. */
  87396. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87397. /**
  87398. * Gets the far frustum plane transformed by the transform matrix
  87399. * @param transform transformation matrix to be applied to the resulting frustum plane
  87400. * @param frustumPlane the resuling frustum plane
  87401. */
  87402. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87403. /**
  87404. * Gets the left frustum plane transformed by the transform matrix
  87405. * @param transform transformation matrix to be applied to the resulting frustum plane
  87406. * @param frustumPlane the resuling frustum plane
  87407. */
  87408. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87409. /**
  87410. * Gets the right frustum plane transformed by the transform matrix
  87411. * @param transform transformation matrix to be applied to the resulting frustum plane
  87412. * @param frustumPlane the resuling frustum plane
  87413. */
  87414. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87415. /**
  87416. * Gets the top frustum plane transformed by the transform matrix
  87417. * @param transform transformation matrix to be applied to the resulting frustum plane
  87418. * @param frustumPlane the resuling frustum plane
  87419. */
  87420. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87421. /**
  87422. * Gets the bottom frustum plane transformed by the transform matrix
  87423. * @param transform transformation matrix to be applied to the resulting frustum plane
  87424. * @param frustumPlane the resuling frustum plane
  87425. */
  87426. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87427. /**
  87428. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  87429. * @param transform transformation matrix to be applied to the resulting frustum planes
  87430. * @param frustumPlanes the resuling frustum planes
  87431. */
  87432. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  87433. }
  87434. }
  87435. declare module BABYLON {
  87436. /**
  87437. * Interface for the size containing width and height
  87438. */
  87439. export interface ISize {
  87440. /**
  87441. * Width
  87442. */
  87443. width: number;
  87444. /**
  87445. * Heighht
  87446. */
  87447. height: number;
  87448. }
  87449. /**
  87450. * Size containing widht and height
  87451. */
  87452. export class Size implements ISize {
  87453. /**
  87454. * Width
  87455. */
  87456. width: number;
  87457. /**
  87458. * Height
  87459. */
  87460. height: number;
  87461. /**
  87462. * Creates a Size object from the given width and height (floats).
  87463. * @param width width of the new size
  87464. * @param height height of the new size
  87465. */
  87466. constructor(width: number, height: number);
  87467. /**
  87468. * Returns a string with the Size width and height
  87469. * @returns a string with the Size width and height
  87470. */
  87471. toString(): string;
  87472. /**
  87473. * "Size"
  87474. * @returns the string "Size"
  87475. */
  87476. getClassName(): string;
  87477. /**
  87478. * Returns the Size hash code.
  87479. * @returns a hash code for a unique width and height
  87480. */
  87481. getHashCode(): number;
  87482. /**
  87483. * Updates the current size from the given one.
  87484. * @param src the given size
  87485. */
  87486. copyFrom(src: Size): void;
  87487. /**
  87488. * Updates in place the current Size from the given floats.
  87489. * @param width width of the new size
  87490. * @param height height of the new size
  87491. * @returns the updated Size.
  87492. */
  87493. copyFromFloats(width: number, height: number): Size;
  87494. /**
  87495. * Updates in place the current Size from the given floats.
  87496. * @param width width to set
  87497. * @param height height to set
  87498. * @returns the updated Size.
  87499. */
  87500. set(width: number, height: number): Size;
  87501. /**
  87502. * Multiplies the width and height by numbers
  87503. * @param w factor to multiple the width by
  87504. * @param h factor to multiple the height by
  87505. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  87506. */
  87507. multiplyByFloats(w: number, h: number): Size;
  87508. /**
  87509. * Clones the size
  87510. * @returns a new Size copied from the given one.
  87511. */
  87512. clone(): Size;
  87513. /**
  87514. * True if the current Size and the given one width and height are strictly equal.
  87515. * @param other the other size to compare against
  87516. * @returns True if the current Size and the given one width and height are strictly equal.
  87517. */
  87518. equals(other: Size): boolean;
  87519. /**
  87520. * The surface of the Size : width * height (float).
  87521. */
  87522. get surface(): number;
  87523. /**
  87524. * Create a new size of zero
  87525. * @returns a new Size set to (0.0, 0.0)
  87526. */
  87527. static Zero(): Size;
  87528. /**
  87529. * Sums the width and height of two sizes
  87530. * @param otherSize size to add to this size
  87531. * @returns a new Size set as the addition result of the current Size and the given one.
  87532. */
  87533. add(otherSize: Size): Size;
  87534. /**
  87535. * Subtracts the width and height of two
  87536. * @param otherSize size to subtract to this size
  87537. * @returns a new Size set as the subtraction result of the given one from the current Size.
  87538. */
  87539. subtract(otherSize: Size): Size;
  87540. /**
  87541. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  87542. * @param start starting size to lerp between
  87543. * @param end end size to lerp between
  87544. * @param amount amount to lerp between the start and end values
  87545. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  87546. */
  87547. static Lerp(start: Size, end: Size, amount: number): Size;
  87548. }
  87549. }
  87550. declare module BABYLON {
  87551. /**
  87552. * Contains position and normal vectors for a vertex
  87553. */
  87554. export class PositionNormalVertex {
  87555. /** the position of the vertex (defaut: 0,0,0) */
  87556. position: Vector3;
  87557. /** the normal of the vertex (defaut: 0,1,0) */
  87558. normal: Vector3;
  87559. /**
  87560. * Creates a PositionNormalVertex
  87561. * @param position the position of the vertex (defaut: 0,0,0)
  87562. * @param normal the normal of the vertex (defaut: 0,1,0)
  87563. */
  87564. constructor(
  87565. /** the position of the vertex (defaut: 0,0,0) */
  87566. position?: Vector3,
  87567. /** the normal of the vertex (defaut: 0,1,0) */
  87568. normal?: Vector3);
  87569. /**
  87570. * Clones the PositionNormalVertex
  87571. * @returns the cloned PositionNormalVertex
  87572. */
  87573. clone(): PositionNormalVertex;
  87574. }
  87575. /**
  87576. * Contains position, normal and uv vectors for a vertex
  87577. */
  87578. export class PositionNormalTextureVertex {
  87579. /** the position of the vertex (defaut: 0,0,0) */
  87580. position: Vector3;
  87581. /** the normal of the vertex (defaut: 0,1,0) */
  87582. normal: Vector3;
  87583. /** the uv of the vertex (default: 0,0) */
  87584. uv: Vector2;
  87585. /**
  87586. * Creates a PositionNormalTextureVertex
  87587. * @param position the position of the vertex (defaut: 0,0,0)
  87588. * @param normal the normal of the vertex (defaut: 0,1,0)
  87589. * @param uv the uv of the vertex (default: 0,0)
  87590. */
  87591. constructor(
  87592. /** the position of the vertex (defaut: 0,0,0) */
  87593. position?: Vector3,
  87594. /** the normal of the vertex (defaut: 0,1,0) */
  87595. normal?: Vector3,
  87596. /** the uv of the vertex (default: 0,0) */
  87597. uv?: Vector2);
  87598. /**
  87599. * Clones the PositionNormalTextureVertex
  87600. * @returns the cloned PositionNormalTextureVertex
  87601. */
  87602. clone(): PositionNormalTextureVertex;
  87603. }
  87604. }
  87605. declare module BABYLON {
  87606. /**
  87607. * Enum defining the type of animations supported by InputBlock
  87608. */
  87609. export enum AnimatedInputBlockTypes {
  87610. /** No animation */
  87611. None = 0,
  87612. /** Time based animation. Will only work for floats */
  87613. Time = 1
  87614. }
  87615. }
  87616. declare module BABYLON {
  87617. /**
  87618. * Interface describing all the common properties and methods a shadow light needs to implement.
  87619. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  87620. * as well as binding the different shadow properties to the effects.
  87621. */
  87622. export interface IShadowLight extends Light {
  87623. /**
  87624. * The light id in the scene (used in scene.findLighById for instance)
  87625. */
  87626. id: string;
  87627. /**
  87628. * The position the shdow will be casted from.
  87629. */
  87630. position: Vector3;
  87631. /**
  87632. * In 2d mode (needCube being false), the direction used to cast the shadow.
  87633. */
  87634. direction: Vector3;
  87635. /**
  87636. * The transformed position. Position of the light in world space taking parenting in account.
  87637. */
  87638. transformedPosition: Vector3;
  87639. /**
  87640. * The transformed direction. Direction of the light in world space taking parenting in account.
  87641. */
  87642. transformedDirection: Vector3;
  87643. /**
  87644. * The friendly name of the light in the scene.
  87645. */
  87646. name: string;
  87647. /**
  87648. * Defines the shadow projection clipping minimum z value.
  87649. */
  87650. shadowMinZ: number;
  87651. /**
  87652. * Defines the shadow projection clipping maximum z value.
  87653. */
  87654. shadowMaxZ: number;
  87655. /**
  87656. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87657. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87658. */
  87659. computeTransformedInformation(): boolean;
  87660. /**
  87661. * Gets the scene the light belongs to.
  87662. * @returns The scene
  87663. */
  87664. getScene(): Scene;
  87665. /**
  87666. * Callback defining a custom Projection Matrix Builder.
  87667. * This can be used to override the default projection matrix computation.
  87668. */
  87669. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87670. /**
  87671. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87672. * @param matrix The materix to updated with the projection information
  87673. * @param viewMatrix The transform matrix of the light
  87674. * @param renderList The list of mesh to render in the map
  87675. * @returns The current light
  87676. */
  87677. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87678. /**
  87679. * Gets the current depth scale used in ESM.
  87680. * @returns The scale
  87681. */
  87682. getDepthScale(): number;
  87683. /**
  87684. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87685. * @returns true if a cube texture needs to be use
  87686. */
  87687. needCube(): boolean;
  87688. /**
  87689. * Detects if the projection matrix requires to be recomputed this frame.
  87690. * @returns true if it requires to be recomputed otherwise, false.
  87691. */
  87692. needProjectionMatrixCompute(): boolean;
  87693. /**
  87694. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87695. */
  87696. forceProjectionMatrixCompute(): void;
  87697. /**
  87698. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87699. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87700. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87701. */
  87702. getShadowDirection(faceIndex?: number): Vector3;
  87703. /**
  87704. * Gets the minZ used for shadow according to both the scene and the light.
  87705. * @param activeCamera The camera we are returning the min for
  87706. * @returns the depth min z
  87707. */
  87708. getDepthMinZ(activeCamera: Camera): number;
  87709. /**
  87710. * Gets the maxZ used for shadow according to both the scene and the light.
  87711. * @param activeCamera The camera we are returning the max for
  87712. * @returns the depth max z
  87713. */
  87714. getDepthMaxZ(activeCamera: Camera): number;
  87715. }
  87716. /**
  87717. * Base implementation IShadowLight
  87718. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  87719. */
  87720. export abstract class ShadowLight extends Light implements IShadowLight {
  87721. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  87722. protected _position: Vector3;
  87723. protected _setPosition(value: Vector3): void;
  87724. /**
  87725. * Sets the position the shadow will be casted from. Also use as the light position for both
  87726. * point and spot lights.
  87727. */
  87728. get position(): Vector3;
  87729. /**
  87730. * Sets the position the shadow will be casted from. Also use as the light position for both
  87731. * point and spot lights.
  87732. */
  87733. set position(value: Vector3);
  87734. protected _direction: Vector3;
  87735. protected _setDirection(value: Vector3): void;
  87736. /**
  87737. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  87738. * Also use as the light direction on spot and directional lights.
  87739. */
  87740. get direction(): Vector3;
  87741. /**
  87742. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  87743. * Also use as the light direction on spot and directional lights.
  87744. */
  87745. set direction(value: Vector3);
  87746. protected _shadowMinZ: number;
  87747. /**
  87748. * Gets the shadow projection clipping minimum z value.
  87749. */
  87750. get shadowMinZ(): number;
  87751. /**
  87752. * Sets the shadow projection clipping minimum z value.
  87753. */
  87754. set shadowMinZ(value: number);
  87755. protected _shadowMaxZ: number;
  87756. /**
  87757. * Sets the shadow projection clipping maximum z value.
  87758. */
  87759. get shadowMaxZ(): number;
  87760. /**
  87761. * Gets the shadow projection clipping maximum z value.
  87762. */
  87763. set shadowMaxZ(value: number);
  87764. /**
  87765. * Callback defining a custom Projection Matrix Builder.
  87766. * This can be used to override the default projection matrix computation.
  87767. */
  87768. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87769. /**
  87770. * The transformed position. Position of the light in world space taking parenting in account.
  87771. */
  87772. transformedPosition: Vector3;
  87773. /**
  87774. * The transformed direction. Direction of the light in world space taking parenting in account.
  87775. */
  87776. transformedDirection: Vector3;
  87777. private _needProjectionMatrixCompute;
  87778. /**
  87779. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87780. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87781. */
  87782. computeTransformedInformation(): boolean;
  87783. /**
  87784. * Return the depth scale used for the shadow map.
  87785. * @returns the depth scale.
  87786. */
  87787. getDepthScale(): number;
  87788. /**
  87789. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87790. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87791. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87792. */
  87793. getShadowDirection(faceIndex?: number): Vector3;
  87794. /**
  87795. * Returns the ShadowLight absolute position in the World.
  87796. * @returns the position vector in world space
  87797. */
  87798. getAbsolutePosition(): Vector3;
  87799. /**
  87800. * Sets the ShadowLight direction toward the passed target.
  87801. * @param target The point to target in local space
  87802. * @returns the updated ShadowLight direction
  87803. */
  87804. setDirectionToTarget(target: Vector3): Vector3;
  87805. /**
  87806. * Returns the light rotation in euler definition.
  87807. * @returns the x y z rotation in local space.
  87808. */
  87809. getRotation(): Vector3;
  87810. /**
  87811. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87812. * @returns true if a cube texture needs to be use
  87813. */
  87814. needCube(): boolean;
  87815. /**
  87816. * Detects if the projection matrix requires to be recomputed this frame.
  87817. * @returns true if it requires to be recomputed otherwise, false.
  87818. */
  87819. needProjectionMatrixCompute(): boolean;
  87820. /**
  87821. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87822. */
  87823. forceProjectionMatrixCompute(): void;
  87824. /** @hidden */
  87825. _initCache(): void;
  87826. /** @hidden */
  87827. _isSynchronized(): boolean;
  87828. /**
  87829. * Computes the world matrix of the node
  87830. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87831. * @returns the world matrix
  87832. */
  87833. computeWorldMatrix(force?: boolean): Matrix;
  87834. /**
  87835. * Gets the minZ used for shadow according to both the scene and the light.
  87836. * @param activeCamera The camera we are returning the min for
  87837. * @returns the depth min z
  87838. */
  87839. getDepthMinZ(activeCamera: Camera): number;
  87840. /**
  87841. * Gets the maxZ used for shadow according to both the scene and the light.
  87842. * @param activeCamera The camera we are returning the max for
  87843. * @returns the depth max z
  87844. */
  87845. getDepthMaxZ(activeCamera: Camera): number;
  87846. /**
  87847. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87848. * @param matrix The materix to updated with the projection information
  87849. * @param viewMatrix The transform matrix of the light
  87850. * @param renderList The list of mesh to render in the map
  87851. * @returns The current light
  87852. */
  87853. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87854. }
  87855. }
  87856. declare module BABYLON {
  87857. /** @hidden */
  87858. export var packingFunctions: {
  87859. name: string;
  87860. shader: string;
  87861. };
  87862. }
  87863. declare module BABYLON {
  87864. /** @hidden */
  87865. export var bayerDitherFunctions: {
  87866. name: string;
  87867. shader: string;
  87868. };
  87869. }
  87870. declare module BABYLON {
  87871. /** @hidden */
  87872. export var shadowMapFragmentDeclaration: {
  87873. name: string;
  87874. shader: string;
  87875. };
  87876. }
  87877. declare module BABYLON {
  87878. /** @hidden */
  87879. export var clipPlaneFragmentDeclaration: {
  87880. name: string;
  87881. shader: string;
  87882. };
  87883. }
  87884. declare module BABYLON {
  87885. /** @hidden */
  87886. export var clipPlaneFragment: {
  87887. name: string;
  87888. shader: string;
  87889. };
  87890. }
  87891. declare module BABYLON {
  87892. /** @hidden */
  87893. export var shadowMapFragment: {
  87894. name: string;
  87895. shader: string;
  87896. };
  87897. }
  87898. declare module BABYLON {
  87899. /** @hidden */
  87900. export var shadowMapPixelShader: {
  87901. name: string;
  87902. shader: string;
  87903. };
  87904. }
  87905. declare module BABYLON {
  87906. /** @hidden */
  87907. export var bonesDeclaration: {
  87908. name: string;
  87909. shader: string;
  87910. };
  87911. }
  87912. declare module BABYLON {
  87913. /** @hidden */
  87914. export var morphTargetsVertexGlobalDeclaration: {
  87915. name: string;
  87916. shader: string;
  87917. };
  87918. }
  87919. declare module BABYLON {
  87920. /** @hidden */
  87921. export var morphTargetsVertexDeclaration: {
  87922. name: string;
  87923. shader: string;
  87924. };
  87925. }
  87926. declare module BABYLON {
  87927. /** @hidden */
  87928. export var instancesDeclaration: {
  87929. name: string;
  87930. shader: string;
  87931. };
  87932. }
  87933. declare module BABYLON {
  87934. /** @hidden */
  87935. export var helperFunctions: {
  87936. name: string;
  87937. shader: string;
  87938. };
  87939. }
  87940. declare module BABYLON {
  87941. /** @hidden */
  87942. export var shadowMapVertexDeclaration: {
  87943. name: string;
  87944. shader: string;
  87945. };
  87946. }
  87947. declare module BABYLON {
  87948. /** @hidden */
  87949. export var clipPlaneVertexDeclaration: {
  87950. name: string;
  87951. shader: string;
  87952. };
  87953. }
  87954. declare module BABYLON {
  87955. /** @hidden */
  87956. export var morphTargetsVertex: {
  87957. name: string;
  87958. shader: string;
  87959. };
  87960. }
  87961. declare module BABYLON {
  87962. /** @hidden */
  87963. export var instancesVertex: {
  87964. name: string;
  87965. shader: string;
  87966. };
  87967. }
  87968. declare module BABYLON {
  87969. /** @hidden */
  87970. export var bonesVertex: {
  87971. name: string;
  87972. shader: string;
  87973. };
  87974. }
  87975. declare module BABYLON {
  87976. /** @hidden */
  87977. export var shadowMapVertexNormalBias: {
  87978. name: string;
  87979. shader: string;
  87980. };
  87981. }
  87982. declare module BABYLON {
  87983. /** @hidden */
  87984. export var shadowMapVertexMetric: {
  87985. name: string;
  87986. shader: string;
  87987. };
  87988. }
  87989. declare module BABYLON {
  87990. /** @hidden */
  87991. export var clipPlaneVertex: {
  87992. name: string;
  87993. shader: string;
  87994. };
  87995. }
  87996. declare module BABYLON {
  87997. /** @hidden */
  87998. export var shadowMapVertexShader: {
  87999. name: string;
  88000. shader: string;
  88001. };
  88002. }
  88003. declare module BABYLON {
  88004. /** @hidden */
  88005. export var depthBoxBlurPixelShader: {
  88006. name: string;
  88007. shader: string;
  88008. };
  88009. }
  88010. declare module BABYLON {
  88011. /** @hidden */
  88012. export var shadowMapFragmentSoftTransparentShadow: {
  88013. name: string;
  88014. shader: string;
  88015. };
  88016. }
  88017. declare module BABYLON {
  88018. /**
  88019. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88020. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88021. */
  88022. export class EffectFallbacks implements IEffectFallbacks {
  88023. private _defines;
  88024. private _currentRank;
  88025. private _maxRank;
  88026. private _mesh;
  88027. /**
  88028. * Removes the fallback from the bound mesh.
  88029. */
  88030. unBindMesh(): void;
  88031. /**
  88032. * Adds a fallback on the specified property.
  88033. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88034. * @param define The name of the define in the shader
  88035. */
  88036. addFallback(rank: number, define: string): void;
  88037. /**
  88038. * Sets the mesh to use CPU skinning when needing to fallback.
  88039. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88040. * @param mesh The mesh to use the fallbacks.
  88041. */
  88042. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88043. /**
  88044. * Checks to see if more fallbacks are still availible.
  88045. */
  88046. get hasMoreFallbacks(): boolean;
  88047. /**
  88048. * Removes the defines that should be removed when falling back.
  88049. * @param currentDefines defines the current define statements for the shader.
  88050. * @param effect defines the current effect we try to compile
  88051. * @returns The resulting defines with defines of the current rank removed.
  88052. */
  88053. reduce(currentDefines: string, effect: Effect): string;
  88054. }
  88055. }
  88056. declare module BABYLON {
  88057. /**
  88058. * Interface used to define Action
  88059. */
  88060. export interface IAction {
  88061. /**
  88062. * Trigger for the action
  88063. */
  88064. trigger: number;
  88065. /** Options of the trigger */
  88066. triggerOptions: any;
  88067. /**
  88068. * Gets the trigger parameters
  88069. * @returns the trigger parameters
  88070. */
  88071. getTriggerParameter(): any;
  88072. /**
  88073. * Internal only - executes current action event
  88074. * @hidden
  88075. */
  88076. _executeCurrent(evt?: ActionEvent): void;
  88077. /**
  88078. * Serialize placeholder for child classes
  88079. * @param parent of child
  88080. * @returns the serialized object
  88081. */
  88082. serialize(parent: any): any;
  88083. /**
  88084. * Internal only
  88085. * @hidden
  88086. */
  88087. _prepare(): void;
  88088. /**
  88089. * Internal only - manager for action
  88090. * @hidden
  88091. */
  88092. _actionManager: AbstractActionManager;
  88093. /**
  88094. * Adds action to chain of actions, may be a DoNothingAction
  88095. * @param action defines the next action to execute
  88096. * @returns The action passed in
  88097. * @see https://www.babylonjs-playground.com/#1T30HR#0
  88098. */
  88099. then(action: IAction): IAction;
  88100. }
  88101. /**
  88102. * The action to be carried out following a trigger
  88103. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  88104. */
  88105. export class Action implements IAction {
  88106. /** the trigger, with or without parameters, for the action */
  88107. triggerOptions: any;
  88108. /**
  88109. * Trigger for the action
  88110. */
  88111. trigger: number;
  88112. /**
  88113. * Internal only - manager for action
  88114. * @hidden
  88115. */
  88116. _actionManager: ActionManager;
  88117. private _nextActiveAction;
  88118. private _child;
  88119. private _condition?;
  88120. private _triggerParameter;
  88121. /**
  88122. * An event triggered prior to action being executed.
  88123. */
  88124. onBeforeExecuteObservable: Observable<Action>;
  88125. /**
  88126. * Creates a new Action
  88127. * @param triggerOptions the trigger, with or without parameters, for the action
  88128. * @param condition an optional determinant of action
  88129. */
  88130. constructor(
  88131. /** the trigger, with or without parameters, for the action */
  88132. triggerOptions: any, condition?: Condition);
  88133. /**
  88134. * Internal only
  88135. * @hidden
  88136. */
  88137. _prepare(): void;
  88138. /**
  88139. * Gets the trigger parameters
  88140. * @returns the trigger parameters
  88141. */
  88142. getTriggerParameter(): any;
  88143. /**
  88144. * Internal only - executes current action event
  88145. * @hidden
  88146. */
  88147. _executeCurrent(evt?: ActionEvent): void;
  88148. /**
  88149. * Execute placeholder for child classes
  88150. * @param evt optional action event
  88151. */
  88152. execute(evt?: ActionEvent): void;
  88153. /**
  88154. * Skips to next active action
  88155. */
  88156. skipToNextActiveAction(): void;
  88157. /**
  88158. * Adds action to chain of actions, may be a DoNothingAction
  88159. * @param action defines the next action to execute
  88160. * @returns The action passed in
  88161. * @see https://www.babylonjs-playground.com/#1T30HR#0
  88162. */
  88163. then(action: Action): Action;
  88164. /**
  88165. * Internal only
  88166. * @hidden
  88167. */
  88168. _getProperty(propertyPath: string): string;
  88169. /**
  88170. * Internal only
  88171. * @hidden
  88172. */
  88173. _getEffectiveTarget(target: any, propertyPath: string): any;
  88174. /**
  88175. * Serialize placeholder for child classes
  88176. * @param parent of child
  88177. * @returns the serialized object
  88178. */
  88179. serialize(parent: any): any;
  88180. /**
  88181. * Internal only called by serialize
  88182. * @hidden
  88183. */
  88184. protected _serialize(serializedAction: any, parent?: any): any;
  88185. /**
  88186. * Internal only
  88187. * @hidden
  88188. */
  88189. static _SerializeValueAsString: (value: any) => string;
  88190. /**
  88191. * Internal only
  88192. * @hidden
  88193. */
  88194. static _GetTargetProperty: (target: Scene | Node) => {
  88195. name: string;
  88196. targetType: string;
  88197. value: string;
  88198. };
  88199. }
  88200. }
  88201. declare module BABYLON {
  88202. /**
  88203. * A Condition applied to an Action
  88204. */
  88205. export class Condition {
  88206. /**
  88207. * Internal only - manager for action
  88208. * @hidden
  88209. */
  88210. _actionManager: ActionManager;
  88211. /**
  88212. * Internal only
  88213. * @hidden
  88214. */
  88215. _evaluationId: number;
  88216. /**
  88217. * Internal only
  88218. * @hidden
  88219. */
  88220. _currentResult: boolean;
  88221. /**
  88222. * Creates a new Condition
  88223. * @param actionManager the manager of the action the condition is applied to
  88224. */
  88225. constructor(actionManager: ActionManager);
  88226. /**
  88227. * Check if the current condition is valid
  88228. * @returns a boolean
  88229. */
  88230. isValid(): boolean;
  88231. /**
  88232. * Internal only
  88233. * @hidden
  88234. */
  88235. _getProperty(propertyPath: string): string;
  88236. /**
  88237. * Internal only
  88238. * @hidden
  88239. */
  88240. _getEffectiveTarget(target: any, propertyPath: string): any;
  88241. /**
  88242. * Serialize placeholder for child classes
  88243. * @returns the serialized object
  88244. */
  88245. serialize(): any;
  88246. /**
  88247. * Internal only
  88248. * @hidden
  88249. */
  88250. protected _serialize(serializedCondition: any): any;
  88251. }
  88252. /**
  88253. * Defines specific conditional operators as extensions of Condition
  88254. */
  88255. export class ValueCondition extends Condition {
  88256. /** path to specify the property of the target the conditional operator uses */
  88257. propertyPath: string;
  88258. /** the value compared by the conditional operator against the current value of the property */
  88259. value: any;
  88260. /** the conditional operator, default ValueCondition.IsEqual */
  88261. operator: number;
  88262. /**
  88263. * Internal only
  88264. * @hidden
  88265. */
  88266. private static _IsEqual;
  88267. /**
  88268. * Internal only
  88269. * @hidden
  88270. */
  88271. private static _IsDifferent;
  88272. /**
  88273. * Internal only
  88274. * @hidden
  88275. */
  88276. private static _IsGreater;
  88277. /**
  88278. * Internal only
  88279. * @hidden
  88280. */
  88281. private static _IsLesser;
  88282. /**
  88283. * returns the number for IsEqual
  88284. */
  88285. static get IsEqual(): number;
  88286. /**
  88287. * Returns the number for IsDifferent
  88288. */
  88289. static get IsDifferent(): number;
  88290. /**
  88291. * Returns the number for IsGreater
  88292. */
  88293. static get IsGreater(): number;
  88294. /**
  88295. * Returns the number for IsLesser
  88296. */
  88297. static get IsLesser(): number;
  88298. /**
  88299. * Internal only The action manager for the condition
  88300. * @hidden
  88301. */
  88302. _actionManager: ActionManager;
  88303. /**
  88304. * Internal only
  88305. * @hidden
  88306. */
  88307. private _target;
  88308. /**
  88309. * Internal only
  88310. * @hidden
  88311. */
  88312. private _effectiveTarget;
  88313. /**
  88314. * Internal only
  88315. * @hidden
  88316. */
  88317. private _property;
  88318. /**
  88319. * Creates a new ValueCondition
  88320. * @param actionManager manager for the action the condition applies to
  88321. * @param target for the action
  88322. * @param propertyPath path to specify the property of the target the conditional operator uses
  88323. * @param value the value compared by the conditional operator against the current value of the property
  88324. * @param operator the conditional operator, default ValueCondition.IsEqual
  88325. */
  88326. constructor(actionManager: ActionManager, target: any,
  88327. /** path to specify the property of the target the conditional operator uses */
  88328. propertyPath: string,
  88329. /** the value compared by the conditional operator against the current value of the property */
  88330. value: any,
  88331. /** the conditional operator, default ValueCondition.IsEqual */
  88332. operator?: number);
  88333. /**
  88334. * Compares the given value with the property value for the specified conditional operator
  88335. * @returns the result of the comparison
  88336. */
  88337. isValid(): boolean;
  88338. /**
  88339. * Serialize the ValueCondition into a JSON compatible object
  88340. * @returns serialization object
  88341. */
  88342. serialize(): any;
  88343. /**
  88344. * Gets the name of the conditional operator for the ValueCondition
  88345. * @param operator the conditional operator
  88346. * @returns the name
  88347. */
  88348. static GetOperatorName(operator: number): string;
  88349. }
  88350. /**
  88351. * Defines a predicate condition as an extension of Condition
  88352. */
  88353. export class PredicateCondition extends Condition {
  88354. /** defines the predicate function used to validate the condition */
  88355. predicate: () => boolean;
  88356. /**
  88357. * Internal only - manager for action
  88358. * @hidden
  88359. */
  88360. _actionManager: ActionManager;
  88361. /**
  88362. * Creates a new PredicateCondition
  88363. * @param actionManager manager for the action the condition applies to
  88364. * @param predicate defines the predicate function used to validate the condition
  88365. */
  88366. constructor(actionManager: ActionManager,
  88367. /** defines the predicate function used to validate the condition */
  88368. predicate: () => boolean);
  88369. /**
  88370. * @returns the validity of the predicate condition
  88371. */
  88372. isValid(): boolean;
  88373. }
  88374. /**
  88375. * Defines a state condition as an extension of Condition
  88376. */
  88377. export class StateCondition extends Condition {
  88378. /** Value to compare with target state */
  88379. value: string;
  88380. /**
  88381. * Internal only - manager for action
  88382. * @hidden
  88383. */
  88384. _actionManager: ActionManager;
  88385. /**
  88386. * Internal only
  88387. * @hidden
  88388. */
  88389. private _target;
  88390. /**
  88391. * Creates a new StateCondition
  88392. * @param actionManager manager for the action the condition applies to
  88393. * @param target of the condition
  88394. * @param value to compare with target state
  88395. */
  88396. constructor(actionManager: ActionManager, target: any,
  88397. /** Value to compare with target state */
  88398. value: string);
  88399. /**
  88400. * Gets a boolean indicating if the current condition is met
  88401. * @returns the validity of the state
  88402. */
  88403. isValid(): boolean;
  88404. /**
  88405. * Serialize the StateCondition into a JSON compatible object
  88406. * @returns serialization object
  88407. */
  88408. serialize(): any;
  88409. }
  88410. }
  88411. declare module BABYLON {
  88412. /**
  88413. * This defines an action responsible to toggle a boolean once triggered.
  88414. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88415. */
  88416. export class SwitchBooleanAction extends Action {
  88417. /**
  88418. * The path to the boolean property in the target object
  88419. */
  88420. propertyPath: string;
  88421. private _target;
  88422. private _effectiveTarget;
  88423. private _property;
  88424. /**
  88425. * Instantiate the action
  88426. * @param triggerOptions defines the trigger options
  88427. * @param target defines the object containing the boolean
  88428. * @param propertyPath defines the path to the boolean property in the target object
  88429. * @param condition defines the trigger related conditions
  88430. */
  88431. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  88432. /** @hidden */
  88433. _prepare(): void;
  88434. /**
  88435. * Execute the action toggle the boolean value.
  88436. */
  88437. execute(): void;
  88438. /**
  88439. * Serializes the actions and its related information.
  88440. * @param parent defines the object to serialize in
  88441. * @returns the serialized object
  88442. */
  88443. serialize(parent: any): any;
  88444. }
  88445. /**
  88446. * This defines an action responsible to set a the state field of the target
  88447. * to a desired value once triggered.
  88448. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88449. */
  88450. export class SetStateAction extends Action {
  88451. /**
  88452. * The value to store in the state field.
  88453. */
  88454. value: string;
  88455. private _target;
  88456. /**
  88457. * Instantiate the action
  88458. * @param triggerOptions defines the trigger options
  88459. * @param target defines the object containing the state property
  88460. * @param value defines the value to store in the state field
  88461. * @param condition defines the trigger related conditions
  88462. */
  88463. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  88464. /**
  88465. * Execute the action and store the value on the target state property.
  88466. */
  88467. execute(): void;
  88468. /**
  88469. * Serializes the actions and its related information.
  88470. * @param parent defines the object to serialize in
  88471. * @returns the serialized object
  88472. */
  88473. serialize(parent: any): any;
  88474. }
  88475. /**
  88476. * This defines an action responsible to set a property of the target
  88477. * to a desired value once triggered.
  88478. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88479. */
  88480. export class SetValueAction extends Action {
  88481. /**
  88482. * The path of the property to set in the target.
  88483. */
  88484. propertyPath: string;
  88485. /**
  88486. * The value to set in the property
  88487. */
  88488. value: any;
  88489. private _target;
  88490. private _effectiveTarget;
  88491. private _property;
  88492. /**
  88493. * Instantiate the action
  88494. * @param triggerOptions defines the trigger options
  88495. * @param target defines the object containing the property
  88496. * @param propertyPath defines the path of the property to set in the target
  88497. * @param value defines the value to set in the property
  88498. * @param condition defines the trigger related conditions
  88499. */
  88500. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88501. /** @hidden */
  88502. _prepare(): void;
  88503. /**
  88504. * Execute the action and set the targetted property to the desired value.
  88505. */
  88506. execute(): void;
  88507. /**
  88508. * Serializes the actions and its related information.
  88509. * @param parent defines the object to serialize in
  88510. * @returns the serialized object
  88511. */
  88512. serialize(parent: any): any;
  88513. }
  88514. /**
  88515. * This defines an action responsible to increment the target value
  88516. * to a desired value once triggered.
  88517. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88518. */
  88519. export class IncrementValueAction extends Action {
  88520. /**
  88521. * The path of the property to increment in the target.
  88522. */
  88523. propertyPath: string;
  88524. /**
  88525. * The value we should increment the property by.
  88526. */
  88527. value: any;
  88528. private _target;
  88529. private _effectiveTarget;
  88530. private _property;
  88531. /**
  88532. * Instantiate the action
  88533. * @param triggerOptions defines the trigger options
  88534. * @param target defines the object containing the property
  88535. * @param propertyPath defines the path of the property to increment in the target
  88536. * @param value defines the value value we should increment the property by
  88537. * @param condition defines the trigger related conditions
  88538. */
  88539. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88540. /** @hidden */
  88541. _prepare(): void;
  88542. /**
  88543. * Execute the action and increment the target of the value amount.
  88544. */
  88545. execute(): void;
  88546. /**
  88547. * Serializes the actions and its related information.
  88548. * @param parent defines the object to serialize in
  88549. * @returns the serialized object
  88550. */
  88551. serialize(parent: any): any;
  88552. }
  88553. /**
  88554. * This defines an action responsible to start an animation once triggered.
  88555. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88556. */
  88557. export class PlayAnimationAction extends Action {
  88558. /**
  88559. * Where the animation should start (animation frame)
  88560. */
  88561. from: number;
  88562. /**
  88563. * Where the animation should stop (animation frame)
  88564. */
  88565. to: number;
  88566. /**
  88567. * Define if the animation should loop or stop after the first play.
  88568. */
  88569. loop?: boolean;
  88570. private _target;
  88571. /**
  88572. * Instantiate the action
  88573. * @param triggerOptions defines the trigger options
  88574. * @param target defines the target animation or animation name
  88575. * @param from defines from where the animation should start (animation frame)
  88576. * @param end defines where the animation should stop (animation frame)
  88577. * @param loop defines if the animation should loop or stop after the first play
  88578. * @param condition defines the trigger related conditions
  88579. */
  88580. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  88581. /** @hidden */
  88582. _prepare(): void;
  88583. /**
  88584. * Execute the action and play the animation.
  88585. */
  88586. execute(): void;
  88587. /**
  88588. * Serializes the actions and its related information.
  88589. * @param parent defines the object to serialize in
  88590. * @returns the serialized object
  88591. */
  88592. serialize(parent: any): any;
  88593. }
  88594. /**
  88595. * This defines an action responsible to stop an animation once triggered.
  88596. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88597. */
  88598. export class StopAnimationAction extends Action {
  88599. private _target;
  88600. /**
  88601. * Instantiate the action
  88602. * @param triggerOptions defines the trigger options
  88603. * @param target defines the target animation or animation name
  88604. * @param condition defines the trigger related conditions
  88605. */
  88606. constructor(triggerOptions: any, target: any, condition?: Condition);
  88607. /** @hidden */
  88608. _prepare(): void;
  88609. /**
  88610. * Execute the action and stop the animation.
  88611. */
  88612. execute(): void;
  88613. /**
  88614. * Serializes the actions and its related information.
  88615. * @param parent defines the object to serialize in
  88616. * @returns the serialized object
  88617. */
  88618. serialize(parent: any): any;
  88619. }
  88620. /**
  88621. * This defines an action responsible that does nothing once triggered.
  88622. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88623. */
  88624. export class DoNothingAction extends Action {
  88625. /**
  88626. * Instantiate the action
  88627. * @param triggerOptions defines the trigger options
  88628. * @param condition defines the trigger related conditions
  88629. */
  88630. constructor(triggerOptions?: any, condition?: Condition);
  88631. /**
  88632. * Execute the action and do nothing.
  88633. */
  88634. execute(): void;
  88635. /**
  88636. * Serializes the actions and its related information.
  88637. * @param parent defines the object to serialize in
  88638. * @returns the serialized object
  88639. */
  88640. serialize(parent: any): any;
  88641. }
  88642. /**
  88643. * This defines an action responsible to trigger several actions once triggered.
  88644. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88645. */
  88646. export class CombineAction extends Action {
  88647. /**
  88648. * The list of aggregated animations to run.
  88649. */
  88650. children: Action[];
  88651. /**
  88652. * Instantiate the action
  88653. * @param triggerOptions defines the trigger options
  88654. * @param children defines the list of aggregated animations to run
  88655. * @param condition defines the trigger related conditions
  88656. */
  88657. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  88658. /** @hidden */
  88659. _prepare(): void;
  88660. /**
  88661. * Execute the action and executes all the aggregated actions.
  88662. */
  88663. execute(evt: ActionEvent): void;
  88664. /**
  88665. * Serializes the actions and its related information.
  88666. * @param parent defines the object to serialize in
  88667. * @returns the serialized object
  88668. */
  88669. serialize(parent: any): any;
  88670. }
  88671. /**
  88672. * This defines an action responsible to run code (external event) once triggered.
  88673. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88674. */
  88675. export class ExecuteCodeAction extends Action {
  88676. /**
  88677. * The callback function to run.
  88678. */
  88679. func: (evt: ActionEvent) => void;
  88680. /**
  88681. * Instantiate the action
  88682. * @param triggerOptions defines the trigger options
  88683. * @param func defines the callback function to run
  88684. * @param condition defines the trigger related conditions
  88685. */
  88686. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  88687. /**
  88688. * Execute the action and run the attached code.
  88689. */
  88690. execute(evt: ActionEvent): void;
  88691. }
  88692. /**
  88693. * This defines an action responsible to set the parent property of the target once triggered.
  88694. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88695. */
  88696. export class SetParentAction extends Action {
  88697. private _parent;
  88698. private _target;
  88699. /**
  88700. * Instantiate the action
  88701. * @param triggerOptions defines the trigger options
  88702. * @param target defines the target containing the parent property
  88703. * @param parent defines from where the animation should start (animation frame)
  88704. * @param condition defines the trigger related conditions
  88705. */
  88706. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  88707. /** @hidden */
  88708. _prepare(): void;
  88709. /**
  88710. * Execute the action and set the parent property.
  88711. */
  88712. execute(): void;
  88713. /**
  88714. * Serializes the actions and its related information.
  88715. * @param parent defines the object to serialize in
  88716. * @returns the serialized object
  88717. */
  88718. serialize(parent: any): any;
  88719. }
  88720. }
  88721. declare module BABYLON {
  88722. /**
  88723. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  88724. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  88725. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88726. */
  88727. export class ActionManager extends AbstractActionManager {
  88728. /**
  88729. * Nothing
  88730. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88731. */
  88732. static readonly NothingTrigger: number;
  88733. /**
  88734. * On pick
  88735. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88736. */
  88737. static readonly OnPickTrigger: number;
  88738. /**
  88739. * On left pick
  88740. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88741. */
  88742. static readonly OnLeftPickTrigger: number;
  88743. /**
  88744. * On right pick
  88745. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88746. */
  88747. static readonly OnRightPickTrigger: number;
  88748. /**
  88749. * On center pick
  88750. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88751. */
  88752. static readonly OnCenterPickTrigger: number;
  88753. /**
  88754. * On pick down
  88755. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88756. */
  88757. static readonly OnPickDownTrigger: number;
  88758. /**
  88759. * On double pick
  88760. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88761. */
  88762. static readonly OnDoublePickTrigger: number;
  88763. /**
  88764. * On pick up
  88765. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88766. */
  88767. static readonly OnPickUpTrigger: number;
  88768. /**
  88769. * On pick out.
  88770. * This trigger will only be raised if you also declared a OnPickDown
  88771. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88772. */
  88773. static readonly OnPickOutTrigger: number;
  88774. /**
  88775. * On long press
  88776. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88777. */
  88778. static readonly OnLongPressTrigger: number;
  88779. /**
  88780. * On pointer over
  88781. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88782. */
  88783. static readonly OnPointerOverTrigger: number;
  88784. /**
  88785. * On pointer out
  88786. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88787. */
  88788. static readonly OnPointerOutTrigger: number;
  88789. /**
  88790. * On every frame
  88791. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88792. */
  88793. static readonly OnEveryFrameTrigger: number;
  88794. /**
  88795. * On intersection enter
  88796. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88797. */
  88798. static readonly OnIntersectionEnterTrigger: number;
  88799. /**
  88800. * On intersection exit
  88801. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88802. */
  88803. static readonly OnIntersectionExitTrigger: number;
  88804. /**
  88805. * On key down
  88806. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88807. */
  88808. static readonly OnKeyDownTrigger: number;
  88809. /**
  88810. * On key up
  88811. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88812. */
  88813. static readonly OnKeyUpTrigger: number;
  88814. private _scene;
  88815. /**
  88816. * Creates a new action manager
  88817. * @param scene defines the hosting scene
  88818. */
  88819. constructor(scene: Scene);
  88820. /**
  88821. * Releases all associated resources
  88822. */
  88823. dispose(): void;
  88824. /**
  88825. * Gets hosting scene
  88826. * @returns the hosting scene
  88827. */
  88828. getScene(): Scene;
  88829. /**
  88830. * Does this action manager handles actions of any of the given triggers
  88831. * @param triggers defines the triggers to be tested
  88832. * @return a boolean indicating whether one (or more) of the triggers is handled
  88833. */
  88834. hasSpecificTriggers(triggers: number[]): boolean;
  88835. /**
  88836. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  88837. * speed.
  88838. * @param triggerA defines the trigger to be tested
  88839. * @param triggerB defines the trigger to be tested
  88840. * @return a boolean indicating whether one (or more) of the triggers is handled
  88841. */
  88842. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  88843. /**
  88844. * Does this action manager handles actions of a given trigger
  88845. * @param trigger defines the trigger to be tested
  88846. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  88847. * @return whether the trigger is handled
  88848. */
  88849. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  88850. /**
  88851. * Does this action manager has pointer triggers
  88852. */
  88853. get hasPointerTriggers(): boolean;
  88854. /**
  88855. * Does this action manager has pick triggers
  88856. */
  88857. get hasPickTriggers(): boolean;
  88858. /**
  88859. * Registers an action to this action manager
  88860. * @param action defines the action to be registered
  88861. * @return the action amended (prepared) after registration
  88862. */
  88863. registerAction(action: IAction): Nullable<IAction>;
  88864. /**
  88865. * Unregisters an action to this action manager
  88866. * @param action defines the action to be unregistered
  88867. * @return a boolean indicating whether the action has been unregistered
  88868. */
  88869. unregisterAction(action: IAction): Boolean;
  88870. /**
  88871. * Process a specific trigger
  88872. * @param trigger defines the trigger to process
  88873. * @param evt defines the event details to be processed
  88874. */
  88875. processTrigger(trigger: number, evt?: IActionEvent): void;
  88876. /** @hidden */
  88877. _getEffectiveTarget(target: any, propertyPath: string): any;
  88878. /** @hidden */
  88879. _getProperty(propertyPath: string): string;
  88880. /**
  88881. * Serialize this manager to a JSON object
  88882. * @param name defines the property name to store this manager
  88883. * @returns a JSON representation of this manager
  88884. */
  88885. serialize(name: string): any;
  88886. /**
  88887. * Creates a new ActionManager from a JSON data
  88888. * @param parsedActions defines the JSON data to read from
  88889. * @param object defines the hosting mesh
  88890. * @param scene defines the hosting scene
  88891. */
  88892. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  88893. /**
  88894. * Get a trigger name by index
  88895. * @param trigger defines the trigger index
  88896. * @returns a trigger name
  88897. */
  88898. static GetTriggerName(trigger: number): string;
  88899. }
  88900. }
  88901. declare module BABYLON {
  88902. /**
  88903. * Class used to represent a sprite
  88904. * @see https://doc.babylonjs.com/babylon101/sprites
  88905. */
  88906. export class Sprite implements IAnimatable {
  88907. /** defines the name */
  88908. name: string;
  88909. /** Gets or sets the current world position */
  88910. position: Vector3;
  88911. /** Gets or sets the main color */
  88912. color: Color4;
  88913. /** Gets or sets the width */
  88914. width: number;
  88915. /** Gets or sets the height */
  88916. height: number;
  88917. /** Gets or sets rotation angle */
  88918. angle: number;
  88919. /** Gets or sets the cell index in the sprite sheet */
  88920. cellIndex: number;
  88921. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  88922. cellRef: string;
  88923. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  88924. invertU: boolean;
  88925. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  88926. invertV: boolean;
  88927. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  88928. disposeWhenFinishedAnimating: boolean;
  88929. /** Gets the list of attached animations */
  88930. animations: Nullable<Array<Animation>>;
  88931. /** Gets or sets a boolean indicating if the sprite can be picked */
  88932. isPickable: boolean;
  88933. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  88934. useAlphaForPicking: boolean;
  88935. /** @hidden */
  88936. _xOffset: number;
  88937. /** @hidden */
  88938. _yOffset: number;
  88939. /** @hidden */
  88940. _xSize: number;
  88941. /** @hidden */
  88942. _ySize: number;
  88943. /**
  88944. * Gets or sets the associated action manager
  88945. */
  88946. actionManager: Nullable<ActionManager>;
  88947. /**
  88948. * An event triggered when the control has been disposed
  88949. */
  88950. onDisposeObservable: Observable<Sprite>;
  88951. private _animationStarted;
  88952. private _loopAnimation;
  88953. private _fromIndex;
  88954. private _toIndex;
  88955. private _delay;
  88956. private _direction;
  88957. private _manager;
  88958. private _time;
  88959. private _onAnimationEnd;
  88960. /**
  88961. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  88962. */
  88963. isVisible: boolean;
  88964. /**
  88965. * Gets or sets the sprite size
  88966. */
  88967. get size(): number;
  88968. set size(value: number);
  88969. /**
  88970. * Returns a boolean indicating if the animation is started
  88971. */
  88972. get animationStarted(): boolean;
  88973. /**
  88974. * Gets or sets the unique id of the sprite
  88975. */
  88976. uniqueId: number;
  88977. /**
  88978. * Gets the manager of this sprite
  88979. */
  88980. get manager(): ISpriteManager;
  88981. /**
  88982. * Creates a new Sprite
  88983. * @param name defines the name
  88984. * @param manager defines the manager
  88985. */
  88986. constructor(
  88987. /** defines the name */
  88988. name: string, manager: ISpriteManager);
  88989. /**
  88990. * Returns the string "Sprite"
  88991. * @returns "Sprite"
  88992. */
  88993. getClassName(): string;
  88994. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  88995. get fromIndex(): number;
  88996. set fromIndex(value: number);
  88997. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  88998. get toIndex(): number;
  88999. set toIndex(value: number);
  89000. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  89001. get loopAnimation(): boolean;
  89002. set loopAnimation(value: boolean);
  89003. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  89004. get delay(): number;
  89005. set delay(value: number);
  89006. /**
  89007. * Starts an animation
  89008. * @param from defines the initial key
  89009. * @param to defines the end key
  89010. * @param loop defines if the animation must loop
  89011. * @param delay defines the start delay (in ms)
  89012. * @param onAnimationEnd defines a callback to call when animation ends
  89013. */
  89014. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  89015. /** Stops current animation (if any) */
  89016. stopAnimation(): void;
  89017. /** @hidden */
  89018. _animate(deltaTime: number): void;
  89019. /** Release associated resources */
  89020. dispose(): void;
  89021. /**
  89022. * Serializes the sprite to a JSON object
  89023. * @returns the JSON object
  89024. */
  89025. serialize(): any;
  89026. /**
  89027. * Parses a JSON object to create a new sprite
  89028. * @param parsedSprite The JSON object to parse
  89029. * @param manager defines the hosting manager
  89030. * @returns the new sprite
  89031. */
  89032. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  89033. }
  89034. }
  89035. declare module BABYLON {
  89036. /**
  89037. * Information about the result of picking within a scene
  89038. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  89039. */
  89040. export class PickingInfo {
  89041. /** @hidden */
  89042. _pickingUnavailable: boolean;
  89043. /**
  89044. * If the pick collided with an object
  89045. */
  89046. hit: boolean;
  89047. /**
  89048. * Distance away where the pick collided
  89049. */
  89050. distance: number;
  89051. /**
  89052. * The location of pick collision
  89053. */
  89054. pickedPoint: Nullable<Vector3>;
  89055. /**
  89056. * The mesh corresponding the the pick collision
  89057. */
  89058. pickedMesh: Nullable<AbstractMesh>;
  89059. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  89060. bu: number;
  89061. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  89062. bv: number;
  89063. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  89064. faceId: number;
  89065. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  89066. subMeshFaceId: number;
  89067. /** Id of the the submesh that was picked */
  89068. subMeshId: number;
  89069. /** If a sprite was picked, this will be the sprite the pick collided with */
  89070. pickedSprite: Nullable<Sprite>;
  89071. /**
  89072. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  89073. */
  89074. originMesh: Nullable<AbstractMesh>;
  89075. /**
  89076. * The ray that was used to perform the picking.
  89077. */
  89078. ray: Nullable<Ray>;
  89079. /**
  89080. * Gets the normal correspodning to the face the pick collided with
  89081. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  89082. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  89083. * @returns The normal correspodning to the face the pick collided with
  89084. */
  89085. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  89086. /**
  89087. * Gets the texture coordinates of where the pick occured
  89088. * @returns the vector containing the coordnates of the texture
  89089. */
  89090. getTextureCoordinates(): Nullable<Vector2>;
  89091. }
  89092. }
  89093. declare module BABYLON {
  89094. /**
  89095. * Class representing a ray with position and direction
  89096. */
  89097. export class Ray {
  89098. /** origin point */
  89099. origin: Vector3;
  89100. /** direction */
  89101. direction: Vector3;
  89102. /** length of the ray */
  89103. length: number;
  89104. private static readonly TmpVector3;
  89105. private _tmpRay;
  89106. /**
  89107. * Creates a new ray
  89108. * @param origin origin point
  89109. * @param direction direction
  89110. * @param length length of the ray
  89111. */
  89112. constructor(
  89113. /** origin point */
  89114. origin: Vector3,
  89115. /** direction */
  89116. direction: Vector3,
  89117. /** length of the ray */
  89118. length?: number);
  89119. /**
  89120. * Checks if the ray intersects a box
  89121. * This does not account for the ray lenght by design to improve perfs.
  89122. * @param minimum bound of the box
  89123. * @param maximum bound of the box
  89124. * @param intersectionTreshold extra extend to be added to the box in all direction
  89125. * @returns if the box was hit
  89126. */
  89127. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  89128. /**
  89129. * Checks if the ray intersects a box
  89130. * This does not account for the ray lenght by design to improve perfs.
  89131. * @param box the bounding box to check
  89132. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  89133. * @returns if the box was hit
  89134. */
  89135. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  89136. /**
  89137. * If the ray hits a sphere
  89138. * @param sphere the bounding sphere to check
  89139. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  89140. * @returns true if it hits the sphere
  89141. */
  89142. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  89143. /**
  89144. * If the ray hits a triange
  89145. * @param vertex0 triangle vertex
  89146. * @param vertex1 triangle vertex
  89147. * @param vertex2 triangle vertex
  89148. * @returns intersection information if hit
  89149. */
  89150. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  89151. /**
  89152. * Checks if ray intersects a plane
  89153. * @param plane the plane to check
  89154. * @returns the distance away it was hit
  89155. */
  89156. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  89157. /**
  89158. * Calculate the intercept of a ray on a given axis
  89159. * @param axis to check 'x' | 'y' | 'z'
  89160. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  89161. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  89162. */
  89163. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  89164. /**
  89165. * Checks if ray intersects a mesh
  89166. * @param mesh the mesh to check
  89167. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89168. * @returns picking info of the intersecton
  89169. */
  89170. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  89171. /**
  89172. * Checks if ray intersects a mesh
  89173. * @param meshes the meshes to check
  89174. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89175. * @param results array to store result in
  89176. * @returns Array of picking infos
  89177. */
  89178. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  89179. private _comparePickingInfo;
  89180. private static smallnum;
  89181. private static rayl;
  89182. /**
  89183. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  89184. * @param sega the first point of the segment to test the intersection against
  89185. * @param segb the second point of the segment to test the intersection against
  89186. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  89187. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  89188. */
  89189. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  89190. /**
  89191. * Update the ray from viewport position
  89192. * @param x position
  89193. * @param y y position
  89194. * @param viewportWidth viewport width
  89195. * @param viewportHeight viewport height
  89196. * @param world world matrix
  89197. * @param view view matrix
  89198. * @param projection projection matrix
  89199. * @returns this ray updated
  89200. */
  89201. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89202. /**
  89203. * Creates a ray with origin and direction of 0,0,0
  89204. * @returns the new ray
  89205. */
  89206. static Zero(): Ray;
  89207. /**
  89208. * Creates a new ray from screen space and viewport
  89209. * @param x position
  89210. * @param y y position
  89211. * @param viewportWidth viewport width
  89212. * @param viewportHeight viewport height
  89213. * @param world world matrix
  89214. * @param view view matrix
  89215. * @param projection projection matrix
  89216. * @returns new ray
  89217. */
  89218. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89219. /**
  89220. * 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
  89221. * transformed to the given world matrix.
  89222. * @param origin The origin point
  89223. * @param end The end point
  89224. * @param world a matrix to transform the ray to. Default is the identity matrix.
  89225. * @returns the new ray
  89226. */
  89227. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  89228. /**
  89229. * Transforms a ray by a matrix
  89230. * @param ray ray to transform
  89231. * @param matrix matrix to apply
  89232. * @returns the resulting new ray
  89233. */
  89234. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  89235. /**
  89236. * Transforms a ray by a matrix
  89237. * @param ray ray to transform
  89238. * @param matrix matrix to apply
  89239. * @param result ray to store result in
  89240. */
  89241. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  89242. /**
  89243. * Unproject a ray from screen space to object space
  89244. * @param sourceX defines the screen space x coordinate to use
  89245. * @param sourceY defines the screen space y coordinate to use
  89246. * @param viewportWidth defines the current width of the viewport
  89247. * @param viewportHeight defines the current height of the viewport
  89248. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  89249. * @param view defines the view matrix to use
  89250. * @param projection defines the projection matrix to use
  89251. */
  89252. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  89253. }
  89254. /**
  89255. * Type used to define predicate used to select faces when a mesh intersection is detected
  89256. */
  89257. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  89258. interface Scene {
  89259. /** @hidden */
  89260. _tempPickingRay: Nullable<Ray>;
  89261. /** @hidden */
  89262. _cachedRayForTransform: Ray;
  89263. /** @hidden */
  89264. _pickWithRayInverseMatrix: Matrix;
  89265. /** @hidden */
  89266. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  89267. /** @hidden */
  89268. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  89269. }
  89270. }
  89271. declare module BABYLON {
  89272. /**
  89273. * Groups all the scene component constants in one place to ease maintenance.
  89274. * @hidden
  89275. */
  89276. export class SceneComponentConstants {
  89277. static readonly NAME_EFFECTLAYER: string;
  89278. static readonly NAME_LAYER: string;
  89279. static readonly NAME_LENSFLARESYSTEM: string;
  89280. static readonly NAME_BOUNDINGBOXRENDERER: string;
  89281. static readonly NAME_PARTICLESYSTEM: string;
  89282. static readonly NAME_GAMEPAD: string;
  89283. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  89284. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  89285. static readonly NAME_PREPASSRENDERER: string;
  89286. static readonly NAME_DEPTHRENDERER: string;
  89287. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  89288. static readonly NAME_SPRITE: string;
  89289. static readonly NAME_OUTLINERENDERER: string;
  89290. static readonly NAME_PROCEDURALTEXTURE: string;
  89291. static readonly NAME_SHADOWGENERATOR: string;
  89292. static readonly NAME_OCTREE: string;
  89293. static readonly NAME_PHYSICSENGINE: string;
  89294. static readonly NAME_AUDIO: string;
  89295. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  89296. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89297. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  89298. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89299. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  89300. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  89301. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  89302. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  89303. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  89304. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  89305. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  89306. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  89307. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  89308. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  89309. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  89310. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  89311. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  89312. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  89313. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  89314. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  89315. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  89316. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  89317. static readonly STEP_AFTERRENDER_AUDIO: number;
  89318. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  89319. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  89320. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  89321. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  89322. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  89323. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  89324. static readonly STEP_POINTERMOVE_SPRITE: number;
  89325. static readonly STEP_POINTERDOWN_SPRITE: number;
  89326. static readonly STEP_POINTERUP_SPRITE: number;
  89327. }
  89328. /**
  89329. * This represents a scene component.
  89330. *
  89331. * This is used to decouple the dependency the scene is having on the different workloads like
  89332. * layers, post processes...
  89333. */
  89334. export interface ISceneComponent {
  89335. /**
  89336. * The name of the component. Each component must have a unique name.
  89337. */
  89338. name: string;
  89339. /**
  89340. * The scene the component belongs to.
  89341. */
  89342. scene: Scene;
  89343. /**
  89344. * Register the component to one instance of a scene.
  89345. */
  89346. register(): void;
  89347. /**
  89348. * Rebuilds the elements related to this component in case of
  89349. * context lost for instance.
  89350. */
  89351. rebuild(): void;
  89352. /**
  89353. * Disposes the component and the associated ressources.
  89354. */
  89355. dispose(): void;
  89356. }
  89357. /**
  89358. * This represents a SERIALIZABLE scene component.
  89359. *
  89360. * This extends Scene Component to add Serialization methods on top.
  89361. */
  89362. export interface ISceneSerializableComponent extends ISceneComponent {
  89363. /**
  89364. * Adds all the elements from the container to the scene
  89365. * @param container the container holding the elements
  89366. */
  89367. addFromContainer(container: AbstractScene): void;
  89368. /**
  89369. * Removes all the elements in the container from the scene
  89370. * @param container contains the elements to remove
  89371. * @param dispose if the removed element should be disposed (default: false)
  89372. */
  89373. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  89374. /**
  89375. * Serializes the component data to the specified json object
  89376. * @param serializationObject The object to serialize to
  89377. */
  89378. serialize(serializationObject: any): void;
  89379. }
  89380. /**
  89381. * Strong typing of a Mesh related stage step action
  89382. */
  89383. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  89384. /**
  89385. * Strong typing of a Evaluate Sub Mesh related stage step action
  89386. */
  89387. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  89388. /**
  89389. * Strong typing of a Active Mesh related stage step action
  89390. */
  89391. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  89392. /**
  89393. * Strong typing of a Camera related stage step action
  89394. */
  89395. export type CameraStageAction = (camera: Camera) => void;
  89396. /**
  89397. * Strong typing of a Camera Frame buffer related stage step action
  89398. */
  89399. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  89400. /**
  89401. * Strong typing of a Render Target related stage step action
  89402. */
  89403. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  89404. /**
  89405. * Strong typing of a RenderingGroup related stage step action
  89406. */
  89407. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  89408. /**
  89409. * Strong typing of a Mesh Render related stage step action
  89410. */
  89411. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  89412. /**
  89413. * Strong typing of a simple stage step action
  89414. */
  89415. export type SimpleStageAction = () => void;
  89416. /**
  89417. * Strong typing of a render target action.
  89418. */
  89419. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  89420. /**
  89421. * Strong typing of a pointer move action.
  89422. */
  89423. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  89424. /**
  89425. * Strong typing of a pointer up/down action.
  89426. */
  89427. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  89428. /**
  89429. * Representation of a stage in the scene (Basically a list of ordered steps)
  89430. * @hidden
  89431. */
  89432. export class Stage<T extends Function> extends Array<{
  89433. index: number;
  89434. component: ISceneComponent;
  89435. action: T;
  89436. }> {
  89437. /**
  89438. * Hide ctor from the rest of the world.
  89439. * @param items The items to add.
  89440. */
  89441. private constructor();
  89442. /**
  89443. * Creates a new Stage.
  89444. * @returns A new instance of a Stage
  89445. */
  89446. static Create<T extends Function>(): Stage<T>;
  89447. /**
  89448. * Registers a step in an ordered way in the targeted stage.
  89449. * @param index Defines the position to register the step in
  89450. * @param component Defines the component attached to the step
  89451. * @param action Defines the action to launch during the step
  89452. */
  89453. registerStep(index: number, component: ISceneComponent, action: T): void;
  89454. /**
  89455. * Clears all the steps from the stage.
  89456. */
  89457. clear(): void;
  89458. }
  89459. }
  89460. declare module BABYLON {
  89461. interface Scene {
  89462. /** @hidden */
  89463. _pointerOverSprite: Nullable<Sprite>;
  89464. /** @hidden */
  89465. _pickedDownSprite: Nullable<Sprite>;
  89466. /** @hidden */
  89467. _tempSpritePickingRay: Nullable<Ray>;
  89468. /**
  89469. * All of the sprite managers added to this scene
  89470. * @see https://doc.babylonjs.com/babylon101/sprites
  89471. */
  89472. spriteManagers: Array<ISpriteManager>;
  89473. /**
  89474. * An event triggered when sprites rendering is about to start
  89475. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  89476. */
  89477. onBeforeSpritesRenderingObservable: Observable<Scene>;
  89478. /**
  89479. * An event triggered when sprites rendering is done
  89480. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  89481. */
  89482. onAfterSpritesRenderingObservable: Observable<Scene>;
  89483. /** @hidden */
  89484. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89485. /** Launch a ray to try to pick a sprite in the scene
  89486. * @param x position on screen
  89487. * @param y position on screen
  89488. * @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
  89489. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89490. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89491. * @returns a PickingInfo
  89492. */
  89493. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89494. /** Use the given ray to pick a sprite in the scene
  89495. * @param ray The ray (in world space) to use to pick meshes
  89496. * @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
  89497. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89498. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89499. * @returns a PickingInfo
  89500. */
  89501. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89502. /** @hidden */
  89503. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89504. /** Launch a ray to try to pick sprites in the scene
  89505. * @param x position on screen
  89506. * @param y position on screen
  89507. * @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
  89508. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89509. * @returns a PickingInfo array
  89510. */
  89511. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89512. /** Use the given ray to pick sprites in the scene
  89513. * @param ray The ray (in world space) to use to pick meshes
  89514. * @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
  89515. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89516. * @returns a PickingInfo array
  89517. */
  89518. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89519. /**
  89520. * Force the sprite under the pointer
  89521. * @param sprite defines the sprite to use
  89522. */
  89523. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  89524. /**
  89525. * Gets the sprite under the pointer
  89526. * @returns a Sprite or null if no sprite is under the pointer
  89527. */
  89528. getPointerOverSprite(): Nullable<Sprite>;
  89529. }
  89530. /**
  89531. * Defines the sprite scene component responsible to manage sprites
  89532. * in a given scene.
  89533. */
  89534. export class SpriteSceneComponent implements ISceneComponent {
  89535. /**
  89536. * The component name helpfull to identify the component in the list of scene components.
  89537. */
  89538. readonly name: string;
  89539. /**
  89540. * The scene the component belongs to.
  89541. */
  89542. scene: Scene;
  89543. /** @hidden */
  89544. private _spritePredicate;
  89545. /**
  89546. * Creates a new instance of the component for the given scene
  89547. * @param scene Defines the scene to register the component in
  89548. */
  89549. constructor(scene: Scene);
  89550. /**
  89551. * Registers the component in a given scene
  89552. */
  89553. register(): void;
  89554. /**
  89555. * Rebuilds the elements related to this component in case of
  89556. * context lost for instance.
  89557. */
  89558. rebuild(): void;
  89559. /**
  89560. * Disposes the component and the associated ressources.
  89561. */
  89562. dispose(): void;
  89563. private _pickSpriteButKeepRay;
  89564. private _pointerMove;
  89565. private _pointerDown;
  89566. private _pointerUp;
  89567. }
  89568. }
  89569. declare module BABYLON {
  89570. /** @hidden */
  89571. export var fogFragmentDeclaration: {
  89572. name: string;
  89573. shader: string;
  89574. };
  89575. }
  89576. declare module BABYLON {
  89577. /** @hidden */
  89578. export var fogFragment: {
  89579. name: string;
  89580. shader: string;
  89581. };
  89582. }
  89583. declare module BABYLON {
  89584. /** @hidden */
  89585. export var spritesPixelShader: {
  89586. name: string;
  89587. shader: string;
  89588. };
  89589. }
  89590. declare module BABYLON {
  89591. /** @hidden */
  89592. export var fogVertexDeclaration: {
  89593. name: string;
  89594. shader: string;
  89595. };
  89596. }
  89597. declare module BABYLON {
  89598. /** @hidden */
  89599. export var spritesVertexShader: {
  89600. name: string;
  89601. shader: string;
  89602. };
  89603. }
  89604. declare module BABYLON {
  89605. /**
  89606. * Defines the minimum interface to fullfil in order to be a sprite manager.
  89607. */
  89608. export interface ISpriteManager extends IDisposable {
  89609. /**
  89610. * Gets manager's name
  89611. */
  89612. name: string;
  89613. /**
  89614. * Restricts the camera to viewing objects with the same layerMask.
  89615. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  89616. */
  89617. layerMask: number;
  89618. /**
  89619. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89620. */
  89621. isPickable: boolean;
  89622. /**
  89623. * Gets the hosting scene
  89624. */
  89625. scene: Scene;
  89626. /**
  89627. * Specifies the rendering group id for this mesh (0 by default)
  89628. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89629. */
  89630. renderingGroupId: number;
  89631. /**
  89632. * Defines the list of sprites managed by the manager.
  89633. */
  89634. sprites: Array<Sprite>;
  89635. /**
  89636. * Gets or sets the spritesheet texture
  89637. */
  89638. texture: Texture;
  89639. /** Defines the default width of a cell in the spritesheet */
  89640. cellWidth: number;
  89641. /** Defines the default height of a cell in the spritesheet */
  89642. cellHeight: number;
  89643. /**
  89644. * Tests the intersection of a sprite with a specific ray.
  89645. * @param ray The ray we are sending to test the collision
  89646. * @param camera The camera space we are sending rays in
  89647. * @param predicate A predicate allowing excluding sprites from the list of object to test
  89648. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89649. * @returns picking info or null.
  89650. */
  89651. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89652. /**
  89653. * Intersects the sprites with a ray
  89654. * @param ray defines the ray to intersect with
  89655. * @param camera defines the current active camera
  89656. * @param predicate defines a predicate used to select candidate sprites
  89657. * @returns null if no hit or a PickingInfo array
  89658. */
  89659. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89660. /**
  89661. * Renders the list of sprites on screen.
  89662. */
  89663. render(): void;
  89664. }
  89665. /**
  89666. * Class used to manage multiple sprites on the same spritesheet
  89667. * @see https://doc.babylonjs.com/babylon101/sprites
  89668. */
  89669. export class SpriteManager implements ISpriteManager {
  89670. /** defines the manager's name */
  89671. name: string;
  89672. /** Define the Url to load snippets */
  89673. static SnippetUrl: string;
  89674. /** Snippet ID if the manager was created from the snippet server */
  89675. snippetId: string;
  89676. /** Gets the list of sprites */
  89677. sprites: Sprite[];
  89678. /** Gets or sets the rendering group id (0 by default) */
  89679. renderingGroupId: number;
  89680. /** Gets or sets camera layer mask */
  89681. layerMask: number;
  89682. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  89683. fogEnabled: boolean;
  89684. /** Gets or sets a boolean indicating if the sprites are pickable */
  89685. isPickable: boolean;
  89686. /** Defines the default width of a cell in the spritesheet */
  89687. cellWidth: number;
  89688. /** Defines the default height of a cell in the spritesheet */
  89689. cellHeight: number;
  89690. /** Associative array from JSON sprite data file */
  89691. private _cellData;
  89692. /** Array of sprite names from JSON sprite data file */
  89693. private _spriteMap;
  89694. /** True when packed cell data from JSON file is ready*/
  89695. private _packedAndReady;
  89696. private _textureContent;
  89697. /**
  89698. * An event triggered when the manager is disposed.
  89699. */
  89700. onDisposeObservable: Observable<SpriteManager>;
  89701. private _onDisposeObserver;
  89702. /**
  89703. * Callback called when the manager is disposed
  89704. */
  89705. set onDispose(callback: () => void);
  89706. private _capacity;
  89707. private _fromPacked;
  89708. private _spriteTexture;
  89709. private _epsilon;
  89710. private _scene;
  89711. private _vertexData;
  89712. private _buffer;
  89713. private _vertexBuffers;
  89714. private _indexBuffer;
  89715. private _effectBase;
  89716. private _effectFog;
  89717. /**
  89718. * Gets or sets the unique id of the sprite
  89719. */
  89720. uniqueId: number;
  89721. /**
  89722. * Gets the array of sprites
  89723. */
  89724. get children(): Sprite[];
  89725. /**
  89726. * Gets the hosting scene
  89727. */
  89728. get scene(): Scene;
  89729. /**
  89730. * Gets the capacity of the manager
  89731. */
  89732. get capacity(): number;
  89733. /**
  89734. * Gets or sets the spritesheet texture
  89735. */
  89736. get texture(): Texture;
  89737. set texture(value: Texture);
  89738. private _blendMode;
  89739. /**
  89740. * Blend mode use to render the particle, it can be any of
  89741. * the static Constants.ALPHA_x properties provided in this class.
  89742. * Default value is Constants.ALPHA_COMBINE
  89743. */
  89744. get blendMode(): number;
  89745. set blendMode(blendMode: number);
  89746. /** Disables writing to the depth buffer when rendering the sprites.
  89747. * It can be handy to disable depth writing when using textures without alpha channel
  89748. * and setting some specific blend modes.
  89749. */
  89750. disableDepthWrite: boolean;
  89751. /**
  89752. * Creates a new sprite manager
  89753. * @param name defines the manager's name
  89754. * @param imgUrl defines the sprite sheet url
  89755. * @param capacity defines the maximum allowed number of sprites
  89756. * @param cellSize defines the size of a sprite cell
  89757. * @param scene defines the hosting scene
  89758. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  89759. * @param samplingMode defines the smapling mode to use with spritesheet
  89760. * @param fromPacked set to false; do not alter
  89761. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  89762. */
  89763. constructor(
  89764. /** defines the manager's name */
  89765. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  89766. /**
  89767. * Returns the string "SpriteManager"
  89768. * @returns "SpriteManager"
  89769. */
  89770. getClassName(): string;
  89771. private _makePacked;
  89772. private _appendSpriteVertex;
  89773. private _checkTextureAlpha;
  89774. /**
  89775. * Intersects the sprites with a ray
  89776. * @param ray defines the ray to intersect with
  89777. * @param camera defines the current active camera
  89778. * @param predicate defines a predicate used to select candidate sprites
  89779. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  89780. * @returns null if no hit or a PickingInfo
  89781. */
  89782. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89783. /**
  89784. * Intersects the sprites with a ray
  89785. * @param ray defines the ray to intersect with
  89786. * @param camera defines the current active camera
  89787. * @param predicate defines a predicate used to select candidate sprites
  89788. * @returns null if no hit or a PickingInfo array
  89789. */
  89790. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89791. /**
  89792. * Render all child sprites
  89793. */
  89794. render(): void;
  89795. /**
  89796. * Release associated resources
  89797. */
  89798. dispose(): void;
  89799. /**
  89800. * Serializes the sprite manager to a JSON object
  89801. * @param serializeTexture defines if the texture must be serialized as well
  89802. * @returns the JSON object
  89803. */
  89804. serialize(serializeTexture?: boolean): any;
  89805. /**
  89806. * Parses a JSON object to create a new sprite manager.
  89807. * @param parsedManager The JSON object to parse
  89808. * @param scene The scene to create the sprite managerin
  89809. * @param rootUrl The root url to use to load external dependencies like texture
  89810. * @returns the new sprite manager
  89811. */
  89812. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  89813. /**
  89814. * Creates a sprite manager from a snippet saved in a remote file
  89815. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  89816. * @param url defines the url to load from
  89817. * @param scene defines the hosting scene
  89818. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89819. * @returns a promise that will resolve to the new sprite manager
  89820. */
  89821. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  89822. /**
  89823. * Creates a sprite manager from a snippet saved by the sprite editor
  89824. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  89825. * @param scene defines the hosting scene
  89826. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89827. * @returns a promise that will resolve to the new sprite manager
  89828. */
  89829. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  89830. }
  89831. }
  89832. declare module BABYLON {
  89833. /** Interface used by value gradients (color, factor, ...) */
  89834. export interface IValueGradient {
  89835. /**
  89836. * Gets or sets the gradient value (between 0 and 1)
  89837. */
  89838. gradient: number;
  89839. }
  89840. /** Class used to store color4 gradient */
  89841. export class ColorGradient implements IValueGradient {
  89842. /**
  89843. * Gets or sets the gradient value (between 0 and 1)
  89844. */
  89845. gradient: number;
  89846. /**
  89847. * Gets or sets first associated color
  89848. */
  89849. color1: Color4;
  89850. /**
  89851. * Gets or sets second associated color
  89852. */
  89853. color2?: Color4 | undefined;
  89854. /**
  89855. * Creates a new color4 gradient
  89856. * @param gradient gets or sets the gradient value (between 0 and 1)
  89857. * @param color1 gets or sets first associated color
  89858. * @param color2 gets or sets first second color
  89859. */
  89860. constructor(
  89861. /**
  89862. * Gets or sets the gradient value (between 0 and 1)
  89863. */
  89864. gradient: number,
  89865. /**
  89866. * Gets or sets first associated color
  89867. */
  89868. color1: Color4,
  89869. /**
  89870. * Gets or sets second associated color
  89871. */
  89872. color2?: Color4 | undefined);
  89873. /**
  89874. * Will get a color picked randomly between color1 and color2.
  89875. * If color2 is undefined then color1 will be used
  89876. * @param result defines the target Color4 to store the result in
  89877. */
  89878. getColorToRef(result: Color4): void;
  89879. }
  89880. /** Class used to store color 3 gradient */
  89881. export class Color3Gradient implements IValueGradient {
  89882. /**
  89883. * Gets or sets the gradient value (between 0 and 1)
  89884. */
  89885. gradient: number;
  89886. /**
  89887. * Gets or sets the associated color
  89888. */
  89889. color: Color3;
  89890. /**
  89891. * Creates a new color3 gradient
  89892. * @param gradient gets or sets the gradient value (between 0 and 1)
  89893. * @param color gets or sets associated color
  89894. */
  89895. constructor(
  89896. /**
  89897. * Gets or sets the gradient value (between 0 and 1)
  89898. */
  89899. gradient: number,
  89900. /**
  89901. * Gets or sets the associated color
  89902. */
  89903. color: Color3);
  89904. }
  89905. /** Class used to store factor gradient */
  89906. export class FactorGradient implements IValueGradient {
  89907. /**
  89908. * Gets or sets the gradient value (between 0 and 1)
  89909. */
  89910. gradient: number;
  89911. /**
  89912. * Gets or sets first associated factor
  89913. */
  89914. factor1: number;
  89915. /**
  89916. * Gets or sets second associated factor
  89917. */
  89918. factor2?: number | undefined;
  89919. /**
  89920. * Creates a new factor gradient
  89921. * @param gradient gets or sets the gradient value (between 0 and 1)
  89922. * @param factor1 gets or sets first associated factor
  89923. * @param factor2 gets or sets second associated factor
  89924. */
  89925. constructor(
  89926. /**
  89927. * Gets or sets the gradient value (between 0 and 1)
  89928. */
  89929. gradient: number,
  89930. /**
  89931. * Gets or sets first associated factor
  89932. */
  89933. factor1: number,
  89934. /**
  89935. * Gets or sets second associated factor
  89936. */
  89937. factor2?: number | undefined);
  89938. /**
  89939. * Will get a number picked randomly between factor1 and factor2.
  89940. * If factor2 is undefined then factor1 will be used
  89941. * @returns the picked number
  89942. */
  89943. getFactor(): number;
  89944. }
  89945. /**
  89946. * Helper used to simplify some generic gradient tasks
  89947. */
  89948. export class GradientHelper {
  89949. /**
  89950. * Gets the current gradient from an array of IValueGradient
  89951. * @param ratio defines the current ratio to get
  89952. * @param gradients defines the array of IValueGradient
  89953. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89954. */
  89955. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89956. }
  89957. }
  89958. declare module BABYLON {
  89959. interface ThinEngine {
  89960. /**
  89961. * Creates a raw texture
  89962. * @param data defines the data to store in the texture
  89963. * @param width defines the width of the texture
  89964. * @param height defines the height of the texture
  89965. * @param format defines the format of the data
  89966. * @param generateMipMaps defines if the engine should generate the mip levels
  89967. * @param invertY defines if data must be stored with Y axis inverted
  89968. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  89969. * @param compression defines the compression used (null by default)
  89970. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89971. * @returns the raw texture inside an InternalTexture
  89972. */
  89973. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  89974. /**
  89975. * Update a raw texture
  89976. * @param texture defines the texture to update
  89977. * @param data defines the data to store in the texture
  89978. * @param format defines the format of the data
  89979. * @param invertY defines if data must be stored with Y axis inverted
  89980. */
  89981. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89982. /**
  89983. * Update a raw texture
  89984. * @param texture defines the texture to update
  89985. * @param data defines the data to store in the texture
  89986. * @param format defines the format of the data
  89987. * @param invertY defines if data must be stored with Y axis inverted
  89988. * @param compression defines the compression used (null by default)
  89989. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89990. */
  89991. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  89992. /**
  89993. * Creates a new raw cube texture
  89994. * @param data defines the array of data to use to create each face
  89995. * @param size defines the size of the textures
  89996. * @param format defines the format of the data
  89997. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89998. * @param generateMipMaps defines if the engine should generate the mip levels
  89999. * @param invertY defines if data must be stored with Y axis inverted
  90000. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90001. * @param compression defines the compression used (null by default)
  90002. * @returns the cube texture as an InternalTexture
  90003. */
  90004. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  90005. /**
  90006. * Update a raw cube texture
  90007. * @param texture defines the texture to udpdate
  90008. * @param data defines the data to store
  90009. * @param format defines the data format
  90010. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90011. * @param invertY defines if data must be stored with Y axis inverted
  90012. */
  90013. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  90014. /**
  90015. * Update a raw cube texture
  90016. * @param texture defines the texture to udpdate
  90017. * @param data defines the data to store
  90018. * @param format defines the data format
  90019. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90020. * @param invertY defines if data must be stored with Y axis inverted
  90021. * @param compression defines the compression used (null by default)
  90022. */
  90023. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  90024. /**
  90025. * Update a raw cube texture
  90026. * @param texture defines the texture to udpdate
  90027. * @param data defines the data to store
  90028. * @param format defines the data format
  90029. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90030. * @param invertY defines if data must be stored with Y axis inverted
  90031. * @param compression defines the compression used (null by default)
  90032. * @param level defines which level of the texture to update
  90033. */
  90034. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  90035. /**
  90036. * Creates a new raw cube texture from a specified url
  90037. * @param url defines the url where the data is located
  90038. * @param scene defines the current scene
  90039. * @param size defines the size of the textures
  90040. * @param format defines the format of the data
  90041. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90042. * @param noMipmap defines if the engine should avoid generating the mip levels
  90043. * @param callback defines a callback used to extract texture data from loaded data
  90044. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  90045. * @param onLoad defines a callback called when texture is loaded
  90046. * @param onError defines a callback called if there is an error
  90047. * @returns the cube texture as an InternalTexture
  90048. */
  90049. 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;
  90050. /**
  90051. * Creates a new raw cube texture from a specified url
  90052. * @param url defines the url where the data is located
  90053. * @param scene defines the current scene
  90054. * @param size defines the size of the textures
  90055. * @param format defines the format of the data
  90056. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90057. * @param noMipmap defines if the engine should avoid generating the mip levels
  90058. * @param callback defines a callback used to extract texture data from loaded data
  90059. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  90060. * @param onLoad defines a callback called when texture is loaded
  90061. * @param onError defines a callback called if there is an error
  90062. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90063. * @param invertY defines if data must be stored with Y axis inverted
  90064. * @returns the cube texture as an InternalTexture
  90065. */
  90066. 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;
  90067. /**
  90068. * Creates a new raw 3D texture
  90069. * @param data defines the data used to create the texture
  90070. * @param width defines the width of the texture
  90071. * @param height defines the height of the texture
  90072. * @param depth defines the depth of the texture
  90073. * @param format defines the format of the texture
  90074. * @param generateMipMaps defines if the engine must generate mip levels
  90075. * @param invertY defines if data must be stored with Y axis inverted
  90076. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90077. * @param compression defines the compressed used (can be null)
  90078. * @param textureType defines the compressed used (can be null)
  90079. * @returns a new raw 3D texture (stored in an InternalTexture)
  90080. */
  90081. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  90082. /**
  90083. * Update a raw 3D texture
  90084. * @param texture defines the texture to update
  90085. * @param data defines the data to store
  90086. * @param format defines the data format
  90087. * @param invertY defines if data must be stored with Y axis inverted
  90088. */
  90089. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90090. /**
  90091. * Update a raw 3D texture
  90092. * @param texture defines the texture to update
  90093. * @param data defines the data to store
  90094. * @param format defines the data format
  90095. * @param invertY defines if data must be stored with Y axis inverted
  90096. * @param compression defines the used compression (can be null)
  90097. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  90098. */
  90099. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  90100. /**
  90101. * Creates a new raw 2D array texture
  90102. * @param data defines the data used to create the texture
  90103. * @param width defines the width of the texture
  90104. * @param height defines the height of the texture
  90105. * @param depth defines the number of layers of the texture
  90106. * @param format defines the format of the texture
  90107. * @param generateMipMaps defines if the engine must generate mip levels
  90108. * @param invertY defines if data must be stored with Y axis inverted
  90109. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90110. * @param compression defines the compressed used (can be null)
  90111. * @param textureType defines the compressed used (can be null)
  90112. * @returns a new raw 2D array texture (stored in an InternalTexture)
  90113. */
  90114. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  90115. /**
  90116. * Update a raw 2D array texture
  90117. * @param texture defines the texture to update
  90118. * @param data defines the data to store
  90119. * @param format defines the data format
  90120. * @param invertY defines if data must be stored with Y axis inverted
  90121. */
  90122. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90123. /**
  90124. * Update a raw 2D array texture
  90125. * @param texture defines the texture to update
  90126. * @param data defines the data to store
  90127. * @param format defines the data format
  90128. * @param invertY defines if data must be stored with Y axis inverted
  90129. * @param compression defines the used compression (can be null)
  90130. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  90131. */
  90132. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  90133. }
  90134. }
  90135. declare module BABYLON {
  90136. /**
  90137. * Raw texture can help creating a texture directly from an array of data.
  90138. * This can be super useful if you either get the data from an uncompressed source or
  90139. * if you wish to create your texture pixel by pixel.
  90140. */
  90141. export class RawTexture extends Texture {
  90142. /**
  90143. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90144. */
  90145. format: number;
  90146. /**
  90147. * Instantiates a new RawTexture.
  90148. * Raw texture can help creating a texture directly from an array of data.
  90149. * This can be super useful if you either get the data from an uncompressed source or
  90150. * if you wish to create your texture pixel by pixel.
  90151. * @param data define the array of data to use to create the texture
  90152. * @param width define the width of the texture
  90153. * @param height define the height of the texture
  90154. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90155. * @param scene define the scene the texture belongs to
  90156. * @param generateMipMaps define whether mip maps should be generated or not
  90157. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90158. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90159. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90160. */
  90161. constructor(data: ArrayBufferView, width: number, height: number,
  90162. /**
  90163. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90164. */
  90165. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  90166. /**
  90167. * Updates the texture underlying data.
  90168. * @param data Define the new data of the texture
  90169. */
  90170. update(data: ArrayBufferView): void;
  90171. /**
  90172. * Creates a luminance texture from some data.
  90173. * @param data Define the texture data
  90174. * @param width Define the width of the texture
  90175. * @param height Define the height of the texture
  90176. * @param scene Define the scene the texture belongs to
  90177. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90178. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90179. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90180. * @returns the luminance texture
  90181. */
  90182. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90183. /**
  90184. * Creates a luminance alpha texture from some data.
  90185. * @param data Define the texture data
  90186. * @param width Define the width of the texture
  90187. * @param height Define the height of the texture
  90188. * @param scene Define the scene the texture belongs to
  90189. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90190. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90191. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90192. * @returns the luminance alpha texture
  90193. */
  90194. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90195. /**
  90196. * Creates an alpha texture from some data.
  90197. * @param data Define the texture data
  90198. * @param width Define the width of the texture
  90199. * @param height Define the height of the texture
  90200. * @param scene Define the scene the texture belongs to
  90201. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90202. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90203. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90204. * @returns the alpha texture
  90205. */
  90206. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90207. /**
  90208. * Creates a RGB texture from some data.
  90209. * @param data Define the texture data
  90210. * @param width Define the width of the texture
  90211. * @param height Define the height of the texture
  90212. * @param scene Define the scene the texture belongs to
  90213. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90214. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90215. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90216. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90217. * @returns the RGB alpha texture
  90218. */
  90219. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90220. /**
  90221. * Creates a RGBA texture from some data.
  90222. * @param data Define the texture data
  90223. * @param width Define the width of the texture
  90224. * @param height Define the height of the texture
  90225. * @param scene Define the scene the texture belongs to
  90226. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90227. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90228. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90229. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90230. * @returns the RGBA texture
  90231. */
  90232. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90233. /**
  90234. * Creates a R texture from some data.
  90235. * @param data Define the texture data
  90236. * @param width Define the width of the texture
  90237. * @param height Define the height of the texture
  90238. * @param scene Define the scene the texture belongs to
  90239. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90240. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90241. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90242. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90243. * @returns the R texture
  90244. */
  90245. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90246. }
  90247. }
  90248. declare module BABYLON {
  90249. interface AbstractScene {
  90250. /**
  90251. * The list of procedural textures added to the scene
  90252. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90253. */
  90254. proceduralTextures: Array<ProceduralTexture>;
  90255. }
  90256. /**
  90257. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  90258. * in a given scene.
  90259. */
  90260. export class ProceduralTextureSceneComponent implements ISceneComponent {
  90261. /**
  90262. * The component name helpfull to identify the component in the list of scene components.
  90263. */
  90264. readonly name: string;
  90265. /**
  90266. * The scene the component belongs to.
  90267. */
  90268. scene: Scene;
  90269. /**
  90270. * Creates a new instance of the component for the given scene
  90271. * @param scene Defines the scene to register the component in
  90272. */
  90273. constructor(scene: Scene);
  90274. /**
  90275. * Registers the component in a given scene
  90276. */
  90277. register(): void;
  90278. /**
  90279. * Rebuilds the elements related to this component in case of
  90280. * context lost for instance.
  90281. */
  90282. rebuild(): void;
  90283. /**
  90284. * Disposes the component and the associated ressources.
  90285. */
  90286. dispose(): void;
  90287. private _beforeClear;
  90288. }
  90289. }
  90290. declare module BABYLON {
  90291. interface ThinEngine {
  90292. /**
  90293. * Creates a new render target cube texture
  90294. * @param size defines the size of the texture
  90295. * @param options defines the options used to create the texture
  90296. * @returns a new render target cube texture stored in an InternalTexture
  90297. */
  90298. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  90299. }
  90300. }
  90301. declare module BABYLON {
  90302. /** @hidden */
  90303. export var proceduralVertexShader: {
  90304. name: string;
  90305. shader: string;
  90306. };
  90307. }
  90308. declare module BABYLON {
  90309. /**
  90310. * 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.
  90311. * This is the base class of any Procedural texture and contains most of the shareable code.
  90312. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90313. */
  90314. export class ProceduralTexture extends Texture {
  90315. isCube: boolean;
  90316. /**
  90317. * Define if the texture is enabled or not (disabled texture will not render)
  90318. */
  90319. isEnabled: boolean;
  90320. /**
  90321. * Define if the texture must be cleared before rendering (default is true)
  90322. */
  90323. autoClear: boolean;
  90324. /**
  90325. * Callback called when the texture is generated
  90326. */
  90327. onGenerated: () => void;
  90328. /**
  90329. * Event raised when the texture is generated
  90330. */
  90331. onGeneratedObservable: Observable<ProceduralTexture>;
  90332. /** @hidden */
  90333. _generateMipMaps: boolean;
  90334. /** @hidden **/
  90335. _effect: Effect;
  90336. /** @hidden */
  90337. _textures: {
  90338. [key: string]: Texture;
  90339. };
  90340. /** @hidden */
  90341. protected _fallbackTexture: Nullable<Texture>;
  90342. private _size;
  90343. private _currentRefreshId;
  90344. private _frameId;
  90345. private _refreshRate;
  90346. private _vertexBuffers;
  90347. private _indexBuffer;
  90348. private _uniforms;
  90349. private _samplers;
  90350. private _fragment;
  90351. private _floats;
  90352. private _ints;
  90353. private _floatsArrays;
  90354. private _colors3;
  90355. private _colors4;
  90356. private _vectors2;
  90357. private _vectors3;
  90358. private _matrices;
  90359. private _fallbackTextureUsed;
  90360. private _fullEngine;
  90361. private _cachedDefines;
  90362. private _contentUpdateId;
  90363. private _contentData;
  90364. /**
  90365. * Instantiates a new procedural texture.
  90366. * 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.
  90367. * This is the base class of any Procedural texture and contains most of the shareable code.
  90368. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90369. * @param name Define the name of the texture
  90370. * @param size Define the size of the texture to create
  90371. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  90372. * @param scene Define the scene the texture belongs to
  90373. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  90374. * @param generateMipMaps Define if the texture should creates mip maps or not
  90375. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  90376. */
  90377. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  90378. /**
  90379. * The effect that is created when initializing the post process.
  90380. * @returns The created effect corresponding the the postprocess.
  90381. */
  90382. getEffect(): Effect;
  90383. /**
  90384. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  90385. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  90386. */
  90387. getContent(): Nullable<ArrayBufferView>;
  90388. private _createIndexBuffer;
  90389. /** @hidden */
  90390. _rebuild(): void;
  90391. /**
  90392. * Resets the texture in order to recreate its associated resources.
  90393. * This can be called in case of context loss
  90394. */
  90395. reset(): void;
  90396. protected _getDefines(): string;
  90397. /**
  90398. * Is the texture ready to be used ? (rendered at least once)
  90399. * @returns true if ready, otherwise, false.
  90400. */
  90401. isReady(): boolean;
  90402. /**
  90403. * Resets the refresh counter of the texture and start bak from scratch.
  90404. * Could be useful to regenerate the texture if it is setup to render only once.
  90405. */
  90406. resetRefreshCounter(): void;
  90407. /**
  90408. * Set the fragment shader to use in order to render the texture.
  90409. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  90410. */
  90411. setFragment(fragment: any): void;
  90412. /**
  90413. * Define the refresh rate of the texture or the rendering frequency.
  90414. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  90415. */
  90416. get refreshRate(): number;
  90417. set refreshRate(value: number);
  90418. /** @hidden */
  90419. _shouldRender(): boolean;
  90420. /**
  90421. * Get the size the texture is rendering at.
  90422. * @returns the size (texture is always squared)
  90423. */
  90424. getRenderSize(): number;
  90425. /**
  90426. * Resize the texture to new value.
  90427. * @param size Define the new size the texture should have
  90428. * @param generateMipMaps Define whether the new texture should create mip maps
  90429. */
  90430. resize(size: number, generateMipMaps: boolean): void;
  90431. private _checkUniform;
  90432. /**
  90433. * Set a texture in the shader program used to render.
  90434. * @param name Define the name of the uniform samplers as defined in the shader
  90435. * @param texture Define the texture to bind to this sampler
  90436. * @return the texture itself allowing "fluent" like uniform updates
  90437. */
  90438. setTexture(name: string, texture: Texture): ProceduralTexture;
  90439. /**
  90440. * Set a float in the shader.
  90441. * @param name Define the name of the uniform as defined in the shader
  90442. * @param value Define the value to give to the uniform
  90443. * @return the texture itself allowing "fluent" like uniform updates
  90444. */
  90445. setFloat(name: string, value: number): ProceduralTexture;
  90446. /**
  90447. * Set a int in the shader.
  90448. * @param name Define the name of the uniform as defined in the shader
  90449. * @param value Define the value to give to the uniform
  90450. * @return the texture itself allowing "fluent" like uniform updates
  90451. */
  90452. setInt(name: string, value: number): ProceduralTexture;
  90453. /**
  90454. * Set an array of floats in the shader.
  90455. * @param name Define the name of the uniform as defined in the shader
  90456. * @param value Define the value to give to the uniform
  90457. * @return the texture itself allowing "fluent" like uniform updates
  90458. */
  90459. setFloats(name: string, value: number[]): ProceduralTexture;
  90460. /**
  90461. * Set a vec3 in the shader from a Color3.
  90462. * @param name Define the name of the uniform as defined in the shader
  90463. * @param value Define the value to give to the uniform
  90464. * @return the texture itself allowing "fluent" like uniform updates
  90465. */
  90466. setColor3(name: string, value: Color3): ProceduralTexture;
  90467. /**
  90468. * Set a vec4 in the shader from a Color4.
  90469. * @param name Define the name of the uniform as defined in the shader
  90470. * @param value Define the value to give to the uniform
  90471. * @return the texture itself allowing "fluent" like uniform updates
  90472. */
  90473. setColor4(name: string, value: Color4): ProceduralTexture;
  90474. /**
  90475. * Set a vec2 in the shader from a Vector2.
  90476. * @param name Define the name of the uniform as defined in the shader
  90477. * @param value Define the value to give to the uniform
  90478. * @return the texture itself allowing "fluent" like uniform updates
  90479. */
  90480. setVector2(name: string, value: Vector2): ProceduralTexture;
  90481. /**
  90482. * Set a vec3 in the shader from a Vector3.
  90483. * @param name Define the name of the uniform as defined in the shader
  90484. * @param value Define the value to give to the uniform
  90485. * @return the texture itself allowing "fluent" like uniform updates
  90486. */
  90487. setVector3(name: string, value: Vector3): ProceduralTexture;
  90488. /**
  90489. * Set a mat4 in the shader from a MAtrix.
  90490. * @param name Define the name of the uniform as defined in the shader
  90491. * @param value Define the value to give to the uniform
  90492. * @return the texture itself allowing "fluent" like uniform updates
  90493. */
  90494. setMatrix(name: string, value: Matrix): ProceduralTexture;
  90495. /**
  90496. * Render the texture to its associated render target.
  90497. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  90498. */
  90499. render(useCameraPostProcess?: boolean): void;
  90500. /**
  90501. * Clone the texture.
  90502. * @returns the cloned texture
  90503. */
  90504. clone(): ProceduralTexture;
  90505. /**
  90506. * Dispose the texture and release its asoociated resources.
  90507. */
  90508. dispose(): void;
  90509. }
  90510. }
  90511. declare module BABYLON {
  90512. /**
  90513. * This represents the base class for particle system in Babylon.
  90514. * 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.
  90515. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90516. * @example https://doc.babylonjs.com/babylon101/particles
  90517. */
  90518. export class BaseParticleSystem {
  90519. /**
  90520. * Source color is added to the destination color without alpha affecting the result
  90521. */
  90522. static BLENDMODE_ONEONE: number;
  90523. /**
  90524. * Blend current color and particle color using particle’s alpha
  90525. */
  90526. static BLENDMODE_STANDARD: number;
  90527. /**
  90528. * Add current color and particle color multiplied by particle’s alpha
  90529. */
  90530. static BLENDMODE_ADD: number;
  90531. /**
  90532. * Multiply current color with particle color
  90533. */
  90534. static BLENDMODE_MULTIPLY: number;
  90535. /**
  90536. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  90537. */
  90538. static BLENDMODE_MULTIPLYADD: number;
  90539. /**
  90540. * List of animations used by the particle system.
  90541. */
  90542. animations: Animation[];
  90543. /**
  90544. * Gets or sets the unique id of the particle system
  90545. */
  90546. uniqueId: number;
  90547. /**
  90548. * The id of the Particle system.
  90549. */
  90550. id: string;
  90551. /**
  90552. * The friendly name of the Particle system.
  90553. */
  90554. name: string;
  90555. /**
  90556. * Snippet ID if the particle system was created from the snippet server
  90557. */
  90558. snippetId: string;
  90559. /**
  90560. * The rendering group used by the Particle system to chose when to render.
  90561. */
  90562. renderingGroupId: number;
  90563. /**
  90564. * The emitter represents the Mesh or position we are attaching the particle system to.
  90565. */
  90566. emitter: Nullable<AbstractMesh | Vector3>;
  90567. /**
  90568. * The maximum number of particles to emit per frame
  90569. */
  90570. emitRate: number;
  90571. /**
  90572. * If you want to launch only a few particles at once, that can be done, as well.
  90573. */
  90574. manualEmitCount: number;
  90575. /**
  90576. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90577. */
  90578. updateSpeed: number;
  90579. /**
  90580. * The amount of time the particle system is running (depends of the overall update speed).
  90581. */
  90582. targetStopDuration: number;
  90583. /**
  90584. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90585. */
  90586. disposeOnStop: boolean;
  90587. /**
  90588. * Minimum power of emitting particles.
  90589. */
  90590. minEmitPower: number;
  90591. /**
  90592. * Maximum power of emitting particles.
  90593. */
  90594. maxEmitPower: number;
  90595. /**
  90596. * Minimum life time of emitting particles.
  90597. */
  90598. minLifeTime: number;
  90599. /**
  90600. * Maximum life time of emitting particles.
  90601. */
  90602. maxLifeTime: number;
  90603. /**
  90604. * Minimum Size of emitting particles.
  90605. */
  90606. minSize: number;
  90607. /**
  90608. * Maximum Size of emitting particles.
  90609. */
  90610. maxSize: number;
  90611. /**
  90612. * Minimum scale of emitting particles on X axis.
  90613. */
  90614. minScaleX: number;
  90615. /**
  90616. * Maximum scale of emitting particles on X axis.
  90617. */
  90618. maxScaleX: number;
  90619. /**
  90620. * Minimum scale of emitting particles on Y axis.
  90621. */
  90622. minScaleY: number;
  90623. /**
  90624. * Maximum scale of emitting particles on Y axis.
  90625. */
  90626. maxScaleY: number;
  90627. /**
  90628. * Gets or sets the minimal initial rotation in radians.
  90629. */
  90630. minInitialRotation: number;
  90631. /**
  90632. * Gets or sets the maximal initial rotation in radians.
  90633. */
  90634. maxInitialRotation: number;
  90635. /**
  90636. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90637. */
  90638. minAngularSpeed: number;
  90639. /**
  90640. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90641. */
  90642. maxAngularSpeed: number;
  90643. /**
  90644. * The texture used to render each particle. (this can be a spritesheet)
  90645. */
  90646. particleTexture: Nullable<Texture>;
  90647. /**
  90648. * The layer mask we are rendering the particles through.
  90649. */
  90650. layerMask: number;
  90651. /**
  90652. * This can help using your own shader to render the particle system.
  90653. * The according effect will be created
  90654. */
  90655. customShader: any;
  90656. /**
  90657. * By default particle system starts as soon as they are created. This prevents the
  90658. * automatic start to happen and let you decide when to start emitting particles.
  90659. */
  90660. preventAutoStart: boolean;
  90661. private _noiseTexture;
  90662. /**
  90663. * Gets or sets a texture used to add random noise to particle positions
  90664. */
  90665. get noiseTexture(): Nullable<ProceduralTexture>;
  90666. set noiseTexture(value: Nullable<ProceduralTexture>);
  90667. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  90668. noiseStrength: Vector3;
  90669. /**
  90670. * Callback triggered when the particle animation is ending.
  90671. */
  90672. onAnimationEnd: Nullable<() => void>;
  90673. /**
  90674. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  90675. */
  90676. blendMode: number;
  90677. /**
  90678. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  90679. * to override the particles.
  90680. */
  90681. forceDepthWrite: boolean;
  90682. /** 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 */
  90683. preWarmCycles: number;
  90684. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  90685. preWarmStepOffset: number;
  90686. /**
  90687. * 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)
  90688. */
  90689. spriteCellChangeSpeed: number;
  90690. /**
  90691. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  90692. */
  90693. startSpriteCellID: number;
  90694. /**
  90695. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  90696. */
  90697. endSpriteCellID: number;
  90698. /**
  90699. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  90700. */
  90701. spriteCellWidth: number;
  90702. /**
  90703. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  90704. */
  90705. spriteCellHeight: number;
  90706. /**
  90707. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  90708. */
  90709. spriteRandomStartCell: boolean;
  90710. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  90711. translationPivot: Vector2;
  90712. /** @hidden */
  90713. protected _isAnimationSheetEnabled: boolean;
  90714. /**
  90715. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  90716. */
  90717. beginAnimationOnStart: boolean;
  90718. /**
  90719. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  90720. */
  90721. beginAnimationFrom: number;
  90722. /**
  90723. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  90724. */
  90725. beginAnimationTo: number;
  90726. /**
  90727. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  90728. */
  90729. beginAnimationLoop: boolean;
  90730. /**
  90731. * Gets or sets a world offset applied to all particles
  90732. */
  90733. worldOffset: Vector3;
  90734. /**
  90735. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  90736. */
  90737. get isAnimationSheetEnabled(): boolean;
  90738. set isAnimationSheetEnabled(value: boolean);
  90739. /**
  90740. * Get hosting scene
  90741. * @returns the scene
  90742. */
  90743. getScene(): Scene;
  90744. /**
  90745. * You can use gravity if you want to give an orientation to your particles.
  90746. */
  90747. gravity: Vector3;
  90748. protected _colorGradients: Nullable<Array<ColorGradient>>;
  90749. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  90750. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  90751. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  90752. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  90753. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  90754. protected _dragGradients: Nullable<Array<FactorGradient>>;
  90755. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  90756. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  90757. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  90758. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  90759. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  90760. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  90761. /**
  90762. * Defines the delay in milliseconds before starting the system (0 by default)
  90763. */
  90764. startDelay: number;
  90765. /**
  90766. * Gets the current list of drag gradients.
  90767. * You must use addDragGradient and removeDragGradient to udpate this list
  90768. * @returns the list of drag gradients
  90769. */
  90770. getDragGradients(): Nullable<Array<FactorGradient>>;
  90771. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  90772. limitVelocityDamping: number;
  90773. /**
  90774. * Gets the current list of limit velocity gradients.
  90775. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  90776. * @returns the list of limit velocity gradients
  90777. */
  90778. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  90779. /**
  90780. * Gets the current list of color gradients.
  90781. * You must use addColorGradient and removeColorGradient to udpate this list
  90782. * @returns the list of color gradients
  90783. */
  90784. getColorGradients(): Nullable<Array<ColorGradient>>;
  90785. /**
  90786. * Gets the current list of size gradients.
  90787. * You must use addSizeGradient and removeSizeGradient to udpate this list
  90788. * @returns the list of size gradients
  90789. */
  90790. getSizeGradients(): Nullable<Array<FactorGradient>>;
  90791. /**
  90792. * Gets the current list of color remap gradients.
  90793. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  90794. * @returns the list of color remap gradients
  90795. */
  90796. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  90797. /**
  90798. * Gets the current list of alpha remap gradients.
  90799. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  90800. * @returns the list of alpha remap gradients
  90801. */
  90802. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  90803. /**
  90804. * Gets the current list of life time gradients.
  90805. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  90806. * @returns the list of life time gradients
  90807. */
  90808. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  90809. /**
  90810. * Gets the current list of angular speed gradients.
  90811. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  90812. * @returns the list of angular speed gradients
  90813. */
  90814. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  90815. /**
  90816. * Gets the current list of velocity gradients.
  90817. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  90818. * @returns the list of velocity gradients
  90819. */
  90820. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  90821. /**
  90822. * Gets the current list of start size gradients.
  90823. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  90824. * @returns the list of start size gradients
  90825. */
  90826. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  90827. /**
  90828. * Gets the current list of emit rate gradients.
  90829. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  90830. * @returns the list of emit rate gradients
  90831. */
  90832. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  90833. /**
  90834. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90835. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90836. */
  90837. get direction1(): Vector3;
  90838. set direction1(value: Vector3);
  90839. /**
  90840. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90841. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90842. */
  90843. get direction2(): Vector3;
  90844. set direction2(value: Vector3);
  90845. /**
  90846. * 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.
  90847. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90848. */
  90849. get minEmitBox(): Vector3;
  90850. set minEmitBox(value: Vector3);
  90851. /**
  90852. * 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.
  90853. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90854. */
  90855. get maxEmitBox(): Vector3;
  90856. set maxEmitBox(value: Vector3);
  90857. /**
  90858. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90859. */
  90860. color1: Color4;
  90861. /**
  90862. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90863. */
  90864. color2: Color4;
  90865. /**
  90866. * Color the particle will have at the end of its lifetime
  90867. */
  90868. colorDead: Color4;
  90869. /**
  90870. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  90871. */
  90872. textureMask: Color4;
  90873. /**
  90874. * The particle emitter type defines the emitter used by the particle system.
  90875. * It can be for example box, sphere, or cone...
  90876. */
  90877. particleEmitterType: IParticleEmitterType;
  90878. /** @hidden */
  90879. _isSubEmitter: boolean;
  90880. /**
  90881. * Gets or sets the billboard mode to use when isBillboardBased = true.
  90882. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  90883. */
  90884. billboardMode: number;
  90885. protected _isBillboardBased: boolean;
  90886. /**
  90887. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  90888. */
  90889. get isBillboardBased(): boolean;
  90890. set isBillboardBased(value: boolean);
  90891. /**
  90892. * The scene the particle system belongs to.
  90893. */
  90894. protected _scene: Scene;
  90895. /**
  90896. * Local cache of defines for image processing.
  90897. */
  90898. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  90899. /**
  90900. * Default configuration related to image processing available in the standard Material.
  90901. */
  90902. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  90903. /**
  90904. * Gets the image processing configuration used either in this material.
  90905. */
  90906. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  90907. /**
  90908. * Sets the Default image processing configuration used either in the this material.
  90909. *
  90910. * If sets to null, the scene one is in use.
  90911. */
  90912. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  90913. /**
  90914. * Attaches a new image processing configuration to the Standard Material.
  90915. * @param configuration
  90916. */
  90917. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  90918. /** @hidden */
  90919. protected _reset(): void;
  90920. /** @hidden */
  90921. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  90922. /**
  90923. * Instantiates a particle system.
  90924. * 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.
  90925. * @param name The name of the particle system
  90926. */
  90927. constructor(name: string);
  90928. /**
  90929. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  90930. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90931. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90932. * @returns the emitter
  90933. */
  90934. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  90935. /**
  90936. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  90937. * @param radius The radius of the hemisphere to emit from
  90938. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90939. * @returns the emitter
  90940. */
  90941. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  90942. /**
  90943. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  90944. * @param radius The radius of the sphere to emit from
  90945. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90946. * @returns the emitter
  90947. */
  90948. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  90949. /**
  90950. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  90951. * @param radius The radius of the sphere to emit from
  90952. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  90953. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  90954. * @returns the emitter
  90955. */
  90956. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  90957. /**
  90958. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  90959. * @param radius The radius of the emission cylinder
  90960. * @param height The height of the emission cylinder
  90961. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  90962. * @param directionRandomizer How much to randomize the particle direction [0-1]
  90963. * @returns the emitter
  90964. */
  90965. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  90966. /**
  90967. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  90968. * @param radius The radius of the cylinder to emit from
  90969. * @param height The height of the emission cylinder
  90970. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90971. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  90972. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  90973. * @returns the emitter
  90974. */
  90975. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  90976. /**
  90977. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  90978. * @param radius The radius of the cone to emit from
  90979. * @param angle The base angle of the cone
  90980. * @returns the emitter
  90981. */
  90982. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  90983. /**
  90984. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  90985. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90986. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90987. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90988. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90989. * @returns the emitter
  90990. */
  90991. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  90992. }
  90993. }
  90994. declare module BABYLON {
  90995. /**
  90996. * Type of sub emitter
  90997. */
  90998. export enum SubEmitterType {
  90999. /**
  91000. * Attached to the particle over it's lifetime
  91001. */
  91002. ATTACHED = 0,
  91003. /**
  91004. * Created when the particle dies
  91005. */
  91006. END = 1
  91007. }
  91008. /**
  91009. * Sub emitter class used to emit particles from an existing particle
  91010. */
  91011. export class SubEmitter {
  91012. /**
  91013. * the particle system to be used by the sub emitter
  91014. */
  91015. particleSystem: ParticleSystem;
  91016. /**
  91017. * Type of the submitter (Default: END)
  91018. */
  91019. type: SubEmitterType;
  91020. /**
  91021. * 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)
  91022. * Note: This only is supported when using an emitter of type Mesh
  91023. */
  91024. inheritDirection: boolean;
  91025. /**
  91026. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  91027. */
  91028. inheritedVelocityAmount: number;
  91029. /**
  91030. * Creates a sub emitter
  91031. * @param particleSystem the particle system to be used by the sub emitter
  91032. */
  91033. constructor(
  91034. /**
  91035. * the particle system to be used by the sub emitter
  91036. */
  91037. particleSystem: ParticleSystem);
  91038. /**
  91039. * Clones the sub emitter
  91040. * @returns the cloned sub emitter
  91041. */
  91042. clone(): SubEmitter;
  91043. /**
  91044. * Serialize current object to a JSON object
  91045. * @returns the serialized object
  91046. */
  91047. serialize(): any;
  91048. /** @hidden */
  91049. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  91050. /**
  91051. * Creates a new SubEmitter from a serialized JSON version
  91052. * @param serializationObject defines the JSON object to read from
  91053. * @param scene defines the hosting scene
  91054. * @param rootUrl defines the rootUrl for data loading
  91055. * @returns a new SubEmitter
  91056. */
  91057. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  91058. /** Release associated resources */
  91059. dispose(): void;
  91060. }
  91061. }
  91062. declare module BABYLON {
  91063. /** @hidden */
  91064. export var imageProcessingDeclaration: {
  91065. name: string;
  91066. shader: string;
  91067. };
  91068. }
  91069. declare module BABYLON {
  91070. /** @hidden */
  91071. export var imageProcessingFunctions: {
  91072. name: string;
  91073. shader: string;
  91074. };
  91075. }
  91076. declare module BABYLON {
  91077. /** @hidden */
  91078. export var particlesPixelShader: {
  91079. name: string;
  91080. shader: string;
  91081. };
  91082. }
  91083. declare module BABYLON {
  91084. /** @hidden */
  91085. export var particlesVertexShader: {
  91086. name: string;
  91087. shader: string;
  91088. };
  91089. }
  91090. declare module BABYLON {
  91091. /**
  91092. * This represents a particle system in Babylon.
  91093. * 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.
  91094. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  91095. * @example https://doc.babylonjs.com/babylon101/particles
  91096. */
  91097. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  91098. /**
  91099. * Billboard mode will only apply to Y axis
  91100. */
  91101. static readonly BILLBOARDMODE_Y: number;
  91102. /**
  91103. * Billboard mode will apply to all axes
  91104. */
  91105. static readonly BILLBOARDMODE_ALL: number;
  91106. /**
  91107. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  91108. */
  91109. static readonly BILLBOARDMODE_STRETCHED: number;
  91110. /**
  91111. * This function can be defined to provide custom update for active particles.
  91112. * This function will be called instead of regular update (age, position, color, etc.).
  91113. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  91114. */
  91115. updateFunction: (particles: Particle[]) => void;
  91116. private _emitterWorldMatrix;
  91117. /**
  91118. * This function can be defined to specify initial direction for every new particle.
  91119. * It by default use the emitterType defined function
  91120. */
  91121. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  91122. /**
  91123. * This function can be defined to specify initial position for every new particle.
  91124. * It by default use the emitterType defined function
  91125. */
  91126. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  91127. /**
  91128. * @hidden
  91129. */
  91130. _inheritedVelocityOffset: Vector3;
  91131. /**
  91132. * An event triggered when the system is disposed
  91133. */
  91134. onDisposeObservable: Observable<IParticleSystem>;
  91135. private _onDisposeObserver;
  91136. /**
  91137. * Sets a callback that will be triggered when the system is disposed
  91138. */
  91139. set onDispose(callback: () => void);
  91140. private _particles;
  91141. private _epsilon;
  91142. private _capacity;
  91143. private _stockParticles;
  91144. private _newPartsExcess;
  91145. private _vertexData;
  91146. private _vertexBuffer;
  91147. private _vertexBuffers;
  91148. private _spriteBuffer;
  91149. private _indexBuffer;
  91150. private _effect;
  91151. private _customEffect;
  91152. private _cachedDefines;
  91153. private _scaledColorStep;
  91154. private _colorDiff;
  91155. private _scaledDirection;
  91156. private _scaledGravity;
  91157. private _currentRenderId;
  91158. private _alive;
  91159. private _useInstancing;
  91160. private _started;
  91161. private _stopped;
  91162. private _actualFrame;
  91163. private _scaledUpdateSpeed;
  91164. private _vertexBufferSize;
  91165. /** @hidden */
  91166. _currentEmitRateGradient: Nullable<FactorGradient>;
  91167. /** @hidden */
  91168. _currentEmitRate1: number;
  91169. /** @hidden */
  91170. _currentEmitRate2: number;
  91171. /** @hidden */
  91172. _currentStartSizeGradient: Nullable<FactorGradient>;
  91173. /** @hidden */
  91174. _currentStartSize1: number;
  91175. /** @hidden */
  91176. _currentStartSize2: number;
  91177. private readonly _rawTextureWidth;
  91178. private _rampGradientsTexture;
  91179. private _useRampGradients;
  91180. /** Gets or sets a boolean indicating that ramp gradients must be used
  91181. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91182. */
  91183. get useRampGradients(): boolean;
  91184. set useRampGradients(value: boolean);
  91185. /**
  91186. * 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.
  91187. * 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: [])
  91188. */
  91189. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  91190. private _subEmitters;
  91191. /**
  91192. * @hidden
  91193. * If the particle systems emitter should be disposed when the particle system is disposed
  91194. */
  91195. _disposeEmitterOnDispose: boolean;
  91196. /**
  91197. * The current active Sub-systems, this property is used by the root particle system only.
  91198. */
  91199. activeSubSystems: Array<ParticleSystem>;
  91200. /**
  91201. * Specifies if the particles are updated in emitter local space or world space
  91202. */
  91203. isLocal: boolean;
  91204. private _rootParticleSystem;
  91205. /**
  91206. * Gets the current list of active particles
  91207. */
  91208. get particles(): Particle[];
  91209. /**
  91210. * Gets the number of particles active at the same time.
  91211. * @returns The number of active particles.
  91212. */
  91213. getActiveCount(): number;
  91214. /**
  91215. * Returns the string "ParticleSystem"
  91216. * @returns a string containing the class name
  91217. */
  91218. getClassName(): string;
  91219. /**
  91220. * Gets a boolean indicating that the system is stopping
  91221. * @returns true if the system is currently stopping
  91222. */
  91223. isStopping(): boolean;
  91224. /**
  91225. * Gets the custom effect used to render the particles
  91226. * @param blendMode Blend mode for which the effect should be retrieved
  91227. * @returns The effect
  91228. */
  91229. getCustomEffect(blendMode?: number): Nullable<Effect>;
  91230. /**
  91231. * Sets the custom effect used to render the particles
  91232. * @param effect The effect to set
  91233. * @param blendMode Blend mode for which the effect should be set
  91234. */
  91235. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  91236. /** @hidden */
  91237. private _onBeforeDrawParticlesObservable;
  91238. /**
  91239. * Observable that will be called just before the particles are drawn
  91240. */
  91241. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  91242. /**
  91243. * Gets the name of the particle vertex shader
  91244. */
  91245. get vertexShaderName(): string;
  91246. /**
  91247. * Instantiates a particle system.
  91248. * 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.
  91249. * @param name The name of the particle system
  91250. * @param capacity The max number of particles alive at the same time
  91251. * @param scene The scene the particle system belongs to
  91252. * @param customEffect a custom effect used to change the way particles are rendered by default
  91253. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  91254. * @param epsilon Offset used to render the particles
  91255. */
  91256. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  91257. private _addFactorGradient;
  91258. private _removeFactorGradient;
  91259. /**
  91260. * Adds a new life time gradient
  91261. * @param gradient defines the gradient to use (between 0 and 1)
  91262. * @param factor defines the life time factor to affect to the specified gradient
  91263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91264. * @returns the current particle system
  91265. */
  91266. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91267. /**
  91268. * Remove a specific life time gradient
  91269. * @param gradient defines the gradient to remove
  91270. * @returns the current particle system
  91271. */
  91272. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91273. /**
  91274. * Adds a new size gradient
  91275. * @param gradient defines the gradient to use (between 0 and 1)
  91276. * @param factor defines the size factor to affect to the specified gradient
  91277. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91278. * @returns the current particle system
  91279. */
  91280. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91281. /**
  91282. * Remove a specific size gradient
  91283. * @param gradient defines the gradient to remove
  91284. * @returns the current particle system
  91285. */
  91286. removeSizeGradient(gradient: number): IParticleSystem;
  91287. /**
  91288. * Adds a new color remap gradient
  91289. * @param gradient defines the gradient to use (between 0 and 1)
  91290. * @param min defines the color remap minimal range
  91291. * @param max defines the color remap maximal range
  91292. * @returns the current particle system
  91293. */
  91294. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91295. /**
  91296. * Remove a specific color remap gradient
  91297. * @param gradient defines the gradient to remove
  91298. * @returns the current particle system
  91299. */
  91300. removeColorRemapGradient(gradient: number): IParticleSystem;
  91301. /**
  91302. * Adds a new alpha remap gradient
  91303. * @param gradient defines the gradient to use (between 0 and 1)
  91304. * @param min defines the alpha remap minimal range
  91305. * @param max defines the alpha remap maximal range
  91306. * @returns the current particle system
  91307. */
  91308. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91309. /**
  91310. * Remove a specific alpha remap gradient
  91311. * @param gradient defines the gradient to remove
  91312. * @returns the current particle system
  91313. */
  91314. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  91315. /**
  91316. * Adds a new angular speed gradient
  91317. * @param gradient defines the gradient to use (between 0 and 1)
  91318. * @param factor defines the angular speed to affect to the specified gradient
  91319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91320. * @returns the current particle system
  91321. */
  91322. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91323. /**
  91324. * Remove a specific angular speed gradient
  91325. * @param gradient defines the gradient to remove
  91326. * @returns the current particle system
  91327. */
  91328. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91329. /**
  91330. * Adds a new velocity gradient
  91331. * @param gradient defines the gradient to use (between 0 and 1)
  91332. * @param factor defines the velocity to affect to the specified gradient
  91333. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91334. * @returns the current particle system
  91335. */
  91336. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91337. /**
  91338. * Remove a specific velocity gradient
  91339. * @param gradient defines the gradient to remove
  91340. * @returns the current particle system
  91341. */
  91342. removeVelocityGradient(gradient: number): IParticleSystem;
  91343. /**
  91344. * Adds a new limit velocity gradient
  91345. * @param gradient defines the gradient to use (between 0 and 1)
  91346. * @param factor defines the limit velocity value to affect to the specified gradient
  91347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91348. * @returns the current particle system
  91349. */
  91350. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91351. /**
  91352. * Remove a specific limit velocity gradient
  91353. * @param gradient defines the gradient to remove
  91354. * @returns the current particle system
  91355. */
  91356. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91357. /**
  91358. * Adds a new drag gradient
  91359. * @param gradient defines the gradient to use (between 0 and 1)
  91360. * @param factor defines the drag value to affect to the specified gradient
  91361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91362. * @returns the current particle system
  91363. */
  91364. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91365. /**
  91366. * Remove a specific drag gradient
  91367. * @param gradient defines the gradient to remove
  91368. * @returns the current particle system
  91369. */
  91370. removeDragGradient(gradient: number): IParticleSystem;
  91371. /**
  91372. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91373. * @param gradient defines the gradient to use (between 0 and 1)
  91374. * @param factor defines the emit rate value to affect to the specified gradient
  91375. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91376. * @returns the current particle system
  91377. */
  91378. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91379. /**
  91380. * Remove a specific emit rate gradient
  91381. * @param gradient defines the gradient to remove
  91382. * @returns the current particle system
  91383. */
  91384. removeEmitRateGradient(gradient: number): IParticleSystem;
  91385. /**
  91386. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91387. * @param gradient defines the gradient to use (between 0 and 1)
  91388. * @param factor defines the start size value to affect to the specified gradient
  91389. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91390. * @returns the current particle system
  91391. */
  91392. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91393. /**
  91394. * Remove a specific start size gradient
  91395. * @param gradient defines the gradient to remove
  91396. * @returns the current particle system
  91397. */
  91398. removeStartSizeGradient(gradient: number): IParticleSystem;
  91399. private _createRampGradientTexture;
  91400. /**
  91401. * Gets the current list of ramp gradients.
  91402. * You must use addRampGradient and removeRampGradient to udpate this list
  91403. * @returns the list of ramp gradients
  91404. */
  91405. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91406. /** Force the system to rebuild all gradients that need to be resync */
  91407. forceRefreshGradients(): void;
  91408. private _syncRampGradientTexture;
  91409. /**
  91410. * Adds a new ramp gradient used to remap particle colors
  91411. * @param gradient defines the gradient to use (between 0 and 1)
  91412. * @param color defines the color to affect to the specified gradient
  91413. * @returns the current particle system
  91414. */
  91415. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  91416. /**
  91417. * Remove a specific ramp gradient
  91418. * @param gradient defines the gradient to remove
  91419. * @returns the current particle system
  91420. */
  91421. removeRampGradient(gradient: number): ParticleSystem;
  91422. /**
  91423. * Adds a new color gradient
  91424. * @param gradient defines the gradient to use (between 0 and 1)
  91425. * @param color1 defines the color to affect to the specified gradient
  91426. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91427. * @returns this particle system
  91428. */
  91429. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91430. /**
  91431. * Remove a specific color gradient
  91432. * @param gradient defines the gradient to remove
  91433. * @returns this particle system
  91434. */
  91435. removeColorGradient(gradient: number): IParticleSystem;
  91436. private _fetchR;
  91437. protected _reset(): void;
  91438. private _resetEffect;
  91439. private _createVertexBuffers;
  91440. private _createIndexBuffer;
  91441. /**
  91442. * Gets the maximum number of particles active at the same time.
  91443. * @returns The max number of active particles.
  91444. */
  91445. getCapacity(): number;
  91446. /**
  91447. * Gets whether there are still active particles in the system.
  91448. * @returns True if it is alive, otherwise false.
  91449. */
  91450. isAlive(): boolean;
  91451. /**
  91452. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91453. * @returns True if it has been started, otherwise false.
  91454. */
  91455. isStarted(): boolean;
  91456. private _prepareSubEmitterInternalArray;
  91457. /**
  91458. * Starts the particle system and begins to emit
  91459. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  91460. */
  91461. start(delay?: number): void;
  91462. /**
  91463. * Stops the particle system.
  91464. * @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.
  91465. */
  91466. stop(stopSubEmitters?: boolean): void;
  91467. /**
  91468. * Remove all active particles
  91469. */
  91470. reset(): void;
  91471. /**
  91472. * @hidden (for internal use only)
  91473. */
  91474. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  91475. /**
  91476. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  91477. * Its lifetime will start back at 0.
  91478. */
  91479. recycleParticle: (particle: Particle) => void;
  91480. private _stopSubEmitters;
  91481. private _createParticle;
  91482. private _removeFromRoot;
  91483. private _emitFromParticle;
  91484. private _update;
  91485. /** @hidden */
  91486. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  91487. /** @hidden */
  91488. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  91489. /**
  91490. * Fill the defines array according to the current settings of the particle system
  91491. * @param defines Array to be updated
  91492. * @param blendMode blend mode to take into account when updating the array
  91493. */
  91494. fillDefines(defines: Array<string>, blendMode: number): void;
  91495. /**
  91496. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91497. * @param uniforms Uniforms array to fill
  91498. * @param attributes Attributes array to fill
  91499. * @param samplers Samplers array to fill
  91500. */
  91501. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91502. /** @hidden */
  91503. private _getEffect;
  91504. /**
  91505. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  91506. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  91507. */
  91508. animate(preWarmOnly?: boolean): void;
  91509. private _appendParticleVertices;
  91510. /**
  91511. * Rebuilds the particle system.
  91512. */
  91513. rebuild(): void;
  91514. /**
  91515. * Is this system ready to be used/rendered
  91516. * @return true if the system is ready
  91517. */
  91518. isReady(): boolean;
  91519. private _render;
  91520. /**
  91521. * Renders the particle system in its current state.
  91522. * @returns the current number of particles
  91523. */
  91524. render(): number;
  91525. /**
  91526. * Disposes the particle system and free the associated resources
  91527. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91528. */
  91529. dispose(disposeTexture?: boolean): void;
  91530. /**
  91531. * Clones the particle system.
  91532. * @param name The name of the cloned object
  91533. * @param newEmitter The new emitter to use
  91534. * @returns the cloned particle system
  91535. */
  91536. clone(name: string, newEmitter: any): ParticleSystem;
  91537. /**
  91538. * Serializes the particle system to a JSON object
  91539. * @param serializeTexture defines if the texture must be serialized as well
  91540. * @returns the JSON object
  91541. */
  91542. serialize(serializeTexture?: boolean): any;
  91543. /** @hidden */
  91544. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  91545. /** @hidden */
  91546. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  91547. /**
  91548. * Parses a JSON object to create a particle system.
  91549. * @param parsedParticleSystem The JSON object to parse
  91550. * @param scene The scene to create the particle system in
  91551. * @param rootUrl The root url to use to load external dependencies like texture
  91552. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  91553. * @returns the Parsed particle system
  91554. */
  91555. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  91556. }
  91557. }
  91558. declare module BABYLON {
  91559. /**
  91560. * A particle represents one of the element emitted by a particle system.
  91561. * This is mainly define by its coordinates, direction, velocity and age.
  91562. */
  91563. export class Particle {
  91564. /**
  91565. * The particle system the particle belongs to.
  91566. */
  91567. particleSystem: ParticleSystem;
  91568. private static _Count;
  91569. /**
  91570. * Unique ID of the particle
  91571. */
  91572. id: number;
  91573. /**
  91574. * The world position of the particle in the scene.
  91575. */
  91576. position: Vector3;
  91577. /**
  91578. * The world direction of the particle in the scene.
  91579. */
  91580. direction: Vector3;
  91581. /**
  91582. * The color of the particle.
  91583. */
  91584. color: Color4;
  91585. /**
  91586. * The color change of the particle per step.
  91587. */
  91588. colorStep: Color4;
  91589. /**
  91590. * Defines how long will the life of the particle be.
  91591. */
  91592. lifeTime: number;
  91593. /**
  91594. * The current age of the particle.
  91595. */
  91596. age: number;
  91597. /**
  91598. * The current size of the particle.
  91599. */
  91600. size: number;
  91601. /**
  91602. * The current scale of the particle.
  91603. */
  91604. scale: Vector2;
  91605. /**
  91606. * The current angle of the particle.
  91607. */
  91608. angle: number;
  91609. /**
  91610. * Defines how fast is the angle changing.
  91611. */
  91612. angularSpeed: number;
  91613. /**
  91614. * Defines the cell index used by the particle to be rendered from a sprite.
  91615. */
  91616. cellIndex: number;
  91617. /**
  91618. * The information required to support color remapping
  91619. */
  91620. remapData: Vector4;
  91621. /** @hidden */
  91622. _randomCellOffset?: number;
  91623. /** @hidden */
  91624. _initialDirection: Nullable<Vector3>;
  91625. /** @hidden */
  91626. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  91627. /** @hidden */
  91628. _initialStartSpriteCellID: number;
  91629. /** @hidden */
  91630. _initialEndSpriteCellID: number;
  91631. /** @hidden */
  91632. _currentColorGradient: Nullable<ColorGradient>;
  91633. /** @hidden */
  91634. _currentColor1: Color4;
  91635. /** @hidden */
  91636. _currentColor2: Color4;
  91637. /** @hidden */
  91638. _currentSizeGradient: Nullable<FactorGradient>;
  91639. /** @hidden */
  91640. _currentSize1: number;
  91641. /** @hidden */
  91642. _currentSize2: number;
  91643. /** @hidden */
  91644. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  91645. /** @hidden */
  91646. _currentAngularSpeed1: number;
  91647. /** @hidden */
  91648. _currentAngularSpeed2: number;
  91649. /** @hidden */
  91650. _currentVelocityGradient: Nullable<FactorGradient>;
  91651. /** @hidden */
  91652. _currentVelocity1: number;
  91653. /** @hidden */
  91654. _currentVelocity2: number;
  91655. /** @hidden */
  91656. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  91657. /** @hidden */
  91658. _currentLimitVelocity1: number;
  91659. /** @hidden */
  91660. _currentLimitVelocity2: number;
  91661. /** @hidden */
  91662. _currentDragGradient: Nullable<FactorGradient>;
  91663. /** @hidden */
  91664. _currentDrag1: number;
  91665. /** @hidden */
  91666. _currentDrag2: number;
  91667. /** @hidden */
  91668. _randomNoiseCoordinates1: Vector3;
  91669. /** @hidden */
  91670. _randomNoiseCoordinates2: Vector3;
  91671. /** @hidden */
  91672. _localPosition?: Vector3;
  91673. /**
  91674. * Creates a new instance Particle
  91675. * @param particleSystem the particle system the particle belongs to
  91676. */
  91677. constructor(
  91678. /**
  91679. * The particle system the particle belongs to.
  91680. */
  91681. particleSystem: ParticleSystem);
  91682. private updateCellInfoFromSystem;
  91683. /**
  91684. * Defines how the sprite cell index is updated for the particle
  91685. */
  91686. updateCellIndex(): void;
  91687. /** @hidden */
  91688. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  91689. /** @hidden */
  91690. _inheritParticleInfoToSubEmitters(): void;
  91691. /** @hidden */
  91692. _reset(): void;
  91693. /**
  91694. * Copy the properties of particle to another one.
  91695. * @param other the particle to copy the information to.
  91696. */
  91697. copyTo(other: Particle): void;
  91698. }
  91699. }
  91700. declare module BABYLON {
  91701. /**
  91702. * Particle emitter represents a volume emitting particles.
  91703. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  91704. */
  91705. export interface IParticleEmitterType {
  91706. /**
  91707. * Called by the particle System when the direction is computed for the created particle.
  91708. * @param worldMatrix is the world matrix of the particle system
  91709. * @param directionToUpdate is the direction vector to update with the result
  91710. * @param particle is the particle we are computed the direction for
  91711. * @param isLocal defines if the direction should be set in local space
  91712. */
  91713. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91714. /**
  91715. * Called by the particle System when the position is computed for the created particle.
  91716. * @param worldMatrix is the world matrix of the particle system
  91717. * @param positionToUpdate is the position vector to update with the result
  91718. * @param particle is the particle we are computed the position for
  91719. * @param isLocal defines if the position should be set in local space
  91720. */
  91721. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91722. /**
  91723. * Clones the current emitter and returns a copy of it
  91724. * @returns the new emitter
  91725. */
  91726. clone(): IParticleEmitterType;
  91727. /**
  91728. * Called by the GPUParticleSystem to setup the update shader
  91729. * @param effect defines the update shader
  91730. */
  91731. applyToShader(effect: Effect): void;
  91732. /**
  91733. * Returns a string to use to update the GPU particles update shader
  91734. * @returns the effect defines string
  91735. */
  91736. getEffectDefines(): string;
  91737. /**
  91738. * Returns a string representing the class name
  91739. * @returns a string containing the class name
  91740. */
  91741. getClassName(): string;
  91742. /**
  91743. * Serializes the particle system to a JSON object.
  91744. * @returns the JSON object
  91745. */
  91746. serialize(): any;
  91747. /**
  91748. * Parse properties from a JSON object
  91749. * @param serializationObject defines the JSON object
  91750. * @param scene defines the hosting scene
  91751. */
  91752. parse(serializationObject: any, scene: Scene): void;
  91753. }
  91754. }
  91755. declare module BABYLON {
  91756. /**
  91757. * Particle emitter emitting particles from the inside of a box.
  91758. * It emits the particles randomly between 2 given directions.
  91759. */
  91760. export class BoxParticleEmitter implements IParticleEmitterType {
  91761. /**
  91762. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91763. */
  91764. direction1: Vector3;
  91765. /**
  91766. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91767. */
  91768. direction2: Vector3;
  91769. /**
  91770. * 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.
  91771. */
  91772. minEmitBox: Vector3;
  91773. /**
  91774. * 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.
  91775. */
  91776. maxEmitBox: Vector3;
  91777. /**
  91778. * Creates a new instance BoxParticleEmitter
  91779. */
  91780. constructor();
  91781. /**
  91782. * Called by the particle System when the direction is computed for the created particle.
  91783. * @param worldMatrix is the world matrix of the particle system
  91784. * @param directionToUpdate is the direction vector to update with the result
  91785. * @param particle is the particle we are computed the direction for
  91786. * @param isLocal defines if the direction should be set in local space
  91787. */
  91788. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91789. /**
  91790. * Called by the particle System when the position is computed for the created particle.
  91791. * @param worldMatrix is the world matrix of the particle system
  91792. * @param positionToUpdate is the position vector to update with the result
  91793. * @param particle is the particle we are computed the position for
  91794. * @param isLocal defines if the position should be set in local space
  91795. */
  91796. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91797. /**
  91798. * Clones the current emitter and returns a copy of it
  91799. * @returns the new emitter
  91800. */
  91801. clone(): BoxParticleEmitter;
  91802. /**
  91803. * Called by the GPUParticleSystem to setup the update shader
  91804. * @param effect defines the update shader
  91805. */
  91806. applyToShader(effect: Effect): void;
  91807. /**
  91808. * Returns a string to use to update the GPU particles update shader
  91809. * @returns a string containng the defines string
  91810. */
  91811. getEffectDefines(): string;
  91812. /**
  91813. * Returns the string "BoxParticleEmitter"
  91814. * @returns a string containing the class name
  91815. */
  91816. getClassName(): string;
  91817. /**
  91818. * Serializes the particle system to a JSON object.
  91819. * @returns the JSON object
  91820. */
  91821. serialize(): any;
  91822. /**
  91823. * Parse properties from a JSON object
  91824. * @param serializationObject defines the JSON object
  91825. */
  91826. parse(serializationObject: any): void;
  91827. }
  91828. }
  91829. declare module BABYLON {
  91830. /**
  91831. * Particle emitter emitting particles from the inside of a cone.
  91832. * It emits the particles alongside the cone volume from the base to the particle.
  91833. * The emission direction might be randomized.
  91834. */
  91835. export class ConeParticleEmitter implements IParticleEmitterType {
  91836. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91837. directionRandomizer: number;
  91838. private _radius;
  91839. private _angle;
  91840. private _height;
  91841. /**
  91842. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  91843. */
  91844. radiusRange: number;
  91845. /**
  91846. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  91847. */
  91848. heightRange: number;
  91849. /**
  91850. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  91851. */
  91852. emitFromSpawnPointOnly: boolean;
  91853. /**
  91854. * Gets or sets the radius of the emission cone
  91855. */
  91856. get radius(): number;
  91857. set radius(value: number);
  91858. /**
  91859. * Gets or sets the angle of the emission cone
  91860. */
  91861. get angle(): number;
  91862. set angle(value: number);
  91863. private _buildHeight;
  91864. /**
  91865. * Creates a new instance ConeParticleEmitter
  91866. * @param radius the radius of the emission cone (1 by default)
  91867. * @param angle the cone base angle (PI by default)
  91868. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  91869. */
  91870. constructor(radius?: number, angle?: number,
  91871. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91872. directionRandomizer?: number);
  91873. /**
  91874. * Called by the particle System when the direction is computed for the created particle.
  91875. * @param worldMatrix is the world matrix of the particle system
  91876. * @param directionToUpdate is the direction vector to update with the result
  91877. * @param particle is the particle we are computed the direction for
  91878. * @param isLocal defines if the direction should be set in local space
  91879. */
  91880. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91881. /**
  91882. * Called by the particle System when the position is computed for the created particle.
  91883. * @param worldMatrix is the world matrix of the particle system
  91884. * @param positionToUpdate is the position vector to update with the result
  91885. * @param particle is the particle we are computed the position for
  91886. * @param isLocal defines if the position should be set in local space
  91887. */
  91888. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91889. /**
  91890. * Clones the current emitter and returns a copy of it
  91891. * @returns the new emitter
  91892. */
  91893. clone(): ConeParticleEmitter;
  91894. /**
  91895. * Called by the GPUParticleSystem to setup the update shader
  91896. * @param effect defines the update shader
  91897. */
  91898. applyToShader(effect: Effect): void;
  91899. /**
  91900. * Returns a string to use to update the GPU particles update shader
  91901. * @returns a string containng the defines string
  91902. */
  91903. getEffectDefines(): string;
  91904. /**
  91905. * Returns the string "ConeParticleEmitter"
  91906. * @returns a string containing the class name
  91907. */
  91908. getClassName(): string;
  91909. /**
  91910. * Serializes the particle system to a JSON object.
  91911. * @returns the JSON object
  91912. */
  91913. serialize(): any;
  91914. /**
  91915. * Parse properties from a JSON object
  91916. * @param serializationObject defines the JSON object
  91917. */
  91918. parse(serializationObject: any): void;
  91919. }
  91920. }
  91921. declare module BABYLON {
  91922. /**
  91923. * Particle emitter emitting particles from the inside of a cylinder.
  91924. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  91925. */
  91926. export class CylinderParticleEmitter implements IParticleEmitterType {
  91927. /**
  91928. * The radius of the emission cylinder.
  91929. */
  91930. radius: number;
  91931. /**
  91932. * The height of the emission cylinder.
  91933. */
  91934. height: number;
  91935. /**
  91936. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91937. */
  91938. radiusRange: number;
  91939. /**
  91940. * How much to randomize the particle direction [0-1].
  91941. */
  91942. directionRandomizer: number;
  91943. /**
  91944. * Creates a new instance CylinderParticleEmitter
  91945. * @param radius the radius of the emission cylinder (1 by default)
  91946. * @param height the height of the emission cylinder (1 by default)
  91947. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91948. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91949. */
  91950. constructor(
  91951. /**
  91952. * The radius of the emission cylinder.
  91953. */
  91954. radius?: number,
  91955. /**
  91956. * The height of the emission cylinder.
  91957. */
  91958. height?: number,
  91959. /**
  91960. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91961. */
  91962. radiusRange?: number,
  91963. /**
  91964. * How much to randomize the particle direction [0-1].
  91965. */
  91966. directionRandomizer?: number);
  91967. /**
  91968. * Called by the particle System when the direction is computed for the created particle.
  91969. * @param worldMatrix is the world matrix of the particle system
  91970. * @param directionToUpdate is the direction vector to update with the result
  91971. * @param particle is the particle we are computed the direction for
  91972. * @param isLocal defines if the direction should be set in local space
  91973. */
  91974. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91975. /**
  91976. * Called by the particle System when the position is computed for the created particle.
  91977. * @param worldMatrix is the world matrix of the particle system
  91978. * @param positionToUpdate is the position vector to update with the result
  91979. * @param particle is the particle we are computed the position for
  91980. * @param isLocal defines if the position should be set in local space
  91981. */
  91982. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91983. /**
  91984. * Clones the current emitter and returns a copy of it
  91985. * @returns the new emitter
  91986. */
  91987. clone(): CylinderParticleEmitter;
  91988. /**
  91989. * Called by the GPUParticleSystem to setup the update shader
  91990. * @param effect defines the update shader
  91991. */
  91992. applyToShader(effect: Effect): void;
  91993. /**
  91994. * Returns a string to use to update the GPU particles update shader
  91995. * @returns a string containng the defines string
  91996. */
  91997. getEffectDefines(): string;
  91998. /**
  91999. * Returns the string "CylinderParticleEmitter"
  92000. * @returns a string containing the class name
  92001. */
  92002. getClassName(): string;
  92003. /**
  92004. * Serializes the particle system to a JSON object.
  92005. * @returns the JSON object
  92006. */
  92007. serialize(): any;
  92008. /**
  92009. * Parse properties from a JSON object
  92010. * @param serializationObject defines the JSON object
  92011. */
  92012. parse(serializationObject: any): void;
  92013. }
  92014. /**
  92015. * Particle emitter emitting particles from the inside of a cylinder.
  92016. * It emits the particles randomly between two vectors.
  92017. */
  92018. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  92019. /**
  92020. * The min limit of the emission direction.
  92021. */
  92022. direction1: Vector3;
  92023. /**
  92024. * The max limit of the emission direction.
  92025. */
  92026. direction2: Vector3;
  92027. /**
  92028. * Creates a new instance CylinderDirectedParticleEmitter
  92029. * @param radius the radius of the emission cylinder (1 by default)
  92030. * @param height the height of the emission cylinder (1 by default)
  92031. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92032. * @param direction1 the min limit of the emission direction (up vector by default)
  92033. * @param direction2 the max limit of the emission direction (up vector by default)
  92034. */
  92035. constructor(radius?: number, height?: number, radiusRange?: number,
  92036. /**
  92037. * The min limit of the emission direction.
  92038. */
  92039. direction1?: Vector3,
  92040. /**
  92041. * The max limit of the emission direction.
  92042. */
  92043. direction2?: Vector3);
  92044. /**
  92045. * Called by the particle System when the direction is computed for the created particle.
  92046. * @param worldMatrix is the world matrix of the particle system
  92047. * @param directionToUpdate is the direction vector to update with the result
  92048. * @param particle is the particle we are computed the direction for
  92049. */
  92050. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  92051. /**
  92052. * Clones the current emitter and returns a copy of it
  92053. * @returns the new emitter
  92054. */
  92055. clone(): CylinderDirectedParticleEmitter;
  92056. /**
  92057. * Called by the GPUParticleSystem to setup the update shader
  92058. * @param effect defines the update shader
  92059. */
  92060. applyToShader(effect: Effect): void;
  92061. /**
  92062. * Returns a string to use to update the GPU particles update shader
  92063. * @returns a string containng the defines string
  92064. */
  92065. getEffectDefines(): string;
  92066. /**
  92067. * Returns the string "CylinderDirectedParticleEmitter"
  92068. * @returns a string containing the class name
  92069. */
  92070. getClassName(): string;
  92071. /**
  92072. * Serializes the particle system to a JSON object.
  92073. * @returns the JSON object
  92074. */
  92075. serialize(): any;
  92076. /**
  92077. * Parse properties from a JSON object
  92078. * @param serializationObject defines the JSON object
  92079. */
  92080. parse(serializationObject: any): void;
  92081. }
  92082. }
  92083. declare module BABYLON {
  92084. /**
  92085. * Particle emitter emitting particles from the inside of a hemisphere.
  92086. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  92087. */
  92088. export class HemisphericParticleEmitter implements IParticleEmitterType {
  92089. /**
  92090. * The radius of the emission hemisphere.
  92091. */
  92092. radius: number;
  92093. /**
  92094. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92095. */
  92096. radiusRange: number;
  92097. /**
  92098. * How much to randomize the particle direction [0-1].
  92099. */
  92100. directionRandomizer: number;
  92101. /**
  92102. * Creates a new instance HemisphericParticleEmitter
  92103. * @param radius the radius of the emission hemisphere (1 by default)
  92104. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92105. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92106. */
  92107. constructor(
  92108. /**
  92109. * The radius of the emission hemisphere.
  92110. */
  92111. radius?: number,
  92112. /**
  92113. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92114. */
  92115. radiusRange?: number,
  92116. /**
  92117. * How much to randomize the particle direction [0-1].
  92118. */
  92119. directionRandomizer?: number);
  92120. /**
  92121. * Called by the particle System when the direction is computed for the created particle.
  92122. * @param worldMatrix is the world matrix of the particle system
  92123. * @param directionToUpdate is the direction vector to update with the result
  92124. * @param particle is the particle we are computed the direction for
  92125. * @param isLocal defines if the direction should be set in local space
  92126. */
  92127. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92128. /**
  92129. * Called by the particle System when the position is computed for the created particle.
  92130. * @param worldMatrix is the world matrix of the particle system
  92131. * @param positionToUpdate is the position vector to update with the result
  92132. * @param particle is the particle we are computed the position for
  92133. * @param isLocal defines if the position should be set in local space
  92134. */
  92135. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92136. /**
  92137. * Clones the current emitter and returns a copy of it
  92138. * @returns the new emitter
  92139. */
  92140. clone(): HemisphericParticleEmitter;
  92141. /**
  92142. * Called by the GPUParticleSystem to setup the update shader
  92143. * @param effect defines the update shader
  92144. */
  92145. applyToShader(effect: Effect): void;
  92146. /**
  92147. * Returns a string to use to update the GPU particles update shader
  92148. * @returns a string containng the defines string
  92149. */
  92150. getEffectDefines(): string;
  92151. /**
  92152. * Returns the string "HemisphericParticleEmitter"
  92153. * @returns a string containing the class name
  92154. */
  92155. getClassName(): string;
  92156. /**
  92157. * Serializes the particle system to a JSON object.
  92158. * @returns the JSON object
  92159. */
  92160. serialize(): any;
  92161. /**
  92162. * Parse properties from a JSON object
  92163. * @param serializationObject defines the JSON object
  92164. */
  92165. parse(serializationObject: any): void;
  92166. }
  92167. }
  92168. declare module BABYLON {
  92169. /**
  92170. * Particle emitter emitting particles from a point.
  92171. * It emits the particles randomly between 2 given directions.
  92172. */
  92173. export class PointParticleEmitter implements IParticleEmitterType {
  92174. /**
  92175. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92176. */
  92177. direction1: Vector3;
  92178. /**
  92179. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92180. */
  92181. direction2: Vector3;
  92182. /**
  92183. * Creates a new instance PointParticleEmitter
  92184. */
  92185. constructor();
  92186. /**
  92187. * Called by the particle System when the direction is computed for the created particle.
  92188. * @param worldMatrix is the world matrix of the particle system
  92189. * @param directionToUpdate is the direction vector to update with the result
  92190. * @param particle is the particle we are computed the direction for
  92191. * @param isLocal defines if the direction should be set in local space
  92192. */
  92193. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92194. /**
  92195. * Called by the particle System when the position is computed for the created particle.
  92196. * @param worldMatrix is the world matrix of the particle system
  92197. * @param positionToUpdate is the position vector to update with the result
  92198. * @param particle is the particle we are computed the position for
  92199. * @param isLocal defines if the position should be set in local space
  92200. */
  92201. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92202. /**
  92203. * Clones the current emitter and returns a copy of it
  92204. * @returns the new emitter
  92205. */
  92206. clone(): PointParticleEmitter;
  92207. /**
  92208. * Called by the GPUParticleSystem to setup the update shader
  92209. * @param effect defines the update shader
  92210. */
  92211. applyToShader(effect: Effect): void;
  92212. /**
  92213. * Returns a string to use to update the GPU particles update shader
  92214. * @returns a string containng the defines string
  92215. */
  92216. getEffectDefines(): string;
  92217. /**
  92218. * Returns the string "PointParticleEmitter"
  92219. * @returns a string containing the class name
  92220. */
  92221. getClassName(): string;
  92222. /**
  92223. * Serializes the particle system to a JSON object.
  92224. * @returns the JSON object
  92225. */
  92226. serialize(): any;
  92227. /**
  92228. * Parse properties from a JSON object
  92229. * @param serializationObject defines the JSON object
  92230. */
  92231. parse(serializationObject: any): void;
  92232. }
  92233. }
  92234. declare module BABYLON {
  92235. /**
  92236. * Particle emitter emitting particles from the inside of a sphere.
  92237. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  92238. */
  92239. export class SphereParticleEmitter implements IParticleEmitterType {
  92240. /**
  92241. * The radius of the emission sphere.
  92242. */
  92243. radius: number;
  92244. /**
  92245. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92246. */
  92247. radiusRange: number;
  92248. /**
  92249. * How much to randomize the particle direction [0-1].
  92250. */
  92251. directionRandomizer: number;
  92252. /**
  92253. * Creates a new instance SphereParticleEmitter
  92254. * @param radius the radius of the emission sphere (1 by default)
  92255. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92256. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92257. */
  92258. constructor(
  92259. /**
  92260. * The radius of the emission sphere.
  92261. */
  92262. radius?: number,
  92263. /**
  92264. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92265. */
  92266. radiusRange?: number,
  92267. /**
  92268. * How much to randomize the particle direction [0-1].
  92269. */
  92270. directionRandomizer?: number);
  92271. /**
  92272. * Called by the particle System when the direction is computed for the created particle.
  92273. * @param worldMatrix is the world matrix of the particle system
  92274. * @param directionToUpdate is the direction vector to update with the result
  92275. * @param particle is the particle we are computed the direction for
  92276. * @param isLocal defines if the direction should be set in local space
  92277. */
  92278. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92279. /**
  92280. * Called by the particle System when the position is computed for the created particle.
  92281. * @param worldMatrix is the world matrix of the particle system
  92282. * @param positionToUpdate is the position vector to update with the result
  92283. * @param particle is the particle we are computed the position for
  92284. * @param isLocal defines if the position should be set in local space
  92285. */
  92286. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92287. /**
  92288. * Clones the current emitter and returns a copy of it
  92289. * @returns the new emitter
  92290. */
  92291. clone(): SphereParticleEmitter;
  92292. /**
  92293. * Called by the GPUParticleSystem to setup the update shader
  92294. * @param effect defines the update shader
  92295. */
  92296. applyToShader(effect: Effect): void;
  92297. /**
  92298. * Returns a string to use to update the GPU particles update shader
  92299. * @returns a string containng the defines string
  92300. */
  92301. getEffectDefines(): string;
  92302. /**
  92303. * Returns the string "SphereParticleEmitter"
  92304. * @returns a string containing the class name
  92305. */
  92306. getClassName(): string;
  92307. /**
  92308. * Serializes the particle system to a JSON object.
  92309. * @returns the JSON object
  92310. */
  92311. serialize(): any;
  92312. /**
  92313. * Parse properties from a JSON object
  92314. * @param serializationObject defines the JSON object
  92315. */
  92316. parse(serializationObject: any): void;
  92317. }
  92318. /**
  92319. * Particle emitter emitting particles from the inside of a sphere.
  92320. * It emits the particles randomly between two vectors.
  92321. */
  92322. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  92323. /**
  92324. * The min limit of the emission direction.
  92325. */
  92326. direction1: Vector3;
  92327. /**
  92328. * The max limit of the emission direction.
  92329. */
  92330. direction2: Vector3;
  92331. /**
  92332. * Creates a new instance SphereDirectedParticleEmitter
  92333. * @param radius the radius of the emission sphere (1 by default)
  92334. * @param direction1 the min limit of the emission direction (up vector by default)
  92335. * @param direction2 the max limit of the emission direction (up vector by default)
  92336. */
  92337. constructor(radius?: number,
  92338. /**
  92339. * The min limit of the emission direction.
  92340. */
  92341. direction1?: Vector3,
  92342. /**
  92343. * The max limit of the emission direction.
  92344. */
  92345. direction2?: Vector3);
  92346. /**
  92347. * Called by the particle System when the direction is computed for the created particle.
  92348. * @param worldMatrix is the world matrix of the particle system
  92349. * @param directionToUpdate is the direction vector to update with the result
  92350. * @param particle is the particle we are computed the direction for
  92351. */
  92352. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  92353. /**
  92354. * Clones the current emitter and returns a copy of it
  92355. * @returns the new emitter
  92356. */
  92357. clone(): SphereDirectedParticleEmitter;
  92358. /**
  92359. * Called by the GPUParticleSystem to setup the update shader
  92360. * @param effect defines the update shader
  92361. */
  92362. applyToShader(effect: Effect): void;
  92363. /**
  92364. * Returns a string to use to update the GPU particles update shader
  92365. * @returns a string containng the defines string
  92366. */
  92367. getEffectDefines(): string;
  92368. /**
  92369. * Returns the string "SphereDirectedParticleEmitter"
  92370. * @returns a string containing the class name
  92371. */
  92372. getClassName(): string;
  92373. /**
  92374. * Serializes the particle system to a JSON object.
  92375. * @returns the JSON object
  92376. */
  92377. serialize(): any;
  92378. /**
  92379. * Parse properties from a JSON object
  92380. * @param serializationObject defines the JSON object
  92381. */
  92382. parse(serializationObject: any): void;
  92383. }
  92384. }
  92385. declare module BABYLON {
  92386. /**
  92387. * Particle emitter emitting particles from a custom list of positions.
  92388. */
  92389. export class CustomParticleEmitter implements IParticleEmitterType {
  92390. /**
  92391. * Gets or sets the position generator that will create the inital position of each particle.
  92392. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92393. */
  92394. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  92395. /**
  92396. * Gets or sets the destination generator that will create the final destination of each particle.
  92397. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92398. */
  92399. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  92400. /**
  92401. * Creates a new instance CustomParticleEmitter
  92402. */
  92403. constructor();
  92404. /**
  92405. * Called by the particle System when the direction is computed for the created particle.
  92406. * @param worldMatrix is the world matrix of the particle system
  92407. * @param directionToUpdate is the direction vector to update with the result
  92408. * @param particle is the particle we are computed the direction for
  92409. * @param isLocal defines if the direction should be set in local space
  92410. */
  92411. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92412. /**
  92413. * Called by the particle System when the position is computed for the created particle.
  92414. * @param worldMatrix is the world matrix of the particle system
  92415. * @param positionToUpdate is the position vector to update with the result
  92416. * @param particle is the particle we are computed the position for
  92417. * @param isLocal defines if the position should be set in local space
  92418. */
  92419. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92420. /**
  92421. * Clones the current emitter and returns a copy of it
  92422. * @returns the new emitter
  92423. */
  92424. clone(): CustomParticleEmitter;
  92425. /**
  92426. * Called by the GPUParticleSystem to setup the update shader
  92427. * @param effect defines the update shader
  92428. */
  92429. applyToShader(effect: Effect): void;
  92430. /**
  92431. * Returns a string to use to update the GPU particles update shader
  92432. * @returns a string containng the defines string
  92433. */
  92434. getEffectDefines(): string;
  92435. /**
  92436. * Returns the string "PointParticleEmitter"
  92437. * @returns a string containing the class name
  92438. */
  92439. getClassName(): string;
  92440. /**
  92441. * Serializes the particle system to a JSON object.
  92442. * @returns the JSON object
  92443. */
  92444. serialize(): any;
  92445. /**
  92446. * Parse properties from a JSON object
  92447. * @param serializationObject defines the JSON object
  92448. */
  92449. parse(serializationObject: any): void;
  92450. }
  92451. }
  92452. declare module BABYLON {
  92453. /**
  92454. * Particle emitter emitting particles from the inside of a box.
  92455. * It emits the particles randomly between 2 given directions.
  92456. */
  92457. export class MeshParticleEmitter implements IParticleEmitterType {
  92458. private _indices;
  92459. private _positions;
  92460. private _normals;
  92461. private _storedNormal;
  92462. private _mesh;
  92463. /**
  92464. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92465. */
  92466. direction1: Vector3;
  92467. /**
  92468. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92469. */
  92470. direction2: Vector3;
  92471. /**
  92472. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  92473. */
  92474. useMeshNormalsForDirection: boolean;
  92475. /** Defines the mesh to use as source */
  92476. get mesh(): Nullable<AbstractMesh>;
  92477. set mesh(value: Nullable<AbstractMesh>);
  92478. /**
  92479. * Creates a new instance MeshParticleEmitter
  92480. * @param mesh defines the mesh to use as source
  92481. */
  92482. constructor(mesh?: Nullable<AbstractMesh>);
  92483. /**
  92484. * Called by the particle System when the direction is computed for the created particle.
  92485. * @param worldMatrix is the world matrix of the particle system
  92486. * @param directionToUpdate is the direction vector to update with the result
  92487. * @param particle is the particle we are computed the direction for
  92488. * @param isLocal defines if the direction should be set in local space
  92489. */
  92490. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92491. /**
  92492. * Called by the particle System when the position is computed for the created particle.
  92493. * @param worldMatrix is the world matrix of the particle system
  92494. * @param positionToUpdate is the position vector to update with the result
  92495. * @param particle is the particle we are computed the position for
  92496. * @param isLocal defines if the position should be set in local space
  92497. */
  92498. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92499. /**
  92500. * Clones the current emitter and returns a copy of it
  92501. * @returns the new emitter
  92502. */
  92503. clone(): MeshParticleEmitter;
  92504. /**
  92505. * Called by the GPUParticleSystem to setup the update shader
  92506. * @param effect defines the update shader
  92507. */
  92508. applyToShader(effect: Effect): void;
  92509. /**
  92510. * Returns a string to use to update the GPU particles update shader
  92511. * @returns a string containng the defines string
  92512. */
  92513. getEffectDefines(): string;
  92514. /**
  92515. * Returns the string "BoxParticleEmitter"
  92516. * @returns a string containing the class name
  92517. */
  92518. getClassName(): string;
  92519. /**
  92520. * Serializes the particle system to a JSON object.
  92521. * @returns the JSON object
  92522. */
  92523. serialize(): any;
  92524. /**
  92525. * Parse properties from a JSON object
  92526. * @param serializationObject defines the JSON object
  92527. * @param scene defines the hosting scene
  92528. */
  92529. parse(serializationObject: any, scene: Scene): void;
  92530. }
  92531. }
  92532. declare module BABYLON {
  92533. /**
  92534. * Interface representing a particle system in Babylon.js.
  92535. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  92536. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  92537. */
  92538. export interface IParticleSystem {
  92539. /**
  92540. * List of animations used by the particle system.
  92541. */
  92542. animations: Animation[];
  92543. /**
  92544. * The id of the Particle system.
  92545. */
  92546. id: string;
  92547. /**
  92548. * The name of the Particle system.
  92549. */
  92550. name: string;
  92551. /**
  92552. * The emitter represents the Mesh or position we are attaching the particle system to.
  92553. */
  92554. emitter: Nullable<AbstractMesh | Vector3>;
  92555. /**
  92556. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92557. */
  92558. isBillboardBased: boolean;
  92559. /**
  92560. * The rendering group used by the Particle system to chose when to render.
  92561. */
  92562. renderingGroupId: number;
  92563. /**
  92564. * The layer mask we are rendering the particles through.
  92565. */
  92566. layerMask: number;
  92567. /**
  92568. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92569. */
  92570. updateSpeed: number;
  92571. /**
  92572. * The amount of time the particle system is running (depends of the overall update speed).
  92573. */
  92574. targetStopDuration: number;
  92575. /**
  92576. * The texture used to render each particle. (this can be a spritesheet)
  92577. */
  92578. particleTexture: Nullable<Texture>;
  92579. /**
  92580. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  92581. */
  92582. blendMode: number;
  92583. /**
  92584. * Minimum life time of emitting particles.
  92585. */
  92586. minLifeTime: number;
  92587. /**
  92588. * Maximum life time of emitting particles.
  92589. */
  92590. maxLifeTime: number;
  92591. /**
  92592. * Minimum Size of emitting particles.
  92593. */
  92594. minSize: number;
  92595. /**
  92596. * Maximum Size of emitting particles.
  92597. */
  92598. maxSize: number;
  92599. /**
  92600. * Minimum scale of emitting particles on X axis.
  92601. */
  92602. minScaleX: number;
  92603. /**
  92604. * Maximum scale of emitting particles on X axis.
  92605. */
  92606. maxScaleX: number;
  92607. /**
  92608. * Minimum scale of emitting particles on Y axis.
  92609. */
  92610. minScaleY: number;
  92611. /**
  92612. * Maximum scale of emitting particles on Y axis.
  92613. */
  92614. maxScaleY: number;
  92615. /**
  92616. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92617. */
  92618. color1: Color4;
  92619. /**
  92620. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92621. */
  92622. color2: Color4;
  92623. /**
  92624. * Color the particle will have at the end of its lifetime.
  92625. */
  92626. colorDead: Color4;
  92627. /**
  92628. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  92629. */
  92630. emitRate: number;
  92631. /**
  92632. * You can use gravity if you want to give an orientation to your particles.
  92633. */
  92634. gravity: Vector3;
  92635. /**
  92636. * Minimum power of emitting particles.
  92637. */
  92638. minEmitPower: number;
  92639. /**
  92640. * Maximum power of emitting particles.
  92641. */
  92642. maxEmitPower: number;
  92643. /**
  92644. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92645. */
  92646. minAngularSpeed: number;
  92647. /**
  92648. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92649. */
  92650. maxAngularSpeed: number;
  92651. /**
  92652. * Gets or sets the minimal initial rotation in radians.
  92653. */
  92654. minInitialRotation: number;
  92655. /**
  92656. * Gets or sets the maximal initial rotation in radians.
  92657. */
  92658. maxInitialRotation: number;
  92659. /**
  92660. * The particle emitter type defines the emitter used by the particle system.
  92661. * It can be for example box, sphere, or cone...
  92662. */
  92663. particleEmitterType: Nullable<IParticleEmitterType>;
  92664. /**
  92665. * Defines the delay in milliseconds before starting the system (0 by default)
  92666. */
  92667. startDelay: number;
  92668. /**
  92669. * 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
  92670. */
  92671. preWarmCycles: number;
  92672. /**
  92673. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  92674. */
  92675. preWarmStepOffset: number;
  92676. /**
  92677. * 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)
  92678. */
  92679. spriteCellChangeSpeed: number;
  92680. /**
  92681. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92682. */
  92683. startSpriteCellID: number;
  92684. /**
  92685. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92686. */
  92687. endSpriteCellID: number;
  92688. /**
  92689. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92690. */
  92691. spriteCellWidth: number;
  92692. /**
  92693. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92694. */
  92695. spriteCellHeight: number;
  92696. /**
  92697. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92698. */
  92699. spriteRandomStartCell: boolean;
  92700. /**
  92701. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  92702. */
  92703. isAnimationSheetEnabled: boolean;
  92704. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92705. translationPivot: Vector2;
  92706. /**
  92707. * Gets or sets a texture used to add random noise to particle positions
  92708. */
  92709. noiseTexture: Nullable<BaseTexture>;
  92710. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92711. noiseStrength: Vector3;
  92712. /**
  92713. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92714. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92715. */
  92716. billboardMode: number;
  92717. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92718. limitVelocityDamping: number;
  92719. /**
  92720. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92721. */
  92722. beginAnimationOnStart: boolean;
  92723. /**
  92724. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92725. */
  92726. beginAnimationFrom: number;
  92727. /**
  92728. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92729. */
  92730. beginAnimationTo: number;
  92731. /**
  92732. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92733. */
  92734. beginAnimationLoop: boolean;
  92735. /**
  92736. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92737. */
  92738. disposeOnStop: boolean;
  92739. /**
  92740. * Specifies if the particles are updated in emitter local space or world space
  92741. */
  92742. isLocal: boolean;
  92743. /** Snippet ID if the particle system was created from the snippet server */
  92744. snippetId: string;
  92745. /**
  92746. * Gets the maximum number of particles active at the same time.
  92747. * @returns The max number of active particles.
  92748. */
  92749. getCapacity(): number;
  92750. /**
  92751. * Gets the number of particles active at the same time.
  92752. * @returns The number of active particles.
  92753. */
  92754. getActiveCount(): number;
  92755. /**
  92756. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92757. * @returns True if it has been started, otherwise false.
  92758. */
  92759. isStarted(): boolean;
  92760. /**
  92761. * Animates the particle system for this frame.
  92762. */
  92763. animate(): void;
  92764. /**
  92765. * Renders the particle system in its current state.
  92766. * @returns the current number of particles
  92767. */
  92768. render(): number;
  92769. /**
  92770. * Dispose the particle system and frees its associated resources.
  92771. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92772. */
  92773. dispose(disposeTexture?: boolean): void;
  92774. /**
  92775. * An event triggered when the system is disposed
  92776. */
  92777. onDisposeObservable: Observable<IParticleSystem>;
  92778. /**
  92779. * Clones the particle system.
  92780. * @param name The name of the cloned object
  92781. * @param newEmitter The new emitter to use
  92782. * @returns the cloned particle system
  92783. */
  92784. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  92785. /**
  92786. * Serializes the particle system to a JSON object
  92787. * @param serializeTexture defines if the texture must be serialized as well
  92788. * @returns the JSON object
  92789. */
  92790. serialize(serializeTexture: boolean): any;
  92791. /**
  92792. * Rebuild the particle system
  92793. */
  92794. rebuild(): void;
  92795. /** Force the system to rebuild all gradients that need to be resync */
  92796. forceRefreshGradients(): void;
  92797. /**
  92798. * Starts the particle system and begins to emit
  92799. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  92800. */
  92801. start(delay?: number): void;
  92802. /**
  92803. * Stops the particle system.
  92804. */
  92805. stop(): void;
  92806. /**
  92807. * Remove all active particles
  92808. */
  92809. reset(): void;
  92810. /**
  92811. * Gets a boolean indicating that the system is stopping
  92812. * @returns true if the system is currently stopping
  92813. */
  92814. isStopping(): boolean;
  92815. /**
  92816. * Is this system ready to be used/rendered
  92817. * @return true if the system is ready
  92818. */
  92819. isReady(): boolean;
  92820. /**
  92821. * Returns the string "ParticleSystem"
  92822. * @returns a string containing the class name
  92823. */
  92824. getClassName(): string;
  92825. /**
  92826. * Gets the custom effect used to render the particles
  92827. * @param blendMode Blend mode for which the effect should be retrieved
  92828. * @returns The effect
  92829. */
  92830. getCustomEffect(blendMode: number): Nullable<Effect>;
  92831. /**
  92832. * Sets the custom effect used to render the particles
  92833. * @param effect The effect to set
  92834. * @param blendMode Blend mode for which the effect should be set
  92835. */
  92836. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  92837. /**
  92838. * Fill the defines array according to the current settings of the particle system
  92839. * @param defines Array to be updated
  92840. * @param blendMode blend mode to take into account when updating the array
  92841. */
  92842. fillDefines(defines: Array<string>, blendMode: number): void;
  92843. /**
  92844. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  92845. * @param uniforms Uniforms array to fill
  92846. * @param attributes Attributes array to fill
  92847. * @param samplers Samplers array to fill
  92848. */
  92849. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  92850. /**
  92851. * Observable that will be called just before the particles are drawn
  92852. */
  92853. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  92854. /**
  92855. * Gets the name of the particle vertex shader
  92856. */
  92857. vertexShaderName: string;
  92858. /**
  92859. * Adds a new color gradient
  92860. * @param gradient defines the gradient to use (between 0 and 1)
  92861. * @param color1 defines the color to affect to the specified gradient
  92862. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  92863. * @returns the current particle system
  92864. */
  92865. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  92866. /**
  92867. * Remove a specific color gradient
  92868. * @param gradient defines the gradient to remove
  92869. * @returns the current particle system
  92870. */
  92871. removeColorGradient(gradient: number): IParticleSystem;
  92872. /**
  92873. * Adds a new size gradient
  92874. * @param gradient defines the gradient to use (between 0 and 1)
  92875. * @param factor defines the size factor to affect to the specified gradient
  92876. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92877. * @returns the current particle system
  92878. */
  92879. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92880. /**
  92881. * Remove a specific size gradient
  92882. * @param gradient defines the gradient to remove
  92883. * @returns the current particle system
  92884. */
  92885. removeSizeGradient(gradient: number): IParticleSystem;
  92886. /**
  92887. * Gets the current list of color gradients.
  92888. * You must use addColorGradient and removeColorGradient to udpate this list
  92889. * @returns the list of color gradients
  92890. */
  92891. getColorGradients(): Nullable<Array<ColorGradient>>;
  92892. /**
  92893. * Gets the current list of size gradients.
  92894. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92895. * @returns the list of size gradients
  92896. */
  92897. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92898. /**
  92899. * Gets the current list of angular speed gradients.
  92900. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92901. * @returns the list of angular speed gradients
  92902. */
  92903. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92904. /**
  92905. * Adds a new angular speed gradient
  92906. * @param gradient defines the gradient to use (between 0 and 1)
  92907. * @param factor defines the angular speed to affect to the specified gradient
  92908. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92909. * @returns the current particle system
  92910. */
  92911. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92912. /**
  92913. * Remove a specific angular speed gradient
  92914. * @param gradient defines the gradient to remove
  92915. * @returns the current particle system
  92916. */
  92917. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92918. /**
  92919. * Gets the current list of velocity gradients.
  92920. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92921. * @returns the list of velocity gradients
  92922. */
  92923. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92924. /**
  92925. * Adds a new velocity gradient
  92926. * @param gradient defines the gradient to use (between 0 and 1)
  92927. * @param factor defines the velocity to affect to the specified gradient
  92928. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92929. * @returns the current particle system
  92930. */
  92931. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92932. /**
  92933. * Remove a specific velocity gradient
  92934. * @param gradient defines the gradient to remove
  92935. * @returns the current particle system
  92936. */
  92937. removeVelocityGradient(gradient: number): IParticleSystem;
  92938. /**
  92939. * Gets the current list of limit velocity gradients.
  92940. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92941. * @returns the list of limit velocity gradients
  92942. */
  92943. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92944. /**
  92945. * Adds a new limit velocity gradient
  92946. * @param gradient defines the gradient to use (between 0 and 1)
  92947. * @param factor defines the limit velocity to affect to the specified gradient
  92948. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92949. * @returns the current particle system
  92950. */
  92951. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92952. /**
  92953. * Remove a specific limit velocity gradient
  92954. * @param gradient defines the gradient to remove
  92955. * @returns the current particle system
  92956. */
  92957. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92958. /**
  92959. * Adds a new drag gradient
  92960. * @param gradient defines the gradient to use (between 0 and 1)
  92961. * @param factor defines the drag to affect to the specified gradient
  92962. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92963. * @returns the current particle system
  92964. */
  92965. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92966. /**
  92967. * Remove a specific drag gradient
  92968. * @param gradient defines the gradient to remove
  92969. * @returns the current particle system
  92970. */
  92971. removeDragGradient(gradient: number): IParticleSystem;
  92972. /**
  92973. * Gets the current list of drag gradients.
  92974. * You must use addDragGradient and removeDragGradient to udpate this list
  92975. * @returns the list of drag gradients
  92976. */
  92977. getDragGradients(): Nullable<Array<FactorGradient>>;
  92978. /**
  92979. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92980. * @param gradient defines the gradient to use (between 0 and 1)
  92981. * @param factor defines the emit rate to affect to the specified gradient
  92982. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92983. * @returns the current particle system
  92984. */
  92985. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92986. /**
  92987. * Remove a specific emit rate gradient
  92988. * @param gradient defines the gradient to remove
  92989. * @returns the current particle system
  92990. */
  92991. removeEmitRateGradient(gradient: number): IParticleSystem;
  92992. /**
  92993. * Gets the current list of emit rate gradients.
  92994. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92995. * @returns the list of emit rate gradients
  92996. */
  92997. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92998. /**
  92999. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93000. * @param gradient defines the gradient to use (between 0 and 1)
  93001. * @param factor defines the start size to affect to the specified gradient
  93002. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93003. * @returns the current particle system
  93004. */
  93005. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93006. /**
  93007. * Remove a specific start size gradient
  93008. * @param gradient defines the gradient to remove
  93009. * @returns the current particle system
  93010. */
  93011. removeStartSizeGradient(gradient: number): IParticleSystem;
  93012. /**
  93013. * Gets the current list of start size gradients.
  93014. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  93015. * @returns the list of start size gradients
  93016. */
  93017. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  93018. /**
  93019. * Adds a new life time gradient
  93020. * @param gradient defines the gradient to use (between 0 and 1)
  93021. * @param factor defines the life time factor to affect to the specified gradient
  93022. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93023. * @returns the current particle system
  93024. */
  93025. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93026. /**
  93027. * Remove a specific life time gradient
  93028. * @param gradient defines the gradient to remove
  93029. * @returns the current particle system
  93030. */
  93031. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93032. /**
  93033. * Gets the current list of life time gradients.
  93034. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  93035. * @returns the list of life time gradients
  93036. */
  93037. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  93038. /**
  93039. * Gets the current list of color gradients.
  93040. * You must use addColorGradient and removeColorGradient to udpate this list
  93041. * @returns the list of color gradients
  93042. */
  93043. getColorGradients(): Nullable<Array<ColorGradient>>;
  93044. /**
  93045. * Adds a new ramp gradient used to remap particle colors
  93046. * @param gradient defines the gradient to use (between 0 and 1)
  93047. * @param color defines the color to affect to the specified gradient
  93048. * @returns the current particle system
  93049. */
  93050. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  93051. /**
  93052. * Gets the current list of ramp gradients.
  93053. * You must use addRampGradient and removeRampGradient to udpate this list
  93054. * @returns the list of ramp gradients
  93055. */
  93056. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93057. /** Gets or sets a boolean indicating that ramp gradients must be used
  93058. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93059. */
  93060. useRampGradients: boolean;
  93061. /**
  93062. * Adds a new color remap gradient
  93063. * @param gradient defines the gradient to use (between 0 and 1)
  93064. * @param min defines the color remap minimal range
  93065. * @param max defines the color remap maximal range
  93066. * @returns the current particle system
  93067. */
  93068. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93069. /**
  93070. * Gets the current list of color remap gradients.
  93071. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  93072. * @returns the list of color remap gradients
  93073. */
  93074. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  93075. /**
  93076. * Adds a new alpha remap gradient
  93077. * @param gradient defines the gradient to use (between 0 and 1)
  93078. * @param min defines the alpha remap minimal range
  93079. * @param max defines the alpha remap maximal range
  93080. * @returns the current particle system
  93081. */
  93082. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93083. /**
  93084. * Gets the current list of alpha remap gradients.
  93085. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  93086. * @returns the list of alpha remap gradients
  93087. */
  93088. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  93089. /**
  93090. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93091. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93092. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93093. * @returns the emitter
  93094. */
  93095. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93096. /**
  93097. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93098. * @param radius The radius of the hemisphere to emit from
  93099. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93100. * @returns the emitter
  93101. */
  93102. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  93103. /**
  93104. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93105. * @param radius The radius of the sphere to emit from
  93106. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93107. * @returns the emitter
  93108. */
  93109. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  93110. /**
  93111. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93112. * @param radius The radius of the sphere to emit from
  93113. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93114. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93115. * @returns the emitter
  93116. */
  93117. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  93118. /**
  93119. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93120. * @param radius The radius of the emission cylinder
  93121. * @param height The height of the emission cylinder
  93122. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93123. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93124. * @returns the emitter
  93125. */
  93126. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  93127. /**
  93128. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93129. * @param radius The radius of the cylinder to emit from
  93130. * @param height The height of the emission cylinder
  93131. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93132. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93133. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93134. * @returns the emitter
  93135. */
  93136. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  93137. /**
  93138. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93139. * @param radius The radius of the cone to emit from
  93140. * @param angle The base angle of the cone
  93141. * @returns the emitter
  93142. */
  93143. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  93144. /**
  93145. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93146. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93147. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93148. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93149. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93150. * @returns the emitter
  93151. */
  93152. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93153. /**
  93154. * Get hosting scene
  93155. * @returns the scene
  93156. */
  93157. getScene(): Scene;
  93158. }
  93159. }
  93160. declare module BABYLON {
  93161. /**
  93162. * 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.
  93163. * @see https://doc.babylonjs.com/how_to/transformnode
  93164. */
  93165. export class TransformNode extends Node {
  93166. /**
  93167. * Object will not rotate to face the camera
  93168. */
  93169. static BILLBOARDMODE_NONE: number;
  93170. /**
  93171. * Object will rotate to face the camera but only on the x axis
  93172. */
  93173. static BILLBOARDMODE_X: number;
  93174. /**
  93175. * Object will rotate to face the camera but only on the y axis
  93176. */
  93177. static BILLBOARDMODE_Y: number;
  93178. /**
  93179. * Object will rotate to face the camera but only on the z axis
  93180. */
  93181. static BILLBOARDMODE_Z: number;
  93182. /**
  93183. * Object will rotate to face the camera
  93184. */
  93185. static BILLBOARDMODE_ALL: number;
  93186. /**
  93187. * Object will rotate to face the camera's position instead of orientation
  93188. */
  93189. static BILLBOARDMODE_USE_POSITION: number;
  93190. private static _TmpRotation;
  93191. private static _TmpScaling;
  93192. private static _TmpTranslation;
  93193. private _forward;
  93194. private _forwardInverted;
  93195. private _up;
  93196. private _right;
  93197. private _rightInverted;
  93198. private _position;
  93199. private _rotation;
  93200. private _rotationQuaternion;
  93201. protected _scaling: Vector3;
  93202. protected _isDirty: boolean;
  93203. private _transformToBoneReferal;
  93204. private _isAbsoluteSynced;
  93205. private _billboardMode;
  93206. /**
  93207. * Gets or sets the billboard mode. Default is 0.
  93208. *
  93209. * | Value | Type | Description |
  93210. * | --- | --- | --- |
  93211. * | 0 | BILLBOARDMODE_NONE | |
  93212. * | 1 | BILLBOARDMODE_X | |
  93213. * | 2 | BILLBOARDMODE_Y | |
  93214. * | 4 | BILLBOARDMODE_Z | |
  93215. * | 7 | BILLBOARDMODE_ALL | |
  93216. *
  93217. */
  93218. get billboardMode(): number;
  93219. set billboardMode(value: number);
  93220. private _preserveParentRotationForBillboard;
  93221. /**
  93222. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  93223. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  93224. */
  93225. get preserveParentRotationForBillboard(): boolean;
  93226. set preserveParentRotationForBillboard(value: boolean);
  93227. /**
  93228. * 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
  93229. */
  93230. scalingDeterminant: number;
  93231. private _infiniteDistance;
  93232. /**
  93233. * Gets or sets the distance of the object to max, often used by skybox
  93234. */
  93235. get infiniteDistance(): boolean;
  93236. set infiniteDistance(value: boolean);
  93237. /**
  93238. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  93239. * By default the system will update normals to compensate
  93240. */
  93241. ignoreNonUniformScaling: boolean;
  93242. /**
  93243. * 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
  93244. */
  93245. reIntegrateRotationIntoRotationQuaternion: boolean;
  93246. /** @hidden */
  93247. _poseMatrix: Nullable<Matrix>;
  93248. /** @hidden */
  93249. _localMatrix: Matrix;
  93250. private _usePivotMatrix;
  93251. private _absolutePosition;
  93252. private _absoluteScaling;
  93253. private _absoluteRotationQuaternion;
  93254. private _pivotMatrix;
  93255. private _pivotMatrixInverse;
  93256. protected _postMultiplyPivotMatrix: boolean;
  93257. protected _isWorldMatrixFrozen: boolean;
  93258. /** @hidden */
  93259. _indexInSceneTransformNodesArray: number;
  93260. /**
  93261. * An event triggered after the world matrix is updated
  93262. */
  93263. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  93264. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  93265. /**
  93266. * Gets a string identifying the name of the class
  93267. * @returns "TransformNode" string
  93268. */
  93269. getClassName(): string;
  93270. /**
  93271. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  93272. */
  93273. get position(): Vector3;
  93274. set position(newPosition: Vector3);
  93275. /**
  93276. * 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)).
  93277. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  93278. */
  93279. get rotation(): Vector3;
  93280. set rotation(newRotation: Vector3);
  93281. /**
  93282. * 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)).
  93283. */
  93284. get scaling(): Vector3;
  93285. set scaling(newScaling: Vector3);
  93286. /**
  93287. * 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).
  93288. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  93289. */
  93290. get rotationQuaternion(): Nullable<Quaternion>;
  93291. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  93292. /**
  93293. * The forward direction of that transform in world space.
  93294. */
  93295. get forward(): Vector3;
  93296. /**
  93297. * The up direction of that transform in world space.
  93298. */
  93299. get up(): Vector3;
  93300. /**
  93301. * The right direction of that transform in world space.
  93302. */
  93303. get right(): Vector3;
  93304. /**
  93305. * Copies the parameter passed Matrix into the mesh Pose matrix.
  93306. * @param matrix the matrix to copy the pose from
  93307. * @returns this TransformNode.
  93308. */
  93309. updatePoseMatrix(matrix: Matrix): TransformNode;
  93310. /**
  93311. * Returns the mesh Pose matrix.
  93312. * @returns the pose matrix
  93313. */
  93314. getPoseMatrix(): Matrix;
  93315. /** @hidden */
  93316. _isSynchronized(): boolean;
  93317. /** @hidden */
  93318. _initCache(): void;
  93319. /**
  93320. * Flag the transform node as dirty (Forcing it to update everything)
  93321. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  93322. * @returns this transform node
  93323. */
  93324. markAsDirty(property: string): TransformNode;
  93325. /**
  93326. * Returns the current mesh absolute position.
  93327. * Returns a Vector3.
  93328. */
  93329. get absolutePosition(): Vector3;
  93330. /**
  93331. * Returns the current mesh absolute scaling.
  93332. * Returns a Vector3.
  93333. */
  93334. get absoluteScaling(): Vector3;
  93335. /**
  93336. * Returns the current mesh absolute rotation.
  93337. * Returns a Quaternion.
  93338. */
  93339. get absoluteRotationQuaternion(): Quaternion;
  93340. /**
  93341. * Sets a new matrix to apply before all other transformation
  93342. * @param matrix defines the transform matrix
  93343. * @returns the current TransformNode
  93344. */
  93345. setPreTransformMatrix(matrix: Matrix): TransformNode;
  93346. /**
  93347. * Sets a new pivot matrix to the current node
  93348. * @param matrix defines the new pivot matrix to use
  93349. * @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
  93350. * @returns the current TransformNode
  93351. */
  93352. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  93353. /**
  93354. * Returns the mesh pivot matrix.
  93355. * Default : Identity.
  93356. * @returns the matrix
  93357. */
  93358. getPivotMatrix(): Matrix;
  93359. /**
  93360. * Instantiate (when possible) or clone that node with its hierarchy
  93361. * @param newParent defines the new parent to use for the instance (or clone)
  93362. * @param options defines options to configure how copy is done
  93363. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  93364. * @returns an instance (or a clone) of the current node with its hiearchy
  93365. */
  93366. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  93367. doNotInstantiate: boolean;
  93368. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  93369. /**
  93370. * Prevents the World matrix to be computed any longer
  93371. * @param newWorldMatrix defines an optional matrix to use as world matrix
  93372. * @returns the TransformNode.
  93373. */
  93374. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  93375. /**
  93376. * Allows back the World matrix computation.
  93377. * @returns the TransformNode.
  93378. */
  93379. unfreezeWorldMatrix(): this;
  93380. /**
  93381. * True if the World matrix has been frozen.
  93382. */
  93383. get isWorldMatrixFrozen(): boolean;
  93384. /**
  93385. * Retuns the mesh absolute position in the World.
  93386. * @returns a Vector3.
  93387. */
  93388. getAbsolutePosition(): Vector3;
  93389. /**
  93390. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  93391. * @param absolutePosition the absolute position to set
  93392. * @returns the TransformNode.
  93393. */
  93394. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  93395. /**
  93396. * Sets the mesh position in its local space.
  93397. * @param vector3 the position to set in localspace
  93398. * @returns the TransformNode.
  93399. */
  93400. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  93401. /**
  93402. * Returns the mesh position in the local space from the current World matrix values.
  93403. * @returns a new Vector3.
  93404. */
  93405. getPositionExpressedInLocalSpace(): Vector3;
  93406. /**
  93407. * Translates the mesh along the passed Vector3 in its local space.
  93408. * @param vector3 the distance to translate in localspace
  93409. * @returns the TransformNode.
  93410. */
  93411. locallyTranslate(vector3: Vector3): TransformNode;
  93412. private static _lookAtVectorCache;
  93413. /**
  93414. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  93415. * @param targetPoint the position (must be in same space as current mesh) to look at
  93416. * @param yawCor optional yaw (y-axis) correction in radians
  93417. * @param pitchCor optional pitch (x-axis) correction in radians
  93418. * @param rollCor optional roll (z-axis) correction in radians
  93419. * @param space the choosen space of the target
  93420. * @returns the TransformNode.
  93421. */
  93422. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  93423. /**
  93424. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93425. * This Vector3 is expressed in the World space.
  93426. * @param localAxis axis to rotate
  93427. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93428. */
  93429. getDirection(localAxis: Vector3): Vector3;
  93430. /**
  93431. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  93432. * localAxis is expressed in the mesh local space.
  93433. * result is computed in the Wordl space from the mesh World matrix.
  93434. * @param localAxis axis to rotate
  93435. * @param result the resulting transformnode
  93436. * @returns this TransformNode.
  93437. */
  93438. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  93439. /**
  93440. * Sets this transform node rotation to the given local axis.
  93441. * @param localAxis the axis in local space
  93442. * @param yawCor optional yaw (y-axis) correction in radians
  93443. * @param pitchCor optional pitch (x-axis) correction in radians
  93444. * @param rollCor optional roll (z-axis) correction in radians
  93445. * @returns this TransformNode
  93446. */
  93447. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  93448. /**
  93449. * Sets a new pivot point to the current node
  93450. * @param point defines the new pivot point to use
  93451. * @param space defines if the point is in world or local space (local by default)
  93452. * @returns the current TransformNode
  93453. */
  93454. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  93455. /**
  93456. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  93457. * @returns the pivot point
  93458. */
  93459. getPivotPoint(): Vector3;
  93460. /**
  93461. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  93462. * @param result the vector3 to store the result
  93463. * @returns this TransformNode.
  93464. */
  93465. getPivotPointToRef(result: Vector3): TransformNode;
  93466. /**
  93467. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  93468. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  93469. */
  93470. getAbsolutePivotPoint(): Vector3;
  93471. /**
  93472. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  93473. * @param result vector3 to store the result
  93474. * @returns this TransformNode.
  93475. */
  93476. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  93477. /**
  93478. * Defines the passed node as the parent of the current node.
  93479. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  93480. * @see https://doc.babylonjs.com/how_to/parenting
  93481. * @param node the node ot set as the parent
  93482. * @returns this TransformNode.
  93483. */
  93484. setParent(node: Nullable<Node>): TransformNode;
  93485. private _nonUniformScaling;
  93486. /**
  93487. * True if the scaling property of this object is non uniform eg. (1,2,1)
  93488. */
  93489. get nonUniformScaling(): boolean;
  93490. /** @hidden */
  93491. _updateNonUniformScalingState(value: boolean): boolean;
  93492. /**
  93493. * Attach the current TransformNode to another TransformNode associated with a bone
  93494. * @param bone Bone affecting the TransformNode
  93495. * @param affectedTransformNode TransformNode associated with the bone
  93496. * @returns this object
  93497. */
  93498. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  93499. /**
  93500. * Detach the transform node if its associated with a bone
  93501. * @returns this object
  93502. */
  93503. detachFromBone(): TransformNode;
  93504. private static _rotationAxisCache;
  93505. /**
  93506. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  93507. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93508. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93509. * The passed axis is also normalized.
  93510. * @param axis the axis to rotate around
  93511. * @param amount the amount to rotate in radians
  93512. * @param space Space to rotate in (Default: local)
  93513. * @returns the TransformNode.
  93514. */
  93515. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  93516. /**
  93517. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  93518. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93519. * The passed axis is also normalized. .
  93520. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  93521. * @param point the point to rotate around
  93522. * @param axis the axis to rotate around
  93523. * @param amount the amount to rotate in radians
  93524. * @returns the TransformNode
  93525. */
  93526. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  93527. /**
  93528. * Translates the mesh along the axis vector for the passed distance in the given space.
  93529. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93530. * @param axis the axis to translate in
  93531. * @param distance the distance to translate
  93532. * @param space Space to rotate in (Default: local)
  93533. * @returns the TransformNode.
  93534. */
  93535. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  93536. /**
  93537. * Adds a rotation step to the mesh current rotation.
  93538. * x, y, z are Euler angles expressed in radians.
  93539. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  93540. * This means this rotation is made in the mesh local space only.
  93541. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  93542. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  93543. * ```javascript
  93544. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  93545. * ```
  93546. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  93547. * 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.
  93548. * @param x Rotation to add
  93549. * @param y Rotation to add
  93550. * @param z Rotation to add
  93551. * @returns the TransformNode.
  93552. */
  93553. addRotation(x: number, y: number, z: number): TransformNode;
  93554. /**
  93555. * @hidden
  93556. */
  93557. protected _getEffectiveParent(): Nullable<Node>;
  93558. /**
  93559. * Computes the world matrix of the node
  93560. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93561. * @returns the world matrix
  93562. */
  93563. computeWorldMatrix(force?: boolean): Matrix;
  93564. /**
  93565. * Resets this nodeTransform's local matrix to Matrix.Identity().
  93566. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  93567. */
  93568. resetLocalMatrix(independentOfChildren?: boolean): void;
  93569. protected _afterComputeWorldMatrix(): void;
  93570. /**
  93571. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  93572. * @param func callback function to add
  93573. *
  93574. * @returns the TransformNode.
  93575. */
  93576. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93577. /**
  93578. * Removes a registered callback function.
  93579. * @param func callback function to remove
  93580. * @returns the TransformNode.
  93581. */
  93582. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93583. /**
  93584. * Gets the position of the current mesh in camera space
  93585. * @param camera defines the camera to use
  93586. * @returns a position
  93587. */
  93588. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  93589. /**
  93590. * Returns the distance from the mesh to the active camera
  93591. * @param camera defines the camera to use
  93592. * @returns the distance
  93593. */
  93594. getDistanceToCamera(camera?: Nullable<Camera>): number;
  93595. /**
  93596. * Clone the current transform node
  93597. * @param name Name of the new clone
  93598. * @param newParent New parent for the clone
  93599. * @param doNotCloneChildren Do not clone children hierarchy
  93600. * @returns the new transform node
  93601. */
  93602. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  93603. /**
  93604. * Serializes the objects information.
  93605. * @param currentSerializationObject defines the object to serialize in
  93606. * @returns the serialized object
  93607. */
  93608. serialize(currentSerializationObject?: any): any;
  93609. /**
  93610. * Returns a new TransformNode object parsed from the source provided.
  93611. * @param parsedTransformNode is the source.
  93612. * @param scene the scne the object belongs to
  93613. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  93614. * @returns a new TransformNode object parsed from the source provided.
  93615. */
  93616. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  93617. /**
  93618. * Get all child-transformNodes of this node
  93619. * @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
  93620. * @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
  93621. * @returns an array of TransformNode
  93622. */
  93623. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  93624. /**
  93625. * Releases resources associated with this transform node.
  93626. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93627. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93628. */
  93629. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93630. /**
  93631. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93632. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93633. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93634. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93635. * @returns the current mesh
  93636. */
  93637. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  93638. private _syncAbsoluteScalingAndRotation;
  93639. }
  93640. }
  93641. declare module BABYLON {
  93642. /**
  93643. * Class used to override all child animations of a given target
  93644. */
  93645. export class AnimationPropertiesOverride {
  93646. /**
  93647. * Gets or sets a value indicating if animation blending must be used
  93648. */
  93649. enableBlending: boolean;
  93650. /**
  93651. * Gets or sets the blending speed to use when enableBlending is true
  93652. */
  93653. blendingSpeed: number;
  93654. /**
  93655. * Gets or sets the default loop mode to use
  93656. */
  93657. loopMode: number;
  93658. }
  93659. }
  93660. declare module BABYLON {
  93661. /**
  93662. * Class used to store bone information
  93663. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93664. */
  93665. export class Bone extends Node {
  93666. /**
  93667. * defines the bone name
  93668. */
  93669. name: string;
  93670. private static _tmpVecs;
  93671. private static _tmpQuat;
  93672. private static _tmpMats;
  93673. /**
  93674. * Gets the list of child bones
  93675. */
  93676. children: Bone[];
  93677. /** Gets the animations associated with this bone */
  93678. animations: Animation[];
  93679. /**
  93680. * Gets or sets bone length
  93681. */
  93682. length: number;
  93683. /**
  93684. * @hidden Internal only
  93685. * Set this value to map this bone to a different index in the transform matrices
  93686. * Set this value to -1 to exclude the bone from the transform matrices
  93687. */
  93688. _index: Nullable<number>;
  93689. private _skeleton;
  93690. private _localMatrix;
  93691. private _restPose;
  93692. private _baseMatrix;
  93693. private _absoluteTransform;
  93694. private _invertedAbsoluteTransform;
  93695. private _parent;
  93696. private _scalingDeterminant;
  93697. private _worldTransform;
  93698. private _localScaling;
  93699. private _localRotation;
  93700. private _localPosition;
  93701. private _needToDecompose;
  93702. private _needToCompose;
  93703. /** @hidden */
  93704. _linkedTransformNode: Nullable<TransformNode>;
  93705. /** @hidden */
  93706. _waitingTransformNodeId: Nullable<string>;
  93707. /** @hidden */
  93708. get _matrix(): Matrix;
  93709. /** @hidden */
  93710. set _matrix(value: Matrix);
  93711. /**
  93712. * Create a new bone
  93713. * @param name defines the bone name
  93714. * @param skeleton defines the parent skeleton
  93715. * @param parentBone defines the parent (can be null if the bone is the root)
  93716. * @param localMatrix defines the local matrix
  93717. * @param restPose defines the rest pose matrix
  93718. * @param baseMatrix defines the base matrix
  93719. * @param index defines index of the bone in the hiearchy
  93720. */
  93721. constructor(
  93722. /**
  93723. * defines the bone name
  93724. */
  93725. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  93726. /**
  93727. * Gets the current object class name.
  93728. * @return the class name
  93729. */
  93730. getClassName(): string;
  93731. /**
  93732. * Gets the parent skeleton
  93733. * @returns a skeleton
  93734. */
  93735. getSkeleton(): Skeleton;
  93736. /**
  93737. * Gets parent bone
  93738. * @returns a bone or null if the bone is the root of the bone hierarchy
  93739. */
  93740. getParent(): Nullable<Bone>;
  93741. /**
  93742. * Returns an array containing the root bones
  93743. * @returns an array containing the root bones
  93744. */
  93745. getChildren(): Array<Bone>;
  93746. /**
  93747. * Gets the node index in matrix array generated for rendering
  93748. * @returns the node index
  93749. */
  93750. getIndex(): number;
  93751. /**
  93752. * Sets the parent bone
  93753. * @param parent defines the parent (can be null if the bone is the root)
  93754. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93755. */
  93756. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  93757. /**
  93758. * Gets the local matrix
  93759. * @returns a matrix
  93760. */
  93761. getLocalMatrix(): Matrix;
  93762. /**
  93763. * Gets the base matrix (initial matrix which remains unchanged)
  93764. * @returns a matrix
  93765. */
  93766. getBaseMatrix(): Matrix;
  93767. /**
  93768. * Gets the rest pose matrix
  93769. * @returns a matrix
  93770. */
  93771. getRestPose(): Matrix;
  93772. /**
  93773. * Sets the rest pose matrix
  93774. * @param matrix the local-space rest pose to set for this bone
  93775. */
  93776. setRestPose(matrix: Matrix): void;
  93777. /**
  93778. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  93779. */
  93780. getWorldMatrix(): Matrix;
  93781. /**
  93782. * Sets the local matrix to rest pose matrix
  93783. */
  93784. returnToRest(): void;
  93785. /**
  93786. * Gets the inverse of the absolute transform matrix.
  93787. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  93788. * @returns a matrix
  93789. */
  93790. getInvertedAbsoluteTransform(): Matrix;
  93791. /**
  93792. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  93793. * @returns a matrix
  93794. */
  93795. getAbsoluteTransform(): Matrix;
  93796. /**
  93797. * Links with the given transform node.
  93798. * The local matrix of this bone is copied from the transform node every frame.
  93799. * @param transformNode defines the transform node to link to
  93800. */
  93801. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  93802. /**
  93803. * Gets the node used to drive the bone's transformation
  93804. * @returns a transform node or null
  93805. */
  93806. getTransformNode(): Nullable<TransformNode>;
  93807. /** Gets or sets current position (in local space) */
  93808. get position(): Vector3;
  93809. set position(newPosition: Vector3);
  93810. /** Gets or sets current rotation (in local space) */
  93811. get rotation(): Vector3;
  93812. set rotation(newRotation: Vector3);
  93813. /** Gets or sets current rotation quaternion (in local space) */
  93814. get rotationQuaternion(): Quaternion;
  93815. set rotationQuaternion(newRotation: Quaternion);
  93816. /** Gets or sets current scaling (in local space) */
  93817. get scaling(): Vector3;
  93818. set scaling(newScaling: Vector3);
  93819. /**
  93820. * Gets the animation properties override
  93821. */
  93822. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93823. private _decompose;
  93824. private _compose;
  93825. /**
  93826. * Update the base and local matrices
  93827. * @param matrix defines the new base or local matrix
  93828. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93829. * @param updateLocalMatrix defines if the local matrix should be updated
  93830. */
  93831. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  93832. /** @hidden */
  93833. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  93834. /**
  93835. * Flag the bone as dirty (Forcing it to update everything)
  93836. */
  93837. markAsDirty(): void;
  93838. /** @hidden */
  93839. _markAsDirtyAndCompose(): void;
  93840. private _markAsDirtyAndDecompose;
  93841. /**
  93842. * Translate the bone in local or world space
  93843. * @param vec The amount to translate the bone
  93844. * @param space The space that the translation is in
  93845. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93846. */
  93847. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93848. /**
  93849. * Set the postion of the bone in local or world space
  93850. * @param position The position to set the bone
  93851. * @param space The space that the position is in
  93852. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93853. */
  93854. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93855. /**
  93856. * Set the absolute position of the bone (world space)
  93857. * @param position The position to set the bone
  93858. * @param mesh The mesh that this bone is attached to
  93859. */
  93860. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  93861. /**
  93862. * Scale the bone on the x, y and z axes (in local space)
  93863. * @param x The amount to scale the bone on the x axis
  93864. * @param y The amount to scale the bone on the y axis
  93865. * @param z The amount to scale the bone on the z axis
  93866. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  93867. */
  93868. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  93869. /**
  93870. * Set the bone scaling in local space
  93871. * @param scale defines the scaling vector
  93872. */
  93873. setScale(scale: Vector3): void;
  93874. /**
  93875. * Gets the current scaling in local space
  93876. * @returns the current scaling vector
  93877. */
  93878. getScale(): Vector3;
  93879. /**
  93880. * Gets the current scaling in local space and stores it in a target vector
  93881. * @param result defines the target vector
  93882. */
  93883. getScaleToRef(result: Vector3): void;
  93884. /**
  93885. * Set the yaw, pitch, and roll of the bone in local or world space
  93886. * @param yaw The rotation of the bone on the y axis
  93887. * @param pitch The rotation of the bone on the x axis
  93888. * @param roll The rotation of the bone on the z axis
  93889. * @param space The space that the axes of rotation are in
  93890. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93891. */
  93892. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  93893. /**
  93894. * Add a rotation to the bone on an axis in local or world space
  93895. * @param axis The axis to rotate the bone on
  93896. * @param amount The amount to rotate the bone
  93897. * @param space The space that the axis is in
  93898. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93899. */
  93900. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  93901. /**
  93902. * Set the rotation of the bone to a particular axis angle in local or world space
  93903. * @param axis The axis to rotate the bone on
  93904. * @param angle The angle that the bone should be rotated to
  93905. * @param space The space that the axis is in
  93906. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93907. */
  93908. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  93909. /**
  93910. * Set the euler rotation of the bone in local of world space
  93911. * @param rotation The euler rotation that the bone should be set to
  93912. * @param space The space that the rotation is in
  93913. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93914. */
  93915. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93916. /**
  93917. * Set the quaternion rotation of the bone in local of world space
  93918. * @param quat The quaternion rotation that the bone should be set to
  93919. * @param space The space that the rotation is in
  93920. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93921. */
  93922. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  93923. /**
  93924. * Set the rotation matrix of the bone in local of world space
  93925. * @param rotMat The rotation matrix that the bone should be set to
  93926. * @param space The space that the rotation is in
  93927. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93928. */
  93929. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  93930. private _rotateWithMatrix;
  93931. private _getNegativeRotationToRef;
  93932. /**
  93933. * Get the position of the bone in local or world space
  93934. * @param space The space that the returned position is in
  93935. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93936. * @returns The position of the bone
  93937. */
  93938. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93939. /**
  93940. * Copy the position of the bone to a vector3 in local or world space
  93941. * @param space The space that the returned position is in
  93942. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93943. * @param result The vector3 to copy the position to
  93944. */
  93945. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  93946. /**
  93947. * Get the absolute position of the bone (world space)
  93948. * @param mesh The mesh that this bone is attached to
  93949. * @returns The absolute position of the bone
  93950. */
  93951. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  93952. /**
  93953. * Copy the absolute position of the bone (world space) to the result param
  93954. * @param mesh The mesh that this bone is attached to
  93955. * @param result The vector3 to copy the absolute position to
  93956. */
  93957. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  93958. /**
  93959. * Compute the absolute transforms of this bone and its children
  93960. */
  93961. computeAbsoluteTransforms(): void;
  93962. /**
  93963. * Get the world direction from an axis that is in the local space of the bone
  93964. * @param localAxis The local direction that is used to compute the world direction
  93965. * @param mesh The mesh that this bone is attached to
  93966. * @returns The world direction
  93967. */
  93968. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93969. /**
  93970. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  93971. * @param localAxis The local direction that is used to compute the world direction
  93972. * @param mesh The mesh that this bone is attached to
  93973. * @param result The vector3 that the world direction will be copied to
  93974. */
  93975. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93976. /**
  93977. * Get the euler rotation of the bone in local or world space
  93978. * @param space The space that the rotation should be in
  93979. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93980. * @returns The euler rotation
  93981. */
  93982. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93983. /**
  93984. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  93985. * @param space The space that the rotation should be in
  93986. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93987. * @param result The vector3 that the rotation should be copied to
  93988. */
  93989. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93990. /**
  93991. * Get the quaternion rotation of the bone in either local or world space
  93992. * @param space The space that the rotation should be in
  93993. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93994. * @returns The quaternion rotation
  93995. */
  93996. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  93997. /**
  93998. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  93999. * @param space The space that the rotation should be in
  94000. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94001. * @param result The quaternion that the rotation should be copied to
  94002. */
  94003. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  94004. /**
  94005. * Get the rotation matrix of the bone in local or world space
  94006. * @param space The space that the rotation should be in
  94007. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94008. * @returns The rotation matrix
  94009. */
  94010. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  94011. /**
  94012. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  94013. * @param space The space that the rotation should be in
  94014. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94015. * @param result The quaternion that the rotation should be copied to
  94016. */
  94017. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  94018. /**
  94019. * Get the world position of a point that is in the local space of the bone
  94020. * @param position The local position
  94021. * @param mesh The mesh that this bone is attached to
  94022. * @returns The world position
  94023. */
  94024. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94025. /**
  94026. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  94027. * @param position The local position
  94028. * @param mesh The mesh that this bone is attached to
  94029. * @param result The vector3 that the world position should be copied to
  94030. */
  94031. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94032. /**
  94033. * Get the local position of a point that is in world space
  94034. * @param position The world position
  94035. * @param mesh The mesh that this bone is attached to
  94036. * @returns The local position
  94037. */
  94038. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94039. /**
  94040. * Get the local position of a point that is in world space and copy it to the result param
  94041. * @param position The world position
  94042. * @param mesh The mesh that this bone is attached to
  94043. * @param result The vector3 that the local position should be copied to
  94044. */
  94045. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94046. }
  94047. }
  94048. declare module BABYLON {
  94049. /**
  94050. * Defines a runtime animation
  94051. */
  94052. export class RuntimeAnimation {
  94053. private _events;
  94054. /**
  94055. * The current frame of the runtime animation
  94056. */
  94057. private _currentFrame;
  94058. /**
  94059. * The animation used by the runtime animation
  94060. */
  94061. private _animation;
  94062. /**
  94063. * The target of the runtime animation
  94064. */
  94065. private _target;
  94066. /**
  94067. * The initiating animatable
  94068. */
  94069. private _host;
  94070. /**
  94071. * The original value of the runtime animation
  94072. */
  94073. private _originalValue;
  94074. /**
  94075. * The original blend value of the runtime animation
  94076. */
  94077. private _originalBlendValue;
  94078. /**
  94079. * The offsets cache of the runtime animation
  94080. */
  94081. private _offsetsCache;
  94082. /**
  94083. * The high limits cache of the runtime animation
  94084. */
  94085. private _highLimitsCache;
  94086. /**
  94087. * Specifies if the runtime animation has been stopped
  94088. */
  94089. private _stopped;
  94090. /**
  94091. * The blending factor of the runtime animation
  94092. */
  94093. private _blendingFactor;
  94094. /**
  94095. * The BabylonJS scene
  94096. */
  94097. private _scene;
  94098. /**
  94099. * The current value of the runtime animation
  94100. */
  94101. private _currentValue;
  94102. /** @hidden */
  94103. _animationState: _IAnimationState;
  94104. /**
  94105. * The active target of the runtime animation
  94106. */
  94107. private _activeTargets;
  94108. private _currentActiveTarget;
  94109. private _directTarget;
  94110. /**
  94111. * The target path of the runtime animation
  94112. */
  94113. private _targetPath;
  94114. /**
  94115. * The weight of the runtime animation
  94116. */
  94117. private _weight;
  94118. /**
  94119. * The ratio offset of the runtime animation
  94120. */
  94121. private _ratioOffset;
  94122. /**
  94123. * The previous delay of the runtime animation
  94124. */
  94125. private _previousDelay;
  94126. /**
  94127. * The previous ratio of the runtime animation
  94128. */
  94129. private _previousRatio;
  94130. private _enableBlending;
  94131. private _keys;
  94132. private _minFrame;
  94133. private _maxFrame;
  94134. private _minValue;
  94135. private _maxValue;
  94136. private _targetIsArray;
  94137. /**
  94138. * Gets the current frame of the runtime animation
  94139. */
  94140. get currentFrame(): number;
  94141. /**
  94142. * Gets the weight of the runtime animation
  94143. */
  94144. get weight(): number;
  94145. /**
  94146. * Gets the current value of the runtime animation
  94147. */
  94148. get currentValue(): any;
  94149. /**
  94150. * Gets the target path of the runtime animation
  94151. */
  94152. get targetPath(): string;
  94153. /**
  94154. * Gets the actual target of the runtime animation
  94155. */
  94156. get target(): any;
  94157. /**
  94158. * Gets the additive state of the runtime animation
  94159. */
  94160. get isAdditive(): boolean;
  94161. /** @hidden */
  94162. _onLoop: () => void;
  94163. /**
  94164. * Create a new RuntimeAnimation object
  94165. * @param target defines the target of the animation
  94166. * @param animation defines the source animation object
  94167. * @param scene defines the hosting scene
  94168. * @param host defines the initiating Animatable
  94169. */
  94170. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  94171. private _preparePath;
  94172. /**
  94173. * Gets the animation from the runtime animation
  94174. */
  94175. get animation(): Animation;
  94176. /**
  94177. * Resets the runtime animation to the beginning
  94178. * @param restoreOriginal defines whether to restore the target property to the original value
  94179. */
  94180. reset(restoreOriginal?: boolean): void;
  94181. /**
  94182. * Specifies if the runtime animation is stopped
  94183. * @returns Boolean specifying if the runtime animation is stopped
  94184. */
  94185. isStopped(): boolean;
  94186. /**
  94187. * Disposes of the runtime animation
  94188. */
  94189. dispose(): void;
  94190. /**
  94191. * Apply the interpolated value to the target
  94192. * @param currentValue defines the value computed by the animation
  94193. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  94194. */
  94195. setValue(currentValue: any, weight: number): void;
  94196. private _getOriginalValues;
  94197. private _setValue;
  94198. /**
  94199. * Gets the loop pmode of the runtime animation
  94200. * @returns Loop Mode
  94201. */
  94202. private _getCorrectLoopMode;
  94203. /**
  94204. * Move the current animation to a given frame
  94205. * @param frame defines the frame to move to
  94206. */
  94207. goToFrame(frame: number): void;
  94208. /**
  94209. * @hidden Internal use only
  94210. */
  94211. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  94212. /**
  94213. * Execute the current animation
  94214. * @param delay defines the delay to add to the current frame
  94215. * @param from defines the lower bound of the animation range
  94216. * @param to defines the upper bound of the animation range
  94217. * @param loop defines if the current animation must loop
  94218. * @param speedRatio defines the current speed ratio
  94219. * @param weight defines the weight of the animation (default is -1 so no weight)
  94220. * @param onLoop optional callback called when animation loops
  94221. * @returns a boolean indicating if the animation is running
  94222. */
  94223. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  94224. }
  94225. }
  94226. declare module BABYLON {
  94227. /**
  94228. * Class used to store an actual running animation
  94229. */
  94230. export class Animatable {
  94231. /** defines the target object */
  94232. target: any;
  94233. /** defines the starting frame number (default is 0) */
  94234. fromFrame: number;
  94235. /** defines the ending frame number (default is 100) */
  94236. toFrame: number;
  94237. /** defines if the animation must loop (default is false) */
  94238. loopAnimation: boolean;
  94239. /** defines a callback to call when animation ends if it is not looping */
  94240. onAnimationEnd?: (() => void) | null | undefined;
  94241. /** defines a callback to call when animation loops */
  94242. onAnimationLoop?: (() => void) | null | undefined;
  94243. /** defines whether the animation should be evaluated additively */
  94244. isAdditive: boolean;
  94245. private _localDelayOffset;
  94246. private _pausedDelay;
  94247. private _runtimeAnimations;
  94248. private _paused;
  94249. private _scene;
  94250. private _speedRatio;
  94251. private _weight;
  94252. private _syncRoot;
  94253. /**
  94254. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  94255. * This will only apply for non looping animation (default is true)
  94256. */
  94257. disposeOnEnd: boolean;
  94258. /**
  94259. * Gets a boolean indicating if the animation has started
  94260. */
  94261. animationStarted: boolean;
  94262. /**
  94263. * Observer raised when the animation ends
  94264. */
  94265. onAnimationEndObservable: Observable<Animatable>;
  94266. /**
  94267. * Observer raised when the animation loops
  94268. */
  94269. onAnimationLoopObservable: Observable<Animatable>;
  94270. /**
  94271. * Gets the root Animatable used to synchronize and normalize animations
  94272. */
  94273. get syncRoot(): Nullable<Animatable>;
  94274. /**
  94275. * Gets the current frame of the first RuntimeAnimation
  94276. * Used to synchronize Animatables
  94277. */
  94278. get masterFrame(): number;
  94279. /**
  94280. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  94281. */
  94282. get weight(): number;
  94283. set weight(value: number);
  94284. /**
  94285. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  94286. */
  94287. get speedRatio(): number;
  94288. set speedRatio(value: number);
  94289. /**
  94290. * Creates a new Animatable
  94291. * @param scene defines the hosting scene
  94292. * @param target defines the target object
  94293. * @param fromFrame defines the starting frame number (default is 0)
  94294. * @param toFrame defines the ending frame number (default is 100)
  94295. * @param loopAnimation defines if the animation must loop (default is false)
  94296. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  94297. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  94298. * @param animations defines a group of animation to add to the new Animatable
  94299. * @param onAnimationLoop defines a callback to call when animation loops
  94300. * @param isAdditive defines whether the animation should be evaluated additively
  94301. */
  94302. constructor(scene: Scene,
  94303. /** defines the target object */
  94304. target: any,
  94305. /** defines the starting frame number (default is 0) */
  94306. fromFrame?: number,
  94307. /** defines the ending frame number (default is 100) */
  94308. toFrame?: number,
  94309. /** defines if the animation must loop (default is false) */
  94310. loopAnimation?: boolean, speedRatio?: number,
  94311. /** defines a callback to call when animation ends if it is not looping */
  94312. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  94313. /** defines a callback to call when animation loops */
  94314. onAnimationLoop?: (() => void) | null | undefined,
  94315. /** defines whether the animation should be evaluated additively */
  94316. isAdditive?: boolean);
  94317. /**
  94318. * Synchronize and normalize current Animatable with a source Animatable
  94319. * This is useful when using animation weights and when animations are not of the same length
  94320. * @param root defines the root Animatable to synchronize with
  94321. * @returns the current Animatable
  94322. */
  94323. syncWith(root: Animatable): Animatable;
  94324. /**
  94325. * Gets the list of runtime animations
  94326. * @returns an array of RuntimeAnimation
  94327. */
  94328. getAnimations(): RuntimeAnimation[];
  94329. /**
  94330. * Adds more animations to the current animatable
  94331. * @param target defines the target of the animations
  94332. * @param animations defines the new animations to add
  94333. */
  94334. appendAnimations(target: any, animations: Animation[]): void;
  94335. /**
  94336. * Gets the source animation for a specific property
  94337. * @param property defines the propertyu to look for
  94338. * @returns null or the source animation for the given property
  94339. */
  94340. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  94341. /**
  94342. * Gets the runtime animation for a specific property
  94343. * @param property defines the propertyu to look for
  94344. * @returns null or the runtime animation for the given property
  94345. */
  94346. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  94347. /**
  94348. * Resets the animatable to its original state
  94349. */
  94350. reset(): void;
  94351. /**
  94352. * Allows the animatable to blend with current running animations
  94353. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94354. * @param blendingSpeed defines the blending speed to use
  94355. */
  94356. enableBlending(blendingSpeed: number): void;
  94357. /**
  94358. * Disable animation blending
  94359. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94360. */
  94361. disableBlending(): void;
  94362. /**
  94363. * Jump directly to a given frame
  94364. * @param frame defines the frame to jump to
  94365. */
  94366. goToFrame(frame: number): void;
  94367. /**
  94368. * Pause the animation
  94369. */
  94370. pause(): void;
  94371. /**
  94372. * Restart the animation
  94373. */
  94374. restart(): void;
  94375. private _raiseOnAnimationEnd;
  94376. /**
  94377. * Stop and delete the current animation
  94378. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  94379. * @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)
  94380. */
  94381. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  94382. /**
  94383. * Wait asynchronously for the animation to end
  94384. * @returns a promise which will be fullfilled when the animation ends
  94385. */
  94386. waitAsync(): Promise<Animatable>;
  94387. /** @hidden */
  94388. _animate(delay: number): boolean;
  94389. }
  94390. interface Scene {
  94391. /** @hidden */
  94392. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  94393. /** @hidden */
  94394. _processLateAnimationBindingsForMatrices(holder: {
  94395. totalWeight: number;
  94396. totalAdditiveWeight: number;
  94397. animations: RuntimeAnimation[];
  94398. additiveAnimations: RuntimeAnimation[];
  94399. originalValue: Matrix;
  94400. }): any;
  94401. /** @hidden */
  94402. _processLateAnimationBindingsForQuaternions(holder: {
  94403. totalWeight: number;
  94404. totalAdditiveWeight: number;
  94405. animations: RuntimeAnimation[];
  94406. additiveAnimations: RuntimeAnimation[];
  94407. originalValue: Quaternion;
  94408. }, refQuaternion: Quaternion): Quaternion;
  94409. /** @hidden */
  94410. _processLateAnimationBindings(): void;
  94411. /**
  94412. * Will start the animation sequence of a given target
  94413. * @param target defines the target
  94414. * @param from defines from which frame should animation start
  94415. * @param to defines until which frame should animation run.
  94416. * @param weight defines the weight to apply to the animation (1.0 by default)
  94417. * @param loop defines if the animation loops
  94418. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94419. * @param onAnimationEnd defines the function to be executed when the animation ends
  94420. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94421. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94422. * @param onAnimationLoop defines the callback to call when an animation loops
  94423. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94424. * @returns the animatable object created for this animation
  94425. */
  94426. 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;
  94427. /**
  94428. * Will start the animation sequence of a given target
  94429. * @param target defines the target
  94430. * @param from defines from which frame should animation start
  94431. * @param to defines until which frame should animation run.
  94432. * @param loop defines if the animation loops
  94433. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94434. * @param onAnimationEnd defines the function to be executed when the animation ends
  94435. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94436. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94437. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  94438. * @param onAnimationLoop defines the callback to call when an animation loops
  94439. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94440. * @returns the animatable object created for this animation
  94441. */
  94442. 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;
  94443. /**
  94444. * Will start the animation sequence of a given target and its hierarchy
  94445. * @param target defines the target
  94446. * @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.
  94447. * @param from defines from which frame should animation start
  94448. * @param to defines until which frame should animation run.
  94449. * @param loop defines if the animation loops
  94450. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94451. * @param onAnimationEnd defines the function to be executed when the animation ends
  94452. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94453. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94454. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94455. * @param onAnimationLoop defines the callback to call when an animation loops
  94456. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94457. * @returns the list of created animatables
  94458. */
  94459. 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[];
  94460. /**
  94461. * Begin a new animation on a given node
  94462. * @param target defines the target where the animation will take place
  94463. * @param animations defines the list of animations to start
  94464. * @param from defines the initial value
  94465. * @param to defines the final value
  94466. * @param loop defines if you want animation to loop (off by default)
  94467. * @param speedRatio defines the speed ratio to apply to all animations
  94468. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94469. * @param onAnimationLoop defines the callback to call when an animation loops
  94470. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94471. * @returns the list of created animatables
  94472. */
  94473. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  94474. /**
  94475. * Begin a new animation on a given node and its hierarchy
  94476. * @param target defines the root node where the animation will take place
  94477. * @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.
  94478. * @param animations defines the list of animations to start
  94479. * @param from defines the initial value
  94480. * @param to defines the final value
  94481. * @param loop defines if you want animation to loop (off by default)
  94482. * @param speedRatio defines the speed ratio to apply to all animations
  94483. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94484. * @param onAnimationLoop defines the callback to call when an animation loops
  94485. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94486. * @returns the list of animatables created for all nodes
  94487. */
  94488. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  94489. /**
  94490. * Gets the animatable associated with a specific target
  94491. * @param target defines the target of the animatable
  94492. * @returns the required animatable if found
  94493. */
  94494. getAnimatableByTarget(target: any): Nullable<Animatable>;
  94495. /**
  94496. * Gets all animatables associated with a given target
  94497. * @param target defines the target to look animatables for
  94498. * @returns an array of Animatables
  94499. */
  94500. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  94501. /**
  94502. * Stops and removes all animations that have been applied to the scene
  94503. */
  94504. stopAllAnimations(): void;
  94505. /**
  94506. * Gets the current delta time used by animation engine
  94507. */
  94508. deltaTime: number;
  94509. }
  94510. interface Bone {
  94511. /**
  94512. * Copy an animation range from another bone
  94513. * @param source defines the source bone
  94514. * @param rangeName defines the range name to copy
  94515. * @param frameOffset defines the frame offset
  94516. * @param rescaleAsRequired defines if rescaling must be applied if required
  94517. * @param skelDimensionsRatio defines the scaling ratio
  94518. * @returns true if operation was successful
  94519. */
  94520. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  94521. }
  94522. }
  94523. declare module BABYLON {
  94524. /**
  94525. * Class used to handle skinning animations
  94526. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94527. */
  94528. export class Skeleton implements IAnimatable {
  94529. /** defines the skeleton name */
  94530. name: string;
  94531. /** defines the skeleton Id */
  94532. id: string;
  94533. /**
  94534. * Defines the list of child bones
  94535. */
  94536. bones: Bone[];
  94537. /**
  94538. * Defines an estimate of the dimension of the skeleton at rest
  94539. */
  94540. dimensionsAtRest: Vector3;
  94541. /**
  94542. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  94543. */
  94544. needInitialSkinMatrix: boolean;
  94545. /**
  94546. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  94547. */
  94548. overrideMesh: Nullable<AbstractMesh>;
  94549. /**
  94550. * Gets the list of animations attached to this skeleton
  94551. */
  94552. animations: Array<Animation>;
  94553. private _scene;
  94554. private _isDirty;
  94555. private _transformMatrices;
  94556. private _transformMatrixTexture;
  94557. private _meshesWithPoseMatrix;
  94558. private _animatables;
  94559. private _identity;
  94560. private _synchronizedWithMesh;
  94561. private _ranges;
  94562. private _lastAbsoluteTransformsUpdateId;
  94563. private _canUseTextureForBones;
  94564. private _uniqueId;
  94565. /** @hidden */
  94566. _numBonesWithLinkedTransformNode: number;
  94567. /** @hidden */
  94568. _hasWaitingData: Nullable<boolean>;
  94569. /**
  94570. * Specifies if the skeleton should be serialized
  94571. */
  94572. doNotSerialize: boolean;
  94573. private _useTextureToStoreBoneMatrices;
  94574. /**
  94575. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  94576. * Please note that this option is not available if the hardware does not support it
  94577. */
  94578. get useTextureToStoreBoneMatrices(): boolean;
  94579. set useTextureToStoreBoneMatrices(value: boolean);
  94580. private _animationPropertiesOverride;
  94581. /**
  94582. * Gets or sets the animation properties override
  94583. */
  94584. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94585. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  94586. /**
  94587. * List of inspectable custom properties (used by the Inspector)
  94588. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94589. */
  94590. inspectableCustomProperties: IInspectable[];
  94591. /**
  94592. * An observable triggered before computing the skeleton's matrices
  94593. */
  94594. onBeforeComputeObservable: Observable<Skeleton>;
  94595. /**
  94596. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  94597. */
  94598. get isUsingTextureForMatrices(): boolean;
  94599. /**
  94600. * Gets the unique ID of this skeleton
  94601. */
  94602. get uniqueId(): number;
  94603. /**
  94604. * Creates a new skeleton
  94605. * @param name defines the skeleton name
  94606. * @param id defines the skeleton Id
  94607. * @param scene defines the hosting scene
  94608. */
  94609. constructor(
  94610. /** defines the skeleton name */
  94611. name: string,
  94612. /** defines the skeleton Id */
  94613. id: string, scene: Scene);
  94614. /**
  94615. * Gets the current object class name.
  94616. * @return the class name
  94617. */
  94618. getClassName(): string;
  94619. /**
  94620. * Returns an array containing the root bones
  94621. * @returns an array containing the root bones
  94622. */
  94623. getChildren(): Array<Bone>;
  94624. /**
  94625. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  94626. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94627. * @returns a Float32Array containing matrices data
  94628. */
  94629. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  94630. /**
  94631. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  94632. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94633. * @returns a raw texture containing the data
  94634. */
  94635. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  94636. /**
  94637. * Gets the current hosting scene
  94638. * @returns a scene object
  94639. */
  94640. getScene(): Scene;
  94641. /**
  94642. * Gets a string representing the current skeleton data
  94643. * @param fullDetails defines a boolean indicating if we want a verbose version
  94644. * @returns a string representing the current skeleton data
  94645. */
  94646. toString(fullDetails?: boolean): string;
  94647. /**
  94648. * Get bone's index searching by name
  94649. * @param name defines bone's name to search for
  94650. * @return the indice of the bone. Returns -1 if not found
  94651. */
  94652. getBoneIndexByName(name: string): number;
  94653. /**
  94654. * Creater a new animation range
  94655. * @param name defines the name of the range
  94656. * @param from defines the start key
  94657. * @param to defines the end key
  94658. */
  94659. createAnimationRange(name: string, from: number, to: number): void;
  94660. /**
  94661. * Delete a specific animation range
  94662. * @param name defines the name of the range
  94663. * @param deleteFrames defines if frames must be removed as well
  94664. */
  94665. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94666. /**
  94667. * Gets a specific animation range
  94668. * @param name defines the name of the range to look for
  94669. * @returns the requested animation range or null if not found
  94670. */
  94671. getAnimationRange(name: string): Nullable<AnimationRange>;
  94672. /**
  94673. * Gets the list of all animation ranges defined on this skeleton
  94674. * @returns an array
  94675. */
  94676. getAnimationRanges(): Nullable<AnimationRange>[];
  94677. /**
  94678. * Copy animation range from a source skeleton.
  94679. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  94680. * @param source defines the source skeleton
  94681. * @param name defines the name of the range to copy
  94682. * @param rescaleAsRequired defines if rescaling must be applied if required
  94683. * @returns true if operation was successful
  94684. */
  94685. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  94686. /**
  94687. * Forces the skeleton to go to rest pose
  94688. */
  94689. returnToRest(): void;
  94690. private _getHighestAnimationFrame;
  94691. /**
  94692. * Begin a specific animation range
  94693. * @param name defines the name of the range to start
  94694. * @param loop defines if looping must be turned on (false by default)
  94695. * @param speedRatio defines the speed ratio to apply (1 by default)
  94696. * @param onAnimationEnd defines a callback which will be called when animation will end
  94697. * @returns a new animatable
  94698. */
  94699. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94700. /**
  94701. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  94702. * @param skeleton defines the Skeleton containing the animation range to convert
  94703. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  94704. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  94705. * @returns the original skeleton
  94706. */
  94707. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  94708. /** @hidden */
  94709. _markAsDirty(): void;
  94710. /** @hidden */
  94711. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94712. /** @hidden */
  94713. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94714. private _computeTransformMatrices;
  94715. /**
  94716. * Build all resources required to render a skeleton
  94717. */
  94718. prepare(): void;
  94719. /**
  94720. * Gets the list of animatables currently running for this skeleton
  94721. * @returns an array of animatables
  94722. */
  94723. getAnimatables(): IAnimatable[];
  94724. /**
  94725. * Clone the current skeleton
  94726. * @param name defines the name of the new skeleton
  94727. * @param id defines the id of the new skeleton
  94728. * @returns the new skeleton
  94729. */
  94730. clone(name: string, id?: string): Skeleton;
  94731. /**
  94732. * Enable animation blending for this skeleton
  94733. * @param blendingSpeed defines the blending speed to apply
  94734. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94735. */
  94736. enableBlending(blendingSpeed?: number): void;
  94737. /**
  94738. * Releases all resources associated with the current skeleton
  94739. */
  94740. dispose(): void;
  94741. /**
  94742. * Serialize the skeleton in a JSON object
  94743. * @returns a JSON object
  94744. */
  94745. serialize(): any;
  94746. /**
  94747. * Creates a new skeleton from serialized data
  94748. * @param parsedSkeleton defines the serialized data
  94749. * @param scene defines the hosting scene
  94750. * @returns a new skeleton
  94751. */
  94752. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  94753. /**
  94754. * Compute all node absolute transforms
  94755. * @param forceUpdate defines if computation must be done even if cache is up to date
  94756. */
  94757. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  94758. /**
  94759. * Gets the root pose matrix
  94760. * @returns a matrix
  94761. */
  94762. getPoseMatrix(): Nullable<Matrix>;
  94763. /**
  94764. * Sorts bones per internal index
  94765. */
  94766. sortBones(): void;
  94767. private _sortBones;
  94768. }
  94769. }
  94770. declare module BABYLON {
  94771. /**
  94772. * Creates an instance based on a source mesh.
  94773. */
  94774. export class InstancedMesh extends AbstractMesh {
  94775. private _sourceMesh;
  94776. private _currentLOD;
  94777. /** @hidden */
  94778. _indexInSourceMeshInstanceArray: number;
  94779. constructor(name: string, source: Mesh);
  94780. /**
  94781. * Returns the string "InstancedMesh".
  94782. */
  94783. getClassName(): string;
  94784. /** Gets the list of lights affecting that mesh */
  94785. get lightSources(): Light[];
  94786. _resyncLightSources(): void;
  94787. _resyncLightSource(light: Light): void;
  94788. _removeLightSource(light: Light, dispose: boolean): void;
  94789. /**
  94790. * If the source mesh receives shadows
  94791. */
  94792. get receiveShadows(): boolean;
  94793. /**
  94794. * The material of the source mesh
  94795. */
  94796. get material(): Nullable<Material>;
  94797. /**
  94798. * Visibility of the source mesh
  94799. */
  94800. get visibility(): number;
  94801. /**
  94802. * Skeleton of the source mesh
  94803. */
  94804. get skeleton(): Nullable<Skeleton>;
  94805. /**
  94806. * Rendering ground id of the source mesh
  94807. */
  94808. get renderingGroupId(): number;
  94809. set renderingGroupId(value: number);
  94810. /**
  94811. * Returns the total number of vertices (integer).
  94812. */
  94813. getTotalVertices(): number;
  94814. /**
  94815. * Returns a positive integer : the total number of indices in this mesh geometry.
  94816. * @returns the numner of indices or zero if the mesh has no geometry.
  94817. */
  94818. getTotalIndices(): number;
  94819. /**
  94820. * The source mesh of the instance
  94821. */
  94822. get sourceMesh(): Mesh;
  94823. /**
  94824. * Creates a new InstancedMesh object from the mesh model.
  94825. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  94826. * @param name defines the name of the new instance
  94827. * @returns a new InstancedMesh
  94828. */
  94829. createInstance(name: string): InstancedMesh;
  94830. /**
  94831. * Is this node ready to be used/rendered
  94832. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94833. * @return {boolean} is it ready
  94834. */
  94835. isReady(completeCheck?: boolean): boolean;
  94836. /**
  94837. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94838. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  94839. * @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.
  94840. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  94841. */
  94842. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  94843. /**
  94844. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94845. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94846. * The `data` are either a numeric array either a Float32Array.
  94847. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  94848. * 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).
  94849. * Note that a new underlying VertexBuffer object is created each call.
  94850. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94851. *
  94852. * Possible `kind` values :
  94853. * - VertexBuffer.PositionKind
  94854. * - VertexBuffer.UVKind
  94855. * - VertexBuffer.UV2Kind
  94856. * - VertexBuffer.UV3Kind
  94857. * - VertexBuffer.UV4Kind
  94858. * - VertexBuffer.UV5Kind
  94859. * - VertexBuffer.UV6Kind
  94860. * - VertexBuffer.ColorKind
  94861. * - VertexBuffer.MatricesIndicesKind
  94862. * - VertexBuffer.MatricesIndicesExtraKind
  94863. * - VertexBuffer.MatricesWeightsKind
  94864. * - VertexBuffer.MatricesWeightsExtraKind
  94865. *
  94866. * Returns the Mesh.
  94867. */
  94868. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94869. /**
  94870. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94871. * If the mesh has no geometry, it is simply returned as it is.
  94872. * The `data` are either a numeric array either a Float32Array.
  94873. * No new underlying VertexBuffer object is created.
  94874. * 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.
  94875. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  94876. *
  94877. * Possible `kind` values :
  94878. * - VertexBuffer.PositionKind
  94879. * - VertexBuffer.UVKind
  94880. * - VertexBuffer.UV2Kind
  94881. * - VertexBuffer.UV3Kind
  94882. * - VertexBuffer.UV4Kind
  94883. * - VertexBuffer.UV5Kind
  94884. * - VertexBuffer.UV6Kind
  94885. * - VertexBuffer.ColorKind
  94886. * - VertexBuffer.MatricesIndicesKind
  94887. * - VertexBuffer.MatricesIndicesExtraKind
  94888. * - VertexBuffer.MatricesWeightsKind
  94889. * - VertexBuffer.MatricesWeightsExtraKind
  94890. *
  94891. * Returns the Mesh.
  94892. */
  94893. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  94894. /**
  94895. * Sets the mesh indices.
  94896. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  94897. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94898. * This method creates a new index buffer each call.
  94899. * Returns the Mesh.
  94900. */
  94901. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  94902. /**
  94903. * Boolean : True if the mesh owns the requested kind of data.
  94904. */
  94905. isVerticesDataPresent(kind: string): boolean;
  94906. /**
  94907. * Returns an array of indices (IndicesArray).
  94908. */
  94909. getIndices(): Nullable<IndicesArray>;
  94910. get _positions(): Nullable<Vector3[]>;
  94911. /**
  94912. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94913. * This means the mesh underlying bounding box and sphere are recomputed.
  94914. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94915. * @returns the current mesh
  94916. */
  94917. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  94918. /** @hidden */
  94919. _preActivate(): InstancedMesh;
  94920. /** @hidden */
  94921. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94922. /** @hidden */
  94923. _postActivate(): void;
  94924. getWorldMatrix(): Matrix;
  94925. get isAnInstance(): boolean;
  94926. /**
  94927. * Returns the current associated LOD AbstractMesh.
  94928. */
  94929. getLOD(camera: Camera): AbstractMesh;
  94930. /** @hidden */
  94931. _preActivateForIntermediateRendering(renderId: number): Mesh;
  94932. /** @hidden */
  94933. _syncSubMeshes(): InstancedMesh;
  94934. /** @hidden */
  94935. _generatePointsArray(): boolean;
  94936. /**
  94937. * Creates a new InstancedMesh from the current mesh.
  94938. * - name (string) : the cloned mesh name
  94939. * - newParent (optional Node) : the optional Node to parent the clone to.
  94940. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  94941. *
  94942. * Returns the clone.
  94943. */
  94944. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  94945. /**
  94946. * Disposes the InstancedMesh.
  94947. * Returns nothing.
  94948. */
  94949. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94950. }
  94951. interface Mesh {
  94952. /**
  94953. * Register a custom buffer that will be instanced
  94954. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94955. * @param kind defines the buffer kind
  94956. * @param stride defines the stride in floats
  94957. */
  94958. registerInstancedBuffer(kind: string, stride: number): void;
  94959. /**
  94960. * true to use the edge renderer for all instances of this mesh
  94961. */
  94962. edgesShareWithInstances: boolean;
  94963. /** @hidden */
  94964. _userInstancedBuffersStorage: {
  94965. data: {
  94966. [key: string]: Float32Array;
  94967. };
  94968. sizes: {
  94969. [key: string]: number;
  94970. };
  94971. vertexBuffers: {
  94972. [key: string]: Nullable<VertexBuffer>;
  94973. };
  94974. strides: {
  94975. [key: string]: number;
  94976. };
  94977. };
  94978. }
  94979. interface AbstractMesh {
  94980. /**
  94981. * Object used to store instanced buffers defined by user
  94982. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94983. */
  94984. instancedBuffers: {
  94985. [key: string]: any;
  94986. };
  94987. }
  94988. }
  94989. declare module BABYLON {
  94990. /**
  94991. * Defines the options associated with the creation of a shader material.
  94992. */
  94993. export interface IShaderMaterialOptions {
  94994. /**
  94995. * Does the material work in alpha blend mode
  94996. */
  94997. needAlphaBlending: boolean;
  94998. /**
  94999. * Does the material work in alpha test mode
  95000. */
  95001. needAlphaTesting: boolean;
  95002. /**
  95003. * The list of attribute names used in the shader
  95004. */
  95005. attributes: string[];
  95006. /**
  95007. * The list of unifrom names used in the shader
  95008. */
  95009. uniforms: string[];
  95010. /**
  95011. * The list of UBO names used in the shader
  95012. */
  95013. uniformBuffers: string[];
  95014. /**
  95015. * The list of sampler names used in the shader
  95016. */
  95017. samplers: string[];
  95018. /**
  95019. * The list of defines used in the shader
  95020. */
  95021. defines: string[];
  95022. }
  95023. /**
  95024. * 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.
  95025. *
  95026. * This returned material effects how the mesh will look based on the code in the shaders.
  95027. *
  95028. * @see https://doc.babylonjs.com/how_to/shader_material
  95029. */
  95030. export class ShaderMaterial extends Material {
  95031. private _shaderPath;
  95032. private _options;
  95033. private _textures;
  95034. private _textureArrays;
  95035. private _floats;
  95036. private _ints;
  95037. private _floatsArrays;
  95038. private _colors3;
  95039. private _colors3Arrays;
  95040. private _colors4;
  95041. private _colors4Arrays;
  95042. private _vectors2;
  95043. private _vectors3;
  95044. private _vectors4;
  95045. private _matrices;
  95046. private _matrixArrays;
  95047. private _matrices3x3;
  95048. private _matrices2x2;
  95049. private _vectors2Arrays;
  95050. private _vectors3Arrays;
  95051. private _vectors4Arrays;
  95052. private _cachedWorldViewMatrix;
  95053. private _cachedWorldViewProjectionMatrix;
  95054. private _renderId;
  95055. private _multiview;
  95056. private _cachedDefines;
  95057. /** Define the Url to load snippets */
  95058. static SnippetUrl: string;
  95059. /** Snippet ID if the material was created from the snippet server */
  95060. snippetId: string;
  95061. /**
  95062. * Instantiate a new shader material.
  95063. * 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.
  95064. * This returned material effects how the mesh will look based on the code in the shaders.
  95065. * @see https://doc.babylonjs.com/how_to/shader_material
  95066. * @param name Define the name of the material in the scene
  95067. * @param scene Define the scene the material belongs to
  95068. * @param shaderPath Defines the route to the shader code in one of three ways:
  95069. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  95070. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  95071. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  95072. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  95073. * @param options Define the options used to create the shader
  95074. */
  95075. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  95076. /**
  95077. * Gets the shader path used to define the shader code
  95078. * It can be modified to trigger a new compilation
  95079. */
  95080. get shaderPath(): any;
  95081. /**
  95082. * Sets the shader path used to define the shader code
  95083. * It can be modified to trigger a new compilation
  95084. */
  95085. set shaderPath(shaderPath: any);
  95086. /**
  95087. * Gets the options used to compile the shader.
  95088. * They can be modified to trigger a new compilation
  95089. */
  95090. get options(): IShaderMaterialOptions;
  95091. /**
  95092. * Gets the current class name of the material e.g. "ShaderMaterial"
  95093. * Mainly use in serialization.
  95094. * @returns the class name
  95095. */
  95096. getClassName(): string;
  95097. /**
  95098. * Specifies if the material will require alpha blending
  95099. * @returns a boolean specifying if alpha blending is needed
  95100. */
  95101. needAlphaBlending(): boolean;
  95102. /**
  95103. * Specifies if this material should be rendered in alpha test mode
  95104. * @returns a boolean specifying if an alpha test is needed.
  95105. */
  95106. needAlphaTesting(): boolean;
  95107. private _checkUniform;
  95108. /**
  95109. * Set a texture in the shader.
  95110. * @param name Define the name of the uniform samplers as defined in the shader
  95111. * @param texture Define the texture to bind to this sampler
  95112. * @return the material itself allowing "fluent" like uniform updates
  95113. */
  95114. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  95115. /**
  95116. * Set a texture array in the shader.
  95117. * @param name Define the name of the uniform sampler array as defined in the shader
  95118. * @param textures Define the list of textures to bind to this sampler
  95119. * @return the material itself allowing "fluent" like uniform updates
  95120. */
  95121. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  95122. /**
  95123. * Set a float in the shader.
  95124. * @param name Define the name of the uniform as defined in the shader
  95125. * @param value Define the value to give to the uniform
  95126. * @return the material itself allowing "fluent" like uniform updates
  95127. */
  95128. setFloat(name: string, value: number): ShaderMaterial;
  95129. /**
  95130. * Set a int in the shader.
  95131. * @param name Define the name of the uniform as defined in the shader
  95132. * @param value Define the value to give to the uniform
  95133. * @return the material itself allowing "fluent" like uniform updates
  95134. */
  95135. setInt(name: string, value: number): ShaderMaterial;
  95136. /**
  95137. * Set an array of floats in the shader.
  95138. * @param name Define the name of the uniform as defined in the shader
  95139. * @param value Define the value to give to the uniform
  95140. * @return the material itself allowing "fluent" like uniform updates
  95141. */
  95142. setFloats(name: string, value: number[]): ShaderMaterial;
  95143. /**
  95144. * Set a vec3 in the shader from a Color3.
  95145. * @param name Define the name of the uniform as defined in the shader
  95146. * @param value Define the value to give to the uniform
  95147. * @return the material itself allowing "fluent" like uniform updates
  95148. */
  95149. setColor3(name: string, value: Color3): ShaderMaterial;
  95150. /**
  95151. * Set a vec3 array in the shader from a Color3 array.
  95152. * @param name Define the name of the uniform as defined in the shader
  95153. * @param value Define the value to give to the uniform
  95154. * @return the material itself allowing "fluent" like uniform updates
  95155. */
  95156. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  95157. /**
  95158. * Set a vec4 in the shader from a Color4.
  95159. * @param name Define the name of the uniform as defined in the shader
  95160. * @param value Define the value to give to the uniform
  95161. * @return the material itself allowing "fluent" like uniform updates
  95162. */
  95163. setColor4(name: string, value: Color4): ShaderMaterial;
  95164. /**
  95165. * Set a vec4 array in the shader from a Color4 array.
  95166. * @param name Define the name of the uniform as defined in the shader
  95167. * @param value Define the value to give to the uniform
  95168. * @return the material itself allowing "fluent" like uniform updates
  95169. */
  95170. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  95171. /**
  95172. * Set a vec2 in the shader from a Vector2.
  95173. * @param name Define the name of the uniform as defined in the shader
  95174. * @param value Define the value to give to the uniform
  95175. * @return the material itself allowing "fluent" like uniform updates
  95176. */
  95177. setVector2(name: string, value: Vector2): ShaderMaterial;
  95178. /**
  95179. * Set a vec3 in the shader from a Vector3.
  95180. * @param name Define the name of the uniform as defined in the shader
  95181. * @param value Define the value to give to the uniform
  95182. * @return the material itself allowing "fluent" like uniform updates
  95183. */
  95184. setVector3(name: string, value: Vector3): ShaderMaterial;
  95185. /**
  95186. * Set a vec4 in the shader from a Vector4.
  95187. * @param name Define the name of the uniform as defined in the shader
  95188. * @param value Define the value to give to the uniform
  95189. * @return the material itself allowing "fluent" like uniform updates
  95190. */
  95191. setVector4(name: string, value: Vector4): ShaderMaterial;
  95192. /**
  95193. * Set a mat4 in the shader from a Matrix.
  95194. * @param name Define the name of the uniform as defined in the shader
  95195. * @param value Define the value to give to the uniform
  95196. * @return the material itself allowing "fluent" like uniform updates
  95197. */
  95198. setMatrix(name: string, value: Matrix): ShaderMaterial;
  95199. /**
  95200. * Set a float32Array in the shader from a matrix array.
  95201. * @param name Define the name of the uniform as defined in the shader
  95202. * @param value Define the value to give to the uniform
  95203. * @return the material itself allowing "fluent" like uniform updates
  95204. */
  95205. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  95206. /**
  95207. * Set a mat3 in the shader from a Float32Array.
  95208. * @param name Define the name of the uniform as defined in the shader
  95209. * @param value Define the value to give to the uniform
  95210. * @return the material itself allowing "fluent" like uniform updates
  95211. */
  95212. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95213. /**
  95214. * Set a mat2 in the shader from a Float32Array.
  95215. * @param name Define the name of the uniform as defined in the shader
  95216. * @param value Define the value to give to the uniform
  95217. * @return the material itself allowing "fluent" like uniform updates
  95218. */
  95219. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95220. /**
  95221. * Set a vec2 array in the shader from a number array.
  95222. * @param name Define the name of the uniform as defined in the shader
  95223. * @param value Define the value to give to the uniform
  95224. * @return the material itself allowing "fluent" like uniform updates
  95225. */
  95226. setArray2(name: string, value: number[]): ShaderMaterial;
  95227. /**
  95228. * Set a vec3 array in the shader from a number array.
  95229. * @param name Define the name of the uniform as defined in the shader
  95230. * @param value Define the value to give to the uniform
  95231. * @return the material itself allowing "fluent" like uniform updates
  95232. */
  95233. setArray3(name: string, value: number[]): ShaderMaterial;
  95234. /**
  95235. * Set a vec4 array in the shader from a number array.
  95236. * @param name Define the name of the uniform as defined in the shader
  95237. * @param value Define the value to give to the uniform
  95238. * @return the material itself allowing "fluent" like uniform updates
  95239. */
  95240. setArray4(name: string, value: number[]): ShaderMaterial;
  95241. private _checkCache;
  95242. /**
  95243. * Specifies that the submesh is ready to be used
  95244. * @param mesh defines the mesh to check
  95245. * @param subMesh defines which submesh to check
  95246. * @param useInstances specifies that instances should be used
  95247. * @returns a boolean indicating that the submesh is ready or not
  95248. */
  95249. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95250. /**
  95251. * Checks if the material is ready to render the requested mesh
  95252. * @param mesh Define the mesh to render
  95253. * @param useInstances Define whether or not the material is used with instances
  95254. * @returns true if ready, otherwise false
  95255. */
  95256. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95257. /**
  95258. * Binds the world matrix to the material
  95259. * @param world defines the world transformation matrix
  95260. * @param effectOverride - If provided, use this effect instead of internal effect
  95261. */
  95262. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  95263. /**
  95264. * Binds the submesh to this material by preparing the effect and shader to draw
  95265. * @param world defines the world transformation matrix
  95266. * @param mesh defines the mesh containing the submesh
  95267. * @param subMesh defines the submesh to bind the material to
  95268. */
  95269. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95270. /**
  95271. * Binds the material to the mesh
  95272. * @param world defines the world transformation matrix
  95273. * @param mesh defines the mesh to bind the material to
  95274. * @param effectOverride - If provided, use this effect instead of internal effect
  95275. */
  95276. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  95277. protected _afterBind(mesh?: Mesh): void;
  95278. /**
  95279. * Gets the active textures from the material
  95280. * @returns an array of textures
  95281. */
  95282. getActiveTextures(): BaseTexture[];
  95283. /**
  95284. * Specifies if the material uses a texture
  95285. * @param texture defines the texture to check against the material
  95286. * @returns a boolean specifying if the material uses the texture
  95287. */
  95288. hasTexture(texture: BaseTexture): boolean;
  95289. /**
  95290. * Makes a duplicate of the material, and gives it a new name
  95291. * @param name defines the new name for the duplicated material
  95292. * @returns the cloned material
  95293. */
  95294. clone(name: string): ShaderMaterial;
  95295. /**
  95296. * Disposes the material
  95297. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95298. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95299. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  95300. */
  95301. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  95302. /**
  95303. * Serializes this material in a JSON representation
  95304. * @returns the serialized material object
  95305. */
  95306. serialize(): any;
  95307. /**
  95308. * Creates a shader material from parsed shader material data
  95309. * @param source defines the JSON represnetation of the material
  95310. * @param scene defines the hosting scene
  95311. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95312. * @returns a new material
  95313. */
  95314. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  95315. /**
  95316. * Creates a new ShaderMaterial from a snippet saved in a remote file
  95317. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  95318. * @param url defines the url to load from
  95319. * @param scene defines the hosting scene
  95320. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95321. * @returns a promise that will resolve to the new ShaderMaterial
  95322. */
  95323. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  95324. /**
  95325. * Creates a ShaderMaterial from a snippet saved by the Inspector
  95326. * @param snippetId defines the snippet to load
  95327. * @param scene defines the hosting scene
  95328. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95329. * @returns a promise that will resolve to the new ShaderMaterial
  95330. */
  95331. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  95332. }
  95333. }
  95334. declare module BABYLON {
  95335. /** @hidden */
  95336. export var colorPixelShader: {
  95337. name: string;
  95338. shader: string;
  95339. };
  95340. }
  95341. declare module BABYLON {
  95342. /** @hidden */
  95343. export var colorVertexShader: {
  95344. name: string;
  95345. shader: string;
  95346. };
  95347. }
  95348. declare module BABYLON {
  95349. /**
  95350. * Line mesh
  95351. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  95352. */
  95353. export class LinesMesh extends Mesh {
  95354. /**
  95355. * If vertex color should be applied to the mesh
  95356. */
  95357. readonly useVertexColor?: boolean | undefined;
  95358. /**
  95359. * If vertex alpha should be applied to the mesh
  95360. */
  95361. readonly useVertexAlpha?: boolean | undefined;
  95362. /**
  95363. * Color of the line (Default: White)
  95364. */
  95365. color: Color3;
  95366. /**
  95367. * Alpha of the line (Default: 1)
  95368. */
  95369. alpha: number;
  95370. /**
  95371. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  95372. * This margin is expressed in world space coordinates, so its value may vary.
  95373. * Default value is 0.1
  95374. */
  95375. intersectionThreshold: number;
  95376. private _colorShader;
  95377. private color4;
  95378. /**
  95379. * Creates a new LinesMesh
  95380. * @param name defines the name
  95381. * @param scene defines the hosting scene
  95382. * @param parent defines the parent mesh if any
  95383. * @param source defines the optional source LinesMesh used to clone data from
  95384. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  95385. * When false, achieved by calling a clone(), also passing False.
  95386. * This will make creation of children, recursive.
  95387. * @param useVertexColor defines if this LinesMesh supports vertex color
  95388. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  95389. */
  95390. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  95391. /**
  95392. * If vertex color should be applied to the mesh
  95393. */
  95394. useVertexColor?: boolean | undefined,
  95395. /**
  95396. * If vertex alpha should be applied to the mesh
  95397. */
  95398. useVertexAlpha?: boolean | undefined);
  95399. private _addClipPlaneDefine;
  95400. private _removeClipPlaneDefine;
  95401. isReady(): boolean;
  95402. /**
  95403. * Returns the string "LineMesh"
  95404. */
  95405. getClassName(): string;
  95406. /**
  95407. * @hidden
  95408. */
  95409. get material(): Material;
  95410. /**
  95411. * @hidden
  95412. */
  95413. set material(value: Material);
  95414. /**
  95415. * @hidden
  95416. */
  95417. get checkCollisions(): boolean;
  95418. /** @hidden */
  95419. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95420. /** @hidden */
  95421. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95422. /**
  95423. * Disposes of the line mesh
  95424. * @param doNotRecurse If children should be disposed
  95425. */
  95426. dispose(doNotRecurse?: boolean): void;
  95427. /**
  95428. * Returns a new LineMesh object cloned from the current one.
  95429. */
  95430. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  95431. /**
  95432. * Creates a new InstancedLinesMesh object from the mesh model.
  95433. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  95434. * @param name defines the name of the new instance
  95435. * @returns a new InstancedLinesMesh
  95436. */
  95437. createInstance(name: string): InstancedLinesMesh;
  95438. }
  95439. /**
  95440. * Creates an instance based on a source LinesMesh
  95441. */
  95442. export class InstancedLinesMesh extends InstancedMesh {
  95443. /**
  95444. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  95445. * This margin is expressed in world space coordinates, so its value may vary.
  95446. * Initilized with the intersectionThreshold value of the source LinesMesh
  95447. */
  95448. intersectionThreshold: number;
  95449. constructor(name: string, source: LinesMesh);
  95450. /**
  95451. * Returns the string "InstancedLinesMesh".
  95452. */
  95453. getClassName(): string;
  95454. }
  95455. }
  95456. declare module BABYLON {
  95457. /** @hidden */
  95458. export var linePixelShader: {
  95459. name: string;
  95460. shader: string;
  95461. };
  95462. }
  95463. declare module BABYLON {
  95464. /** @hidden */
  95465. export var lineVertexShader: {
  95466. name: string;
  95467. shader: string;
  95468. };
  95469. }
  95470. declare module BABYLON {
  95471. interface Scene {
  95472. /** @hidden */
  95473. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  95474. }
  95475. interface AbstractMesh {
  95476. /**
  95477. * Gets the edgesRenderer associated with the mesh
  95478. */
  95479. edgesRenderer: Nullable<EdgesRenderer>;
  95480. }
  95481. interface LinesMesh {
  95482. /**
  95483. * Enables the edge rendering mode on the mesh.
  95484. * This mode makes the mesh edges visible
  95485. * @param epsilon defines the maximal distance between two angles to detect a face
  95486. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95487. * @returns the currentAbstractMesh
  95488. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95489. */
  95490. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  95491. }
  95492. interface InstancedLinesMesh {
  95493. /**
  95494. * Enables the edge rendering mode on the mesh.
  95495. * This mode makes the mesh edges visible
  95496. * @param epsilon defines the maximal distance between two angles to detect a face
  95497. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95498. * @returns the current InstancedLinesMesh
  95499. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95500. */
  95501. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  95502. }
  95503. /**
  95504. * Defines the minimum contract an Edges renderer should follow.
  95505. */
  95506. export interface IEdgesRenderer extends IDisposable {
  95507. /**
  95508. * Gets or sets a boolean indicating if the edgesRenderer is active
  95509. */
  95510. isEnabled: boolean;
  95511. /**
  95512. * Renders the edges of the attached mesh,
  95513. */
  95514. render(): void;
  95515. /**
  95516. * Checks wether or not the edges renderer is ready to render.
  95517. * @return true if ready, otherwise false.
  95518. */
  95519. isReady(): boolean;
  95520. /**
  95521. * List of instances to render in case the source mesh has instances
  95522. */
  95523. customInstances: SmartArray<Matrix>;
  95524. }
  95525. /**
  95526. * Defines the additional options of the edges renderer
  95527. */
  95528. export interface IEdgesRendererOptions {
  95529. /**
  95530. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  95531. * If not defined, the default value is true
  95532. */
  95533. useAlternateEdgeFinder?: boolean;
  95534. /**
  95535. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  95536. * If not defined, the default value is true.
  95537. * 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)
  95538. * This option is used only if useAlternateEdgeFinder = true
  95539. */
  95540. useFastVertexMerger?: boolean;
  95541. /**
  95542. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  95543. * The default value is 1e-6
  95544. * This option is used only if useAlternateEdgeFinder = true
  95545. */
  95546. epsilonVertexMerge?: number;
  95547. /**
  95548. * 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
  95549. * 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.
  95550. * This option is used only if useAlternateEdgeFinder = true
  95551. */
  95552. applyTessellation?: boolean;
  95553. /**
  95554. * 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
  95555. * The default value is 1e-6
  95556. * This option is used only if useAlternateEdgeFinder = true
  95557. */
  95558. epsilonVertexAligned?: number;
  95559. }
  95560. /**
  95561. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  95562. */
  95563. export class EdgesRenderer implements IEdgesRenderer {
  95564. /**
  95565. * Define the size of the edges with an orthographic camera
  95566. */
  95567. edgesWidthScalerForOrthographic: number;
  95568. /**
  95569. * Define the size of the edges with a perspective camera
  95570. */
  95571. edgesWidthScalerForPerspective: number;
  95572. protected _source: AbstractMesh;
  95573. protected _linesPositions: number[];
  95574. protected _linesNormals: number[];
  95575. protected _linesIndices: number[];
  95576. protected _epsilon: number;
  95577. protected _indicesCount: number;
  95578. protected _lineShader: ShaderMaterial;
  95579. protected _ib: DataBuffer;
  95580. protected _buffers: {
  95581. [key: string]: Nullable<VertexBuffer>;
  95582. };
  95583. protected _buffersForInstances: {
  95584. [key: string]: Nullable<VertexBuffer>;
  95585. };
  95586. protected _checkVerticesInsteadOfIndices: boolean;
  95587. protected _options: Nullable<IEdgesRendererOptions>;
  95588. private _meshRebuildObserver;
  95589. private _meshDisposeObserver;
  95590. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  95591. isEnabled: boolean;
  95592. /**
  95593. * List of instances to render in case the source mesh has instances
  95594. */
  95595. customInstances: SmartArray<Matrix>;
  95596. private static GetShader;
  95597. /**
  95598. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  95599. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  95600. * @param source Mesh used to create edges
  95601. * @param epsilon sum of angles in adjacency to check for edge
  95602. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  95603. * @param generateEdgesLines - should generate Lines or only prepare resources.
  95604. * @param options The options to apply when generating the edges
  95605. */
  95606. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  95607. protected _prepareRessources(): void;
  95608. /** @hidden */
  95609. _rebuild(): void;
  95610. /**
  95611. * Releases the required resources for the edges renderer
  95612. */
  95613. dispose(): void;
  95614. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  95615. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  95616. /**
  95617. * Checks if the pair of p0 and p1 is en edge
  95618. * @param faceIndex
  95619. * @param edge
  95620. * @param faceNormals
  95621. * @param p0
  95622. * @param p1
  95623. * @private
  95624. */
  95625. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  95626. /**
  95627. * push line into the position, normal and index buffer
  95628. * @protected
  95629. */
  95630. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  95631. /**
  95632. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  95633. */
  95634. private _tessellateTriangle;
  95635. private _generateEdgesLinesAlternate;
  95636. /**
  95637. * Generates lines edges from adjacencjes
  95638. * @private
  95639. */
  95640. _generateEdgesLines(): void;
  95641. /**
  95642. * Checks wether or not the edges renderer is ready to render.
  95643. * @return true if ready, otherwise false.
  95644. */
  95645. isReady(): boolean;
  95646. /**
  95647. * Renders the edges of the attached mesh,
  95648. */
  95649. render(): void;
  95650. }
  95651. /**
  95652. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  95653. */
  95654. export class LineEdgesRenderer extends EdgesRenderer {
  95655. /**
  95656. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  95657. * @param source LineMesh used to generate edges
  95658. * @param epsilon not important (specified angle for edge detection)
  95659. * @param checkVerticesInsteadOfIndices not important for LineMesh
  95660. */
  95661. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  95662. /**
  95663. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  95664. */
  95665. _generateEdgesLines(): void;
  95666. }
  95667. }
  95668. declare module BABYLON {
  95669. /**
  95670. * This represents the object necessary to create a rendering group.
  95671. * This is exclusively used and created by the rendering manager.
  95672. * To modify the behavior, you use the available helpers in your scene or meshes.
  95673. * @hidden
  95674. */
  95675. export class RenderingGroup {
  95676. index: number;
  95677. private static _zeroVector;
  95678. private _scene;
  95679. private _opaqueSubMeshes;
  95680. private _transparentSubMeshes;
  95681. private _alphaTestSubMeshes;
  95682. private _depthOnlySubMeshes;
  95683. private _particleSystems;
  95684. private _spriteManagers;
  95685. private _opaqueSortCompareFn;
  95686. private _alphaTestSortCompareFn;
  95687. private _transparentSortCompareFn;
  95688. private _renderOpaque;
  95689. private _renderAlphaTest;
  95690. private _renderTransparent;
  95691. /** @hidden */
  95692. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  95693. onBeforeTransparentRendering: () => void;
  95694. /**
  95695. * Set the opaque sort comparison function.
  95696. * If null the sub meshes will be render in the order they were created
  95697. */
  95698. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95699. /**
  95700. * Set the alpha test sort comparison function.
  95701. * If null the sub meshes will be render in the order they were created
  95702. */
  95703. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95704. /**
  95705. * Set the transparent sort comparison function.
  95706. * If null the sub meshes will be render in the order they were created
  95707. */
  95708. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95709. /**
  95710. * Creates a new rendering group.
  95711. * @param index The rendering group index
  95712. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  95713. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  95714. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  95715. */
  95716. 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>);
  95717. /**
  95718. * Render all the sub meshes contained in the group.
  95719. * @param customRenderFunction Used to override the default render behaviour of the group.
  95720. * @returns true if rendered some submeshes.
  95721. */
  95722. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  95723. /**
  95724. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  95725. * @param subMeshes The submeshes to render
  95726. */
  95727. private renderOpaqueSorted;
  95728. /**
  95729. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  95730. * @param subMeshes The submeshes to render
  95731. */
  95732. private renderAlphaTestSorted;
  95733. /**
  95734. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  95735. * @param subMeshes The submeshes to render
  95736. */
  95737. private renderTransparentSorted;
  95738. /**
  95739. * Renders the submeshes in a specified order.
  95740. * @param subMeshes The submeshes to sort before render
  95741. * @param sortCompareFn The comparison function use to sort
  95742. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  95743. * @param transparent Specifies to activate blending if true
  95744. */
  95745. private static renderSorted;
  95746. /**
  95747. * Renders the submeshes in the order they were dispatched (no sort applied).
  95748. * @param subMeshes The submeshes to render
  95749. */
  95750. private static renderUnsorted;
  95751. /**
  95752. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95753. * are rendered back to front if in the same alpha index.
  95754. *
  95755. * @param a The first submesh
  95756. * @param b The second submesh
  95757. * @returns The result of the comparison
  95758. */
  95759. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  95760. /**
  95761. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95762. * are rendered back to front.
  95763. *
  95764. * @param a The first submesh
  95765. * @param b The second submesh
  95766. * @returns The result of the comparison
  95767. */
  95768. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  95769. /**
  95770. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95771. * are rendered front to back (prevent overdraw).
  95772. *
  95773. * @param a The first submesh
  95774. * @param b The second submesh
  95775. * @returns The result of the comparison
  95776. */
  95777. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  95778. /**
  95779. * Resets the different lists of submeshes to prepare a new frame.
  95780. */
  95781. prepare(): void;
  95782. dispose(): void;
  95783. /**
  95784. * Inserts the submesh in its correct queue depending on its material.
  95785. * @param subMesh The submesh to dispatch
  95786. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95787. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95788. */
  95789. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95790. dispatchSprites(spriteManager: ISpriteManager): void;
  95791. dispatchParticles(particleSystem: IParticleSystem): void;
  95792. private _renderParticles;
  95793. private _renderSprites;
  95794. }
  95795. }
  95796. declare module BABYLON {
  95797. /**
  95798. * Interface describing the different options available in the rendering manager
  95799. * regarding Auto Clear between groups.
  95800. */
  95801. export interface IRenderingManagerAutoClearSetup {
  95802. /**
  95803. * Defines whether or not autoclear is enable.
  95804. */
  95805. autoClear: boolean;
  95806. /**
  95807. * Defines whether or not to autoclear the depth buffer.
  95808. */
  95809. depth: boolean;
  95810. /**
  95811. * Defines whether or not to autoclear the stencil buffer.
  95812. */
  95813. stencil: boolean;
  95814. }
  95815. /**
  95816. * This class is used by the onRenderingGroupObservable
  95817. */
  95818. export class RenderingGroupInfo {
  95819. /**
  95820. * The Scene that being rendered
  95821. */
  95822. scene: Scene;
  95823. /**
  95824. * The camera currently used for the rendering pass
  95825. */
  95826. camera: Nullable<Camera>;
  95827. /**
  95828. * The ID of the renderingGroup being processed
  95829. */
  95830. renderingGroupId: number;
  95831. }
  95832. /**
  95833. * This is the manager responsible of all the rendering for meshes sprites and particles.
  95834. * It is enable to manage the different groups as well as the different necessary sort functions.
  95835. * This should not be used directly aside of the few static configurations
  95836. */
  95837. export class RenderingManager {
  95838. /**
  95839. * The max id used for rendering groups (not included)
  95840. */
  95841. static MAX_RENDERINGGROUPS: number;
  95842. /**
  95843. * The min id used for rendering groups (included)
  95844. */
  95845. static MIN_RENDERINGGROUPS: number;
  95846. /**
  95847. * Used to globally prevent autoclearing scenes.
  95848. */
  95849. static AUTOCLEAR: boolean;
  95850. /**
  95851. * @hidden
  95852. */
  95853. _useSceneAutoClearSetup: boolean;
  95854. private _scene;
  95855. private _renderingGroups;
  95856. private _depthStencilBufferAlreadyCleaned;
  95857. private _autoClearDepthStencil;
  95858. private _customOpaqueSortCompareFn;
  95859. private _customAlphaTestSortCompareFn;
  95860. private _customTransparentSortCompareFn;
  95861. private _renderingGroupInfo;
  95862. /**
  95863. * Instantiates a new rendering group for a particular scene
  95864. * @param scene Defines the scene the groups belongs to
  95865. */
  95866. constructor(scene: Scene);
  95867. private _clearDepthStencilBuffer;
  95868. /**
  95869. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  95870. * @hidden
  95871. */
  95872. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  95873. /**
  95874. * Resets the different information of the group to prepare a new frame
  95875. * @hidden
  95876. */
  95877. reset(): void;
  95878. /**
  95879. * Dispose and release the group and its associated resources.
  95880. * @hidden
  95881. */
  95882. dispose(): void;
  95883. /**
  95884. * Clear the info related to rendering groups preventing retention points during dispose.
  95885. */
  95886. freeRenderingGroups(): void;
  95887. private _prepareRenderingGroup;
  95888. /**
  95889. * Add a sprite manager to the rendering manager in order to render it this frame.
  95890. * @param spriteManager Define the sprite manager to render
  95891. */
  95892. dispatchSprites(spriteManager: ISpriteManager): void;
  95893. /**
  95894. * Add a particle system to the rendering manager in order to render it this frame.
  95895. * @param particleSystem Define the particle system to render
  95896. */
  95897. dispatchParticles(particleSystem: IParticleSystem): void;
  95898. /**
  95899. * Add a submesh to the manager in order to render it this frame
  95900. * @param subMesh The submesh to dispatch
  95901. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95902. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95903. */
  95904. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95905. /**
  95906. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  95907. * This allowed control for front to back rendering or reversly depending of the special needs.
  95908. *
  95909. * @param renderingGroupId The rendering group id corresponding to its index
  95910. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  95911. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  95912. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  95913. */
  95914. 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;
  95915. /**
  95916. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  95917. *
  95918. * @param renderingGroupId The rendering group id corresponding to its index
  95919. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  95920. * @param depth Automatically clears depth between groups if true and autoClear is true.
  95921. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  95922. */
  95923. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  95924. /**
  95925. * Gets the current auto clear configuration for one rendering group of the rendering
  95926. * manager.
  95927. * @param index the rendering group index to get the information for
  95928. * @returns The auto clear setup for the requested rendering group
  95929. */
  95930. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  95931. }
  95932. }
  95933. declare module BABYLON {
  95934. /**
  95935. * Defines the options associated with the creation of a custom shader for a shadow generator.
  95936. */
  95937. export interface ICustomShaderOptions {
  95938. /**
  95939. * Gets or sets the custom shader name to use
  95940. */
  95941. shaderName: string;
  95942. /**
  95943. * The list of attribute names used in the shader
  95944. */
  95945. attributes?: string[];
  95946. /**
  95947. * The list of unifrom names used in the shader
  95948. */
  95949. uniforms?: string[];
  95950. /**
  95951. * The list of sampler names used in the shader
  95952. */
  95953. samplers?: string[];
  95954. /**
  95955. * The list of defines used in the shader
  95956. */
  95957. defines?: string[];
  95958. }
  95959. /**
  95960. * Interface to implement to create a shadow generator compatible with BJS.
  95961. */
  95962. export interface IShadowGenerator {
  95963. /**
  95964. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95965. * @returns The render target texture if present otherwise, null
  95966. */
  95967. getShadowMap(): Nullable<RenderTargetTexture>;
  95968. /**
  95969. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95970. * @param subMesh The submesh we want to render in the shadow map
  95971. * @param useInstances Defines wether will draw in the map using instances
  95972. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95973. * @returns true if ready otherwise, false
  95974. */
  95975. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95976. /**
  95977. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95978. * @param defines Defines of the material we want to update
  95979. * @param lightIndex Index of the light in the enabled light list of the material
  95980. */
  95981. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  95982. /**
  95983. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95984. * defined in the generator but impacting the effect).
  95985. * It implies the unifroms available on the materials are the standard BJS ones.
  95986. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95987. * @param effect The effect we are binfing the information for
  95988. */
  95989. bindShadowLight(lightIndex: string, effect: Effect): void;
  95990. /**
  95991. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95992. * (eq to shadow prjection matrix * light transform matrix)
  95993. * @returns The transform matrix used to create the shadow map
  95994. */
  95995. getTransformMatrix(): Matrix;
  95996. /**
  95997. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95998. * Cube and 2D textures for instance.
  95999. */
  96000. recreateShadowMap(): void;
  96001. /**
  96002. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96003. * @param onCompiled Callback triggered at the and of the effects compilation
  96004. * @param options Sets of optional options forcing the compilation with different modes
  96005. */
  96006. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  96007. useInstances: boolean;
  96008. }>): void;
  96009. /**
  96010. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96011. * @param options Sets of optional options forcing the compilation with different modes
  96012. * @returns A promise that resolves when the compilation completes
  96013. */
  96014. forceCompilationAsync(options?: Partial<{
  96015. useInstances: boolean;
  96016. }>): Promise<void>;
  96017. /**
  96018. * Serializes the shadow generator setup to a json object.
  96019. * @returns The serialized JSON object
  96020. */
  96021. serialize(): any;
  96022. /**
  96023. * Disposes the Shadow map and related Textures and effects.
  96024. */
  96025. dispose(): void;
  96026. }
  96027. /**
  96028. * Default implementation IShadowGenerator.
  96029. * This is the main object responsible of generating shadows in the framework.
  96030. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  96031. */
  96032. export class ShadowGenerator implements IShadowGenerator {
  96033. /**
  96034. * Name of the shadow generator class
  96035. */
  96036. static CLASSNAME: string;
  96037. /**
  96038. * Shadow generator mode None: no filtering applied.
  96039. */
  96040. static readonly FILTER_NONE: number;
  96041. /**
  96042. * Shadow generator mode ESM: Exponential Shadow Mapping.
  96043. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96044. */
  96045. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  96046. /**
  96047. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  96048. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  96049. */
  96050. static readonly FILTER_POISSONSAMPLING: number;
  96051. /**
  96052. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  96053. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96054. */
  96055. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  96056. /**
  96057. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  96058. * edge artifacts on steep falloff.
  96059. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96060. */
  96061. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  96062. /**
  96063. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  96064. * edge artifacts on steep falloff.
  96065. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96066. */
  96067. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  96068. /**
  96069. * Shadow generator mode PCF: Percentage Closer Filtering
  96070. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  96071. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  96072. */
  96073. static readonly FILTER_PCF: number;
  96074. /**
  96075. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  96076. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  96077. * Contact Hardening
  96078. */
  96079. static readonly FILTER_PCSS: number;
  96080. /**
  96081. * Reserved for PCF and PCSS
  96082. * Highest Quality.
  96083. *
  96084. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  96085. *
  96086. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  96087. */
  96088. static readonly QUALITY_HIGH: number;
  96089. /**
  96090. * Reserved for PCF and PCSS
  96091. * Good tradeoff for quality/perf cross devices
  96092. *
  96093. * Execute PCF on a 3*3 kernel.
  96094. *
  96095. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  96096. */
  96097. static readonly QUALITY_MEDIUM: number;
  96098. /**
  96099. * Reserved for PCF and PCSS
  96100. * The lowest quality but the fastest.
  96101. *
  96102. * Execute PCF on a 1*1 kernel.
  96103. *
  96104. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  96105. */
  96106. static readonly QUALITY_LOW: number;
  96107. /** Gets or sets the custom shader name to use */
  96108. customShaderOptions: ICustomShaderOptions;
  96109. /**
  96110. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  96111. */
  96112. onBeforeShadowMapRenderObservable: Observable<Effect>;
  96113. /**
  96114. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  96115. */
  96116. onAfterShadowMapRenderObservable: Observable<Effect>;
  96117. /**
  96118. * Observable triggered before a mesh is rendered in the shadow map.
  96119. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  96120. */
  96121. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  96122. /**
  96123. * Observable triggered after a mesh is rendered in the shadow map.
  96124. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  96125. */
  96126. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  96127. protected _bias: number;
  96128. /**
  96129. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  96130. */
  96131. get bias(): number;
  96132. /**
  96133. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  96134. */
  96135. set bias(bias: number);
  96136. protected _normalBias: number;
  96137. /**
  96138. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  96139. */
  96140. get normalBias(): number;
  96141. /**
  96142. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  96143. */
  96144. set normalBias(normalBias: number);
  96145. protected _blurBoxOffset: number;
  96146. /**
  96147. * Gets the blur box offset: offset applied during the blur pass.
  96148. * Only useful if useKernelBlur = false
  96149. */
  96150. get blurBoxOffset(): number;
  96151. /**
  96152. * Sets the blur box offset: offset applied during the blur pass.
  96153. * Only useful if useKernelBlur = false
  96154. */
  96155. set blurBoxOffset(value: number);
  96156. protected _blurScale: number;
  96157. /**
  96158. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  96159. * 2 means half of the size.
  96160. */
  96161. get blurScale(): number;
  96162. /**
  96163. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  96164. * 2 means half of the size.
  96165. */
  96166. set blurScale(value: number);
  96167. protected _blurKernel: number;
  96168. /**
  96169. * Gets the blur kernel: kernel size of the blur pass.
  96170. * Only useful if useKernelBlur = true
  96171. */
  96172. get blurKernel(): number;
  96173. /**
  96174. * Sets the blur kernel: kernel size of the blur pass.
  96175. * Only useful if useKernelBlur = true
  96176. */
  96177. set blurKernel(value: number);
  96178. protected _useKernelBlur: boolean;
  96179. /**
  96180. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  96181. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96182. */
  96183. get useKernelBlur(): boolean;
  96184. /**
  96185. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  96186. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96187. */
  96188. set useKernelBlur(value: boolean);
  96189. protected _depthScale: number;
  96190. /**
  96191. * Gets the depth scale used in ESM mode.
  96192. */
  96193. get depthScale(): number;
  96194. /**
  96195. * Sets the depth scale used in ESM mode.
  96196. * This can override the scale stored on the light.
  96197. */
  96198. set depthScale(value: number);
  96199. protected _validateFilter(filter: number): number;
  96200. protected _filter: number;
  96201. /**
  96202. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  96203. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  96204. */
  96205. get filter(): number;
  96206. /**
  96207. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  96208. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  96209. */
  96210. set filter(value: number);
  96211. /**
  96212. * Gets if the current filter is set to Poisson Sampling.
  96213. */
  96214. get usePoissonSampling(): boolean;
  96215. /**
  96216. * Sets the current filter to Poisson Sampling.
  96217. */
  96218. set usePoissonSampling(value: boolean);
  96219. /**
  96220. * Gets if the current filter is set to ESM.
  96221. */
  96222. get useExponentialShadowMap(): boolean;
  96223. /**
  96224. * Sets the current filter is to ESM.
  96225. */
  96226. set useExponentialShadowMap(value: boolean);
  96227. /**
  96228. * Gets if the current filter is set to filtered ESM.
  96229. */
  96230. get useBlurExponentialShadowMap(): boolean;
  96231. /**
  96232. * Gets if the current filter is set to filtered ESM.
  96233. */
  96234. set useBlurExponentialShadowMap(value: boolean);
  96235. /**
  96236. * Gets if the current filter is set to "close ESM" (using the inverse of the
  96237. * exponential to prevent steep falloff artifacts).
  96238. */
  96239. get useCloseExponentialShadowMap(): boolean;
  96240. /**
  96241. * Sets the current filter to "close ESM" (using the inverse of the
  96242. * exponential to prevent steep falloff artifacts).
  96243. */
  96244. set useCloseExponentialShadowMap(value: boolean);
  96245. /**
  96246. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  96247. * exponential to prevent steep falloff artifacts).
  96248. */
  96249. get useBlurCloseExponentialShadowMap(): boolean;
  96250. /**
  96251. * Sets the current filter to filtered "close ESM" (using the inverse of the
  96252. * exponential to prevent steep falloff artifacts).
  96253. */
  96254. set useBlurCloseExponentialShadowMap(value: boolean);
  96255. /**
  96256. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  96257. */
  96258. get usePercentageCloserFiltering(): boolean;
  96259. /**
  96260. * Sets the current filter to "PCF" (percentage closer filtering).
  96261. */
  96262. set usePercentageCloserFiltering(value: boolean);
  96263. protected _filteringQuality: number;
  96264. /**
  96265. * Gets the PCF or PCSS Quality.
  96266. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  96267. */
  96268. get filteringQuality(): number;
  96269. /**
  96270. * Sets the PCF or PCSS Quality.
  96271. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  96272. */
  96273. set filteringQuality(filteringQuality: number);
  96274. /**
  96275. * Gets if the current filter is set to "PCSS" (contact hardening).
  96276. */
  96277. get useContactHardeningShadow(): boolean;
  96278. /**
  96279. * Sets the current filter to "PCSS" (contact hardening).
  96280. */
  96281. set useContactHardeningShadow(value: boolean);
  96282. protected _contactHardeningLightSizeUVRatio: number;
  96283. /**
  96284. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  96285. * Using a ratio helps keeping shape stability independently of the map size.
  96286. *
  96287. * It does not account for the light projection as it was having too much
  96288. * instability during the light setup or during light position changes.
  96289. *
  96290. * Only valid if useContactHardeningShadow is true.
  96291. */
  96292. get contactHardeningLightSizeUVRatio(): number;
  96293. /**
  96294. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  96295. * Using a ratio helps keeping shape stability independently of the map size.
  96296. *
  96297. * It does not account for the light projection as it was having too much
  96298. * instability during the light setup or during light position changes.
  96299. *
  96300. * Only valid if useContactHardeningShadow is true.
  96301. */
  96302. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  96303. protected _darkness: number;
  96304. /** Gets or sets the actual darkness of a shadow */
  96305. get darkness(): number;
  96306. set darkness(value: number);
  96307. /**
  96308. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  96309. * 0 means strongest and 1 would means no shadow.
  96310. * @returns the darkness.
  96311. */
  96312. getDarkness(): number;
  96313. /**
  96314. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  96315. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  96316. * @returns the shadow generator allowing fluent coding.
  96317. */
  96318. setDarkness(darkness: number): ShadowGenerator;
  96319. protected _transparencyShadow: boolean;
  96320. /** Gets or sets the ability to have transparent shadow */
  96321. get transparencyShadow(): boolean;
  96322. set transparencyShadow(value: boolean);
  96323. /**
  96324. * Sets the ability to have transparent shadow (boolean).
  96325. * @param transparent True if transparent else False
  96326. * @returns the shadow generator allowing fluent coding
  96327. */
  96328. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  96329. /**
  96330. * Enables or disables shadows with varying strength based on the transparency
  96331. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  96332. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  96333. * mesh.visibility * alphaTexture.a
  96334. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  96335. */
  96336. enableSoftTransparentShadow: boolean;
  96337. protected _shadowMap: Nullable<RenderTargetTexture>;
  96338. protected _shadowMap2: Nullable<RenderTargetTexture>;
  96339. /**
  96340. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  96341. * @returns The render target texture if present otherwise, null
  96342. */
  96343. getShadowMap(): Nullable<RenderTargetTexture>;
  96344. /**
  96345. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  96346. * @returns The render target texture if the shadow map is present otherwise, null
  96347. */
  96348. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  96349. /**
  96350. * Gets the class name of that object
  96351. * @returns "ShadowGenerator"
  96352. */
  96353. getClassName(): string;
  96354. /**
  96355. * Helper function to add a mesh and its descendants to the list of shadow casters.
  96356. * @param mesh Mesh to add
  96357. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  96358. * @returns the Shadow Generator itself
  96359. */
  96360. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  96361. /**
  96362. * Helper function to remove a mesh and its descendants from the list of shadow casters
  96363. * @param mesh Mesh to remove
  96364. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  96365. * @returns the Shadow Generator itself
  96366. */
  96367. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  96368. /**
  96369. * Controls the extent to which the shadows fade out at the edge of the frustum
  96370. */
  96371. frustumEdgeFalloff: number;
  96372. protected _light: IShadowLight;
  96373. /**
  96374. * Returns the associated light object.
  96375. * @returns the light generating the shadow
  96376. */
  96377. getLight(): IShadowLight;
  96378. /**
  96379. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  96380. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  96381. * It might on the other hand introduce peter panning.
  96382. */
  96383. forceBackFacesOnly: boolean;
  96384. protected _scene: Scene;
  96385. protected _lightDirection: Vector3;
  96386. protected _effect: Effect;
  96387. protected _viewMatrix: Matrix;
  96388. protected _projectionMatrix: Matrix;
  96389. protected _transformMatrix: Matrix;
  96390. protected _cachedPosition: Vector3;
  96391. protected _cachedDirection: Vector3;
  96392. protected _cachedDefines: string;
  96393. protected _currentRenderID: number;
  96394. protected _boxBlurPostprocess: Nullable<PostProcess>;
  96395. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  96396. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  96397. protected _blurPostProcesses: PostProcess[];
  96398. protected _mapSize: number;
  96399. protected _currentFaceIndex: number;
  96400. protected _currentFaceIndexCache: number;
  96401. protected _textureType: number;
  96402. protected _defaultTextureMatrix: Matrix;
  96403. protected _storedUniqueId: Nullable<number>;
  96404. /** @hidden */
  96405. static _SceneComponentInitialization: (scene: Scene) => void;
  96406. /**
  96407. * Creates a ShadowGenerator object.
  96408. * A ShadowGenerator is the required tool to use the shadows.
  96409. * Each light casting shadows needs to use its own ShadowGenerator.
  96410. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  96411. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  96412. * @param light The light object generating the shadows.
  96413. * @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.
  96414. */
  96415. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  96416. protected _initializeGenerator(): void;
  96417. protected _createTargetRenderTexture(): void;
  96418. protected _initializeShadowMap(): void;
  96419. protected _initializeBlurRTTAndPostProcesses(): void;
  96420. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  96421. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  96422. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  96423. protected _applyFilterValues(): void;
  96424. /**
  96425. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96426. * @param onCompiled Callback triggered at the and of the effects compilation
  96427. * @param options Sets of optional options forcing the compilation with different modes
  96428. */
  96429. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  96430. useInstances: boolean;
  96431. }>): void;
  96432. /**
  96433. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96434. * @param options Sets of optional options forcing the compilation with different modes
  96435. * @returns A promise that resolves when the compilation completes
  96436. */
  96437. forceCompilationAsync(options?: Partial<{
  96438. useInstances: boolean;
  96439. }>): Promise<void>;
  96440. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  96441. private _prepareShadowDefines;
  96442. /**
  96443. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  96444. * @param subMesh The submesh we want to render in the shadow map
  96445. * @param useInstances Defines wether will draw in the map using instances
  96446. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  96447. * @returns true if ready otherwise, false
  96448. */
  96449. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  96450. /**
  96451. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  96452. * @param defines Defines of the material we want to update
  96453. * @param lightIndex Index of the light in the enabled light list of the material
  96454. */
  96455. prepareDefines(defines: any, lightIndex: number): void;
  96456. /**
  96457. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  96458. * defined in the generator but impacting the effect).
  96459. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  96460. * @param effect The effect we are binfing the information for
  96461. */
  96462. bindShadowLight(lightIndex: string, effect: Effect): void;
  96463. /**
  96464. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  96465. * (eq to shadow prjection matrix * light transform matrix)
  96466. * @returns The transform matrix used to create the shadow map
  96467. */
  96468. getTransformMatrix(): Matrix;
  96469. /**
  96470. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  96471. * Cube and 2D textures for instance.
  96472. */
  96473. recreateShadowMap(): void;
  96474. protected _disposeBlurPostProcesses(): void;
  96475. protected _disposeRTTandPostProcesses(): void;
  96476. /**
  96477. * Disposes the ShadowGenerator.
  96478. * Returns nothing.
  96479. */
  96480. dispose(): void;
  96481. /**
  96482. * Serializes the shadow generator setup to a json object.
  96483. * @returns The serialized JSON object
  96484. */
  96485. serialize(): any;
  96486. /**
  96487. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  96488. * @param parsedShadowGenerator The JSON object to parse
  96489. * @param scene The scene to create the shadow map for
  96490. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  96491. * @returns The parsed shadow generator
  96492. */
  96493. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  96494. }
  96495. }
  96496. declare module BABYLON {
  96497. /**
  96498. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  96499. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  96500. * 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.
  96501. */
  96502. export abstract class Light extends Node {
  96503. /**
  96504. * Falloff Default: light is falling off following the material specification:
  96505. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  96506. */
  96507. static readonly FALLOFF_DEFAULT: number;
  96508. /**
  96509. * Falloff Physical: light is falling off following the inverse squared distance law.
  96510. */
  96511. static readonly FALLOFF_PHYSICAL: number;
  96512. /**
  96513. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  96514. * to enhance interoperability with other engines.
  96515. */
  96516. static readonly FALLOFF_GLTF: number;
  96517. /**
  96518. * Falloff Standard: light is falling off like in the standard material
  96519. * to enhance interoperability with other materials.
  96520. */
  96521. static readonly FALLOFF_STANDARD: number;
  96522. /**
  96523. * If every light affecting the material is in this lightmapMode,
  96524. * material.lightmapTexture adds or multiplies
  96525. * (depends on material.useLightmapAsShadowmap)
  96526. * after every other light calculations.
  96527. */
  96528. static readonly LIGHTMAP_DEFAULT: number;
  96529. /**
  96530. * material.lightmapTexture as only diffuse lighting from this light
  96531. * adds only specular lighting from this light
  96532. * adds dynamic shadows
  96533. */
  96534. static readonly LIGHTMAP_SPECULAR: number;
  96535. /**
  96536. * material.lightmapTexture as only lighting
  96537. * no light calculation from this light
  96538. * only adds dynamic shadows from this light
  96539. */
  96540. static readonly LIGHTMAP_SHADOWSONLY: number;
  96541. /**
  96542. * Each light type uses the default quantity according to its type:
  96543. * point/spot lights use luminous intensity
  96544. * directional lights use illuminance
  96545. */
  96546. static readonly INTENSITYMODE_AUTOMATIC: number;
  96547. /**
  96548. * lumen (lm)
  96549. */
  96550. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  96551. /**
  96552. * candela (lm/sr)
  96553. */
  96554. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  96555. /**
  96556. * lux (lm/m^2)
  96557. */
  96558. static readonly INTENSITYMODE_ILLUMINANCE: number;
  96559. /**
  96560. * nit (cd/m^2)
  96561. */
  96562. static readonly INTENSITYMODE_LUMINANCE: number;
  96563. /**
  96564. * Light type const id of the point light.
  96565. */
  96566. static readonly LIGHTTYPEID_POINTLIGHT: number;
  96567. /**
  96568. * Light type const id of the directional light.
  96569. */
  96570. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  96571. /**
  96572. * Light type const id of the spot light.
  96573. */
  96574. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  96575. /**
  96576. * Light type const id of the hemispheric light.
  96577. */
  96578. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  96579. /**
  96580. * Diffuse gives the basic color to an object.
  96581. */
  96582. diffuse: Color3;
  96583. /**
  96584. * Specular produces a highlight color on an object.
  96585. * Note: This is note affecting PBR materials.
  96586. */
  96587. specular: Color3;
  96588. /**
  96589. * Defines the falloff type for this light. This lets overrriding how punctual light are
  96590. * falling off base on range or angle.
  96591. * This can be set to any values in Light.FALLOFF_x.
  96592. *
  96593. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  96594. * other types of materials.
  96595. */
  96596. falloffType: number;
  96597. /**
  96598. * Strength of the light.
  96599. * Note: By default it is define in the framework own unit.
  96600. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  96601. */
  96602. intensity: number;
  96603. private _range;
  96604. protected _inverseSquaredRange: number;
  96605. /**
  96606. * Defines how far from the source the light is impacting in scene units.
  96607. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96608. */
  96609. get range(): number;
  96610. /**
  96611. * Defines how far from the source the light is impacting in scene units.
  96612. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96613. */
  96614. set range(value: number);
  96615. /**
  96616. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  96617. * of light.
  96618. */
  96619. private _photometricScale;
  96620. private _intensityMode;
  96621. /**
  96622. * Gets the photometric scale used to interpret the intensity.
  96623. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96624. */
  96625. get intensityMode(): number;
  96626. /**
  96627. * Sets the photometric scale used to interpret the intensity.
  96628. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96629. */
  96630. set intensityMode(value: number);
  96631. private _radius;
  96632. /**
  96633. * Gets the light radius used by PBR Materials to simulate soft area lights.
  96634. */
  96635. get radius(): number;
  96636. /**
  96637. * sets the light radius used by PBR Materials to simulate soft area lights.
  96638. */
  96639. set radius(value: number);
  96640. private _renderPriority;
  96641. /**
  96642. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  96643. * exceeding the number allowed of the materials.
  96644. */
  96645. renderPriority: number;
  96646. private _shadowEnabled;
  96647. /**
  96648. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96649. * the current shadow generator.
  96650. */
  96651. get shadowEnabled(): boolean;
  96652. /**
  96653. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96654. * the current shadow generator.
  96655. */
  96656. set shadowEnabled(value: boolean);
  96657. private _includedOnlyMeshes;
  96658. /**
  96659. * Gets the only meshes impacted by this light.
  96660. */
  96661. get includedOnlyMeshes(): AbstractMesh[];
  96662. /**
  96663. * Sets the only meshes impacted by this light.
  96664. */
  96665. set includedOnlyMeshes(value: AbstractMesh[]);
  96666. private _excludedMeshes;
  96667. /**
  96668. * Gets the meshes not impacted by this light.
  96669. */
  96670. get excludedMeshes(): AbstractMesh[];
  96671. /**
  96672. * Sets the meshes not impacted by this light.
  96673. */
  96674. set excludedMeshes(value: AbstractMesh[]);
  96675. private _excludeWithLayerMask;
  96676. /**
  96677. * Gets the layer id use to find what meshes are not impacted by the light.
  96678. * Inactive if 0
  96679. */
  96680. get excludeWithLayerMask(): number;
  96681. /**
  96682. * Sets the layer id use to find what meshes are not impacted by the light.
  96683. * Inactive if 0
  96684. */
  96685. set excludeWithLayerMask(value: number);
  96686. private _includeOnlyWithLayerMask;
  96687. /**
  96688. * Gets the layer id use to find what meshes are impacted by the light.
  96689. * Inactive if 0
  96690. */
  96691. get includeOnlyWithLayerMask(): number;
  96692. /**
  96693. * Sets the layer id use to find what meshes are impacted by the light.
  96694. * Inactive if 0
  96695. */
  96696. set includeOnlyWithLayerMask(value: number);
  96697. private _lightmapMode;
  96698. /**
  96699. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96700. */
  96701. get lightmapMode(): number;
  96702. /**
  96703. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96704. */
  96705. set lightmapMode(value: number);
  96706. /**
  96707. * Shadow generator associted to the light.
  96708. * @hidden Internal use only.
  96709. */
  96710. _shadowGenerator: Nullable<IShadowGenerator>;
  96711. /**
  96712. * @hidden Internal use only.
  96713. */
  96714. _excludedMeshesIds: string[];
  96715. /**
  96716. * @hidden Internal use only.
  96717. */
  96718. _includedOnlyMeshesIds: string[];
  96719. /**
  96720. * The current light unifom buffer.
  96721. * @hidden Internal use only.
  96722. */
  96723. _uniformBuffer: UniformBuffer;
  96724. /** @hidden */
  96725. _renderId: number;
  96726. /**
  96727. * Creates a Light object in the scene.
  96728. * Documentation : https://doc.babylonjs.com/babylon101/lights
  96729. * @param name The firendly name of the light
  96730. * @param scene The scene the light belongs too
  96731. */
  96732. constructor(name: string, scene: Scene);
  96733. protected abstract _buildUniformLayout(): void;
  96734. /**
  96735. * Sets the passed Effect "effect" with the Light information.
  96736. * @param effect The effect to update
  96737. * @param lightIndex The index of the light in the effect to update
  96738. * @returns The light
  96739. */
  96740. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  96741. /**
  96742. * Sets the passed Effect "effect" with the Light textures.
  96743. * @param effect The effect to update
  96744. * @param lightIndex The index of the light in the effect to update
  96745. * @returns The light
  96746. */
  96747. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  96748. /**
  96749. * Binds the lights information from the scene to the effect for the given mesh.
  96750. * @param lightIndex Light index
  96751. * @param scene The scene where the light belongs to
  96752. * @param effect The effect we are binding the data to
  96753. * @param useSpecular Defines if specular is supported
  96754. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  96755. */
  96756. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  96757. /**
  96758. * Sets the passed Effect "effect" with the Light information.
  96759. * @param effect The effect to update
  96760. * @param lightDataUniformName The uniform used to store light data (position or direction)
  96761. * @returns The light
  96762. */
  96763. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  96764. /**
  96765. * Returns the string "Light".
  96766. * @returns the class name
  96767. */
  96768. getClassName(): string;
  96769. /** @hidden */
  96770. readonly _isLight: boolean;
  96771. /**
  96772. * Converts the light information to a readable string for debug purpose.
  96773. * @param fullDetails Supports for multiple levels of logging within scene loading
  96774. * @returns the human readable light info
  96775. */
  96776. toString(fullDetails?: boolean): string;
  96777. /** @hidden */
  96778. protected _syncParentEnabledState(): void;
  96779. /**
  96780. * Set the enabled state of this node.
  96781. * @param value - the new enabled state
  96782. */
  96783. setEnabled(value: boolean): void;
  96784. /**
  96785. * Returns the Light associated shadow generator if any.
  96786. * @return the associated shadow generator.
  96787. */
  96788. getShadowGenerator(): Nullable<IShadowGenerator>;
  96789. /**
  96790. * Returns a Vector3, the absolute light position in the World.
  96791. * @returns the world space position of the light
  96792. */
  96793. getAbsolutePosition(): Vector3;
  96794. /**
  96795. * Specifies if the light will affect the passed mesh.
  96796. * @param mesh The mesh to test against the light
  96797. * @return true the mesh is affected otherwise, false.
  96798. */
  96799. canAffectMesh(mesh: AbstractMesh): boolean;
  96800. /**
  96801. * Sort function to order lights for rendering.
  96802. * @param a First Light object to compare to second.
  96803. * @param b Second Light object to compare first.
  96804. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  96805. */
  96806. static CompareLightsPriority(a: Light, b: Light): number;
  96807. /**
  96808. * Releases resources associated with this node.
  96809. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96810. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96811. */
  96812. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96813. /**
  96814. * Returns the light type ID (integer).
  96815. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  96816. */
  96817. getTypeID(): number;
  96818. /**
  96819. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  96820. * @returns the scaled intensity in intensity mode unit
  96821. */
  96822. getScaledIntensity(): number;
  96823. /**
  96824. * Returns a new Light object, named "name", from the current one.
  96825. * @param name The name of the cloned light
  96826. * @param newParent The parent of this light, if it has one
  96827. * @returns the new created light
  96828. */
  96829. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  96830. /**
  96831. * Serializes the current light into a Serialization object.
  96832. * @returns the serialized object.
  96833. */
  96834. serialize(): any;
  96835. /**
  96836. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  96837. * This new light is named "name" and added to the passed scene.
  96838. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  96839. * @param name The friendly name of the light
  96840. * @param scene The scene the new light will belong to
  96841. * @returns the constructor function
  96842. */
  96843. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  96844. /**
  96845. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  96846. * @param parsedLight The JSON representation of the light
  96847. * @param scene The scene to create the parsed light in
  96848. * @returns the created light after parsing
  96849. */
  96850. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  96851. private _hookArrayForExcluded;
  96852. private _hookArrayForIncludedOnly;
  96853. private _resyncMeshes;
  96854. /**
  96855. * Forces the meshes to update their light related information in their rendering used effects
  96856. * @hidden Internal Use Only
  96857. */
  96858. _markMeshesAsLightDirty(): void;
  96859. /**
  96860. * Recomputes the cached photometric scale if needed.
  96861. */
  96862. private _computePhotometricScale;
  96863. /**
  96864. * Returns the Photometric Scale according to the light type and intensity mode.
  96865. */
  96866. private _getPhotometricScale;
  96867. /**
  96868. * Reorder the light in the scene according to their defined priority.
  96869. * @hidden Internal Use Only
  96870. */
  96871. _reorderLightsInScene(): void;
  96872. /**
  96873. * Prepares the list of defines specific to the light type.
  96874. * @param defines the list of defines
  96875. * @param lightIndex defines the index of the light for the effect
  96876. */
  96877. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  96878. }
  96879. }
  96880. declare module BABYLON {
  96881. /**
  96882. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  96883. * This is the base of the follow, arc rotate cameras and Free camera
  96884. * @see https://doc.babylonjs.com/features/cameras
  96885. */
  96886. export class TargetCamera extends Camera {
  96887. private static _RigCamTransformMatrix;
  96888. private static _TargetTransformMatrix;
  96889. private static _TargetFocalPoint;
  96890. private _tmpUpVector;
  96891. private _tmpTargetVector;
  96892. /**
  96893. * Define the current direction the camera is moving to
  96894. */
  96895. cameraDirection: Vector3;
  96896. /**
  96897. * Define the current rotation the camera is rotating to
  96898. */
  96899. cameraRotation: Vector2;
  96900. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  96901. ignoreParentScaling: boolean;
  96902. /**
  96903. * When set, the up vector of the camera will be updated by the rotation of the camera
  96904. */
  96905. updateUpVectorFromRotation: boolean;
  96906. private _tmpQuaternion;
  96907. /**
  96908. * Define the current rotation of the camera
  96909. */
  96910. rotation: Vector3;
  96911. /**
  96912. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  96913. */
  96914. rotationQuaternion: Quaternion;
  96915. /**
  96916. * Define the current speed of the camera
  96917. */
  96918. speed: number;
  96919. /**
  96920. * Add constraint to the camera to prevent it to move freely in all directions and
  96921. * around all axis.
  96922. */
  96923. noRotationConstraint: boolean;
  96924. /**
  96925. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  96926. * panning
  96927. */
  96928. invertRotation: boolean;
  96929. /**
  96930. * Speed multiplier for inverse camera panning
  96931. */
  96932. inverseRotationSpeed: number;
  96933. /**
  96934. * Define the current target of the camera as an object or a position.
  96935. */
  96936. lockedTarget: any;
  96937. /** @hidden */
  96938. _currentTarget: Vector3;
  96939. /** @hidden */
  96940. _initialFocalDistance: number;
  96941. /** @hidden */
  96942. _viewMatrix: Matrix;
  96943. /** @hidden */
  96944. _camMatrix: Matrix;
  96945. /** @hidden */
  96946. _cameraTransformMatrix: Matrix;
  96947. /** @hidden */
  96948. _cameraRotationMatrix: Matrix;
  96949. /** @hidden */
  96950. _referencePoint: Vector3;
  96951. /** @hidden */
  96952. _transformedReferencePoint: Vector3;
  96953. /** @hidden */
  96954. _reset: () => void;
  96955. private _defaultUp;
  96956. /**
  96957. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  96958. * This is the base of the follow, arc rotate cameras and Free camera
  96959. * @see https://doc.babylonjs.com/features/cameras
  96960. * @param name Defines the name of the camera in the scene
  96961. * @param position Defines the start position of the camera in the scene
  96962. * @param scene Defines the scene the camera belongs to
  96963. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96964. */
  96965. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96966. /**
  96967. * Gets the position in front of the camera at a given distance.
  96968. * @param distance The distance from the camera we want the position to be
  96969. * @returns the position
  96970. */
  96971. getFrontPosition(distance: number): Vector3;
  96972. /** @hidden */
  96973. _getLockedTargetPosition(): Nullable<Vector3>;
  96974. private _storedPosition;
  96975. private _storedRotation;
  96976. private _storedRotationQuaternion;
  96977. /**
  96978. * Store current camera state of the camera (fov, position, rotation, etc..)
  96979. * @returns the camera
  96980. */
  96981. storeState(): Camera;
  96982. /**
  96983. * Restored camera state. You must call storeState() first
  96984. * @returns whether it was successful or not
  96985. * @hidden
  96986. */
  96987. _restoreStateValues(): boolean;
  96988. /** @hidden */
  96989. _initCache(): void;
  96990. /** @hidden */
  96991. _updateCache(ignoreParentClass?: boolean): void;
  96992. /** @hidden */
  96993. _isSynchronizedViewMatrix(): boolean;
  96994. /** @hidden */
  96995. _computeLocalCameraSpeed(): number;
  96996. /**
  96997. * Defines the target the camera should look at.
  96998. * @param target Defines the new target as a Vector or a mesh
  96999. */
  97000. setTarget(target: Vector3): void;
  97001. /**
  97002. * Return the current target position of the camera. This value is expressed in local space.
  97003. * @returns the target position
  97004. */
  97005. getTarget(): Vector3;
  97006. /** @hidden */
  97007. _decideIfNeedsToMove(): boolean;
  97008. /** @hidden */
  97009. _updatePosition(): void;
  97010. /** @hidden */
  97011. _checkInputs(): void;
  97012. protected _updateCameraRotationMatrix(): void;
  97013. /**
  97014. * 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)
  97015. * @returns the current camera
  97016. */
  97017. private _rotateUpVectorWithCameraRotationMatrix;
  97018. private _cachedRotationZ;
  97019. private _cachedQuaternionRotationZ;
  97020. /** @hidden */
  97021. _getViewMatrix(): Matrix;
  97022. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  97023. /**
  97024. * @hidden
  97025. */
  97026. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  97027. /**
  97028. * @hidden
  97029. */
  97030. _updateRigCameras(): void;
  97031. private _getRigCamPositionAndTarget;
  97032. /**
  97033. * Gets the current object class name.
  97034. * @return the class name
  97035. */
  97036. getClassName(): string;
  97037. }
  97038. }
  97039. declare module BABYLON {
  97040. /**
  97041. * Gather the list of keyboard event types as constants.
  97042. */
  97043. export class KeyboardEventTypes {
  97044. /**
  97045. * The keydown event is fired when a key becomes active (pressed).
  97046. */
  97047. static readonly KEYDOWN: number;
  97048. /**
  97049. * The keyup event is fired when a key has been released.
  97050. */
  97051. static readonly KEYUP: number;
  97052. }
  97053. /**
  97054. * This class is used to store keyboard related info for the onKeyboardObservable event.
  97055. */
  97056. export class KeyboardInfo {
  97057. /**
  97058. * Defines the type of event (KeyboardEventTypes)
  97059. */
  97060. type: number;
  97061. /**
  97062. * Defines the related dom event
  97063. */
  97064. event: KeyboardEvent;
  97065. /**
  97066. * Instantiates a new keyboard info.
  97067. * This class is used to store keyboard related info for the onKeyboardObservable event.
  97068. * @param type Defines the type of event (KeyboardEventTypes)
  97069. * @param event Defines the related dom event
  97070. */
  97071. constructor(
  97072. /**
  97073. * Defines the type of event (KeyboardEventTypes)
  97074. */
  97075. type: number,
  97076. /**
  97077. * Defines the related dom event
  97078. */
  97079. event: KeyboardEvent);
  97080. }
  97081. /**
  97082. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  97083. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  97084. */
  97085. export class KeyboardInfoPre extends KeyboardInfo {
  97086. /**
  97087. * Defines the type of event (KeyboardEventTypes)
  97088. */
  97089. type: number;
  97090. /**
  97091. * Defines the related dom event
  97092. */
  97093. event: KeyboardEvent;
  97094. /**
  97095. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  97096. */
  97097. skipOnPointerObservable: boolean;
  97098. /**
  97099. * Instantiates a new keyboard pre info.
  97100. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  97101. * @param type Defines the type of event (KeyboardEventTypes)
  97102. * @param event Defines the related dom event
  97103. */
  97104. constructor(
  97105. /**
  97106. * Defines the type of event (KeyboardEventTypes)
  97107. */
  97108. type: number,
  97109. /**
  97110. * Defines the related dom event
  97111. */
  97112. event: KeyboardEvent);
  97113. }
  97114. }
  97115. declare module BABYLON {
  97116. /**
  97117. * Manage the keyboard inputs to control the movement of a free camera.
  97118. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97119. */
  97120. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  97121. /**
  97122. * Defines the camera the input is attached to.
  97123. */
  97124. camera: FreeCamera;
  97125. /**
  97126. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  97127. */
  97128. keysUp: number[];
  97129. /**
  97130. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  97131. */
  97132. keysUpward: number[];
  97133. /**
  97134. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  97135. */
  97136. keysDown: number[];
  97137. /**
  97138. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  97139. */
  97140. keysDownward: number[];
  97141. /**
  97142. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  97143. */
  97144. keysLeft: number[];
  97145. /**
  97146. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  97147. */
  97148. keysRight: number[];
  97149. private _keys;
  97150. private _onCanvasBlurObserver;
  97151. private _onKeyboardObserver;
  97152. private _engine;
  97153. private _scene;
  97154. /**
  97155. * Attach the input controls to a specific dom element to get the input from.
  97156. * @param element Defines the element the controls should be listened from
  97157. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97158. */
  97159. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97160. /**
  97161. * Detach the current controls from the specified dom element.
  97162. * @param element Defines the element to stop listening the inputs from
  97163. */
  97164. detachControl(element: Nullable<HTMLElement>): void;
  97165. /**
  97166. * Update the current camera state depending on the inputs that have been used this frame.
  97167. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97168. */
  97169. checkInputs(): void;
  97170. /**
  97171. * Gets the class name of the current intput.
  97172. * @returns the class name
  97173. */
  97174. getClassName(): string;
  97175. /** @hidden */
  97176. _onLostFocus(): void;
  97177. /**
  97178. * Get the friendly name associated with the input class.
  97179. * @returns the input friendly name
  97180. */
  97181. getSimpleName(): string;
  97182. }
  97183. }
  97184. declare module BABYLON {
  97185. /**
  97186. * Gather the list of pointer event types as constants.
  97187. */
  97188. export class PointerEventTypes {
  97189. /**
  97190. * 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.
  97191. */
  97192. static readonly POINTERDOWN: number;
  97193. /**
  97194. * The pointerup event is fired when a pointer is no longer active.
  97195. */
  97196. static readonly POINTERUP: number;
  97197. /**
  97198. * The pointermove event is fired when a pointer changes coordinates.
  97199. */
  97200. static readonly POINTERMOVE: number;
  97201. /**
  97202. * The pointerwheel event is fired when a mouse wheel has been rotated.
  97203. */
  97204. static readonly POINTERWHEEL: number;
  97205. /**
  97206. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  97207. */
  97208. static readonly POINTERPICK: number;
  97209. /**
  97210. * The pointertap event is fired when a the object has been touched and released without drag.
  97211. */
  97212. static readonly POINTERTAP: number;
  97213. /**
  97214. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  97215. */
  97216. static readonly POINTERDOUBLETAP: number;
  97217. }
  97218. /**
  97219. * Base class of pointer info types.
  97220. */
  97221. export class PointerInfoBase {
  97222. /**
  97223. * Defines the type of event (PointerEventTypes)
  97224. */
  97225. type: number;
  97226. /**
  97227. * Defines the related dom event
  97228. */
  97229. event: PointerEvent | MouseWheelEvent;
  97230. /**
  97231. * Instantiates the base class of pointers info.
  97232. * @param type Defines the type of event (PointerEventTypes)
  97233. * @param event Defines the related dom event
  97234. */
  97235. constructor(
  97236. /**
  97237. * Defines the type of event (PointerEventTypes)
  97238. */
  97239. type: number,
  97240. /**
  97241. * Defines the related dom event
  97242. */
  97243. event: PointerEvent | MouseWheelEvent);
  97244. }
  97245. /**
  97246. * This class is used to store pointer related info for the onPrePointerObservable event.
  97247. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  97248. */
  97249. export class PointerInfoPre extends PointerInfoBase {
  97250. /**
  97251. * Ray from a pointer if availible (eg. 6dof controller)
  97252. */
  97253. ray: Nullable<Ray>;
  97254. /**
  97255. * Defines the local position of the pointer on the canvas.
  97256. */
  97257. localPosition: Vector2;
  97258. /**
  97259. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  97260. */
  97261. skipOnPointerObservable: boolean;
  97262. /**
  97263. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  97264. * @param type Defines the type of event (PointerEventTypes)
  97265. * @param event Defines the related dom event
  97266. * @param localX Defines the local x coordinates of the pointer when the event occured
  97267. * @param localY Defines the local y coordinates of the pointer when the event occured
  97268. */
  97269. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  97270. }
  97271. /**
  97272. * This type contains all the data related to a pointer event in Babylon.js.
  97273. * 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.
  97274. */
  97275. export class PointerInfo extends PointerInfoBase {
  97276. /**
  97277. * Defines the picking info associated to the info (if any)\
  97278. */
  97279. pickInfo: Nullable<PickingInfo>;
  97280. /**
  97281. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  97282. * @param type Defines the type of event (PointerEventTypes)
  97283. * @param event Defines the related dom event
  97284. * @param pickInfo Defines the picking info associated to the info (if any)\
  97285. */
  97286. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  97287. /**
  97288. * Defines the picking info associated to the info (if any)\
  97289. */
  97290. pickInfo: Nullable<PickingInfo>);
  97291. }
  97292. /**
  97293. * Data relating to a touch event on the screen.
  97294. */
  97295. export interface PointerTouch {
  97296. /**
  97297. * X coordinate of touch.
  97298. */
  97299. x: number;
  97300. /**
  97301. * Y coordinate of touch.
  97302. */
  97303. y: number;
  97304. /**
  97305. * Id of touch. Unique for each finger.
  97306. */
  97307. pointerId: number;
  97308. /**
  97309. * Event type passed from DOM.
  97310. */
  97311. type: any;
  97312. }
  97313. }
  97314. declare module BABYLON {
  97315. /**
  97316. * Manage the mouse inputs to control the movement of a free camera.
  97317. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97318. */
  97319. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  97320. /**
  97321. * Define if touch is enabled in the mouse input
  97322. */
  97323. touchEnabled: boolean;
  97324. /**
  97325. * Defines the camera the input is attached to.
  97326. */
  97327. camera: FreeCamera;
  97328. /**
  97329. * Defines the buttons associated with the input to handle camera move.
  97330. */
  97331. buttons: number[];
  97332. /**
  97333. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  97334. */
  97335. angularSensibility: number;
  97336. private _pointerInput;
  97337. private _onMouseMove;
  97338. private _observer;
  97339. private previousPosition;
  97340. /**
  97341. * Observable for when a pointer move event occurs containing the move offset
  97342. */
  97343. onPointerMovedObservable: Observable<{
  97344. offsetX: number;
  97345. offsetY: number;
  97346. }>;
  97347. /**
  97348. * @hidden
  97349. * If the camera should be rotated automatically based on pointer movement
  97350. */
  97351. _allowCameraRotation: boolean;
  97352. /**
  97353. * Manage the mouse inputs to control the movement of a free camera.
  97354. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97355. * @param touchEnabled Defines if touch is enabled or not
  97356. */
  97357. constructor(
  97358. /**
  97359. * Define if touch is enabled in the mouse input
  97360. */
  97361. touchEnabled?: boolean);
  97362. /**
  97363. * Attach the input controls to a specific dom element to get the input from.
  97364. * @param element Defines the element the controls should be listened from
  97365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97366. */
  97367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97368. /**
  97369. * Called on JS contextmenu event.
  97370. * Override this method to provide functionality.
  97371. */
  97372. protected onContextMenu(evt: PointerEvent): void;
  97373. /**
  97374. * Detach the current controls from the specified dom element.
  97375. * @param element Defines the element to stop listening the inputs from
  97376. */
  97377. detachControl(element: Nullable<HTMLElement>): void;
  97378. /**
  97379. * Gets the class name of the current intput.
  97380. * @returns the class name
  97381. */
  97382. getClassName(): string;
  97383. /**
  97384. * Get the friendly name associated with the input class.
  97385. * @returns the input friendly name
  97386. */
  97387. getSimpleName(): string;
  97388. }
  97389. }
  97390. declare module BABYLON {
  97391. /**
  97392. * Manage the touch inputs to control the movement of a free camera.
  97393. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97394. */
  97395. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  97396. /**
  97397. * Defines the camera the input is attached to.
  97398. */
  97399. camera: FreeCamera;
  97400. /**
  97401. * Defines the touch sensibility for rotation.
  97402. * The higher the faster.
  97403. */
  97404. touchAngularSensibility: number;
  97405. /**
  97406. * Defines the touch sensibility for move.
  97407. * The higher the faster.
  97408. */
  97409. touchMoveSensibility: number;
  97410. private _offsetX;
  97411. private _offsetY;
  97412. private _pointerPressed;
  97413. private _pointerInput;
  97414. private _observer;
  97415. private _onLostFocus;
  97416. /**
  97417. * Attach the input controls to a specific dom element to get the input from.
  97418. * @param element Defines the element the controls should be listened from
  97419. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97420. */
  97421. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97422. /**
  97423. * Detach the current controls from the specified dom element.
  97424. * @param element Defines the element to stop listening the inputs from
  97425. */
  97426. detachControl(element: Nullable<HTMLElement>): void;
  97427. /**
  97428. * Update the current camera state depending on the inputs that have been used this frame.
  97429. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97430. */
  97431. checkInputs(): void;
  97432. /**
  97433. * Gets the class name of the current intput.
  97434. * @returns the class name
  97435. */
  97436. getClassName(): string;
  97437. /**
  97438. * Get the friendly name associated with the input class.
  97439. * @returns the input friendly name
  97440. */
  97441. getSimpleName(): string;
  97442. }
  97443. }
  97444. declare module BABYLON {
  97445. /**
  97446. * Default Inputs manager for the FreeCamera.
  97447. * It groups all the default supported inputs for ease of use.
  97448. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97449. */
  97450. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  97451. /**
  97452. * @hidden
  97453. */
  97454. _mouseInput: Nullable<FreeCameraMouseInput>;
  97455. /**
  97456. * Instantiates a new FreeCameraInputsManager.
  97457. * @param camera Defines the camera the inputs belong to
  97458. */
  97459. constructor(camera: FreeCamera);
  97460. /**
  97461. * Add keyboard input support to the input manager.
  97462. * @returns the current input manager
  97463. */
  97464. addKeyboard(): FreeCameraInputsManager;
  97465. /**
  97466. * Add mouse input support to the input manager.
  97467. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  97468. * @returns the current input manager
  97469. */
  97470. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  97471. /**
  97472. * Removes the mouse input support from the manager
  97473. * @returns the current input manager
  97474. */
  97475. removeMouse(): FreeCameraInputsManager;
  97476. /**
  97477. * Add touch input support to the input manager.
  97478. * @returns the current input manager
  97479. */
  97480. addTouch(): FreeCameraInputsManager;
  97481. /**
  97482. * Remove all attached input methods from a camera
  97483. */
  97484. clear(): void;
  97485. }
  97486. }
  97487. declare module BABYLON {
  97488. /**
  97489. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97490. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  97491. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97492. */
  97493. export class FreeCamera extends TargetCamera {
  97494. /**
  97495. * Define the collision ellipsoid of the camera.
  97496. * This is helpful to simulate a camera body like the player body around the camera
  97497. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  97498. */
  97499. ellipsoid: Vector3;
  97500. /**
  97501. * Define an offset for the position of the ellipsoid around the camera.
  97502. * This can be helpful to determine the center of the body near the gravity center of the body
  97503. * instead of its head.
  97504. */
  97505. ellipsoidOffset: Vector3;
  97506. /**
  97507. * Enable or disable collisions of the camera with the rest of the scene objects.
  97508. */
  97509. checkCollisions: boolean;
  97510. /**
  97511. * Enable or disable gravity on the camera.
  97512. */
  97513. applyGravity: boolean;
  97514. /**
  97515. * Define the input manager associated to the camera.
  97516. */
  97517. inputs: FreeCameraInputsManager;
  97518. /**
  97519. * Gets the input sensibility for a mouse input. (default is 2000.0)
  97520. * Higher values reduce sensitivity.
  97521. */
  97522. get angularSensibility(): number;
  97523. /**
  97524. * Sets the input sensibility for a mouse input. (default is 2000.0)
  97525. * Higher values reduce sensitivity.
  97526. */
  97527. set angularSensibility(value: number);
  97528. /**
  97529. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  97530. */
  97531. get keysUp(): number[];
  97532. set keysUp(value: number[]);
  97533. /**
  97534. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  97535. */
  97536. get keysUpward(): number[];
  97537. set keysUpward(value: number[]);
  97538. /**
  97539. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  97540. */
  97541. get keysDown(): number[];
  97542. set keysDown(value: number[]);
  97543. /**
  97544. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  97545. */
  97546. get keysDownward(): number[];
  97547. set keysDownward(value: number[]);
  97548. /**
  97549. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  97550. */
  97551. get keysLeft(): number[];
  97552. set keysLeft(value: number[]);
  97553. /**
  97554. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  97555. */
  97556. get keysRight(): number[];
  97557. set keysRight(value: number[]);
  97558. /**
  97559. * Event raised when the camera collide with a mesh in the scene.
  97560. */
  97561. onCollide: (collidedMesh: AbstractMesh) => void;
  97562. private _collider;
  97563. private _needMoveForGravity;
  97564. private _oldPosition;
  97565. private _diffPosition;
  97566. private _newPosition;
  97567. /** @hidden */
  97568. _localDirection: Vector3;
  97569. /** @hidden */
  97570. _transformedDirection: Vector3;
  97571. /**
  97572. * Instantiates a Free Camera.
  97573. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97574. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  97575. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97576. * @param name Define the name of the camera in the scene
  97577. * @param position Define the start position of the camera in the scene
  97578. * @param scene Define the scene the camera belongs to
  97579. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97580. */
  97581. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97582. /**
  97583. * Attached controls to the current camera.
  97584. * @param element Defines the element the controls should be listened from
  97585. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97586. */
  97587. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97588. /**
  97589. * Detach the current controls from the camera.
  97590. * The camera will stop reacting to inputs.
  97591. * @param element Defines the element to stop listening the inputs from
  97592. */
  97593. detachControl(element: HTMLElement): void;
  97594. private _collisionMask;
  97595. /**
  97596. * Define a collision mask to limit the list of object the camera can collide with
  97597. */
  97598. get collisionMask(): number;
  97599. set collisionMask(mask: number);
  97600. /** @hidden */
  97601. _collideWithWorld(displacement: Vector3): void;
  97602. private _onCollisionPositionChange;
  97603. /** @hidden */
  97604. _checkInputs(): void;
  97605. /** @hidden */
  97606. _decideIfNeedsToMove(): boolean;
  97607. /** @hidden */
  97608. _updatePosition(): void;
  97609. /**
  97610. * Destroy the camera and release the current resources hold by it.
  97611. */
  97612. dispose(): void;
  97613. /**
  97614. * Gets the current object class name.
  97615. * @return the class name
  97616. */
  97617. getClassName(): string;
  97618. }
  97619. }
  97620. declare module BABYLON {
  97621. /**
  97622. * Represents a gamepad control stick position
  97623. */
  97624. export class StickValues {
  97625. /**
  97626. * The x component of the control stick
  97627. */
  97628. x: number;
  97629. /**
  97630. * The y component of the control stick
  97631. */
  97632. y: number;
  97633. /**
  97634. * Initializes the gamepad x and y control stick values
  97635. * @param x The x component of the gamepad control stick value
  97636. * @param y The y component of the gamepad control stick value
  97637. */
  97638. constructor(
  97639. /**
  97640. * The x component of the control stick
  97641. */
  97642. x: number,
  97643. /**
  97644. * The y component of the control stick
  97645. */
  97646. y: number);
  97647. }
  97648. /**
  97649. * An interface which manages callbacks for gamepad button changes
  97650. */
  97651. export interface GamepadButtonChanges {
  97652. /**
  97653. * Called when a gamepad has been changed
  97654. */
  97655. changed: boolean;
  97656. /**
  97657. * Called when a gamepad press event has been triggered
  97658. */
  97659. pressChanged: boolean;
  97660. /**
  97661. * Called when a touch event has been triggered
  97662. */
  97663. touchChanged: boolean;
  97664. /**
  97665. * Called when a value has changed
  97666. */
  97667. valueChanged: boolean;
  97668. }
  97669. /**
  97670. * Represents a gamepad
  97671. */
  97672. export class Gamepad {
  97673. /**
  97674. * The id of the gamepad
  97675. */
  97676. id: string;
  97677. /**
  97678. * The index of the gamepad
  97679. */
  97680. index: number;
  97681. /**
  97682. * The browser gamepad
  97683. */
  97684. browserGamepad: any;
  97685. /**
  97686. * Specifies what type of gamepad this represents
  97687. */
  97688. type: number;
  97689. private _leftStick;
  97690. private _rightStick;
  97691. /** @hidden */
  97692. _isConnected: boolean;
  97693. private _leftStickAxisX;
  97694. private _leftStickAxisY;
  97695. private _rightStickAxisX;
  97696. private _rightStickAxisY;
  97697. /**
  97698. * Triggered when the left control stick has been changed
  97699. */
  97700. private _onleftstickchanged;
  97701. /**
  97702. * Triggered when the right control stick has been changed
  97703. */
  97704. private _onrightstickchanged;
  97705. /**
  97706. * Represents a gamepad controller
  97707. */
  97708. static GAMEPAD: number;
  97709. /**
  97710. * Represents a generic controller
  97711. */
  97712. static GENERIC: number;
  97713. /**
  97714. * Represents an XBox controller
  97715. */
  97716. static XBOX: number;
  97717. /**
  97718. * Represents a pose-enabled controller
  97719. */
  97720. static POSE_ENABLED: number;
  97721. /**
  97722. * Represents an Dual Shock controller
  97723. */
  97724. static DUALSHOCK: number;
  97725. /**
  97726. * Specifies whether the left control stick should be Y-inverted
  97727. */
  97728. protected _invertLeftStickY: boolean;
  97729. /**
  97730. * Specifies if the gamepad has been connected
  97731. */
  97732. get isConnected(): boolean;
  97733. /**
  97734. * Initializes the gamepad
  97735. * @param id The id of the gamepad
  97736. * @param index The index of the gamepad
  97737. * @param browserGamepad The browser gamepad
  97738. * @param leftStickX The x component of the left joystick
  97739. * @param leftStickY The y component of the left joystick
  97740. * @param rightStickX The x component of the right joystick
  97741. * @param rightStickY The y component of the right joystick
  97742. */
  97743. constructor(
  97744. /**
  97745. * The id of the gamepad
  97746. */
  97747. id: string,
  97748. /**
  97749. * The index of the gamepad
  97750. */
  97751. index: number,
  97752. /**
  97753. * The browser gamepad
  97754. */
  97755. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  97756. /**
  97757. * Callback triggered when the left joystick has changed
  97758. * @param callback
  97759. */
  97760. onleftstickchanged(callback: (values: StickValues) => void): void;
  97761. /**
  97762. * Callback triggered when the right joystick has changed
  97763. * @param callback
  97764. */
  97765. onrightstickchanged(callback: (values: StickValues) => void): void;
  97766. /**
  97767. * Gets the left joystick
  97768. */
  97769. get leftStick(): StickValues;
  97770. /**
  97771. * Sets the left joystick values
  97772. */
  97773. set leftStick(newValues: StickValues);
  97774. /**
  97775. * Gets the right joystick
  97776. */
  97777. get rightStick(): StickValues;
  97778. /**
  97779. * Sets the right joystick value
  97780. */
  97781. set rightStick(newValues: StickValues);
  97782. /**
  97783. * Updates the gamepad joystick positions
  97784. */
  97785. update(): void;
  97786. /**
  97787. * Disposes the gamepad
  97788. */
  97789. dispose(): void;
  97790. }
  97791. /**
  97792. * Represents a generic gamepad
  97793. */
  97794. export class GenericPad extends Gamepad {
  97795. private _buttons;
  97796. private _onbuttondown;
  97797. private _onbuttonup;
  97798. /**
  97799. * Observable triggered when a button has been pressed
  97800. */
  97801. onButtonDownObservable: Observable<number>;
  97802. /**
  97803. * Observable triggered when a button has been released
  97804. */
  97805. onButtonUpObservable: Observable<number>;
  97806. /**
  97807. * Callback triggered when a button has been pressed
  97808. * @param callback Called when a button has been pressed
  97809. */
  97810. onbuttondown(callback: (buttonPressed: number) => void): void;
  97811. /**
  97812. * Callback triggered when a button has been released
  97813. * @param callback Called when a button has been released
  97814. */
  97815. onbuttonup(callback: (buttonReleased: number) => void): void;
  97816. /**
  97817. * Initializes the generic gamepad
  97818. * @param id The id of the generic gamepad
  97819. * @param index The index of the generic gamepad
  97820. * @param browserGamepad The browser gamepad
  97821. */
  97822. constructor(id: string, index: number, browserGamepad: any);
  97823. private _setButtonValue;
  97824. /**
  97825. * Updates the generic gamepad
  97826. */
  97827. update(): void;
  97828. /**
  97829. * Disposes the generic gamepad
  97830. */
  97831. dispose(): void;
  97832. }
  97833. }
  97834. declare module BABYLON {
  97835. /**
  97836. * Defines the types of pose enabled controllers that are supported
  97837. */
  97838. export enum PoseEnabledControllerType {
  97839. /**
  97840. * HTC Vive
  97841. */
  97842. VIVE = 0,
  97843. /**
  97844. * Oculus Rift
  97845. */
  97846. OCULUS = 1,
  97847. /**
  97848. * Windows mixed reality
  97849. */
  97850. WINDOWS = 2,
  97851. /**
  97852. * Samsung gear VR
  97853. */
  97854. GEAR_VR = 3,
  97855. /**
  97856. * Google Daydream
  97857. */
  97858. DAYDREAM = 4,
  97859. /**
  97860. * Generic
  97861. */
  97862. GENERIC = 5
  97863. }
  97864. /**
  97865. * Defines the MutableGamepadButton interface for the state of a gamepad button
  97866. */
  97867. export interface MutableGamepadButton {
  97868. /**
  97869. * Value of the button/trigger
  97870. */
  97871. value: number;
  97872. /**
  97873. * If the button/trigger is currently touched
  97874. */
  97875. touched: boolean;
  97876. /**
  97877. * If the button/trigger is currently pressed
  97878. */
  97879. pressed: boolean;
  97880. }
  97881. /**
  97882. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  97883. * @hidden
  97884. */
  97885. export interface ExtendedGamepadButton extends GamepadButton {
  97886. /**
  97887. * If the button/trigger is currently pressed
  97888. */
  97889. readonly pressed: boolean;
  97890. /**
  97891. * If the button/trigger is currently touched
  97892. */
  97893. readonly touched: boolean;
  97894. /**
  97895. * Value of the button/trigger
  97896. */
  97897. readonly value: number;
  97898. }
  97899. /** @hidden */
  97900. export interface _GamePadFactory {
  97901. /**
  97902. * Returns whether or not the current gamepad can be created for this type of controller.
  97903. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  97904. * @returns true if it can be created, otherwise false
  97905. */
  97906. canCreate(gamepadInfo: any): boolean;
  97907. /**
  97908. * Creates a new instance of the Gamepad.
  97909. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  97910. * @returns the new gamepad instance
  97911. */
  97912. create(gamepadInfo: any): Gamepad;
  97913. }
  97914. /**
  97915. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  97916. */
  97917. export class PoseEnabledControllerHelper {
  97918. /** @hidden */
  97919. static _ControllerFactories: _GamePadFactory[];
  97920. /** @hidden */
  97921. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  97922. /**
  97923. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  97924. * @param vrGamepad the gamepad to initialized
  97925. * @returns a vr controller of the type the gamepad identified as
  97926. */
  97927. static InitiateController(vrGamepad: any): Gamepad;
  97928. }
  97929. /**
  97930. * Defines the PoseEnabledController object that contains state of a vr capable controller
  97931. */
  97932. export class PoseEnabledController extends Gamepad implements PoseControlled {
  97933. /**
  97934. * If the controller is used in a webXR session
  97935. */
  97936. isXR: boolean;
  97937. private _deviceRoomPosition;
  97938. private _deviceRoomRotationQuaternion;
  97939. /**
  97940. * The device position in babylon space
  97941. */
  97942. devicePosition: Vector3;
  97943. /**
  97944. * The device rotation in babylon space
  97945. */
  97946. deviceRotationQuaternion: Quaternion;
  97947. /**
  97948. * The scale factor of the device in babylon space
  97949. */
  97950. deviceScaleFactor: number;
  97951. /**
  97952. * (Likely devicePosition should be used instead) The device position in its room space
  97953. */
  97954. position: Vector3;
  97955. /**
  97956. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  97957. */
  97958. rotationQuaternion: Quaternion;
  97959. /**
  97960. * The type of controller (Eg. Windows mixed reality)
  97961. */
  97962. controllerType: PoseEnabledControllerType;
  97963. protected _calculatedPosition: Vector3;
  97964. private _calculatedRotation;
  97965. /**
  97966. * The raw pose from the device
  97967. */
  97968. rawPose: DevicePose;
  97969. private _trackPosition;
  97970. private _maxRotationDistFromHeadset;
  97971. private _draggedRoomRotation;
  97972. /**
  97973. * @hidden
  97974. */
  97975. _disableTrackPosition(fixedPosition: Vector3): void;
  97976. /**
  97977. * Internal, the mesh attached to the controller
  97978. * @hidden
  97979. */
  97980. _mesh: Nullable<AbstractMesh>;
  97981. private _poseControlledCamera;
  97982. private _leftHandSystemQuaternion;
  97983. /**
  97984. * Internal, matrix used to convert room space to babylon space
  97985. * @hidden
  97986. */
  97987. _deviceToWorld: Matrix;
  97988. /**
  97989. * Node to be used when casting a ray from the controller
  97990. * @hidden
  97991. */
  97992. _pointingPoseNode: Nullable<TransformNode>;
  97993. /**
  97994. * Name of the child mesh that can be used to cast a ray from the controller
  97995. */
  97996. static readonly POINTING_POSE: string;
  97997. /**
  97998. * Creates a new PoseEnabledController from a gamepad
  97999. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  98000. */
  98001. constructor(browserGamepad: any);
  98002. private _workingMatrix;
  98003. /**
  98004. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  98005. */
  98006. update(): void;
  98007. /**
  98008. * Updates only the pose device and mesh without doing any button event checking
  98009. */
  98010. protected _updatePoseAndMesh(): void;
  98011. /**
  98012. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  98013. * @param poseData raw pose fromthe device
  98014. */
  98015. updateFromDevice(poseData: DevicePose): void;
  98016. /**
  98017. * @hidden
  98018. */
  98019. _meshAttachedObservable: Observable<AbstractMesh>;
  98020. /**
  98021. * Attaches a mesh to the controller
  98022. * @param mesh the mesh to be attached
  98023. */
  98024. attachToMesh(mesh: AbstractMesh): void;
  98025. /**
  98026. * Attaches the controllers mesh to a camera
  98027. * @param camera the camera the mesh should be attached to
  98028. */
  98029. attachToPoseControlledCamera(camera: TargetCamera): void;
  98030. /**
  98031. * Disposes of the controller
  98032. */
  98033. dispose(): void;
  98034. /**
  98035. * The mesh that is attached to the controller
  98036. */
  98037. get mesh(): Nullable<AbstractMesh>;
  98038. /**
  98039. * Gets the ray of the controller in the direction the controller is pointing
  98040. * @param length the length the resulting ray should be
  98041. * @returns a ray in the direction the controller is pointing
  98042. */
  98043. getForwardRay(length?: number): Ray;
  98044. }
  98045. }
  98046. declare module BABYLON {
  98047. /**
  98048. * Defines the WebVRController object that represents controllers tracked in 3D space
  98049. */
  98050. export abstract class WebVRController extends PoseEnabledController {
  98051. /**
  98052. * Internal, the default controller model for the controller
  98053. */
  98054. protected _defaultModel: Nullable<AbstractMesh>;
  98055. /**
  98056. * Fired when the trigger state has changed
  98057. */
  98058. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98059. /**
  98060. * Fired when the main button state has changed
  98061. */
  98062. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98063. /**
  98064. * Fired when the secondary button state has changed
  98065. */
  98066. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98067. /**
  98068. * Fired when the pad state has changed
  98069. */
  98070. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  98071. /**
  98072. * Fired when controllers stick values have changed
  98073. */
  98074. onPadValuesChangedObservable: Observable<StickValues>;
  98075. /**
  98076. * Array of button availible on the controller
  98077. */
  98078. protected _buttons: Array<MutableGamepadButton>;
  98079. private _onButtonStateChange;
  98080. /**
  98081. * Fired when a controller button's state has changed
  98082. * @param callback the callback containing the button that was modified
  98083. */
  98084. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  98085. /**
  98086. * X and Y axis corresponding to the controllers joystick
  98087. */
  98088. pad: StickValues;
  98089. /**
  98090. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  98091. */
  98092. hand: string;
  98093. /**
  98094. * The default controller model for the controller
  98095. */
  98096. get defaultModel(): Nullable<AbstractMesh>;
  98097. /**
  98098. * Creates a new WebVRController from a gamepad
  98099. * @param vrGamepad the gamepad that the WebVRController should be created from
  98100. */
  98101. constructor(vrGamepad: any);
  98102. /**
  98103. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  98104. */
  98105. update(): void;
  98106. /**
  98107. * Function to be called when a button is modified
  98108. */
  98109. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98110. /**
  98111. * Loads a mesh and attaches it to the controller
  98112. * @param scene the scene the mesh should be added to
  98113. * @param meshLoaded callback for when the mesh has been loaded
  98114. */
  98115. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98116. private _setButtonValue;
  98117. private _changes;
  98118. private _checkChanges;
  98119. /**
  98120. * Disposes of th webVRCOntroller
  98121. */
  98122. dispose(): void;
  98123. }
  98124. }
  98125. declare module BABYLON {
  98126. /**
  98127. * The HemisphericLight simulates the ambient environment light,
  98128. * so the passed direction is the light reflection direction, not the incoming direction.
  98129. */
  98130. export class HemisphericLight extends Light {
  98131. /**
  98132. * The groundColor is the light in the opposite direction to the one specified during creation.
  98133. * 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.
  98134. */
  98135. groundColor: Color3;
  98136. /**
  98137. * The light reflection direction, not the incoming direction.
  98138. */
  98139. direction: Vector3;
  98140. /**
  98141. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  98142. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  98143. * The HemisphericLight can't cast shadows.
  98144. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98145. * @param name The friendly name of the light
  98146. * @param direction The direction of the light reflection
  98147. * @param scene The scene the light belongs to
  98148. */
  98149. constructor(name: string, direction: Vector3, scene: Scene);
  98150. protected _buildUniformLayout(): void;
  98151. /**
  98152. * Returns the string "HemisphericLight".
  98153. * @return The class name
  98154. */
  98155. getClassName(): string;
  98156. /**
  98157. * Sets the HemisphericLight direction towards the passed target (Vector3).
  98158. * Returns the updated direction.
  98159. * @param target The target the direction should point to
  98160. * @return The computed direction
  98161. */
  98162. setDirectionToTarget(target: Vector3): Vector3;
  98163. /**
  98164. * Returns the shadow generator associated to the light.
  98165. * @returns Always null for hemispheric lights because it does not support shadows.
  98166. */
  98167. getShadowGenerator(): Nullable<IShadowGenerator>;
  98168. /**
  98169. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  98170. * @param effect The effect to update
  98171. * @param lightIndex The index of the light in the effect to update
  98172. * @returns The hemispheric light
  98173. */
  98174. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  98175. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  98176. /**
  98177. * Computes the world matrix of the node
  98178. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  98179. * @param useWasUpdatedFlag defines a reserved property
  98180. * @returns the world matrix
  98181. */
  98182. computeWorldMatrix(): Matrix;
  98183. /**
  98184. * Returns the integer 3.
  98185. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98186. */
  98187. getTypeID(): number;
  98188. /**
  98189. * Prepares the list of defines specific to the light type.
  98190. * @param defines the list of defines
  98191. * @param lightIndex defines the index of the light for the effect
  98192. */
  98193. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98194. }
  98195. }
  98196. declare module BABYLON {
  98197. /** @hidden */
  98198. export var vrMultiviewToSingleviewPixelShader: {
  98199. name: string;
  98200. shader: string;
  98201. };
  98202. }
  98203. declare module BABYLON {
  98204. /**
  98205. * Renders to multiple views with a single draw call
  98206. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  98207. */
  98208. export class MultiviewRenderTarget extends RenderTargetTexture {
  98209. /**
  98210. * Creates a multiview render target
  98211. * @param scene scene used with the render target
  98212. * @param size the size of the render target (used for each view)
  98213. */
  98214. constructor(scene: Scene, size?: number | {
  98215. width: number;
  98216. height: number;
  98217. } | {
  98218. ratio: number;
  98219. });
  98220. /**
  98221. * @hidden
  98222. * @param faceIndex the face index, if its a cube texture
  98223. */
  98224. _bindFrameBuffer(faceIndex?: number): void;
  98225. /**
  98226. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  98227. * @returns the view count
  98228. */
  98229. getViewCount(): number;
  98230. }
  98231. }
  98232. declare module BABYLON {
  98233. interface Engine {
  98234. /**
  98235. * Creates a new multiview render target
  98236. * @param width defines the width of the texture
  98237. * @param height defines the height of the texture
  98238. * @returns the created multiview texture
  98239. */
  98240. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  98241. /**
  98242. * Binds a multiview framebuffer to be drawn to
  98243. * @param multiviewTexture texture to bind
  98244. */
  98245. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  98246. }
  98247. interface Camera {
  98248. /**
  98249. * @hidden
  98250. * 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)
  98251. */
  98252. _useMultiviewToSingleView: boolean;
  98253. /**
  98254. * @hidden
  98255. * 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)
  98256. */
  98257. _multiviewTexture: Nullable<RenderTargetTexture>;
  98258. /**
  98259. * @hidden
  98260. * ensures the multiview texture of the camera exists and has the specified width/height
  98261. * @param width height to set on the multiview texture
  98262. * @param height width to set on the multiview texture
  98263. */
  98264. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  98265. }
  98266. interface Scene {
  98267. /** @hidden */
  98268. _transformMatrixR: Matrix;
  98269. /** @hidden */
  98270. _multiviewSceneUbo: Nullable<UniformBuffer>;
  98271. /** @hidden */
  98272. _createMultiviewUbo(): void;
  98273. /** @hidden */
  98274. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  98275. /** @hidden */
  98276. _renderMultiviewToSingleView(camera: Camera): void;
  98277. }
  98278. }
  98279. declare module BABYLON {
  98280. /**
  98281. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  98282. * This will not be used for webXR as it supports displaying texture arrays directly
  98283. */
  98284. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  98285. /**
  98286. * Initializes a VRMultiviewToSingleview
  98287. * @param name name of the post process
  98288. * @param camera camera to be applied to
  98289. * @param scaleFactor scaling factor to the size of the output texture
  98290. */
  98291. constructor(name: string, camera: Camera, scaleFactor: number);
  98292. }
  98293. }
  98294. declare module BABYLON {
  98295. /**
  98296. * Interface used to define additional presentation attributes
  98297. */
  98298. export interface IVRPresentationAttributes {
  98299. /**
  98300. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  98301. */
  98302. highRefreshRate: boolean;
  98303. /**
  98304. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  98305. */
  98306. foveationLevel: number;
  98307. }
  98308. interface Engine {
  98309. /** @hidden */
  98310. _vrDisplay: any;
  98311. /** @hidden */
  98312. _vrSupported: boolean;
  98313. /** @hidden */
  98314. _oldSize: Size;
  98315. /** @hidden */
  98316. _oldHardwareScaleFactor: number;
  98317. /** @hidden */
  98318. _vrExclusivePointerMode: boolean;
  98319. /** @hidden */
  98320. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  98321. /** @hidden */
  98322. _onVRDisplayPointerRestricted: () => void;
  98323. /** @hidden */
  98324. _onVRDisplayPointerUnrestricted: () => void;
  98325. /** @hidden */
  98326. _onVrDisplayConnect: Nullable<(display: any) => void>;
  98327. /** @hidden */
  98328. _onVrDisplayDisconnect: Nullable<() => void>;
  98329. /** @hidden */
  98330. _onVrDisplayPresentChange: Nullable<() => void>;
  98331. /**
  98332. * Observable signaled when VR display mode changes
  98333. */
  98334. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  98335. /**
  98336. * Observable signaled when VR request present is complete
  98337. */
  98338. onVRRequestPresentComplete: Observable<boolean>;
  98339. /**
  98340. * Observable signaled when VR request present starts
  98341. */
  98342. onVRRequestPresentStart: Observable<Engine>;
  98343. /**
  98344. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  98345. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  98346. */
  98347. isInVRExclusivePointerMode: boolean;
  98348. /**
  98349. * Gets a boolean indicating if a webVR device was detected
  98350. * @returns true if a webVR device was detected
  98351. */
  98352. isVRDevicePresent(): boolean;
  98353. /**
  98354. * Gets the current webVR device
  98355. * @returns the current webVR device (or null)
  98356. */
  98357. getVRDevice(): any;
  98358. /**
  98359. * Initializes a webVR display and starts listening to display change events
  98360. * The onVRDisplayChangedObservable will be notified upon these changes
  98361. * @returns A promise containing a VRDisplay and if vr is supported
  98362. */
  98363. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  98364. /** @hidden */
  98365. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  98366. /**
  98367. * Gets or sets the presentation attributes used to configure VR rendering
  98368. */
  98369. vrPresentationAttributes?: IVRPresentationAttributes;
  98370. /**
  98371. * Call this function to switch to webVR mode
  98372. * Will do nothing if webVR is not supported or if there is no webVR device
  98373. * @param options the webvr options provided to the camera. mainly used for multiview
  98374. * @see https://doc.babylonjs.com/how_to/webvr_camera
  98375. */
  98376. enableVR(options: WebVROptions): void;
  98377. /** @hidden */
  98378. _onVRFullScreenTriggered(): void;
  98379. }
  98380. }
  98381. declare module BABYLON {
  98382. /**
  98383. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  98384. * IMPORTANT!! The data is right-hand data.
  98385. * @export
  98386. * @interface DevicePose
  98387. */
  98388. export interface DevicePose {
  98389. /**
  98390. * The position of the device, values in array are [x,y,z].
  98391. */
  98392. readonly position: Nullable<Float32Array>;
  98393. /**
  98394. * The linearVelocity of the device, values in array are [x,y,z].
  98395. */
  98396. readonly linearVelocity: Nullable<Float32Array>;
  98397. /**
  98398. * The linearAcceleration of the device, values in array are [x,y,z].
  98399. */
  98400. readonly linearAcceleration: Nullable<Float32Array>;
  98401. /**
  98402. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  98403. */
  98404. readonly orientation: Nullable<Float32Array>;
  98405. /**
  98406. * The angularVelocity of the device, values in array are [x,y,z].
  98407. */
  98408. readonly angularVelocity: Nullable<Float32Array>;
  98409. /**
  98410. * The angularAcceleration of the device, values in array are [x,y,z].
  98411. */
  98412. readonly angularAcceleration: Nullable<Float32Array>;
  98413. }
  98414. /**
  98415. * Interface representing a pose controlled object in Babylon.
  98416. * A pose controlled object has both regular pose values as well as pose values
  98417. * from an external device such as a VR head mounted display
  98418. */
  98419. export interface PoseControlled {
  98420. /**
  98421. * The position of the object in babylon space.
  98422. */
  98423. position: Vector3;
  98424. /**
  98425. * The rotation quaternion of the object in babylon space.
  98426. */
  98427. rotationQuaternion: Quaternion;
  98428. /**
  98429. * The position of the device in babylon space.
  98430. */
  98431. devicePosition?: Vector3;
  98432. /**
  98433. * The rotation quaternion of the device in babylon space.
  98434. */
  98435. deviceRotationQuaternion: Quaternion;
  98436. /**
  98437. * The raw pose coming from the device.
  98438. */
  98439. rawPose: Nullable<DevicePose>;
  98440. /**
  98441. * The scale of the device to be used when translating from device space to babylon space.
  98442. */
  98443. deviceScaleFactor: number;
  98444. /**
  98445. * Updates the poseControlled values based on the input device pose.
  98446. * @param poseData the pose data to update the object with
  98447. */
  98448. updateFromDevice(poseData: DevicePose): void;
  98449. }
  98450. /**
  98451. * Set of options to customize the webVRCamera
  98452. */
  98453. export interface WebVROptions {
  98454. /**
  98455. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  98456. */
  98457. trackPosition?: boolean;
  98458. /**
  98459. * Sets the scale of the vrDevice in babylon space. (default: 1)
  98460. */
  98461. positionScale?: number;
  98462. /**
  98463. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  98464. */
  98465. displayName?: string;
  98466. /**
  98467. * Should the native controller meshes be initialized. (default: true)
  98468. */
  98469. controllerMeshes?: boolean;
  98470. /**
  98471. * Creating a default HemiLight only on controllers. (default: true)
  98472. */
  98473. defaultLightingOnControllers?: boolean;
  98474. /**
  98475. * If you don't want to use the default VR button of the helper. (default: false)
  98476. */
  98477. useCustomVRButton?: boolean;
  98478. /**
  98479. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  98480. */
  98481. customVRButton?: HTMLButtonElement;
  98482. /**
  98483. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  98484. */
  98485. rayLength?: number;
  98486. /**
  98487. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  98488. */
  98489. defaultHeight?: number;
  98490. /**
  98491. * If multiview should be used if availible (default: false)
  98492. */
  98493. useMultiview?: boolean;
  98494. }
  98495. /**
  98496. * This represents a WebVR camera.
  98497. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  98498. * @example https://doc.babylonjs.com/how_to/webvr_camera
  98499. */
  98500. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  98501. private webVROptions;
  98502. /**
  98503. * @hidden
  98504. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  98505. */
  98506. _vrDevice: any;
  98507. /**
  98508. * The rawPose of the vrDevice.
  98509. */
  98510. rawPose: Nullable<DevicePose>;
  98511. private _onVREnabled;
  98512. private _specsVersion;
  98513. private _attached;
  98514. private _frameData;
  98515. protected _descendants: Array<Node>;
  98516. private _deviceRoomPosition;
  98517. /** @hidden */
  98518. _deviceRoomRotationQuaternion: Quaternion;
  98519. private _standingMatrix;
  98520. /**
  98521. * Represents device position in babylon space.
  98522. */
  98523. devicePosition: Vector3;
  98524. /**
  98525. * Represents device rotation in babylon space.
  98526. */
  98527. deviceRotationQuaternion: Quaternion;
  98528. /**
  98529. * The scale of the device to be used when translating from device space to babylon space.
  98530. */
  98531. deviceScaleFactor: number;
  98532. private _deviceToWorld;
  98533. private _worldToDevice;
  98534. /**
  98535. * References to the webVR controllers for the vrDevice.
  98536. */
  98537. controllers: Array<WebVRController>;
  98538. /**
  98539. * Emits an event when a controller is attached.
  98540. */
  98541. onControllersAttachedObservable: Observable<WebVRController[]>;
  98542. /**
  98543. * Emits an event when a controller's mesh has been loaded;
  98544. */
  98545. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98546. /**
  98547. * Emits an event when the HMD's pose has been updated.
  98548. */
  98549. onPoseUpdatedFromDeviceObservable: Observable<any>;
  98550. private _poseSet;
  98551. /**
  98552. * If the rig cameras be used as parent instead of this camera.
  98553. */
  98554. rigParenting: boolean;
  98555. private _lightOnControllers;
  98556. private _defaultHeight?;
  98557. /**
  98558. * Instantiates a WebVRFreeCamera.
  98559. * @param name The name of the WebVRFreeCamera
  98560. * @param position The starting anchor position for the camera
  98561. * @param scene The scene the camera belongs to
  98562. * @param webVROptions a set of customizable options for the webVRCamera
  98563. */
  98564. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  98565. /**
  98566. * Gets the device distance from the ground in meters.
  98567. * @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.
  98568. */
  98569. deviceDistanceToRoomGround(): number;
  98570. /**
  98571. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98572. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  98573. */
  98574. useStandingMatrix(callback?: (bool: boolean) => void): void;
  98575. /**
  98576. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98577. * @returns A promise with a boolean set to if the standing matrix is supported.
  98578. */
  98579. useStandingMatrixAsync(): Promise<boolean>;
  98580. /**
  98581. * Disposes the camera
  98582. */
  98583. dispose(): void;
  98584. /**
  98585. * Gets a vrController by name.
  98586. * @param name The name of the controller to retreive
  98587. * @returns the controller matching the name specified or null if not found
  98588. */
  98589. getControllerByName(name: string): Nullable<WebVRController>;
  98590. private _leftController;
  98591. /**
  98592. * The controller corresponding to the users left hand.
  98593. */
  98594. get leftController(): Nullable<WebVRController>;
  98595. private _rightController;
  98596. /**
  98597. * The controller corresponding to the users right hand.
  98598. */
  98599. get rightController(): Nullable<WebVRController>;
  98600. /**
  98601. * Casts a ray forward from the vrCamera's gaze.
  98602. * @param length Length of the ray (default: 100)
  98603. * @returns the ray corresponding to the gaze
  98604. */
  98605. getForwardRay(length?: number): Ray;
  98606. /**
  98607. * @hidden
  98608. * Updates the camera based on device's frame data
  98609. */
  98610. _checkInputs(): void;
  98611. /**
  98612. * Updates the poseControlled values based on the input device pose.
  98613. * @param poseData Pose coming from the device
  98614. */
  98615. updateFromDevice(poseData: DevicePose): void;
  98616. private _htmlElementAttached;
  98617. private _detachIfAttached;
  98618. /**
  98619. * WebVR's attach control will start broadcasting frames to the device.
  98620. * Note that in certain browsers (chrome for example) this function must be called
  98621. * within a user-interaction callback. Example:
  98622. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  98623. *
  98624. * @param element html element to attach the vrDevice to
  98625. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  98626. */
  98627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98628. /**
  98629. * Detaches the camera from the html element and disables VR
  98630. *
  98631. * @param element html element to detach from
  98632. */
  98633. detachControl(element: HTMLElement): void;
  98634. /**
  98635. * @returns the name of this class
  98636. */
  98637. getClassName(): string;
  98638. /**
  98639. * Calls resetPose on the vrDisplay
  98640. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  98641. */
  98642. resetToCurrentRotation(): void;
  98643. /**
  98644. * @hidden
  98645. * Updates the rig cameras (left and right eye)
  98646. */
  98647. _updateRigCameras(): void;
  98648. private _workingVector;
  98649. private _oneVector;
  98650. private _workingMatrix;
  98651. private updateCacheCalled;
  98652. private _correctPositionIfNotTrackPosition;
  98653. /**
  98654. * @hidden
  98655. * Updates the cached values of the camera
  98656. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  98657. */
  98658. _updateCache(ignoreParentClass?: boolean): void;
  98659. /**
  98660. * @hidden
  98661. * Get current device position in babylon world
  98662. */
  98663. _computeDevicePosition(): void;
  98664. /**
  98665. * Updates the current device position and rotation in the babylon world
  98666. */
  98667. update(): void;
  98668. /**
  98669. * @hidden
  98670. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  98671. * @returns an identity matrix
  98672. */
  98673. _getViewMatrix(): Matrix;
  98674. private _tmpMatrix;
  98675. /**
  98676. * This function is called by the two RIG cameras.
  98677. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  98678. * @hidden
  98679. */
  98680. _getWebVRViewMatrix(): Matrix;
  98681. /** @hidden */
  98682. _getWebVRProjectionMatrix(): Matrix;
  98683. private _onGamepadConnectedObserver;
  98684. private _onGamepadDisconnectedObserver;
  98685. private _updateCacheWhenTrackingDisabledObserver;
  98686. /**
  98687. * Initializes the controllers and their meshes
  98688. */
  98689. initControllers(): void;
  98690. }
  98691. }
  98692. declare module BABYLON {
  98693. /**
  98694. * "Static Class" containing the most commonly used helper while dealing with material for
  98695. * rendering purpose.
  98696. *
  98697. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  98698. *
  98699. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  98700. */
  98701. export class MaterialHelper {
  98702. /**
  98703. * Bind the current view position to an effect.
  98704. * @param effect The effect to be bound
  98705. * @param scene The scene the eyes position is used from
  98706. * @param variableName name of the shader variable that will hold the eye position
  98707. */
  98708. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  98709. /**
  98710. * Helps preparing the defines values about the UVs in used in the effect.
  98711. * UVs are shared as much as we can accross channels in the shaders.
  98712. * @param texture The texture we are preparing the UVs for
  98713. * @param defines The defines to update
  98714. * @param key The channel key "diffuse", "specular"... used in the shader
  98715. */
  98716. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  98717. /**
  98718. * Binds a texture matrix value to its corrsponding uniform
  98719. * @param texture The texture to bind the matrix for
  98720. * @param uniformBuffer The uniform buffer receivin the data
  98721. * @param key The channel key "diffuse", "specular"... used in the shader
  98722. */
  98723. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  98724. /**
  98725. * Gets the current status of the fog (should it be enabled?)
  98726. * @param mesh defines the mesh to evaluate for fog support
  98727. * @param scene defines the hosting scene
  98728. * @returns true if fog must be enabled
  98729. */
  98730. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  98731. /**
  98732. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  98733. * @param mesh defines the current mesh
  98734. * @param scene defines the current scene
  98735. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  98736. * @param pointsCloud defines if point cloud rendering has to be turned on
  98737. * @param fogEnabled defines if fog has to be turned on
  98738. * @param alphaTest defines if alpha testing has to be turned on
  98739. * @param defines defines the current list of defines
  98740. */
  98741. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  98742. /**
  98743. * Helper used to prepare the list of defines associated with frame values for shader compilation
  98744. * @param scene defines the current scene
  98745. * @param engine defines the current engine
  98746. * @param defines specifies the list of active defines
  98747. * @param useInstances defines if instances have to be turned on
  98748. * @param useClipPlane defines if clip plane have to be turned on
  98749. * @param useInstances defines if instances have to be turned on
  98750. * @param useThinInstances defines if thin instances have to be turned on
  98751. */
  98752. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  98753. /**
  98754. * Prepares the defines for bones
  98755. * @param mesh The mesh containing the geometry data we will draw
  98756. * @param defines The defines to update
  98757. */
  98758. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  98759. /**
  98760. * Prepares the defines for morph targets
  98761. * @param mesh The mesh containing the geometry data we will draw
  98762. * @param defines The defines to update
  98763. */
  98764. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  98765. /**
  98766. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  98767. * @param mesh The mesh containing the geometry data we will draw
  98768. * @param defines The defines to update
  98769. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  98770. * @param useBones Precise whether bones should be used or not (override mesh info)
  98771. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  98772. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  98773. * @returns false if defines are considered not dirty and have not been checked
  98774. */
  98775. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  98776. /**
  98777. * Prepares the defines related to multiview
  98778. * @param scene The scene we are intending to draw
  98779. * @param defines The defines to update
  98780. */
  98781. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  98782. /**
  98783. * Prepares the defines related to the prepass
  98784. * @param scene The scene we are intending to draw
  98785. * @param defines The defines to update
  98786. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  98787. */
  98788. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  98789. /**
  98790. * Prepares the defines related to the light information passed in parameter
  98791. * @param scene The scene we are intending to draw
  98792. * @param mesh The mesh the effect is compiling for
  98793. * @param light The light the effect is compiling for
  98794. * @param lightIndex The index of the light
  98795. * @param defines The defines to update
  98796. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98797. * @param state Defines the current state regarding what is needed (normals, etc...)
  98798. */
  98799. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  98800. needNormals: boolean;
  98801. needRebuild: boolean;
  98802. shadowEnabled: boolean;
  98803. specularEnabled: boolean;
  98804. lightmapMode: boolean;
  98805. }): void;
  98806. /**
  98807. * Prepares the defines related to the light information passed in parameter
  98808. * @param scene The scene we are intending to draw
  98809. * @param mesh The mesh the effect is compiling for
  98810. * @param defines The defines to update
  98811. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98812. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  98813. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  98814. * @returns true if normals will be required for the rest of the effect
  98815. */
  98816. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  98817. /**
  98818. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  98819. * @param lightIndex defines the light index
  98820. * @param uniformsList The uniform list
  98821. * @param samplersList The sampler list
  98822. * @param projectedLightTexture defines if projected texture must be used
  98823. * @param uniformBuffersList defines an optional list of uniform buffers
  98824. */
  98825. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  98826. /**
  98827. * Prepares the uniforms and samplers list to be used in the effect
  98828. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  98829. * @param samplersList The sampler list
  98830. * @param defines The defines helping in the list generation
  98831. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  98832. */
  98833. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  98834. /**
  98835. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  98836. * @param defines The defines to update while falling back
  98837. * @param fallbacks The authorized effect fallbacks
  98838. * @param maxSimultaneousLights The maximum number of lights allowed
  98839. * @param rank the current rank of the Effect
  98840. * @returns The newly affected rank
  98841. */
  98842. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  98843. private static _TmpMorphInfluencers;
  98844. /**
  98845. * Prepares the list of attributes required for morph targets according to the effect defines.
  98846. * @param attribs The current list of supported attribs
  98847. * @param mesh The mesh to prepare the morph targets attributes for
  98848. * @param influencers The number of influencers
  98849. */
  98850. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  98851. /**
  98852. * Prepares the list of attributes required for morph targets according to the effect defines.
  98853. * @param attribs The current list of supported attribs
  98854. * @param mesh The mesh to prepare the morph targets attributes for
  98855. * @param defines The current Defines of the effect
  98856. */
  98857. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  98858. /**
  98859. * Prepares the list of attributes required for bones according to the effect defines.
  98860. * @param attribs The current list of supported attribs
  98861. * @param mesh The mesh to prepare the bones attributes for
  98862. * @param defines The current Defines of the effect
  98863. * @param fallbacks The current efffect fallback strategy
  98864. */
  98865. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  98866. /**
  98867. * Check and prepare the list of attributes required for instances according to the effect defines.
  98868. * @param attribs The current list of supported attribs
  98869. * @param defines The current MaterialDefines of the effect
  98870. */
  98871. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  98872. /**
  98873. * Add the list of attributes required for instances to the attribs array.
  98874. * @param attribs The current list of supported attribs
  98875. */
  98876. static PushAttributesForInstances(attribs: string[]): void;
  98877. /**
  98878. * Binds the light information to the effect.
  98879. * @param light The light containing the generator
  98880. * @param effect The effect we are binding the data to
  98881. * @param lightIndex The light index in the effect used to render
  98882. */
  98883. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  98884. /**
  98885. * Binds the lights information from the scene to the effect for the given mesh.
  98886. * @param light Light to bind
  98887. * @param lightIndex Light index
  98888. * @param scene The scene where the light belongs to
  98889. * @param effect The effect we are binding the data to
  98890. * @param useSpecular Defines if specular is supported
  98891. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98892. */
  98893. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98894. /**
  98895. * Binds the lights information from the scene to the effect for the given mesh.
  98896. * @param scene The scene the lights belongs to
  98897. * @param mesh The mesh we are binding the information to render
  98898. * @param effect The effect we are binding the data to
  98899. * @param defines The generated defines for the effect
  98900. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  98901. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98902. */
  98903. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  98904. private static _tempFogColor;
  98905. /**
  98906. * Binds the fog information from the scene to the effect for the given mesh.
  98907. * @param scene The scene the lights belongs to
  98908. * @param mesh The mesh we are binding the information to render
  98909. * @param effect The effect we are binding the data to
  98910. * @param linearSpace Defines if the fog effect is applied in linear space
  98911. */
  98912. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  98913. /**
  98914. * Binds the bones information from the mesh to the effect.
  98915. * @param mesh The mesh we are binding the information to render
  98916. * @param effect The effect we are binding the data to
  98917. */
  98918. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  98919. /**
  98920. * Binds the morph targets information from the mesh to the effect.
  98921. * @param abstractMesh The mesh we are binding the information to render
  98922. * @param effect The effect we are binding the data to
  98923. */
  98924. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  98925. /**
  98926. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  98927. * @param defines The generated defines used in the effect
  98928. * @param effect The effect we are binding the data to
  98929. * @param scene The scene we are willing to render with logarithmic scale for
  98930. */
  98931. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  98932. /**
  98933. * Binds the clip plane information from the scene to the effect.
  98934. * @param scene The scene the clip plane information are extracted from
  98935. * @param effect The effect we are binding the data to
  98936. */
  98937. static BindClipPlane(effect: Effect, scene: Scene): void;
  98938. }
  98939. }
  98940. declare module BABYLON {
  98941. /**
  98942. * Block used to expose an input value
  98943. */
  98944. export class InputBlock extends NodeMaterialBlock {
  98945. private _mode;
  98946. private _associatedVariableName;
  98947. private _storedValue;
  98948. private _valueCallback;
  98949. private _type;
  98950. private _animationType;
  98951. /** Gets or set a value used to limit the range of float values */
  98952. min: number;
  98953. /** Gets or set a value used to limit the range of float values */
  98954. max: number;
  98955. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  98956. isBoolean: boolean;
  98957. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  98958. matrixMode: number;
  98959. /** @hidden */
  98960. _systemValue: Nullable<NodeMaterialSystemValues>;
  98961. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  98962. visibleInInspector: boolean;
  98963. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  98964. isConstant: boolean;
  98965. /** Gets or sets the group to use to display this block in the Inspector */
  98966. groupInInspector: string;
  98967. /** Gets an observable raised when the value is changed */
  98968. onValueChangedObservable: Observable<InputBlock>;
  98969. /**
  98970. * Gets or sets the connection point type (default is float)
  98971. */
  98972. get type(): NodeMaterialBlockConnectionPointTypes;
  98973. /**
  98974. * Creates a new InputBlock
  98975. * @param name defines the block name
  98976. * @param target defines the target of that block (Vertex by default)
  98977. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  98978. */
  98979. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  98980. /**
  98981. * Validates if a name is a reserve word.
  98982. * @param newName the new name to be given to the node.
  98983. * @returns false if the name is a reserve word, else true.
  98984. */
  98985. validateBlockName(newName: string): boolean;
  98986. /**
  98987. * Gets the output component
  98988. */
  98989. get output(): NodeMaterialConnectionPoint;
  98990. /**
  98991. * Set the source of this connection point to a vertex attribute
  98992. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  98993. * @returns the current connection point
  98994. */
  98995. setAsAttribute(attributeName?: string): InputBlock;
  98996. /**
  98997. * Set the source of this connection point to a system value
  98998. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  98999. * @returns the current connection point
  99000. */
  99001. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  99002. /**
  99003. * Gets or sets the value of that point.
  99004. * Please note that this value will be ignored if valueCallback is defined
  99005. */
  99006. get value(): any;
  99007. set value(value: any);
  99008. /**
  99009. * Gets or sets a callback used to get the value of that point.
  99010. * Please note that setting this value will force the connection point to ignore the value property
  99011. */
  99012. get valueCallback(): () => any;
  99013. set valueCallback(value: () => any);
  99014. /**
  99015. * Gets or sets the associated variable name in the shader
  99016. */
  99017. get associatedVariableName(): string;
  99018. set associatedVariableName(value: string);
  99019. /** Gets or sets the type of animation applied to the input */
  99020. get animationType(): AnimatedInputBlockTypes;
  99021. set animationType(value: AnimatedInputBlockTypes);
  99022. /**
  99023. * Gets a boolean indicating that this connection point not defined yet
  99024. */
  99025. get isUndefined(): boolean;
  99026. /**
  99027. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  99028. * In this case the connection point name must be the name of the uniform to use.
  99029. * Can only be set on inputs
  99030. */
  99031. get isUniform(): boolean;
  99032. set isUniform(value: boolean);
  99033. /**
  99034. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  99035. * In this case the connection point name must be the name of the attribute to use
  99036. * Can only be set on inputs
  99037. */
  99038. get isAttribute(): boolean;
  99039. set isAttribute(value: boolean);
  99040. /**
  99041. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  99042. * Can only be set on exit points
  99043. */
  99044. get isVarying(): boolean;
  99045. set isVarying(value: boolean);
  99046. /**
  99047. * Gets a boolean indicating that the current connection point is a system value
  99048. */
  99049. get isSystemValue(): boolean;
  99050. /**
  99051. * Gets or sets the current well known value or null if not defined as a system value
  99052. */
  99053. get systemValue(): Nullable<NodeMaterialSystemValues>;
  99054. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  99055. /**
  99056. * Gets the current class name
  99057. * @returns the class name
  99058. */
  99059. getClassName(): string;
  99060. /**
  99061. * Animate the input if animationType !== None
  99062. * @param scene defines the rendering scene
  99063. */
  99064. animate(scene: Scene): void;
  99065. private _emitDefine;
  99066. initialize(state: NodeMaterialBuildState): void;
  99067. /**
  99068. * Set the input block to its default value (based on its type)
  99069. */
  99070. setDefaultValue(): void;
  99071. private _emitConstant;
  99072. /** @hidden */
  99073. get _noContextSwitch(): boolean;
  99074. private _emit;
  99075. /** @hidden */
  99076. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  99077. /** @hidden */
  99078. _transmit(effect: Effect, scene: Scene): void;
  99079. protected _buildBlock(state: NodeMaterialBuildState): void;
  99080. protected _dumpPropertiesCode(): string;
  99081. dispose(): void;
  99082. serialize(): any;
  99083. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99084. }
  99085. }
  99086. declare module BABYLON {
  99087. /**
  99088. * Enum used to define the compatibility state between two connection points
  99089. */
  99090. export enum NodeMaterialConnectionPointCompatibilityStates {
  99091. /** Points are compatibles */
  99092. Compatible = 0,
  99093. /** Points are incompatible because of their types */
  99094. TypeIncompatible = 1,
  99095. /** Points are incompatible because of their targets (vertex vs fragment) */
  99096. TargetIncompatible = 2
  99097. }
  99098. /**
  99099. * Defines the direction of a connection point
  99100. */
  99101. export enum NodeMaterialConnectionPointDirection {
  99102. /** Input */
  99103. Input = 0,
  99104. /** Output */
  99105. Output = 1
  99106. }
  99107. /**
  99108. * Defines a connection point for a block
  99109. */
  99110. export class NodeMaterialConnectionPoint {
  99111. /** @hidden */
  99112. _ownerBlock: NodeMaterialBlock;
  99113. /** @hidden */
  99114. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  99115. private _endpoints;
  99116. private _associatedVariableName;
  99117. private _direction;
  99118. /** @hidden */
  99119. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  99120. /** @hidden */
  99121. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  99122. private _type;
  99123. /** @hidden */
  99124. _enforceAssociatedVariableName: boolean;
  99125. /** Gets the direction of the point */
  99126. get direction(): NodeMaterialConnectionPointDirection;
  99127. /** Indicates that this connection point needs dual validation before being connected to another point */
  99128. needDualDirectionValidation: boolean;
  99129. /**
  99130. * Gets or sets the additional types supported by this connection point
  99131. */
  99132. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  99133. /**
  99134. * Gets or sets the additional types excluded by this connection point
  99135. */
  99136. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  99137. /**
  99138. * Observable triggered when this point is connected
  99139. */
  99140. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  99141. /**
  99142. * Gets or sets the associated variable name in the shader
  99143. */
  99144. get associatedVariableName(): string;
  99145. set associatedVariableName(value: string);
  99146. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  99147. get innerType(): NodeMaterialBlockConnectionPointTypes;
  99148. /**
  99149. * Gets or sets the connection point type (default is float)
  99150. */
  99151. get type(): NodeMaterialBlockConnectionPointTypes;
  99152. set type(value: NodeMaterialBlockConnectionPointTypes);
  99153. /**
  99154. * Gets or sets the connection point name
  99155. */
  99156. name: string;
  99157. /**
  99158. * Gets or sets the connection point name
  99159. */
  99160. displayName: string;
  99161. /**
  99162. * Gets or sets a boolean indicating that this connection point can be omitted
  99163. */
  99164. isOptional: boolean;
  99165. /**
  99166. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  99167. */
  99168. isExposedOnFrame: boolean;
  99169. /**
  99170. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  99171. */
  99172. define: string;
  99173. /** @hidden */
  99174. _prioritizeVertex: boolean;
  99175. private _target;
  99176. /** Gets or sets the target of that connection point */
  99177. get target(): NodeMaterialBlockTargets;
  99178. set target(value: NodeMaterialBlockTargets);
  99179. /**
  99180. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  99181. */
  99182. get isConnected(): boolean;
  99183. /**
  99184. * Gets a boolean indicating that the current point is connected to an input block
  99185. */
  99186. get isConnectedToInputBlock(): boolean;
  99187. /**
  99188. * Gets a the connected input block (if any)
  99189. */
  99190. get connectInputBlock(): Nullable<InputBlock>;
  99191. /** Get the other side of the connection (if any) */
  99192. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  99193. /** Get the block that owns this connection point */
  99194. get ownerBlock(): NodeMaterialBlock;
  99195. /** Get the block connected on the other side of this connection (if any) */
  99196. get sourceBlock(): Nullable<NodeMaterialBlock>;
  99197. /** Get the block connected on the endpoints of this connection (if any) */
  99198. get connectedBlocks(): Array<NodeMaterialBlock>;
  99199. /** Gets the list of connected endpoints */
  99200. get endpoints(): NodeMaterialConnectionPoint[];
  99201. /** Gets a boolean indicating if that output point is connected to at least one input */
  99202. get hasEndpoints(): boolean;
  99203. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  99204. get isConnectedInVertexShader(): boolean;
  99205. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  99206. get isConnectedInFragmentShader(): boolean;
  99207. /**
  99208. * Creates a block suitable to be used as an input for this input point.
  99209. * If null is returned, a block based on the point type will be created.
  99210. * @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
  99211. */
  99212. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99213. /**
  99214. * Creates a new connection point
  99215. * @param name defines the connection point name
  99216. * @param ownerBlock defines the block hosting this connection point
  99217. * @param direction defines the direction of the connection point
  99218. */
  99219. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  99220. /**
  99221. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  99222. * @returns the class name
  99223. */
  99224. getClassName(): string;
  99225. /**
  99226. * Gets a boolean indicating if the current point can be connected to another point
  99227. * @param connectionPoint defines the other connection point
  99228. * @returns a boolean
  99229. */
  99230. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  99231. /**
  99232. * Gets a number indicating if the current point can be connected to another point
  99233. * @param connectionPoint defines the other connection point
  99234. * @returns a number defining the compatibility state
  99235. */
  99236. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  99237. /**
  99238. * Connect this point to another connection point
  99239. * @param connectionPoint defines the other connection point
  99240. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  99241. * @returns the current connection point
  99242. */
  99243. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  99244. /**
  99245. * Disconnect this point from one of his endpoint
  99246. * @param endpoint defines the other connection point
  99247. * @returns the current connection point
  99248. */
  99249. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  99250. /**
  99251. * Serializes this point in a JSON representation
  99252. * @param isInput defines if the connection point is an input (default is true)
  99253. * @returns the serialized point object
  99254. */
  99255. serialize(isInput?: boolean): any;
  99256. /**
  99257. * Release resources
  99258. */
  99259. dispose(): void;
  99260. }
  99261. }
  99262. declare module BABYLON {
  99263. /**
  99264. * Enum used to define the material modes
  99265. */
  99266. export enum NodeMaterialModes {
  99267. /** Regular material */
  99268. Material = 0,
  99269. /** For post process */
  99270. PostProcess = 1,
  99271. /** For particle system */
  99272. Particle = 2
  99273. }
  99274. }
  99275. declare module BABYLON {
  99276. /**
  99277. * Block used to read a texture from a sampler
  99278. */
  99279. export class TextureBlock extends NodeMaterialBlock {
  99280. private _defineName;
  99281. private _linearDefineName;
  99282. private _gammaDefineName;
  99283. private _tempTextureRead;
  99284. private _samplerName;
  99285. private _transformedUVName;
  99286. private _textureTransformName;
  99287. private _textureInfoName;
  99288. private _mainUVName;
  99289. private _mainUVDefineName;
  99290. private _fragmentOnly;
  99291. /**
  99292. * Gets or sets the texture associated with the node
  99293. */
  99294. texture: Nullable<Texture>;
  99295. /**
  99296. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99297. */
  99298. convertToGammaSpace: boolean;
  99299. /**
  99300. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99301. */
  99302. convertToLinearSpace: boolean;
  99303. /**
  99304. * Create a new TextureBlock
  99305. * @param name defines the block name
  99306. */
  99307. constructor(name: string, fragmentOnly?: boolean);
  99308. /**
  99309. * Gets the current class name
  99310. * @returns the class name
  99311. */
  99312. getClassName(): string;
  99313. /**
  99314. * Gets the uv input component
  99315. */
  99316. get uv(): NodeMaterialConnectionPoint;
  99317. /**
  99318. * Gets the rgba output component
  99319. */
  99320. get rgba(): NodeMaterialConnectionPoint;
  99321. /**
  99322. * Gets the rgb output component
  99323. */
  99324. get rgb(): NodeMaterialConnectionPoint;
  99325. /**
  99326. * Gets the r output component
  99327. */
  99328. get r(): NodeMaterialConnectionPoint;
  99329. /**
  99330. * Gets the g output component
  99331. */
  99332. get g(): NodeMaterialConnectionPoint;
  99333. /**
  99334. * Gets the b output component
  99335. */
  99336. get b(): NodeMaterialConnectionPoint;
  99337. /**
  99338. * Gets the a output component
  99339. */
  99340. get a(): NodeMaterialConnectionPoint;
  99341. get target(): NodeMaterialBlockTargets;
  99342. autoConfigure(material: NodeMaterial): void;
  99343. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99344. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99345. isReady(): boolean;
  99346. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  99347. private get _isMixed();
  99348. private _injectVertexCode;
  99349. private _writeTextureRead;
  99350. private _writeOutput;
  99351. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99352. protected _dumpPropertiesCode(): string;
  99353. serialize(): any;
  99354. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99355. }
  99356. }
  99357. declare module BABYLON {
  99358. /** @hidden */
  99359. export var reflectionFunction: {
  99360. name: string;
  99361. shader: string;
  99362. };
  99363. }
  99364. declare module BABYLON {
  99365. /**
  99366. * Base block used to read a reflection texture from a sampler
  99367. */
  99368. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  99369. /** @hidden */
  99370. _define3DName: string;
  99371. /** @hidden */
  99372. _defineCubicName: string;
  99373. /** @hidden */
  99374. _defineExplicitName: string;
  99375. /** @hidden */
  99376. _defineProjectionName: string;
  99377. /** @hidden */
  99378. _defineLocalCubicName: string;
  99379. /** @hidden */
  99380. _defineSphericalName: string;
  99381. /** @hidden */
  99382. _definePlanarName: string;
  99383. /** @hidden */
  99384. _defineEquirectangularName: string;
  99385. /** @hidden */
  99386. _defineMirroredEquirectangularFixedName: string;
  99387. /** @hidden */
  99388. _defineEquirectangularFixedName: string;
  99389. /** @hidden */
  99390. _defineSkyboxName: string;
  99391. /** @hidden */
  99392. _defineOppositeZ: string;
  99393. /** @hidden */
  99394. _cubeSamplerName: string;
  99395. /** @hidden */
  99396. _2DSamplerName: string;
  99397. protected _positionUVWName: string;
  99398. protected _directionWName: string;
  99399. protected _reflectionVectorName: string;
  99400. /** @hidden */
  99401. _reflectionCoordsName: string;
  99402. /** @hidden */
  99403. _reflectionMatrixName: string;
  99404. protected _reflectionColorName: string;
  99405. /**
  99406. * Gets or sets the texture associated with the node
  99407. */
  99408. texture: Nullable<BaseTexture>;
  99409. /**
  99410. * Create a new ReflectionTextureBaseBlock
  99411. * @param name defines the block name
  99412. */
  99413. constructor(name: string);
  99414. /**
  99415. * Gets the current class name
  99416. * @returns the class name
  99417. */
  99418. getClassName(): string;
  99419. /**
  99420. * Gets the world position input component
  99421. */
  99422. abstract get position(): NodeMaterialConnectionPoint;
  99423. /**
  99424. * Gets the world position input component
  99425. */
  99426. abstract get worldPosition(): NodeMaterialConnectionPoint;
  99427. /**
  99428. * Gets the world normal input component
  99429. */
  99430. abstract get worldNormal(): NodeMaterialConnectionPoint;
  99431. /**
  99432. * Gets the world input component
  99433. */
  99434. abstract get world(): NodeMaterialConnectionPoint;
  99435. /**
  99436. * Gets the camera (or eye) position component
  99437. */
  99438. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  99439. /**
  99440. * Gets the view input component
  99441. */
  99442. abstract get view(): NodeMaterialConnectionPoint;
  99443. protected _getTexture(): Nullable<BaseTexture>;
  99444. autoConfigure(material: NodeMaterial): void;
  99445. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99446. isReady(): boolean;
  99447. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  99448. /**
  99449. * Gets the code to inject in the vertex shader
  99450. * @param state current state of the node material building
  99451. * @returns the shader code
  99452. */
  99453. handleVertexSide(state: NodeMaterialBuildState): string;
  99454. /**
  99455. * Handles the inits for the fragment code path
  99456. * @param state node material build state
  99457. */
  99458. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  99459. /**
  99460. * Generates the reflection coords code for the fragment code path
  99461. * @param worldNormalVarName name of the world normal variable
  99462. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  99463. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  99464. * @returns the shader code
  99465. */
  99466. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  99467. /**
  99468. * Generates the reflection color code for the fragment code path
  99469. * @param lodVarName name of the lod variable
  99470. * @param swizzleLookupTexture swizzle to use for the final color variable
  99471. * @returns the shader code
  99472. */
  99473. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  99474. /**
  99475. * Generates the code corresponding to the connected output points
  99476. * @param state node material build state
  99477. * @param varName name of the variable to output
  99478. * @returns the shader code
  99479. */
  99480. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  99481. protected _buildBlock(state: NodeMaterialBuildState): this;
  99482. protected _dumpPropertiesCode(): string;
  99483. serialize(): any;
  99484. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99485. }
  99486. }
  99487. declare module BABYLON {
  99488. /**
  99489. * Defines a connection point to be used for points with a custom object type
  99490. */
  99491. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  99492. private _blockType;
  99493. private _blockName;
  99494. private _nameForCheking?;
  99495. /**
  99496. * Creates a new connection point
  99497. * @param name defines the connection point name
  99498. * @param ownerBlock defines the block hosting this connection point
  99499. * @param direction defines the direction of the connection point
  99500. */
  99501. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  99502. /**
  99503. * Gets a number indicating if the current point can be connected to another point
  99504. * @param connectionPoint defines the other connection point
  99505. * @returns a number defining the compatibility state
  99506. */
  99507. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  99508. /**
  99509. * Creates a block suitable to be used as an input for this input point.
  99510. * If null is returned, a block based on the point type will be created.
  99511. * @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
  99512. */
  99513. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99514. }
  99515. }
  99516. declare module BABYLON {
  99517. /**
  99518. * Enum defining the type of properties that can be edited in the property pages in the NME
  99519. */
  99520. export enum PropertyTypeForEdition {
  99521. /** property is a boolean */
  99522. Boolean = 0,
  99523. /** property is a float */
  99524. Float = 1,
  99525. /** property is a Vector2 */
  99526. Vector2 = 2,
  99527. /** property is a list of values */
  99528. List = 3
  99529. }
  99530. /**
  99531. * Interface that defines an option in a variable of type list
  99532. */
  99533. export interface IEditablePropertyListOption {
  99534. /** label of the option */
  99535. "label": string;
  99536. /** value of the option */
  99537. "value": number;
  99538. }
  99539. /**
  99540. * Interface that defines the options available for an editable property
  99541. */
  99542. export interface IEditablePropertyOption {
  99543. /** min value */
  99544. "min"?: number;
  99545. /** max value */
  99546. "max"?: number;
  99547. /** notifiers: indicates which actions to take when the property is changed */
  99548. "notifiers"?: {
  99549. /** the material should be rebuilt */
  99550. "rebuild"?: boolean;
  99551. /** the preview should be updated */
  99552. "update"?: boolean;
  99553. };
  99554. /** list of the options for a variable of type list */
  99555. "options"?: IEditablePropertyListOption[];
  99556. }
  99557. /**
  99558. * Interface that describes an editable property
  99559. */
  99560. export interface IPropertyDescriptionForEdition {
  99561. /** name of the property */
  99562. "propertyName": string;
  99563. /** display name of the property */
  99564. "displayName": string;
  99565. /** type of the property */
  99566. "type": PropertyTypeForEdition;
  99567. /** group of the property - all properties with the same group value will be displayed in a specific section */
  99568. "groupName": string;
  99569. /** options for the property */
  99570. "options": IEditablePropertyOption;
  99571. }
  99572. /**
  99573. * Decorator that flags a property in a node material block as being editable
  99574. */
  99575. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  99576. }
  99577. declare module BABYLON {
  99578. /**
  99579. * Block used to implement the refraction part of the sub surface module of the PBR material
  99580. */
  99581. export class RefractionBlock extends NodeMaterialBlock {
  99582. /** @hidden */
  99583. _define3DName: string;
  99584. /** @hidden */
  99585. _refractionMatrixName: string;
  99586. /** @hidden */
  99587. _defineLODRefractionAlpha: string;
  99588. /** @hidden */
  99589. _defineLinearSpecularRefraction: string;
  99590. /** @hidden */
  99591. _defineOppositeZ: string;
  99592. /** @hidden */
  99593. _cubeSamplerName: string;
  99594. /** @hidden */
  99595. _2DSamplerName: string;
  99596. /** @hidden */
  99597. _vRefractionMicrosurfaceInfosName: string;
  99598. /** @hidden */
  99599. _vRefractionInfosName: string;
  99600. private _scene;
  99601. /**
  99602. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99603. * Materials half opaque for instance using refraction could benefit from this control.
  99604. */
  99605. linkRefractionWithTransparency: boolean;
  99606. /**
  99607. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99608. */
  99609. invertRefractionY: boolean;
  99610. /**
  99611. * Gets or sets the texture associated with the node
  99612. */
  99613. texture: Nullable<BaseTexture>;
  99614. /**
  99615. * Create a new RefractionBlock
  99616. * @param name defines the block name
  99617. */
  99618. constructor(name: string);
  99619. /**
  99620. * Gets the current class name
  99621. * @returns the class name
  99622. */
  99623. getClassName(): string;
  99624. /**
  99625. * Gets the intensity input component
  99626. */
  99627. get intensity(): NodeMaterialConnectionPoint;
  99628. /**
  99629. * Gets the index of refraction input component
  99630. */
  99631. get indexOfRefraction(): NodeMaterialConnectionPoint;
  99632. /**
  99633. * Gets the tint at distance input component
  99634. */
  99635. get tintAtDistance(): NodeMaterialConnectionPoint;
  99636. /**
  99637. * Gets the view input component
  99638. */
  99639. get view(): NodeMaterialConnectionPoint;
  99640. /**
  99641. * Gets the refraction object output component
  99642. */
  99643. get refraction(): NodeMaterialConnectionPoint;
  99644. /**
  99645. * Returns true if the block has a texture
  99646. */
  99647. get hasTexture(): boolean;
  99648. protected _getTexture(): Nullable<BaseTexture>;
  99649. autoConfigure(material: NodeMaterial): void;
  99650. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99651. isReady(): boolean;
  99652. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99653. /**
  99654. * Gets the main code of the block (fragment side)
  99655. * @param state current state of the node material building
  99656. * @returns the shader code
  99657. */
  99658. getCode(state: NodeMaterialBuildState): string;
  99659. protected _buildBlock(state: NodeMaterialBuildState): this;
  99660. protected _dumpPropertiesCode(): string;
  99661. serialize(): any;
  99662. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99663. }
  99664. }
  99665. declare module BABYLON {
  99666. /**
  99667. * Base block used as input for post process
  99668. */
  99669. export class CurrentScreenBlock extends NodeMaterialBlock {
  99670. private _samplerName;
  99671. private _linearDefineName;
  99672. private _gammaDefineName;
  99673. private _mainUVName;
  99674. private _tempTextureRead;
  99675. /**
  99676. * Gets or sets the texture associated with the node
  99677. */
  99678. texture: Nullable<BaseTexture>;
  99679. /**
  99680. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99681. */
  99682. convertToGammaSpace: boolean;
  99683. /**
  99684. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99685. */
  99686. convertToLinearSpace: boolean;
  99687. /**
  99688. * Create a new CurrentScreenBlock
  99689. * @param name defines the block name
  99690. */
  99691. constructor(name: string);
  99692. /**
  99693. * Gets the current class name
  99694. * @returns the class name
  99695. */
  99696. getClassName(): string;
  99697. /**
  99698. * Gets the uv input component
  99699. */
  99700. get uv(): NodeMaterialConnectionPoint;
  99701. /**
  99702. * Gets the rgba output component
  99703. */
  99704. get rgba(): NodeMaterialConnectionPoint;
  99705. /**
  99706. * Gets the rgb output component
  99707. */
  99708. get rgb(): NodeMaterialConnectionPoint;
  99709. /**
  99710. * Gets the r output component
  99711. */
  99712. get r(): NodeMaterialConnectionPoint;
  99713. /**
  99714. * Gets the g output component
  99715. */
  99716. get g(): NodeMaterialConnectionPoint;
  99717. /**
  99718. * Gets the b output component
  99719. */
  99720. get b(): NodeMaterialConnectionPoint;
  99721. /**
  99722. * Gets the a output component
  99723. */
  99724. get a(): NodeMaterialConnectionPoint;
  99725. /**
  99726. * Initialize the block and prepare the context for build
  99727. * @param state defines the state that will be used for the build
  99728. */
  99729. initialize(state: NodeMaterialBuildState): void;
  99730. get target(): NodeMaterialBlockTargets;
  99731. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99732. isReady(): boolean;
  99733. private _injectVertexCode;
  99734. private _writeTextureRead;
  99735. private _writeOutput;
  99736. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99737. serialize(): any;
  99738. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99739. }
  99740. }
  99741. declare module BABYLON {
  99742. /**
  99743. * Base block used for the particle texture
  99744. */
  99745. export class ParticleTextureBlock extends NodeMaterialBlock {
  99746. private _samplerName;
  99747. private _linearDefineName;
  99748. private _gammaDefineName;
  99749. private _tempTextureRead;
  99750. /**
  99751. * Gets or sets the texture associated with the node
  99752. */
  99753. texture: Nullable<BaseTexture>;
  99754. /**
  99755. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99756. */
  99757. convertToGammaSpace: boolean;
  99758. /**
  99759. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99760. */
  99761. convertToLinearSpace: boolean;
  99762. /**
  99763. * Create a new ParticleTextureBlock
  99764. * @param name defines the block name
  99765. */
  99766. constructor(name: string);
  99767. /**
  99768. * Gets the current class name
  99769. * @returns the class name
  99770. */
  99771. getClassName(): string;
  99772. /**
  99773. * Gets the uv input component
  99774. */
  99775. get uv(): NodeMaterialConnectionPoint;
  99776. /**
  99777. * Gets the rgba output component
  99778. */
  99779. get rgba(): NodeMaterialConnectionPoint;
  99780. /**
  99781. * Gets the rgb output component
  99782. */
  99783. get rgb(): NodeMaterialConnectionPoint;
  99784. /**
  99785. * Gets the r output component
  99786. */
  99787. get r(): NodeMaterialConnectionPoint;
  99788. /**
  99789. * Gets the g output component
  99790. */
  99791. get g(): NodeMaterialConnectionPoint;
  99792. /**
  99793. * Gets the b output component
  99794. */
  99795. get b(): NodeMaterialConnectionPoint;
  99796. /**
  99797. * Gets the a output component
  99798. */
  99799. get a(): NodeMaterialConnectionPoint;
  99800. /**
  99801. * Initialize the block and prepare the context for build
  99802. * @param state defines the state that will be used for the build
  99803. */
  99804. initialize(state: NodeMaterialBuildState): void;
  99805. autoConfigure(material: NodeMaterial): void;
  99806. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99807. isReady(): boolean;
  99808. private _writeOutput;
  99809. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99810. serialize(): any;
  99811. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99812. }
  99813. }
  99814. declare module BABYLON {
  99815. /**
  99816. * Class used to store shared data between 2 NodeMaterialBuildState
  99817. */
  99818. export class NodeMaterialBuildStateSharedData {
  99819. /**
  99820. * Gets the list of emitted varyings
  99821. */
  99822. temps: string[];
  99823. /**
  99824. * Gets the list of emitted varyings
  99825. */
  99826. varyings: string[];
  99827. /**
  99828. * Gets the varying declaration string
  99829. */
  99830. varyingDeclaration: string;
  99831. /**
  99832. * Input blocks
  99833. */
  99834. inputBlocks: InputBlock[];
  99835. /**
  99836. * Input blocks
  99837. */
  99838. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99839. /**
  99840. * Bindable blocks (Blocks that need to set data to the effect)
  99841. */
  99842. bindableBlocks: NodeMaterialBlock[];
  99843. /**
  99844. * List of blocks that can provide a compilation fallback
  99845. */
  99846. blocksWithFallbacks: NodeMaterialBlock[];
  99847. /**
  99848. * List of blocks that can provide a define update
  99849. */
  99850. blocksWithDefines: NodeMaterialBlock[];
  99851. /**
  99852. * List of blocks that can provide a repeatable content
  99853. */
  99854. repeatableContentBlocks: NodeMaterialBlock[];
  99855. /**
  99856. * List of blocks that can provide a dynamic list of uniforms
  99857. */
  99858. dynamicUniformBlocks: NodeMaterialBlock[];
  99859. /**
  99860. * List of blocks that can block the isReady function for the material
  99861. */
  99862. blockingBlocks: NodeMaterialBlock[];
  99863. /**
  99864. * Gets the list of animated inputs
  99865. */
  99866. animatedInputs: InputBlock[];
  99867. /**
  99868. * Build Id used to avoid multiple recompilations
  99869. */
  99870. buildId: number;
  99871. /** List of emitted variables */
  99872. variableNames: {
  99873. [key: string]: number;
  99874. };
  99875. /** List of emitted defines */
  99876. defineNames: {
  99877. [key: string]: number;
  99878. };
  99879. /** Should emit comments? */
  99880. emitComments: boolean;
  99881. /** Emit build activity */
  99882. verbose: boolean;
  99883. /** Gets or sets the hosting scene */
  99884. scene: Scene;
  99885. /**
  99886. * Gets the compilation hints emitted at compilation time
  99887. */
  99888. hints: {
  99889. needWorldViewMatrix: boolean;
  99890. needWorldViewProjectionMatrix: boolean;
  99891. needAlphaBlending: boolean;
  99892. needAlphaTesting: boolean;
  99893. };
  99894. /**
  99895. * List of compilation checks
  99896. */
  99897. checks: {
  99898. emitVertex: boolean;
  99899. emitFragment: boolean;
  99900. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  99901. };
  99902. /**
  99903. * Is vertex program allowed to be empty?
  99904. */
  99905. allowEmptyVertexProgram: boolean;
  99906. /** Creates a new shared data */
  99907. constructor();
  99908. /**
  99909. * Emits console errors and exceptions if there is a failing check
  99910. */
  99911. emitErrors(): void;
  99912. }
  99913. }
  99914. declare module BABYLON {
  99915. /**
  99916. * Class used to store node based material build state
  99917. */
  99918. export class NodeMaterialBuildState {
  99919. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  99920. supportUniformBuffers: boolean;
  99921. /**
  99922. * Gets the list of emitted attributes
  99923. */
  99924. attributes: string[];
  99925. /**
  99926. * Gets the list of emitted uniforms
  99927. */
  99928. uniforms: string[];
  99929. /**
  99930. * Gets the list of emitted constants
  99931. */
  99932. constants: string[];
  99933. /**
  99934. * Gets the list of emitted samplers
  99935. */
  99936. samplers: string[];
  99937. /**
  99938. * Gets the list of emitted functions
  99939. */
  99940. functions: {
  99941. [key: string]: string;
  99942. };
  99943. /**
  99944. * Gets the list of emitted extensions
  99945. */
  99946. extensions: {
  99947. [key: string]: string;
  99948. };
  99949. /**
  99950. * Gets the target of the compilation state
  99951. */
  99952. target: NodeMaterialBlockTargets;
  99953. /**
  99954. * Gets the list of emitted counters
  99955. */
  99956. counters: {
  99957. [key: string]: number;
  99958. };
  99959. /**
  99960. * Shared data between multiple NodeMaterialBuildState instances
  99961. */
  99962. sharedData: NodeMaterialBuildStateSharedData;
  99963. /** @hidden */
  99964. _vertexState: NodeMaterialBuildState;
  99965. /** @hidden */
  99966. _attributeDeclaration: string;
  99967. /** @hidden */
  99968. _uniformDeclaration: string;
  99969. /** @hidden */
  99970. _constantDeclaration: string;
  99971. /** @hidden */
  99972. _samplerDeclaration: string;
  99973. /** @hidden */
  99974. _varyingTransfer: string;
  99975. /** @hidden */
  99976. _injectAtEnd: string;
  99977. private _repeatableContentAnchorIndex;
  99978. /** @hidden */
  99979. _builtCompilationString: string;
  99980. /**
  99981. * Gets the emitted compilation strings
  99982. */
  99983. compilationString: string;
  99984. /**
  99985. * Finalize the compilation strings
  99986. * @param state defines the current compilation state
  99987. */
  99988. finalize(state: NodeMaterialBuildState): void;
  99989. /** @hidden */
  99990. get _repeatableContentAnchor(): string;
  99991. /** @hidden */
  99992. _getFreeVariableName(prefix: string): string;
  99993. /** @hidden */
  99994. _getFreeDefineName(prefix: string): string;
  99995. /** @hidden */
  99996. _excludeVariableName(name: string): void;
  99997. /** @hidden */
  99998. _emit2DSampler(name: string): void;
  99999. /** @hidden */
  100000. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  100001. /** @hidden */
  100002. _emitExtension(name: string, extension: string, define?: string): void;
  100003. /** @hidden */
  100004. _emitFunction(name: string, code: string, comments: string): void;
  100005. /** @hidden */
  100006. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  100007. replaceStrings?: {
  100008. search: RegExp;
  100009. replace: string;
  100010. }[];
  100011. repeatKey?: string;
  100012. }): string;
  100013. /** @hidden */
  100014. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  100015. repeatKey?: string;
  100016. removeAttributes?: boolean;
  100017. removeUniforms?: boolean;
  100018. removeVaryings?: boolean;
  100019. removeIfDef?: boolean;
  100020. replaceStrings?: {
  100021. search: RegExp;
  100022. replace: string;
  100023. }[];
  100024. }, storeKey?: string): void;
  100025. /** @hidden */
  100026. _registerTempVariable(name: string): boolean;
  100027. /** @hidden */
  100028. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  100029. /** @hidden */
  100030. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  100031. /** @hidden */
  100032. _emitFloat(value: number): string;
  100033. }
  100034. }
  100035. declare module BABYLON {
  100036. /**
  100037. * Helper class used to generate session unique ID
  100038. */
  100039. export class UniqueIdGenerator {
  100040. private static _UniqueIdCounter;
  100041. /**
  100042. * Gets an unique (relatively to the current scene) Id
  100043. */
  100044. static get UniqueId(): number;
  100045. }
  100046. }
  100047. declare module BABYLON {
  100048. /**
  100049. * Defines a block that can be used inside a node based material
  100050. */
  100051. export class NodeMaterialBlock {
  100052. private _buildId;
  100053. private _buildTarget;
  100054. private _target;
  100055. private _isFinalMerger;
  100056. private _isInput;
  100057. private _name;
  100058. protected _isUnique: boolean;
  100059. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  100060. inputsAreExclusive: boolean;
  100061. /** @hidden */
  100062. _codeVariableName: string;
  100063. /** @hidden */
  100064. _inputs: NodeMaterialConnectionPoint[];
  100065. /** @hidden */
  100066. _outputs: NodeMaterialConnectionPoint[];
  100067. /** @hidden */
  100068. _preparationId: number;
  100069. /**
  100070. * Gets the name of the block
  100071. */
  100072. get name(): string;
  100073. /**
  100074. * Sets the name of the block. Will check if the name is valid.
  100075. */
  100076. set name(newName: string);
  100077. /**
  100078. * Gets or sets the unique id of the node
  100079. */
  100080. uniqueId: number;
  100081. /**
  100082. * Gets or sets the comments associated with this block
  100083. */
  100084. comments: string;
  100085. /**
  100086. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  100087. */
  100088. get isUnique(): boolean;
  100089. /**
  100090. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  100091. */
  100092. get isFinalMerger(): boolean;
  100093. /**
  100094. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  100095. */
  100096. get isInput(): boolean;
  100097. /**
  100098. * Gets or sets the build Id
  100099. */
  100100. get buildId(): number;
  100101. set buildId(value: number);
  100102. /**
  100103. * Gets or sets the target of the block
  100104. */
  100105. get target(): NodeMaterialBlockTargets;
  100106. set target(value: NodeMaterialBlockTargets);
  100107. /**
  100108. * Gets the list of input points
  100109. */
  100110. get inputs(): NodeMaterialConnectionPoint[];
  100111. /** Gets the list of output points */
  100112. get outputs(): NodeMaterialConnectionPoint[];
  100113. /**
  100114. * Find an input by its name
  100115. * @param name defines the name of the input to look for
  100116. * @returns the input or null if not found
  100117. */
  100118. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  100119. /**
  100120. * Find an output by its name
  100121. * @param name defines the name of the outputto look for
  100122. * @returns the output or null if not found
  100123. */
  100124. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  100125. /**
  100126. * Creates a new NodeMaterialBlock
  100127. * @param name defines the block name
  100128. * @param target defines the target of that block (Vertex by default)
  100129. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  100130. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  100131. */
  100132. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  100133. /**
  100134. * Initialize the block and prepare the context for build
  100135. * @param state defines the state that will be used for the build
  100136. */
  100137. initialize(state: NodeMaterialBuildState): void;
  100138. /**
  100139. * Bind data to effect. Will only be called for blocks with isBindable === true
  100140. * @param effect defines the effect to bind data to
  100141. * @param nodeMaterial defines the hosting NodeMaterial
  100142. * @param mesh defines the mesh that will be rendered
  100143. * @param subMesh defines the submesh that will be rendered
  100144. */
  100145. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  100146. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  100147. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  100148. protected _writeFloat(value: number): string;
  100149. /**
  100150. * Gets the current class name e.g. "NodeMaterialBlock"
  100151. * @returns the class name
  100152. */
  100153. getClassName(): string;
  100154. /**
  100155. * Register a new input. Must be called inside a block constructor
  100156. * @param name defines the connection point name
  100157. * @param type defines the connection point type
  100158. * @param isOptional defines a boolean indicating that this input can be omitted
  100159. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  100160. * @param point an already created connection point. If not provided, create a new one
  100161. * @returns the current block
  100162. */
  100163. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100164. /**
  100165. * Register a new output. Must be called inside a block constructor
  100166. * @param name defines the connection point name
  100167. * @param type defines the connection point type
  100168. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  100169. * @param point an already created connection point. If not provided, create a new one
  100170. * @returns the current block
  100171. */
  100172. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100173. /**
  100174. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  100175. * @param forOutput defines an optional connection point to check compatibility with
  100176. * @returns the first available input or null
  100177. */
  100178. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  100179. /**
  100180. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  100181. * @param forBlock defines an optional block to check compatibility with
  100182. * @returns the first available input or null
  100183. */
  100184. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  100185. /**
  100186. * Gets the sibling of the given output
  100187. * @param current defines the current output
  100188. * @returns the next output in the list or null
  100189. */
  100190. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  100191. /**
  100192. * Connect current block with another block
  100193. * @param other defines the block to connect with
  100194. * @param options define the various options to help pick the right connections
  100195. * @returns the current block
  100196. */
  100197. connectTo(other: NodeMaterialBlock, options?: {
  100198. input?: string;
  100199. output?: string;
  100200. outputSwizzle?: string;
  100201. }): this | undefined;
  100202. protected _buildBlock(state: NodeMaterialBuildState): void;
  100203. /**
  100204. * Add uniforms, samplers and uniform buffers at compilation time
  100205. * @param state defines the state to update
  100206. * @param nodeMaterial defines the node material requesting the update
  100207. * @param defines defines the material defines to update
  100208. * @param uniformBuffers defines the list of uniform buffer names
  100209. */
  100210. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  100211. /**
  100212. * Add potential fallbacks if shader compilation fails
  100213. * @param mesh defines the mesh to be rendered
  100214. * @param fallbacks defines the current prioritized list of fallbacks
  100215. */
  100216. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  100217. /**
  100218. * Initialize defines for shader compilation
  100219. * @param mesh defines the mesh to be rendered
  100220. * @param nodeMaterial defines the node material requesting the update
  100221. * @param defines defines the material defines to update
  100222. * @param useInstances specifies that instances should be used
  100223. */
  100224. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  100225. /**
  100226. * Update defines for shader compilation
  100227. * @param mesh defines the mesh to be rendered
  100228. * @param nodeMaterial defines the node material requesting the update
  100229. * @param defines defines the material defines to update
  100230. * @param useInstances specifies that instances should be used
  100231. * @param subMesh defines which submesh to render
  100232. */
  100233. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  100234. /**
  100235. * Lets the block try to connect some inputs automatically
  100236. * @param material defines the hosting NodeMaterial
  100237. */
  100238. autoConfigure(material: NodeMaterial): void;
  100239. /**
  100240. * Function called when a block is declared as repeatable content generator
  100241. * @param vertexShaderState defines the current compilation state for the vertex shader
  100242. * @param fragmentShaderState defines the current compilation state for the fragment shader
  100243. * @param mesh defines the mesh to be rendered
  100244. * @param defines defines the material defines to update
  100245. */
  100246. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  100247. /**
  100248. * Checks if the block is ready
  100249. * @param mesh defines the mesh to be rendered
  100250. * @param nodeMaterial defines the node material requesting the update
  100251. * @param defines defines the material defines to update
  100252. * @param useInstances specifies that instances should be used
  100253. * @returns true if the block is ready
  100254. */
  100255. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  100256. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  100257. private _processBuild;
  100258. /**
  100259. * Validates the new name for the block node.
  100260. * @param newName the new name to be given to the node.
  100261. * @returns false if the name is a reserve word, else true.
  100262. */
  100263. validateBlockName(newName: string): boolean;
  100264. /**
  100265. * Compile the current node and generate the shader code
  100266. * @param state defines the current compilation state (uniforms, samplers, current string)
  100267. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  100268. * @returns true if already built
  100269. */
  100270. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  100271. protected _inputRename(name: string): string;
  100272. protected _outputRename(name: string): string;
  100273. protected _dumpPropertiesCode(): string;
  100274. /** @hidden */
  100275. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  100276. /** @hidden */
  100277. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  100278. /**
  100279. * Clone the current block to a new identical block
  100280. * @param scene defines the hosting scene
  100281. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100282. * @returns a copy of the current block
  100283. */
  100284. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  100285. /**
  100286. * Serializes this block in a JSON representation
  100287. * @returns the serialized block object
  100288. */
  100289. serialize(): any;
  100290. /** @hidden */
  100291. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100292. private _deserializePortDisplayNamesAndExposedOnFrame;
  100293. /**
  100294. * Release resources
  100295. */
  100296. dispose(): void;
  100297. }
  100298. }
  100299. declare module BABYLON {
  100300. /**
  100301. * Base class of materials working in push mode in babylon JS
  100302. * @hidden
  100303. */
  100304. export class PushMaterial extends Material {
  100305. protected _activeEffect: Effect;
  100306. protected _normalMatrix: Matrix;
  100307. constructor(name: string, scene: Scene);
  100308. getEffect(): Effect;
  100309. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100310. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  100311. /**
  100312. * Binds the given world matrix to the active effect
  100313. *
  100314. * @param world the matrix to bind
  100315. */
  100316. bindOnlyWorldMatrix(world: Matrix): void;
  100317. /**
  100318. * Binds the given normal matrix to the active effect
  100319. *
  100320. * @param normalMatrix the matrix to bind
  100321. */
  100322. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100323. bind(world: Matrix, mesh?: Mesh): void;
  100324. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100325. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100326. }
  100327. }
  100328. declare module BABYLON {
  100329. /**
  100330. * Root class for all node material optimizers
  100331. */
  100332. export class NodeMaterialOptimizer {
  100333. /**
  100334. * Function used to optimize a NodeMaterial graph
  100335. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  100336. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  100337. */
  100338. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  100339. }
  100340. }
  100341. declare module BABYLON {
  100342. /**
  100343. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  100344. */
  100345. export class TransformBlock extends NodeMaterialBlock {
  100346. /**
  100347. * Defines the value to use to complement W value to transform it to a Vector4
  100348. */
  100349. complementW: number;
  100350. /**
  100351. * Defines the value to use to complement z value to transform it to a Vector4
  100352. */
  100353. complementZ: number;
  100354. /**
  100355. * Creates a new TransformBlock
  100356. * @param name defines the block name
  100357. */
  100358. constructor(name: string);
  100359. /**
  100360. * Gets the current class name
  100361. * @returns the class name
  100362. */
  100363. getClassName(): string;
  100364. /**
  100365. * Gets the vector input
  100366. */
  100367. get vector(): NodeMaterialConnectionPoint;
  100368. /**
  100369. * Gets the output component
  100370. */
  100371. get output(): NodeMaterialConnectionPoint;
  100372. /**
  100373. * Gets the xyz output component
  100374. */
  100375. get xyz(): NodeMaterialConnectionPoint;
  100376. /**
  100377. * Gets the matrix transform input
  100378. */
  100379. get transform(): NodeMaterialConnectionPoint;
  100380. protected _buildBlock(state: NodeMaterialBuildState): this;
  100381. /**
  100382. * Update defines for shader compilation
  100383. * @param mesh defines the mesh to be rendered
  100384. * @param nodeMaterial defines the node material requesting the update
  100385. * @param defines defines the material defines to update
  100386. * @param useInstances specifies that instances should be used
  100387. * @param subMesh defines which submesh to render
  100388. */
  100389. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  100390. serialize(): any;
  100391. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100392. protected _dumpPropertiesCode(): string;
  100393. }
  100394. }
  100395. declare module BABYLON {
  100396. /**
  100397. * Block used to output the vertex position
  100398. */
  100399. export class VertexOutputBlock extends NodeMaterialBlock {
  100400. /**
  100401. * Creates a new VertexOutputBlock
  100402. * @param name defines the block name
  100403. */
  100404. constructor(name: string);
  100405. /**
  100406. * Gets the current class name
  100407. * @returns the class name
  100408. */
  100409. getClassName(): string;
  100410. /**
  100411. * Gets the vector input component
  100412. */
  100413. get vector(): NodeMaterialConnectionPoint;
  100414. protected _buildBlock(state: NodeMaterialBuildState): this;
  100415. }
  100416. }
  100417. declare module BABYLON {
  100418. /**
  100419. * Block used to output the final color
  100420. */
  100421. export class FragmentOutputBlock extends NodeMaterialBlock {
  100422. /**
  100423. * Create a new FragmentOutputBlock
  100424. * @param name defines the block name
  100425. */
  100426. constructor(name: string);
  100427. /**
  100428. * Gets the current class name
  100429. * @returns the class name
  100430. */
  100431. getClassName(): string;
  100432. /**
  100433. * Gets the rgba input component
  100434. */
  100435. get rgba(): NodeMaterialConnectionPoint;
  100436. /**
  100437. * Gets the rgb input component
  100438. */
  100439. get rgb(): NodeMaterialConnectionPoint;
  100440. /**
  100441. * Gets the a input component
  100442. */
  100443. get a(): NodeMaterialConnectionPoint;
  100444. protected _buildBlock(state: NodeMaterialBuildState): this;
  100445. }
  100446. }
  100447. declare module BABYLON {
  100448. /**
  100449. * Block used for the particle ramp gradient section
  100450. */
  100451. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  100452. /**
  100453. * Create a new ParticleRampGradientBlock
  100454. * @param name defines the block name
  100455. */
  100456. constructor(name: string);
  100457. /**
  100458. * Gets the current class name
  100459. * @returns the class name
  100460. */
  100461. getClassName(): string;
  100462. /**
  100463. * Gets the color input component
  100464. */
  100465. get color(): NodeMaterialConnectionPoint;
  100466. /**
  100467. * Gets the rampColor output component
  100468. */
  100469. get rampColor(): NodeMaterialConnectionPoint;
  100470. /**
  100471. * Initialize the block and prepare the context for build
  100472. * @param state defines the state that will be used for the build
  100473. */
  100474. initialize(state: NodeMaterialBuildState): void;
  100475. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100476. }
  100477. }
  100478. declare module BABYLON {
  100479. /**
  100480. * Block used for the particle blend multiply section
  100481. */
  100482. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  100483. /**
  100484. * Create a new ParticleBlendMultiplyBlock
  100485. * @param name defines the block name
  100486. */
  100487. constructor(name: string);
  100488. /**
  100489. * Gets the current class name
  100490. * @returns the class name
  100491. */
  100492. getClassName(): string;
  100493. /**
  100494. * Gets the color input component
  100495. */
  100496. get color(): NodeMaterialConnectionPoint;
  100497. /**
  100498. * Gets the alphaTexture input component
  100499. */
  100500. get alphaTexture(): NodeMaterialConnectionPoint;
  100501. /**
  100502. * Gets the alphaColor input component
  100503. */
  100504. get alphaColor(): NodeMaterialConnectionPoint;
  100505. /**
  100506. * Gets the blendColor output component
  100507. */
  100508. get blendColor(): NodeMaterialConnectionPoint;
  100509. /**
  100510. * Initialize the block and prepare the context for build
  100511. * @param state defines the state that will be used for the build
  100512. */
  100513. initialize(state: NodeMaterialBuildState): void;
  100514. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100515. }
  100516. }
  100517. declare module BABYLON {
  100518. /**
  100519. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  100520. */
  100521. export class VectorMergerBlock extends NodeMaterialBlock {
  100522. /**
  100523. * Create a new VectorMergerBlock
  100524. * @param name defines the block name
  100525. */
  100526. constructor(name: string);
  100527. /**
  100528. * Gets the current class name
  100529. * @returns the class name
  100530. */
  100531. getClassName(): string;
  100532. /**
  100533. * Gets the xyz component (input)
  100534. */
  100535. get xyzIn(): NodeMaterialConnectionPoint;
  100536. /**
  100537. * Gets the xy component (input)
  100538. */
  100539. get xyIn(): NodeMaterialConnectionPoint;
  100540. /**
  100541. * Gets the x component (input)
  100542. */
  100543. get x(): NodeMaterialConnectionPoint;
  100544. /**
  100545. * Gets the y component (input)
  100546. */
  100547. get y(): NodeMaterialConnectionPoint;
  100548. /**
  100549. * Gets the z component (input)
  100550. */
  100551. get z(): NodeMaterialConnectionPoint;
  100552. /**
  100553. * Gets the w component (input)
  100554. */
  100555. get w(): NodeMaterialConnectionPoint;
  100556. /**
  100557. * Gets the xyzw component (output)
  100558. */
  100559. get xyzw(): NodeMaterialConnectionPoint;
  100560. /**
  100561. * Gets the xyz component (output)
  100562. */
  100563. get xyzOut(): NodeMaterialConnectionPoint;
  100564. /**
  100565. * Gets the xy component (output)
  100566. */
  100567. get xyOut(): NodeMaterialConnectionPoint;
  100568. /**
  100569. * Gets the xy component (output)
  100570. * @deprecated Please use xyOut instead.
  100571. */
  100572. get xy(): NodeMaterialConnectionPoint;
  100573. /**
  100574. * Gets the xyz component (output)
  100575. * @deprecated Please use xyzOut instead.
  100576. */
  100577. get xyz(): NodeMaterialConnectionPoint;
  100578. protected _buildBlock(state: NodeMaterialBuildState): this;
  100579. }
  100580. }
  100581. declare module BABYLON {
  100582. /**
  100583. * Block used to remap a float from a range to a new one
  100584. */
  100585. export class RemapBlock extends NodeMaterialBlock {
  100586. /**
  100587. * Gets or sets the source range
  100588. */
  100589. sourceRange: Vector2;
  100590. /**
  100591. * Gets or sets the target range
  100592. */
  100593. targetRange: Vector2;
  100594. /**
  100595. * Creates a new RemapBlock
  100596. * @param name defines the block name
  100597. */
  100598. constructor(name: string);
  100599. /**
  100600. * Gets the current class name
  100601. * @returns the class name
  100602. */
  100603. getClassName(): string;
  100604. /**
  100605. * Gets the input component
  100606. */
  100607. get input(): NodeMaterialConnectionPoint;
  100608. /**
  100609. * Gets the source min input component
  100610. */
  100611. get sourceMin(): NodeMaterialConnectionPoint;
  100612. /**
  100613. * Gets the source max input component
  100614. */
  100615. get sourceMax(): NodeMaterialConnectionPoint;
  100616. /**
  100617. * Gets the target min input component
  100618. */
  100619. get targetMin(): NodeMaterialConnectionPoint;
  100620. /**
  100621. * Gets the target max input component
  100622. */
  100623. get targetMax(): NodeMaterialConnectionPoint;
  100624. /**
  100625. * Gets the output component
  100626. */
  100627. get output(): NodeMaterialConnectionPoint;
  100628. protected _buildBlock(state: NodeMaterialBuildState): this;
  100629. protected _dumpPropertiesCode(): string;
  100630. serialize(): any;
  100631. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100632. }
  100633. }
  100634. declare module BABYLON {
  100635. /**
  100636. * Block used to multiply 2 values
  100637. */
  100638. export class MultiplyBlock extends NodeMaterialBlock {
  100639. /**
  100640. * Creates a new MultiplyBlock
  100641. * @param name defines the block name
  100642. */
  100643. constructor(name: string);
  100644. /**
  100645. * Gets the current class name
  100646. * @returns the class name
  100647. */
  100648. getClassName(): string;
  100649. /**
  100650. * Gets the left operand input component
  100651. */
  100652. get left(): NodeMaterialConnectionPoint;
  100653. /**
  100654. * Gets the right operand input component
  100655. */
  100656. get right(): NodeMaterialConnectionPoint;
  100657. /**
  100658. * Gets the output component
  100659. */
  100660. get output(): NodeMaterialConnectionPoint;
  100661. protected _buildBlock(state: NodeMaterialBuildState): this;
  100662. }
  100663. }
  100664. declare module BABYLON {
  100665. /**
  100666. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  100667. */
  100668. export class ColorSplitterBlock extends NodeMaterialBlock {
  100669. /**
  100670. * Create a new ColorSplitterBlock
  100671. * @param name defines the block name
  100672. */
  100673. constructor(name: string);
  100674. /**
  100675. * Gets the current class name
  100676. * @returns the class name
  100677. */
  100678. getClassName(): string;
  100679. /**
  100680. * Gets the rgba component (input)
  100681. */
  100682. get rgba(): NodeMaterialConnectionPoint;
  100683. /**
  100684. * Gets the rgb component (input)
  100685. */
  100686. get rgbIn(): NodeMaterialConnectionPoint;
  100687. /**
  100688. * Gets the rgb component (output)
  100689. */
  100690. get rgbOut(): NodeMaterialConnectionPoint;
  100691. /**
  100692. * Gets the r component (output)
  100693. */
  100694. get r(): NodeMaterialConnectionPoint;
  100695. /**
  100696. * Gets the g component (output)
  100697. */
  100698. get g(): NodeMaterialConnectionPoint;
  100699. /**
  100700. * Gets the b component (output)
  100701. */
  100702. get b(): NodeMaterialConnectionPoint;
  100703. /**
  100704. * Gets the a component (output)
  100705. */
  100706. get a(): NodeMaterialConnectionPoint;
  100707. protected _inputRename(name: string): string;
  100708. protected _outputRename(name: string): string;
  100709. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100710. }
  100711. }
  100712. declare module BABYLON {
  100713. /**
  100714. * Interface used to configure the node material editor
  100715. */
  100716. export interface INodeMaterialEditorOptions {
  100717. /** Define the URl to load node editor script */
  100718. editorURL?: string;
  100719. }
  100720. /** @hidden */
  100721. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100722. NORMAL: boolean;
  100723. TANGENT: boolean;
  100724. UV1: boolean;
  100725. /** BONES */
  100726. NUM_BONE_INFLUENCERS: number;
  100727. BonesPerMesh: number;
  100728. BONETEXTURE: boolean;
  100729. /** MORPH TARGETS */
  100730. MORPHTARGETS: boolean;
  100731. MORPHTARGETS_NORMAL: boolean;
  100732. MORPHTARGETS_TANGENT: boolean;
  100733. MORPHTARGETS_UV: boolean;
  100734. NUM_MORPH_INFLUENCERS: number;
  100735. /** IMAGE PROCESSING */
  100736. IMAGEPROCESSING: boolean;
  100737. VIGNETTE: boolean;
  100738. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100739. VIGNETTEBLENDMODEOPAQUE: boolean;
  100740. TONEMAPPING: boolean;
  100741. TONEMAPPING_ACES: boolean;
  100742. CONTRAST: boolean;
  100743. EXPOSURE: boolean;
  100744. COLORCURVES: boolean;
  100745. COLORGRADING: boolean;
  100746. COLORGRADING3D: boolean;
  100747. SAMPLER3DGREENDEPTH: boolean;
  100748. SAMPLER3DBGRMAP: boolean;
  100749. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100750. /** MISC. */
  100751. BUMPDIRECTUV: number;
  100752. constructor();
  100753. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  100754. }
  100755. /**
  100756. * Class used to configure NodeMaterial
  100757. */
  100758. export interface INodeMaterialOptions {
  100759. /**
  100760. * Defines if blocks should emit comments
  100761. */
  100762. emitComments: boolean;
  100763. }
  100764. /**
  100765. * Class used to create a node based material built by assembling shader blocks
  100766. */
  100767. export class NodeMaterial extends PushMaterial {
  100768. private static _BuildIdGenerator;
  100769. private _options;
  100770. private _vertexCompilationState;
  100771. private _fragmentCompilationState;
  100772. private _sharedData;
  100773. private _buildId;
  100774. private _buildWasSuccessful;
  100775. private _cachedWorldViewMatrix;
  100776. private _cachedWorldViewProjectionMatrix;
  100777. private _optimizers;
  100778. private _animationFrame;
  100779. /** Define the Url to load node editor script */
  100780. static EditorURL: string;
  100781. /** Define the Url to load snippets */
  100782. static SnippetUrl: string;
  100783. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  100784. static IgnoreTexturesAtLoadTime: boolean;
  100785. private BJSNODEMATERIALEDITOR;
  100786. /** Get the inspector from bundle or global */
  100787. private _getGlobalNodeMaterialEditor;
  100788. /**
  100789. * Snippet ID if the material was created from the snippet server
  100790. */
  100791. snippetId: string;
  100792. /**
  100793. * Gets or sets data used by visual editor
  100794. * @see https://nme.babylonjs.com
  100795. */
  100796. editorData: any;
  100797. /**
  100798. * 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)
  100799. */
  100800. ignoreAlpha: boolean;
  100801. /**
  100802. * Defines the maximum number of lights that can be used in the material
  100803. */
  100804. maxSimultaneousLights: number;
  100805. /**
  100806. * Observable raised when the material is built
  100807. */
  100808. onBuildObservable: Observable<NodeMaterial>;
  100809. /**
  100810. * Gets or sets the root nodes of the material vertex shader
  100811. */
  100812. _vertexOutputNodes: NodeMaterialBlock[];
  100813. /**
  100814. * Gets or sets the root nodes of the material fragment (pixel) shader
  100815. */
  100816. _fragmentOutputNodes: NodeMaterialBlock[];
  100817. /** Gets or sets options to control the node material overall behavior */
  100818. get options(): INodeMaterialOptions;
  100819. set options(options: INodeMaterialOptions);
  100820. /**
  100821. * Default configuration related to image processing available in the standard Material.
  100822. */
  100823. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100824. /**
  100825. * Gets the image processing configuration used either in this material.
  100826. */
  100827. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100828. /**
  100829. * Sets the Default image processing configuration used either in the this material.
  100830. *
  100831. * If sets to null, the scene one is in use.
  100832. */
  100833. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100834. /**
  100835. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  100836. */
  100837. attachedBlocks: NodeMaterialBlock[];
  100838. /**
  100839. * Specifies the mode of the node material
  100840. * @hidden
  100841. */
  100842. _mode: NodeMaterialModes;
  100843. /**
  100844. * Gets the mode property
  100845. */
  100846. get mode(): NodeMaterialModes;
  100847. /**
  100848. * Create a new node based material
  100849. * @param name defines the material name
  100850. * @param scene defines the hosting scene
  100851. * @param options defines creation option
  100852. */
  100853. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  100854. /**
  100855. * Gets the current class name of the material e.g. "NodeMaterial"
  100856. * @returns the class name
  100857. */
  100858. getClassName(): string;
  100859. /**
  100860. * Keep track of the image processing observer to allow dispose and replace.
  100861. */
  100862. private _imageProcessingObserver;
  100863. /**
  100864. * Attaches a new image processing configuration to the Standard Material.
  100865. * @param configuration
  100866. */
  100867. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100868. /**
  100869. * Get a block by its name
  100870. * @param name defines the name of the block to retrieve
  100871. * @returns the required block or null if not found
  100872. */
  100873. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  100874. /**
  100875. * Get a block by its name
  100876. * @param predicate defines the predicate used to find the good candidate
  100877. * @returns the required block or null if not found
  100878. */
  100879. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  100880. /**
  100881. * Get an input block by its name
  100882. * @param predicate defines the predicate used to find the good candidate
  100883. * @returns the required input block or null if not found
  100884. */
  100885. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  100886. /**
  100887. * Gets the list of input blocks attached to this material
  100888. * @returns an array of InputBlocks
  100889. */
  100890. getInputBlocks(): InputBlock[];
  100891. /**
  100892. * Adds a new optimizer to the list of optimizers
  100893. * @param optimizer defines the optimizers to add
  100894. * @returns the current material
  100895. */
  100896. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  100897. /**
  100898. * Remove an optimizer from the list of optimizers
  100899. * @param optimizer defines the optimizers to remove
  100900. * @returns the current material
  100901. */
  100902. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  100903. /**
  100904. * Add a new block to the list of output nodes
  100905. * @param node defines the node to add
  100906. * @returns the current material
  100907. */
  100908. addOutputNode(node: NodeMaterialBlock): this;
  100909. /**
  100910. * Remove a block from the list of root nodes
  100911. * @param node defines the node to remove
  100912. * @returns the current material
  100913. */
  100914. removeOutputNode(node: NodeMaterialBlock): this;
  100915. private _addVertexOutputNode;
  100916. private _removeVertexOutputNode;
  100917. private _addFragmentOutputNode;
  100918. private _removeFragmentOutputNode;
  100919. /**
  100920. * Specifies if the material will require alpha blending
  100921. * @returns a boolean specifying if alpha blending is needed
  100922. */
  100923. needAlphaBlending(): boolean;
  100924. /**
  100925. * Specifies if this material should be rendered in alpha test mode
  100926. * @returns a boolean specifying if an alpha test is needed.
  100927. */
  100928. needAlphaTesting(): boolean;
  100929. private _initializeBlock;
  100930. private _resetDualBlocks;
  100931. /**
  100932. * Remove a block from the current node material
  100933. * @param block defines the block to remove
  100934. */
  100935. removeBlock(block: NodeMaterialBlock): void;
  100936. /**
  100937. * Build the material and generates the inner effect
  100938. * @param verbose defines if the build should log activity
  100939. */
  100940. build(verbose?: boolean): void;
  100941. /**
  100942. * Runs an otpimization phase to try to improve the shader code
  100943. */
  100944. optimize(): void;
  100945. private _prepareDefinesForAttributes;
  100946. /**
  100947. * Create a post process from the material
  100948. * @param camera The camera to apply the render pass to.
  100949. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100950. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100951. * @param engine The engine which the post process will be applied. (default: current engine)
  100952. * @param reusable If the post process can be reused on the same frame. (default: false)
  100953. * @param textureType Type of textures used when performing the post process. (default: 0)
  100954. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100955. * @returns the post process created
  100956. */
  100957. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  100958. /**
  100959. * Create the post process effect from the material
  100960. * @param postProcess The post process to create the effect for
  100961. */
  100962. createEffectForPostProcess(postProcess: PostProcess): void;
  100963. private _createEffectOrPostProcess;
  100964. private _createEffectForParticles;
  100965. /**
  100966. * Create the effect to be used as the custom effect for a particle system
  100967. * @param particleSystem Particle system to create the effect for
  100968. * @param onCompiled defines a function to call when the effect creation is successful
  100969. * @param onError defines a function to call when the effect creation has failed
  100970. */
  100971. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100972. private _processDefines;
  100973. /**
  100974. * Get if the submesh is ready to be used and all its information available.
  100975. * Child classes can use it to update shaders
  100976. * @param mesh defines the mesh to check
  100977. * @param subMesh defines which submesh to check
  100978. * @param useInstances specifies that instances should be used
  100979. * @returns a boolean indicating that the submesh is ready or not
  100980. */
  100981. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100982. /**
  100983. * Get a string representing the shaders built by the current node graph
  100984. */
  100985. get compiledShaders(): string;
  100986. /**
  100987. * Binds the world matrix to the material
  100988. * @param world defines the world transformation matrix
  100989. */
  100990. bindOnlyWorldMatrix(world: Matrix): void;
  100991. /**
  100992. * Binds the submesh to this material by preparing the effect and shader to draw
  100993. * @param world defines the world transformation matrix
  100994. * @param mesh defines the mesh containing the submesh
  100995. * @param subMesh defines the submesh to bind the material to
  100996. */
  100997. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100998. /**
  100999. * Gets the active textures from the material
  101000. * @returns an array of textures
  101001. */
  101002. getActiveTextures(): BaseTexture[];
  101003. /**
  101004. * Gets the list of texture blocks
  101005. * @returns an array of texture blocks
  101006. */
  101007. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101008. /**
  101009. * Specifies if the material uses a texture
  101010. * @param texture defines the texture to check against the material
  101011. * @returns a boolean specifying if the material uses the texture
  101012. */
  101013. hasTexture(texture: BaseTexture): boolean;
  101014. /**
  101015. * Disposes the material
  101016. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101017. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101018. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  101019. */
  101020. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  101021. /** Creates the node editor window. */
  101022. private _createNodeEditor;
  101023. /**
  101024. * Launch the node material editor
  101025. * @param config Define the configuration of the editor
  101026. * @return a promise fulfilled when the node editor is visible
  101027. */
  101028. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  101029. /**
  101030. * Clear the current material
  101031. */
  101032. clear(): void;
  101033. /**
  101034. * Clear the current material and set it to a default state
  101035. */
  101036. setToDefault(): void;
  101037. /**
  101038. * Clear the current material and set it to a default state for post process
  101039. */
  101040. setToDefaultPostProcess(): void;
  101041. /**
  101042. * Clear the current material and set it to a default state for particle
  101043. */
  101044. setToDefaultParticle(): void;
  101045. /**
  101046. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  101047. * @param url defines the url to load from
  101048. * @returns a promise that will fullfil when the material is fully loaded
  101049. */
  101050. loadAsync(url: string): Promise<void>;
  101051. private _gatherBlocks;
  101052. /**
  101053. * Generate a string containing the code declaration required to create an equivalent of this material
  101054. * @returns a string
  101055. */
  101056. generateCode(): string;
  101057. /**
  101058. * Serializes this material in a JSON representation
  101059. * @returns the serialized material object
  101060. */
  101061. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  101062. private _restoreConnections;
  101063. /**
  101064. * Clear the current graph and load a new one from a serialization object
  101065. * @param source defines the JSON representation of the material
  101066. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101067. * @param merge defines whether or not the source must be merged or replace the current content
  101068. */
  101069. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  101070. /**
  101071. * Makes a duplicate of the current material.
  101072. * @param name - name to use for the new material.
  101073. */
  101074. clone(name: string): NodeMaterial;
  101075. /**
  101076. * Creates a node material from parsed material data
  101077. * @param source defines the JSON representation of the material
  101078. * @param scene defines the hosting scene
  101079. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101080. * @returns a new node material
  101081. */
  101082. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  101083. /**
  101084. * Creates a node material from a snippet saved in a remote file
  101085. * @param name defines the name of the material to create
  101086. * @param url defines the url to load from
  101087. * @param scene defines the hosting scene
  101088. * @returns a promise that will resolve to the new node material
  101089. */
  101090. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  101091. /**
  101092. * Creates a node material from a snippet saved by the node material editor
  101093. * @param snippetId defines the snippet to load
  101094. * @param scene defines the hosting scene
  101095. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101096. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  101097. * @returns a promise that will resolve to the new node material
  101098. */
  101099. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  101100. /**
  101101. * Creates a new node material set to default basic configuration
  101102. * @param name defines the name of the material
  101103. * @param scene defines the hosting scene
  101104. * @returns a new NodeMaterial
  101105. */
  101106. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  101107. }
  101108. }
  101109. declare module BABYLON {
  101110. /**
  101111. * Size options for a post process
  101112. */
  101113. export type PostProcessOptions = {
  101114. width: number;
  101115. height: number;
  101116. };
  101117. /**
  101118. * PostProcess can be used to apply a shader to a texture after it has been rendered
  101119. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  101120. */
  101121. export class PostProcess {
  101122. /** Name of the PostProcess. */
  101123. name: string;
  101124. /**
  101125. * Gets or sets the unique id of the post process
  101126. */
  101127. uniqueId: number;
  101128. /**
  101129. * Width of the texture to apply the post process on
  101130. */
  101131. width: number;
  101132. /**
  101133. * Height of the texture to apply the post process on
  101134. */
  101135. height: number;
  101136. /**
  101137. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  101138. */
  101139. nodeMaterialSource: Nullable<NodeMaterial>;
  101140. /**
  101141. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  101142. * @hidden
  101143. */
  101144. _outputTexture: Nullable<InternalTexture>;
  101145. /**
  101146. * Sampling mode used by the shader
  101147. * See https://doc.babylonjs.com/classes/3.1/texture
  101148. */
  101149. renderTargetSamplingMode: number;
  101150. /**
  101151. * Clear color to use when screen clearing
  101152. */
  101153. clearColor: Color4;
  101154. /**
  101155. * If the buffer needs to be cleared before applying the post process. (default: true)
  101156. * Should be set to false if shader will overwrite all previous pixels.
  101157. */
  101158. autoClear: boolean;
  101159. /**
  101160. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  101161. */
  101162. alphaMode: number;
  101163. /**
  101164. * Sets the setAlphaBlendConstants of the babylon engine
  101165. */
  101166. alphaConstants: Color4;
  101167. /**
  101168. * Animations to be used for the post processing
  101169. */
  101170. animations: Animation[];
  101171. /**
  101172. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  101173. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  101174. */
  101175. enablePixelPerfectMode: boolean;
  101176. /**
  101177. * Force the postprocess to be applied without taking in account viewport
  101178. */
  101179. forceFullscreenViewport: boolean;
  101180. /**
  101181. * List of inspectable custom properties (used by the Inspector)
  101182. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101183. */
  101184. inspectableCustomProperties: IInspectable[];
  101185. /**
  101186. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  101187. *
  101188. * | Value | Type | Description |
  101189. * | ----- | ----------------------------------- | ----------- |
  101190. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  101191. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  101192. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  101193. *
  101194. */
  101195. scaleMode: number;
  101196. /**
  101197. * Force textures to be a power of two (default: false)
  101198. */
  101199. alwaysForcePOT: boolean;
  101200. private _samples;
  101201. /**
  101202. * Number of sample textures (default: 1)
  101203. */
  101204. get samples(): number;
  101205. set samples(n: number);
  101206. /**
  101207. * Modify the scale of the post process to be the same as the viewport (default: false)
  101208. */
  101209. adaptScaleToCurrentViewport: boolean;
  101210. private _camera;
  101211. protected _scene: Scene;
  101212. private _engine;
  101213. private _options;
  101214. private _reusable;
  101215. private _textureType;
  101216. private _textureFormat;
  101217. /**
  101218. * Smart array of input and output textures for the post process.
  101219. * @hidden
  101220. */
  101221. _textures: SmartArray<InternalTexture>;
  101222. /**
  101223. * The index in _textures that corresponds to the output texture.
  101224. * @hidden
  101225. */
  101226. _currentRenderTextureInd: number;
  101227. private _effect;
  101228. private _samplers;
  101229. private _fragmentUrl;
  101230. private _vertexUrl;
  101231. private _parameters;
  101232. private _scaleRatio;
  101233. protected _indexParameters: any;
  101234. private _shareOutputWithPostProcess;
  101235. private _texelSize;
  101236. private _forcedOutputTexture;
  101237. /**
  101238. * Returns the fragment url or shader name used in the post process.
  101239. * @returns the fragment url or name in the shader store.
  101240. */
  101241. getEffectName(): string;
  101242. /**
  101243. * An event triggered when the postprocess is activated.
  101244. */
  101245. onActivateObservable: Observable<Camera>;
  101246. private _onActivateObserver;
  101247. /**
  101248. * A function that is added to the onActivateObservable
  101249. */
  101250. set onActivate(callback: Nullable<(camera: Camera) => void>);
  101251. /**
  101252. * An event triggered when the postprocess changes its size.
  101253. */
  101254. onSizeChangedObservable: Observable<PostProcess>;
  101255. private _onSizeChangedObserver;
  101256. /**
  101257. * A function that is added to the onSizeChangedObservable
  101258. */
  101259. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  101260. /**
  101261. * An event triggered when the postprocess applies its effect.
  101262. */
  101263. onApplyObservable: Observable<Effect>;
  101264. private _onApplyObserver;
  101265. /**
  101266. * A function that is added to the onApplyObservable
  101267. */
  101268. set onApply(callback: (effect: Effect) => void);
  101269. /**
  101270. * An event triggered before rendering the postprocess
  101271. */
  101272. onBeforeRenderObservable: Observable<Effect>;
  101273. private _onBeforeRenderObserver;
  101274. /**
  101275. * A function that is added to the onBeforeRenderObservable
  101276. */
  101277. set onBeforeRender(callback: (effect: Effect) => void);
  101278. /**
  101279. * An event triggered after rendering the postprocess
  101280. */
  101281. onAfterRenderObservable: Observable<Effect>;
  101282. private _onAfterRenderObserver;
  101283. /**
  101284. * A function that is added to the onAfterRenderObservable
  101285. */
  101286. set onAfterRender(callback: (efect: Effect) => void);
  101287. /**
  101288. * 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
  101289. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  101290. */
  101291. get inputTexture(): InternalTexture;
  101292. set inputTexture(value: InternalTexture);
  101293. /**
  101294. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  101295. * the only way to unset it is to use this function to restore its internal state
  101296. */
  101297. restoreDefaultInputTexture(): void;
  101298. /**
  101299. * Gets the camera which post process is applied to.
  101300. * @returns The camera the post process is applied to.
  101301. */
  101302. getCamera(): Camera;
  101303. /**
  101304. * Gets the texel size of the postprocess.
  101305. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  101306. */
  101307. get texelSize(): Vector2;
  101308. /**
  101309. * Creates a new instance PostProcess
  101310. * @param name The name of the PostProcess.
  101311. * @param fragmentUrl The url of the fragment shader to be used.
  101312. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  101313. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  101314. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101315. * @param camera The camera to apply the render pass to.
  101316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101317. * @param engine The engine which the post process will be applied. (default: current engine)
  101318. * @param reusable If the post process can be reused on the same frame. (default: false)
  101319. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  101320. * @param textureType Type of textures used when performing the post process. (default: 0)
  101321. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  101322. * @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
  101323. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  101324. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  101325. */
  101326. constructor(
  101327. /** Name of the PostProcess. */
  101328. 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);
  101329. /**
  101330. * Gets a string idenfifying the name of the class
  101331. * @returns "PostProcess" string
  101332. */
  101333. getClassName(): string;
  101334. /**
  101335. * Gets the engine which this post process belongs to.
  101336. * @returns The engine the post process was enabled with.
  101337. */
  101338. getEngine(): Engine;
  101339. /**
  101340. * The effect that is created when initializing the post process.
  101341. * @returns The created effect corresponding the the postprocess.
  101342. */
  101343. getEffect(): Effect;
  101344. /**
  101345. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  101346. * @param postProcess The post process to share the output with.
  101347. * @returns This post process.
  101348. */
  101349. shareOutputWith(postProcess: PostProcess): PostProcess;
  101350. /**
  101351. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  101352. * This should be called if the post process that shares output with this post process is disabled/disposed.
  101353. */
  101354. useOwnOutput(): void;
  101355. /**
  101356. * Updates the effect with the current post process compile time values and recompiles the shader.
  101357. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  101358. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  101359. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  101360. * @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
  101361. * @param onCompiled Called when the shader has been compiled.
  101362. * @param onError Called if there is an error when compiling a shader.
  101363. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  101364. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  101365. */
  101366. 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;
  101367. /**
  101368. * The post process is reusable if it can be used multiple times within one frame.
  101369. * @returns If the post process is reusable
  101370. */
  101371. isReusable(): boolean;
  101372. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  101373. markTextureDirty(): void;
  101374. /**
  101375. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  101376. * 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.
  101377. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  101378. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  101379. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  101380. * @returns The target texture that was bound to be written to.
  101381. */
  101382. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  101383. /**
  101384. * If the post process is supported.
  101385. */
  101386. get isSupported(): boolean;
  101387. /**
  101388. * The aspect ratio of the output texture.
  101389. */
  101390. get aspectRatio(): number;
  101391. /**
  101392. * Get a value indicating if the post-process is ready to be used
  101393. * @returns true if the post-process is ready (shader is compiled)
  101394. */
  101395. isReady(): boolean;
  101396. /**
  101397. * Binds all textures and uniforms to the shader, this will be run on every pass.
  101398. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  101399. */
  101400. apply(): Nullable<Effect>;
  101401. private _disposeTextures;
  101402. /**
  101403. * Disposes the post process.
  101404. * @param camera The camera to dispose the post process on.
  101405. */
  101406. dispose(camera?: Camera): void;
  101407. }
  101408. }
  101409. declare module BABYLON {
  101410. /** @hidden */
  101411. export var kernelBlurVaryingDeclaration: {
  101412. name: string;
  101413. shader: string;
  101414. };
  101415. }
  101416. declare module BABYLON {
  101417. /** @hidden */
  101418. export var kernelBlurFragment: {
  101419. name: string;
  101420. shader: string;
  101421. };
  101422. }
  101423. declare module BABYLON {
  101424. /** @hidden */
  101425. export var kernelBlurFragment2: {
  101426. name: string;
  101427. shader: string;
  101428. };
  101429. }
  101430. declare module BABYLON {
  101431. /** @hidden */
  101432. export var kernelBlurPixelShader: {
  101433. name: string;
  101434. shader: string;
  101435. };
  101436. }
  101437. declare module BABYLON {
  101438. /** @hidden */
  101439. export var kernelBlurVertex: {
  101440. name: string;
  101441. shader: string;
  101442. };
  101443. }
  101444. declare module BABYLON {
  101445. /** @hidden */
  101446. export var kernelBlurVertexShader: {
  101447. name: string;
  101448. shader: string;
  101449. };
  101450. }
  101451. declare module BABYLON {
  101452. /**
  101453. * The Blur Post Process which blurs an image based on a kernel and direction.
  101454. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  101455. */
  101456. export class BlurPostProcess extends PostProcess {
  101457. /** The direction in which to blur the image. */
  101458. direction: Vector2;
  101459. private blockCompilation;
  101460. protected _kernel: number;
  101461. protected _idealKernel: number;
  101462. protected _packedFloat: boolean;
  101463. private _staticDefines;
  101464. /**
  101465. * Sets the length in pixels of the blur sample region
  101466. */
  101467. set kernel(v: number);
  101468. /**
  101469. * Gets the length in pixels of the blur sample region
  101470. */
  101471. get kernel(): number;
  101472. /**
  101473. * Sets wether or not the blur needs to unpack/repack floats
  101474. */
  101475. set packedFloat(v: boolean);
  101476. /**
  101477. * Gets wether or not the blur is unpacking/repacking floats
  101478. */
  101479. get packedFloat(): boolean;
  101480. /**
  101481. * Creates a new instance BlurPostProcess
  101482. * @param name The name of the effect.
  101483. * @param direction The direction in which to blur the image.
  101484. * @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.
  101485. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101486. * @param camera The camera to apply the render pass to.
  101487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101488. * @param engine The engine which the post process will be applied. (default: current engine)
  101489. * @param reusable If the post process can be reused on the same frame. (default: false)
  101490. * @param textureType Type of textures used when performing the post process. (default: 0)
  101491. * @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)
  101492. */
  101493. constructor(name: string,
  101494. /** The direction in which to blur the image. */
  101495. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  101496. /**
  101497. * Updates the effect with the current post process compile time values and recompiles the shader.
  101498. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  101499. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  101500. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  101501. * @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
  101502. * @param onCompiled Called when the shader has been compiled.
  101503. * @param onError Called if there is an error when compiling a shader.
  101504. */
  101505. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101506. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101507. /**
  101508. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  101509. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  101510. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  101511. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  101512. * The gaps between physical kernels are compensated for in the weighting of the samples
  101513. * @param idealKernel Ideal blur kernel.
  101514. * @return Nearest best kernel.
  101515. */
  101516. protected _nearestBestKernel(idealKernel: number): number;
  101517. /**
  101518. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  101519. * @param x The point on the Gaussian distribution to sample.
  101520. * @return the value of the Gaussian function at x.
  101521. */
  101522. protected _gaussianWeight(x: number): number;
  101523. /**
  101524. * Generates a string that can be used as a floating point number in GLSL.
  101525. * @param x Value to print.
  101526. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  101527. * @return GLSL float string.
  101528. */
  101529. protected _glslFloat(x: number, decimalFigures?: number): string;
  101530. }
  101531. }
  101532. declare module BABYLON {
  101533. /**
  101534. * Mirror texture can be used to simulate the view from a mirror in a scene.
  101535. * It will dynamically be rendered every frame to adapt to the camera point of view.
  101536. * You can then easily use it as a reflectionTexture on a flat surface.
  101537. * In case the surface is not a plane, please consider relying on reflection probes.
  101538. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101539. */
  101540. export class MirrorTexture extends RenderTargetTexture {
  101541. private scene;
  101542. /**
  101543. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  101544. * 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.
  101545. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101546. */
  101547. mirrorPlane: Plane;
  101548. /**
  101549. * Define the blur ratio used to blur the reflection if needed.
  101550. */
  101551. set blurRatio(value: number);
  101552. get blurRatio(): number;
  101553. /**
  101554. * Define the adaptive blur kernel used to blur the reflection if needed.
  101555. * This will autocompute the closest best match for the `blurKernel`
  101556. */
  101557. set adaptiveBlurKernel(value: number);
  101558. /**
  101559. * Define the blur kernel used to blur the reflection if needed.
  101560. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101561. */
  101562. set blurKernel(value: number);
  101563. /**
  101564. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  101565. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101566. */
  101567. set blurKernelX(value: number);
  101568. get blurKernelX(): number;
  101569. /**
  101570. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  101571. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101572. */
  101573. set blurKernelY(value: number);
  101574. get blurKernelY(): number;
  101575. private _autoComputeBlurKernel;
  101576. protected _onRatioRescale(): void;
  101577. private _updateGammaSpace;
  101578. private _imageProcessingConfigChangeObserver;
  101579. private _transformMatrix;
  101580. private _mirrorMatrix;
  101581. private _savedViewMatrix;
  101582. private _blurX;
  101583. private _blurY;
  101584. private _adaptiveBlurKernel;
  101585. private _blurKernelX;
  101586. private _blurKernelY;
  101587. private _blurRatio;
  101588. /**
  101589. * Instantiates a Mirror Texture.
  101590. * Mirror texture can be used to simulate the view from a mirror in a scene.
  101591. * It will dynamically be rendered every frame to adapt to the camera point of view.
  101592. * You can then easily use it as a reflectionTexture on a flat surface.
  101593. * In case the surface is not a plane, please consider relying on reflection probes.
  101594. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101595. * @param name
  101596. * @param size
  101597. * @param scene
  101598. * @param generateMipMaps
  101599. * @param type
  101600. * @param samplingMode
  101601. * @param generateDepthBuffer
  101602. */
  101603. constructor(name: string, size: number | {
  101604. width: number;
  101605. height: number;
  101606. } | {
  101607. ratio: number;
  101608. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  101609. private _preparePostProcesses;
  101610. /**
  101611. * Clone the mirror texture.
  101612. * @returns the cloned texture
  101613. */
  101614. clone(): MirrorTexture;
  101615. /**
  101616. * Serialize the texture to a JSON representation you could use in Parse later on
  101617. * @returns the serialized JSON representation
  101618. */
  101619. serialize(): any;
  101620. /**
  101621. * Dispose the texture and release its associated resources.
  101622. */
  101623. dispose(): void;
  101624. }
  101625. }
  101626. declare module BABYLON {
  101627. /**
  101628. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101629. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101630. */
  101631. export class Texture extends BaseTexture {
  101632. /**
  101633. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  101634. */
  101635. static SerializeBuffers: boolean;
  101636. /** @hidden */
  101637. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  101638. /** @hidden */
  101639. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  101640. /** @hidden */
  101641. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  101642. /** nearest is mag = nearest and min = nearest and mip = linear */
  101643. static readonly NEAREST_SAMPLINGMODE: number;
  101644. /** nearest is mag = nearest and min = nearest and mip = linear */
  101645. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  101646. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101647. static readonly BILINEAR_SAMPLINGMODE: number;
  101648. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101649. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  101650. /** Trilinear is mag = linear and min = linear and mip = linear */
  101651. static readonly TRILINEAR_SAMPLINGMODE: number;
  101652. /** Trilinear is mag = linear and min = linear and mip = linear */
  101653. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  101654. /** mag = nearest and min = nearest and mip = nearest */
  101655. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  101656. /** mag = nearest and min = linear and mip = nearest */
  101657. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  101658. /** mag = nearest and min = linear and mip = linear */
  101659. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  101660. /** mag = nearest and min = linear and mip = none */
  101661. static readonly NEAREST_LINEAR: number;
  101662. /** mag = nearest and min = nearest and mip = none */
  101663. static readonly NEAREST_NEAREST: number;
  101664. /** mag = linear and min = nearest and mip = nearest */
  101665. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  101666. /** mag = linear and min = nearest and mip = linear */
  101667. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  101668. /** mag = linear and min = linear and mip = none */
  101669. static readonly LINEAR_LINEAR: number;
  101670. /** mag = linear and min = nearest and mip = none */
  101671. static readonly LINEAR_NEAREST: number;
  101672. /** Explicit coordinates mode */
  101673. static readonly EXPLICIT_MODE: number;
  101674. /** Spherical coordinates mode */
  101675. static readonly SPHERICAL_MODE: number;
  101676. /** Planar coordinates mode */
  101677. static readonly PLANAR_MODE: number;
  101678. /** Cubic coordinates mode */
  101679. static readonly CUBIC_MODE: number;
  101680. /** Projection coordinates mode */
  101681. static readonly PROJECTION_MODE: number;
  101682. /** Inverse Cubic coordinates mode */
  101683. static readonly SKYBOX_MODE: number;
  101684. /** Inverse Cubic coordinates mode */
  101685. static readonly INVCUBIC_MODE: number;
  101686. /** Equirectangular coordinates mode */
  101687. static readonly EQUIRECTANGULAR_MODE: number;
  101688. /** Equirectangular Fixed coordinates mode */
  101689. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  101690. /** Equirectangular Fixed Mirrored coordinates mode */
  101691. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  101692. /** Texture is not repeating outside of 0..1 UVs */
  101693. static readonly CLAMP_ADDRESSMODE: number;
  101694. /** Texture is repeating outside of 0..1 UVs */
  101695. static readonly WRAP_ADDRESSMODE: number;
  101696. /** Texture is repeating and mirrored */
  101697. static readonly MIRROR_ADDRESSMODE: number;
  101698. /**
  101699. * 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
  101700. */
  101701. static UseSerializedUrlIfAny: boolean;
  101702. /**
  101703. * Define the url of the texture.
  101704. */
  101705. url: Nullable<string>;
  101706. /**
  101707. * Define an offset on the texture to offset the u coordinates of the UVs
  101708. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101709. */
  101710. uOffset: number;
  101711. /**
  101712. * Define an offset on the texture to offset the v coordinates of the UVs
  101713. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101714. */
  101715. vOffset: number;
  101716. /**
  101717. * Define an offset on the texture to scale the u coordinates of the UVs
  101718. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101719. */
  101720. uScale: number;
  101721. /**
  101722. * Define an offset on the texture to scale the v coordinates of the UVs
  101723. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101724. */
  101725. vScale: number;
  101726. /**
  101727. * Define an offset on the texture to rotate around the u coordinates of the UVs
  101728. * @see https://doc.babylonjs.com/how_to/more_materials
  101729. */
  101730. uAng: number;
  101731. /**
  101732. * Define an offset on the texture to rotate around the v coordinates of the UVs
  101733. * @see https://doc.babylonjs.com/how_to/more_materials
  101734. */
  101735. vAng: number;
  101736. /**
  101737. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  101738. * @see https://doc.babylonjs.com/how_to/more_materials
  101739. */
  101740. wAng: number;
  101741. /**
  101742. * Defines the center of rotation (U)
  101743. */
  101744. uRotationCenter: number;
  101745. /**
  101746. * Defines the center of rotation (V)
  101747. */
  101748. vRotationCenter: number;
  101749. /**
  101750. * Defines the center of rotation (W)
  101751. */
  101752. wRotationCenter: number;
  101753. /**
  101754. * Are mip maps generated for this texture or not.
  101755. */
  101756. get noMipmap(): boolean;
  101757. /**
  101758. * List of inspectable custom properties (used by the Inspector)
  101759. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101760. */
  101761. inspectableCustomProperties: Nullable<IInspectable[]>;
  101762. private _noMipmap;
  101763. /** @hidden */
  101764. _invertY: boolean;
  101765. private _rowGenerationMatrix;
  101766. private _cachedTextureMatrix;
  101767. private _projectionModeMatrix;
  101768. private _t0;
  101769. private _t1;
  101770. private _t2;
  101771. private _cachedUOffset;
  101772. private _cachedVOffset;
  101773. private _cachedUScale;
  101774. private _cachedVScale;
  101775. private _cachedUAng;
  101776. private _cachedVAng;
  101777. private _cachedWAng;
  101778. private _cachedProjectionMatrixId;
  101779. private _cachedCoordinatesMode;
  101780. /** @hidden */
  101781. protected _initialSamplingMode: number;
  101782. /** @hidden */
  101783. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  101784. private _deleteBuffer;
  101785. protected _format: Nullable<number>;
  101786. private _delayedOnLoad;
  101787. private _delayedOnError;
  101788. private _mimeType?;
  101789. /**
  101790. * Observable triggered once the texture has been loaded.
  101791. */
  101792. onLoadObservable: Observable<Texture>;
  101793. protected _isBlocking: boolean;
  101794. /**
  101795. * Is the texture preventing material to render while loading.
  101796. * If false, a default texture will be used instead of the loading one during the preparation step.
  101797. */
  101798. set isBlocking(value: boolean);
  101799. get isBlocking(): boolean;
  101800. /**
  101801. * Get the current sampling mode associated with the texture.
  101802. */
  101803. get samplingMode(): number;
  101804. /**
  101805. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  101806. */
  101807. get invertY(): boolean;
  101808. /**
  101809. * Instantiates a new texture.
  101810. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101811. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101812. * @param url defines the url of the picture to load as a texture
  101813. * @param sceneOrEngine defines the scene or engine the texture will belong to
  101814. * @param noMipmap defines if the texture will require mip maps or not
  101815. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  101816. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101817. * @param onLoad defines a callback triggered when the texture has been loaded
  101818. * @param onError defines a callback triggered when an error occurred during the loading session
  101819. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  101820. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  101821. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101822. * @param mimeType defines an optional mime type information
  101823. */
  101824. 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);
  101825. /**
  101826. * Update the url (and optional buffer) of this texture if url was null during construction.
  101827. * @param url the url of the texture
  101828. * @param buffer the buffer of the texture (defaults to null)
  101829. * @param onLoad callback called when the texture is loaded (defaults to null)
  101830. */
  101831. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  101832. /**
  101833. * Finish the loading sequence of a texture flagged as delayed load.
  101834. * @hidden
  101835. */
  101836. delayLoad(): void;
  101837. private _prepareRowForTextureGeneration;
  101838. /**
  101839. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  101840. * @returns the transform matrix of the texture.
  101841. */
  101842. getTextureMatrix(uBase?: number): Matrix;
  101843. /**
  101844. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  101845. * @returns The reflection texture transform
  101846. */
  101847. getReflectionTextureMatrix(): Matrix;
  101848. /**
  101849. * Clones the texture.
  101850. * @returns the cloned texture
  101851. */
  101852. clone(): Texture;
  101853. /**
  101854. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101855. * @returns The JSON representation of the texture
  101856. */
  101857. serialize(): any;
  101858. /**
  101859. * Get the current class name of the texture useful for serialization or dynamic coding.
  101860. * @returns "Texture"
  101861. */
  101862. getClassName(): string;
  101863. /**
  101864. * Dispose the texture and release its associated resources.
  101865. */
  101866. dispose(): void;
  101867. /**
  101868. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  101869. * @param parsedTexture Define the JSON representation of the texture
  101870. * @param scene Define the scene the parsed texture should be instantiated in
  101871. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  101872. * @returns The parsed texture if successful
  101873. */
  101874. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  101875. /**
  101876. * Creates a texture from its base 64 representation.
  101877. * @param data Define the base64 payload without the data: prefix
  101878. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  101879. * @param scene Define the scene the texture should belong to
  101880. * @param noMipmap Forces the texture to not create mip map information if true
  101881. * @param invertY define if the texture needs to be inverted on the y axis during loading
  101882. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101883. * @param onLoad define a callback triggered when the texture has been loaded
  101884. * @param onError define a callback triggered when an error occurred during the loading session
  101885. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101886. * @returns the created texture
  101887. */
  101888. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  101889. /**
  101890. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  101891. * @param data Define the base64 payload without the data: prefix
  101892. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  101893. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  101894. * @param scene Define the scene the texture should belong to
  101895. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  101896. * @param noMipmap Forces the texture to not create mip map information if true
  101897. * @param invertY define if the texture needs to be inverted on the y axis during loading
  101898. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101899. * @param onLoad define a callback triggered when the texture has been loaded
  101900. * @param onError define a callback triggered when an error occurred during the loading session
  101901. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101902. * @returns the created texture
  101903. */
  101904. 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;
  101905. }
  101906. }
  101907. declare module BABYLON {
  101908. /**
  101909. * PostProcessManager is used to manage one or more post processes or post process pipelines
  101910. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  101911. */
  101912. export class PostProcessManager {
  101913. private _scene;
  101914. private _indexBuffer;
  101915. private _vertexBuffers;
  101916. /**
  101917. * Creates a new instance PostProcess
  101918. * @param scene The scene that the post process is associated with.
  101919. */
  101920. constructor(scene: Scene);
  101921. private _prepareBuffers;
  101922. private _buildIndexBuffer;
  101923. /**
  101924. * Rebuilds the vertex buffers of the manager.
  101925. * @hidden
  101926. */
  101927. _rebuild(): void;
  101928. /**
  101929. * Prepares a frame to be run through a post process.
  101930. * @param sourceTexture The input texture to the post procesess. (default: null)
  101931. * @param postProcesses An array of post processes to be run. (default: null)
  101932. * @returns True if the post processes were able to be run.
  101933. * @hidden
  101934. */
  101935. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  101936. /**
  101937. * Manually render a set of post processes to a texture.
  101938. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  101939. * @param postProcesses An array of post processes to be run.
  101940. * @param targetTexture The target texture to render to.
  101941. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  101942. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  101943. * @param lodLevel defines which lod of the texture to render to
  101944. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  101945. */
  101946. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  101947. /**
  101948. * Finalize the result of the output of the postprocesses.
  101949. * @param doNotPresent If true the result will not be displayed to the screen.
  101950. * @param targetTexture The target texture to render to.
  101951. * @param faceIndex The index of the face to bind the target texture to.
  101952. * @param postProcesses The array of post processes to render.
  101953. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  101954. * @hidden
  101955. */
  101956. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  101957. /**
  101958. * Disposes of the post process manager.
  101959. */
  101960. dispose(): void;
  101961. }
  101962. }
  101963. declare module BABYLON {
  101964. /**
  101965. * This Helps creating a texture that will be created from a camera in your scene.
  101966. * It is basically a dynamic texture that could be used to create special effects for instance.
  101967. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  101968. */
  101969. export class RenderTargetTexture extends Texture {
  101970. isCube: boolean;
  101971. /**
  101972. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  101973. */
  101974. static readonly REFRESHRATE_RENDER_ONCE: number;
  101975. /**
  101976. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  101977. */
  101978. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  101979. /**
  101980. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  101981. * the central point of your effect and can save a lot of performances.
  101982. */
  101983. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  101984. /**
  101985. * Use this predicate to dynamically define the list of mesh you want to render.
  101986. * If set, the renderList property will be overwritten.
  101987. */
  101988. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  101989. private _renderList;
  101990. /**
  101991. * Use this list to define the list of mesh you want to render.
  101992. */
  101993. get renderList(): Nullable<Array<AbstractMesh>>;
  101994. set renderList(value: Nullable<Array<AbstractMesh>>);
  101995. /**
  101996. * Use this function to overload the renderList array at rendering time.
  101997. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  101998. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  101999. * the cube (if the RTT is a cube, else layerOrFace=0).
  102000. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  102001. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  102002. * hold dummy elements!
  102003. */
  102004. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  102005. private _hookArray;
  102006. /**
  102007. * Define if particles should be rendered in your texture.
  102008. */
  102009. renderParticles: boolean;
  102010. /**
  102011. * Define if sprites should be rendered in your texture.
  102012. */
  102013. renderSprites: boolean;
  102014. /**
  102015. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  102016. */
  102017. coordinatesMode: number;
  102018. /**
  102019. * Define the camera used to render the texture.
  102020. */
  102021. activeCamera: Nullable<Camera>;
  102022. /**
  102023. * Override the mesh isReady function with your own one.
  102024. */
  102025. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  102026. /**
  102027. * Override the render function of the texture with your own one.
  102028. */
  102029. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  102030. /**
  102031. * Define if camera post processes should be use while rendering the texture.
  102032. */
  102033. useCameraPostProcesses: boolean;
  102034. /**
  102035. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  102036. */
  102037. ignoreCameraViewport: boolean;
  102038. private _postProcessManager;
  102039. private _postProcesses;
  102040. private _resizeObserver;
  102041. /**
  102042. * An event triggered when the texture is unbind.
  102043. */
  102044. onBeforeBindObservable: Observable<RenderTargetTexture>;
  102045. /**
  102046. * An event triggered when the texture is unbind.
  102047. */
  102048. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  102049. private _onAfterUnbindObserver;
  102050. /**
  102051. * Set a after unbind callback in the texture.
  102052. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  102053. */
  102054. set onAfterUnbind(callback: () => void);
  102055. /**
  102056. * An event triggered before rendering the texture
  102057. */
  102058. onBeforeRenderObservable: Observable<number>;
  102059. private _onBeforeRenderObserver;
  102060. /**
  102061. * Set a before render callback in the texture.
  102062. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  102063. */
  102064. set onBeforeRender(callback: (faceIndex: number) => void);
  102065. /**
  102066. * An event triggered after rendering the texture
  102067. */
  102068. onAfterRenderObservable: Observable<number>;
  102069. private _onAfterRenderObserver;
  102070. /**
  102071. * Set a after render callback in the texture.
  102072. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  102073. */
  102074. set onAfterRender(callback: (faceIndex: number) => void);
  102075. /**
  102076. * An event triggered after the texture clear
  102077. */
  102078. onClearObservable: Observable<Engine>;
  102079. private _onClearObserver;
  102080. /**
  102081. * Set a clear callback in the texture.
  102082. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  102083. */
  102084. set onClear(callback: (Engine: Engine) => void);
  102085. /**
  102086. * An event triggered when the texture is resized.
  102087. */
  102088. onResizeObservable: Observable<RenderTargetTexture>;
  102089. /**
  102090. * Define the clear color of the Render Target if it should be different from the scene.
  102091. */
  102092. clearColor: Color4;
  102093. protected _size: number | {
  102094. width: number;
  102095. height: number;
  102096. layers?: number;
  102097. };
  102098. protected _initialSizeParameter: number | {
  102099. width: number;
  102100. height: number;
  102101. } | {
  102102. ratio: number;
  102103. };
  102104. protected _sizeRatio: Nullable<number>;
  102105. /** @hidden */
  102106. _generateMipMaps: boolean;
  102107. protected _renderingManager: RenderingManager;
  102108. /** @hidden */
  102109. _waitingRenderList: string[];
  102110. protected _doNotChangeAspectRatio: boolean;
  102111. protected _currentRefreshId: number;
  102112. protected _refreshRate: number;
  102113. protected _textureMatrix: Matrix;
  102114. protected _samples: number;
  102115. protected _renderTargetOptions: RenderTargetCreationOptions;
  102116. /**
  102117. * Gets render target creation options that were used.
  102118. */
  102119. get renderTargetOptions(): RenderTargetCreationOptions;
  102120. protected _onRatioRescale(): void;
  102121. /**
  102122. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  102123. * It must define where the camera used to render the texture is set
  102124. */
  102125. boundingBoxPosition: Vector3;
  102126. private _boundingBoxSize;
  102127. /**
  102128. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  102129. * When defined, the cubemap will switch to local mode
  102130. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  102131. * @example https://www.babylonjs-playground.com/#RNASML
  102132. */
  102133. set boundingBoxSize(value: Vector3);
  102134. get boundingBoxSize(): Vector3;
  102135. /**
  102136. * In case the RTT has been created with a depth texture, get the associated
  102137. * depth texture.
  102138. * Otherwise, return null.
  102139. */
  102140. get depthStencilTexture(): Nullable<InternalTexture>;
  102141. /**
  102142. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  102143. * or used a shadow, depth texture...
  102144. * @param name The friendly name of the texture
  102145. * @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)
  102146. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  102147. * @param generateMipMaps True if mip maps need to be generated after render.
  102148. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  102149. * @param type The type of the buffer in the RTT (int, half float, float...)
  102150. * @param isCube True if a cube texture needs to be created
  102151. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  102152. * @param generateDepthBuffer True to generate a depth buffer
  102153. * @param generateStencilBuffer True to generate a stencil buffer
  102154. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  102155. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  102156. * @param delayAllocation if the texture allocation should be delayed (default: false)
  102157. */
  102158. constructor(name: string, size: number | {
  102159. width: number;
  102160. height: number;
  102161. layers?: number;
  102162. } | {
  102163. ratio: number;
  102164. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  102165. /**
  102166. * Creates a depth stencil texture.
  102167. * This is only available in WebGL 2 or with the depth texture extension available.
  102168. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  102169. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  102170. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  102171. */
  102172. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  102173. private _processSizeParameter;
  102174. /**
  102175. * Define the number of samples to use in case of MSAA.
  102176. * It defaults to one meaning no MSAA has been enabled.
  102177. */
  102178. get samples(): number;
  102179. set samples(value: number);
  102180. /**
  102181. * Resets the refresh counter of the texture and start bak from scratch.
  102182. * Could be useful to regenerate the texture if it is setup to render only once.
  102183. */
  102184. resetRefreshCounter(): void;
  102185. /**
  102186. * Define the refresh rate of the texture or the rendering frequency.
  102187. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  102188. */
  102189. get refreshRate(): number;
  102190. set refreshRate(value: number);
  102191. /**
  102192. * Adds a post process to the render target rendering passes.
  102193. * @param postProcess define the post process to add
  102194. */
  102195. addPostProcess(postProcess: PostProcess): void;
  102196. /**
  102197. * Clear all the post processes attached to the render target
  102198. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  102199. */
  102200. clearPostProcesses(dispose?: boolean): void;
  102201. /**
  102202. * Remove one of the post process from the list of attached post processes to the texture
  102203. * @param postProcess define the post process to remove from the list
  102204. */
  102205. removePostProcess(postProcess: PostProcess): void;
  102206. /** @hidden */
  102207. _shouldRender(): boolean;
  102208. /**
  102209. * Gets the actual render size of the texture.
  102210. * @returns the width of the render size
  102211. */
  102212. getRenderSize(): number;
  102213. /**
  102214. * Gets the actual render width of the texture.
  102215. * @returns the width of the render size
  102216. */
  102217. getRenderWidth(): number;
  102218. /**
  102219. * Gets the actual render height of the texture.
  102220. * @returns the height of the render size
  102221. */
  102222. getRenderHeight(): number;
  102223. /**
  102224. * Gets the actual number of layers of the texture.
  102225. * @returns the number of layers
  102226. */
  102227. getRenderLayers(): number;
  102228. /**
  102229. * Get if the texture can be rescaled or not.
  102230. */
  102231. get canRescale(): boolean;
  102232. /**
  102233. * Resize the texture using a ratio.
  102234. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  102235. */
  102236. scale(ratio: number): void;
  102237. /**
  102238. * Get the texture reflection matrix used to rotate/transform the reflection.
  102239. * @returns the reflection matrix
  102240. */
  102241. getReflectionTextureMatrix(): Matrix;
  102242. /**
  102243. * Resize the texture to a new desired size.
  102244. * Be carrefull as it will recreate all the data in the new texture.
  102245. * @param size Define the new size. It can be:
  102246. * - a number for squared texture,
  102247. * - an object containing { width: number, height: number }
  102248. * - or an object containing a ratio { ratio: number }
  102249. */
  102250. resize(size: number | {
  102251. width: number;
  102252. height: number;
  102253. } | {
  102254. ratio: number;
  102255. }): void;
  102256. private _defaultRenderListPrepared;
  102257. /**
  102258. * Renders all the objects from the render list into the texture.
  102259. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  102260. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  102261. */
  102262. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  102263. private _bestReflectionRenderTargetDimension;
  102264. private _prepareRenderingManager;
  102265. /**
  102266. * @hidden
  102267. * @param faceIndex face index to bind to if this is a cubetexture
  102268. * @param layer defines the index of the texture to bind in the array
  102269. */
  102270. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  102271. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  102272. private renderToTarget;
  102273. /**
  102274. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  102275. * This allowed control for front to back rendering or reversly depending of the special needs.
  102276. *
  102277. * @param renderingGroupId The rendering group id corresponding to its index
  102278. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  102279. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  102280. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  102281. */
  102282. 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;
  102283. /**
  102284. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  102285. *
  102286. * @param renderingGroupId The rendering group id corresponding to its index
  102287. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102288. */
  102289. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  102290. /**
  102291. * Clones the texture.
  102292. * @returns the cloned texture
  102293. */
  102294. clone(): RenderTargetTexture;
  102295. /**
  102296. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  102297. * @returns The JSON representation of the texture
  102298. */
  102299. serialize(): any;
  102300. /**
  102301. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  102302. */
  102303. disposeFramebufferObjects(): void;
  102304. /**
  102305. * Dispose the texture and release its associated resources.
  102306. */
  102307. dispose(): void;
  102308. /** @hidden */
  102309. _rebuild(): void;
  102310. /**
  102311. * Clear the info related to rendering groups preventing retention point in material dispose.
  102312. */
  102313. freeRenderingGroups(): void;
  102314. /**
  102315. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  102316. * @returns the view count
  102317. */
  102318. getViewCount(): number;
  102319. }
  102320. }
  102321. declare module BABYLON {
  102322. /**
  102323. * Class used to manipulate GUIDs
  102324. */
  102325. export class GUID {
  102326. /**
  102327. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102328. * Be aware Math.random() could cause collisions, but:
  102329. * "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"
  102330. * @returns a pseudo random id
  102331. */
  102332. static RandomId(): string;
  102333. }
  102334. }
  102335. declare module BABYLON {
  102336. /**
  102337. * Options to be used when creating a shadow depth material
  102338. */
  102339. export interface IIOptionShadowDepthMaterial {
  102340. /** Variables in the vertex shader code that need to have their names remapped.
  102341. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  102342. * "var_name" should be either: worldPos or vNormalW
  102343. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  102344. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  102345. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  102346. */
  102347. remappedVariables?: string[];
  102348. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  102349. standalone?: boolean;
  102350. }
  102351. /**
  102352. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  102353. */
  102354. export class ShadowDepthWrapper {
  102355. private _scene;
  102356. private _options?;
  102357. private _baseMaterial;
  102358. private _onEffectCreatedObserver;
  102359. private _subMeshToEffect;
  102360. private _subMeshToDepthEffect;
  102361. private _meshes;
  102362. /** @hidden */
  102363. _matriceNames: any;
  102364. /** Gets the standalone status of the wrapper */
  102365. get standalone(): boolean;
  102366. /** Gets the base material the wrapper is built upon */
  102367. get baseMaterial(): Material;
  102368. /**
  102369. * Instantiate a new shadow depth wrapper.
  102370. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  102371. * generate the shadow depth map. For more information, please refer to the documentation:
  102372. * https://doc.babylonjs.com/babylon101/shadows
  102373. * @param baseMaterial Material to wrap
  102374. * @param scene Define the scene the material belongs to
  102375. * @param options Options used to create the wrapper
  102376. */
  102377. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  102378. /**
  102379. * Gets the effect to use to generate the depth map
  102380. * @param subMesh subMesh to get the effect for
  102381. * @param shadowGenerator shadow generator to get the effect for
  102382. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  102383. */
  102384. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  102385. /**
  102386. * Specifies that the submesh is ready to be used for depth rendering
  102387. * @param subMesh submesh to check
  102388. * @param defines the list of defines to take into account when checking the effect
  102389. * @param shadowGenerator combined with subMesh, it defines the effect to check
  102390. * @param useInstances specifies that instances should be used
  102391. * @returns a boolean indicating that the submesh is ready or not
  102392. */
  102393. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  102394. /**
  102395. * Disposes the resources
  102396. */
  102397. dispose(): void;
  102398. private _makeEffect;
  102399. }
  102400. }
  102401. declare module BABYLON {
  102402. interface ThinEngine {
  102403. /**
  102404. * Unbind a list of render target textures from the webGL context
  102405. * This is used only when drawBuffer extension or webGL2 are active
  102406. * @param textures defines the render target textures to unbind
  102407. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  102408. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  102409. */
  102410. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  102411. /**
  102412. * Create a multi render target texture
  102413. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  102414. * @param size defines the size of the texture
  102415. * @param options defines the creation options
  102416. * @returns the cube texture as an InternalTexture
  102417. */
  102418. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  102419. /**
  102420. * Update the sample count for a given multiple render target texture
  102421. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  102422. * @param textures defines the textures to update
  102423. * @param samples defines the sample count to set
  102424. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  102425. */
  102426. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  102427. /**
  102428. * Select a subsets of attachments to draw to.
  102429. * @param attachments gl attachments
  102430. */
  102431. bindAttachments(attachments: number[]): void;
  102432. }
  102433. }
  102434. declare module BABYLON {
  102435. /**
  102436. * Creation options of the multi render target texture.
  102437. */
  102438. export interface IMultiRenderTargetOptions {
  102439. /**
  102440. * Define if the texture needs to create mip maps after render.
  102441. */
  102442. generateMipMaps?: boolean;
  102443. /**
  102444. * Define the types of all the draw buffers we want to create
  102445. */
  102446. types?: number[];
  102447. /**
  102448. * Define the sampling modes of all the draw buffers we want to create
  102449. */
  102450. samplingModes?: number[];
  102451. /**
  102452. * Define if a depth buffer is required
  102453. */
  102454. generateDepthBuffer?: boolean;
  102455. /**
  102456. * Define if a stencil buffer is required
  102457. */
  102458. generateStencilBuffer?: boolean;
  102459. /**
  102460. * Define if a depth texture is required instead of a depth buffer
  102461. */
  102462. generateDepthTexture?: boolean;
  102463. /**
  102464. * Define the number of desired draw buffers
  102465. */
  102466. textureCount?: number;
  102467. /**
  102468. * Define if aspect ratio should be adapted to the texture or stay the scene one
  102469. */
  102470. doNotChangeAspectRatio?: boolean;
  102471. /**
  102472. * Define the default type of the buffers we are creating
  102473. */
  102474. defaultType?: number;
  102475. }
  102476. /**
  102477. * A multi render target, like a render target provides the ability to render to a texture.
  102478. * Unlike the render target, it can render to several draw buffers in one draw.
  102479. * This is specially interesting in deferred rendering or for any effects requiring more than
  102480. * just one color from a single pass.
  102481. */
  102482. export class MultiRenderTarget extends RenderTargetTexture {
  102483. private _internalTextures;
  102484. private _textures;
  102485. private _multiRenderTargetOptions;
  102486. private _count;
  102487. /**
  102488. * Get if draw buffers are currently supported by the used hardware and browser.
  102489. */
  102490. get isSupported(): boolean;
  102491. /**
  102492. * Get the list of textures generated by the multi render target.
  102493. */
  102494. get textures(): Texture[];
  102495. /**
  102496. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  102497. */
  102498. get count(): number;
  102499. /**
  102500. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  102501. */
  102502. get depthTexture(): Texture;
  102503. /**
  102504. * Set the wrapping mode on U of all the textures we are rendering to.
  102505. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  102506. */
  102507. set wrapU(wrap: number);
  102508. /**
  102509. * Set the wrapping mode on V of all the textures we are rendering to.
  102510. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  102511. */
  102512. set wrapV(wrap: number);
  102513. /**
  102514. * Instantiate a new multi render target texture.
  102515. * A multi render target, like a render target provides the ability to render to a texture.
  102516. * Unlike the render target, it can render to several draw buffers in one draw.
  102517. * This is specially interesting in deferred rendering or for any effects requiring more than
  102518. * just one color from a single pass.
  102519. * @param name Define the name of the texture
  102520. * @param size Define the size of the buffers to render to
  102521. * @param count Define the number of target we are rendering into
  102522. * @param scene Define the scene the texture belongs to
  102523. * @param options Define the options used to create the multi render target
  102524. */
  102525. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  102526. /** @hidden */
  102527. _rebuild(): void;
  102528. private _createInternalTextures;
  102529. private _createTextures;
  102530. /**
  102531. * Define the number of samples used if MSAA is enabled.
  102532. */
  102533. get samples(): number;
  102534. set samples(value: number);
  102535. /**
  102536. * Resize all the textures in the multi render target.
  102537. * Be carrefull as it will recreate all the data in the new texture.
  102538. * @param size Define the new size
  102539. */
  102540. resize(size: any): void;
  102541. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  102542. /**
  102543. * Dispose the render targets and their associated resources
  102544. */
  102545. dispose(): void;
  102546. /**
  102547. * Release all the underlying texture used as draw buffers.
  102548. */
  102549. releaseInternalTextures(): void;
  102550. }
  102551. }
  102552. declare module BABYLON {
  102553. /** @hidden */
  102554. export var imageProcessingPixelShader: {
  102555. name: string;
  102556. shader: string;
  102557. };
  102558. }
  102559. declare module BABYLON {
  102560. /**
  102561. * ImageProcessingPostProcess
  102562. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102563. */
  102564. export class ImageProcessingPostProcess extends PostProcess {
  102565. /**
  102566. * Default configuration related to image processing available in the PBR Material.
  102567. */
  102568. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102569. /**
  102570. * Gets the image processing configuration used either in this material.
  102571. */
  102572. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102573. /**
  102574. * Sets the Default image processing configuration used either in the this material.
  102575. *
  102576. * If sets to null, the scene one is in use.
  102577. */
  102578. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102579. /**
  102580. * Keep track of the image processing observer to allow dispose and replace.
  102581. */
  102582. private _imageProcessingObserver;
  102583. /**
  102584. * Attaches a new image processing configuration to the PBR Material.
  102585. * @param configuration
  102586. */
  102587. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102588. /**
  102589. * If the post process is supported.
  102590. */
  102591. get isSupported(): boolean;
  102592. /**
  102593. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102594. */
  102595. get colorCurves(): Nullable<ColorCurves>;
  102596. /**
  102597. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102598. */
  102599. set colorCurves(value: Nullable<ColorCurves>);
  102600. /**
  102601. * Gets wether the color curves effect is enabled.
  102602. */
  102603. get colorCurvesEnabled(): boolean;
  102604. /**
  102605. * Sets wether the color curves effect is enabled.
  102606. */
  102607. set colorCurvesEnabled(value: boolean);
  102608. /**
  102609. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102610. */
  102611. get colorGradingTexture(): Nullable<BaseTexture>;
  102612. /**
  102613. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102614. */
  102615. set colorGradingTexture(value: Nullable<BaseTexture>);
  102616. /**
  102617. * Gets wether the color grading effect is enabled.
  102618. */
  102619. get colorGradingEnabled(): boolean;
  102620. /**
  102621. * Gets wether the color grading effect is enabled.
  102622. */
  102623. set colorGradingEnabled(value: boolean);
  102624. /**
  102625. * Gets exposure used in the effect.
  102626. */
  102627. get exposure(): number;
  102628. /**
  102629. * Sets exposure used in the effect.
  102630. */
  102631. set exposure(value: number);
  102632. /**
  102633. * Gets wether tonemapping is enabled or not.
  102634. */
  102635. get toneMappingEnabled(): boolean;
  102636. /**
  102637. * Sets wether tonemapping is enabled or not
  102638. */
  102639. set toneMappingEnabled(value: boolean);
  102640. /**
  102641. * Gets the type of tone mapping effect.
  102642. */
  102643. get toneMappingType(): number;
  102644. /**
  102645. * Sets the type of tone mapping effect.
  102646. */
  102647. set toneMappingType(value: number);
  102648. /**
  102649. * Gets contrast used in the effect.
  102650. */
  102651. get contrast(): number;
  102652. /**
  102653. * Sets contrast used in the effect.
  102654. */
  102655. set contrast(value: number);
  102656. /**
  102657. * Gets Vignette stretch size.
  102658. */
  102659. get vignetteStretch(): number;
  102660. /**
  102661. * Sets Vignette stretch size.
  102662. */
  102663. set vignetteStretch(value: number);
  102664. /**
  102665. * Gets Vignette centre X Offset.
  102666. */
  102667. get vignetteCentreX(): number;
  102668. /**
  102669. * Sets Vignette centre X Offset.
  102670. */
  102671. set vignetteCentreX(value: number);
  102672. /**
  102673. * Gets Vignette centre Y Offset.
  102674. */
  102675. get vignetteCentreY(): number;
  102676. /**
  102677. * Sets Vignette centre Y Offset.
  102678. */
  102679. set vignetteCentreY(value: number);
  102680. /**
  102681. * Gets Vignette weight or intensity of the vignette effect.
  102682. */
  102683. get vignetteWeight(): number;
  102684. /**
  102685. * Sets Vignette weight or intensity of the vignette effect.
  102686. */
  102687. set vignetteWeight(value: number);
  102688. /**
  102689. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102690. * if vignetteEnabled is set to true.
  102691. */
  102692. get vignetteColor(): Color4;
  102693. /**
  102694. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102695. * if vignetteEnabled is set to true.
  102696. */
  102697. set vignetteColor(value: Color4);
  102698. /**
  102699. * Gets Camera field of view used by the Vignette effect.
  102700. */
  102701. get vignetteCameraFov(): number;
  102702. /**
  102703. * Sets Camera field of view used by the Vignette effect.
  102704. */
  102705. set vignetteCameraFov(value: number);
  102706. /**
  102707. * Gets the vignette blend mode allowing different kind of effect.
  102708. */
  102709. get vignetteBlendMode(): number;
  102710. /**
  102711. * Sets the vignette blend mode allowing different kind of effect.
  102712. */
  102713. set vignetteBlendMode(value: number);
  102714. /**
  102715. * Gets wether the vignette effect is enabled.
  102716. */
  102717. get vignetteEnabled(): boolean;
  102718. /**
  102719. * Sets wether the vignette effect is enabled.
  102720. */
  102721. set vignetteEnabled(value: boolean);
  102722. private _fromLinearSpace;
  102723. /**
  102724. * Gets wether the input of the processing is in Gamma or Linear Space.
  102725. */
  102726. get fromLinearSpace(): boolean;
  102727. /**
  102728. * Sets wether the input of the processing is in Gamma or Linear Space.
  102729. */
  102730. set fromLinearSpace(value: boolean);
  102731. /**
  102732. * Defines cache preventing GC.
  102733. */
  102734. private _defines;
  102735. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102736. /**
  102737. * "ImageProcessingPostProcess"
  102738. * @returns "ImageProcessingPostProcess"
  102739. */
  102740. getClassName(): string;
  102741. /**
  102742. * @hidden
  102743. */
  102744. _updateParameters(): void;
  102745. dispose(camera?: Camera): void;
  102746. }
  102747. }
  102748. declare module BABYLON {
  102749. /** @hidden */
  102750. export var fibonacci: {
  102751. name: string;
  102752. shader: string;
  102753. };
  102754. }
  102755. declare module BABYLON {
  102756. /** @hidden */
  102757. export var subSurfaceScatteringFunctions: {
  102758. name: string;
  102759. shader: string;
  102760. };
  102761. }
  102762. declare module BABYLON {
  102763. /** @hidden */
  102764. export var diffusionProfile: {
  102765. name: string;
  102766. shader: string;
  102767. };
  102768. }
  102769. declare module BABYLON {
  102770. /** @hidden */
  102771. export var subSurfaceScatteringPixelShader: {
  102772. name: string;
  102773. shader: string;
  102774. };
  102775. }
  102776. declare module BABYLON {
  102777. /**
  102778. * Sub surface scattering post process
  102779. */
  102780. export class SubSurfaceScatteringPostProcess extends PostProcess {
  102781. /** @hidden */
  102782. texelWidth: number;
  102783. /** @hidden */
  102784. texelHeight: number;
  102785. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  102786. }
  102787. }
  102788. declare module BABYLON {
  102789. /**
  102790. * Interface for defining prepass effects in the prepass post-process pipeline
  102791. */
  102792. export interface PrePassEffectConfiguration {
  102793. /**
  102794. * Post process to attach for this effect
  102795. */
  102796. postProcess: PostProcess;
  102797. /**
  102798. * Is the effect enabled
  102799. */
  102800. enabled: boolean;
  102801. /**
  102802. * Disposes the effect configuration
  102803. */
  102804. dispose(): void;
  102805. /**
  102806. * Disposes the effect configuration
  102807. */
  102808. createPostProcess: () => PostProcess;
  102809. }
  102810. }
  102811. declare module BABYLON {
  102812. /**
  102813. * Contains all parameters needed for the prepass to perform
  102814. * screen space subsurface scattering
  102815. */
  102816. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  102817. private _ssDiffusionS;
  102818. private _ssFilterRadii;
  102819. private _ssDiffusionD;
  102820. /**
  102821. * Post process to attach for screen space subsurface scattering
  102822. */
  102823. postProcess: SubSurfaceScatteringPostProcess;
  102824. /**
  102825. * Diffusion profile color for subsurface scattering
  102826. */
  102827. get ssDiffusionS(): number[];
  102828. /**
  102829. * Diffusion profile max color channel value for subsurface scattering
  102830. */
  102831. get ssDiffusionD(): number[];
  102832. /**
  102833. * Diffusion profile filter radius for subsurface scattering
  102834. */
  102835. get ssFilterRadii(): number[];
  102836. /**
  102837. * Is subsurface enabled
  102838. */
  102839. enabled: boolean;
  102840. /**
  102841. * Diffusion profile colors for subsurface scattering
  102842. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  102843. * See ...
  102844. * Note that you can only store up to 5 of them
  102845. */
  102846. ssDiffusionProfileColors: Color3[];
  102847. /**
  102848. * Defines the ratio real world => scene units.
  102849. * Used for subsurface scattering
  102850. */
  102851. metersPerUnit: number;
  102852. private _scene;
  102853. /**
  102854. * Builds a subsurface configuration object
  102855. * @param scene The scene
  102856. */
  102857. constructor(scene: Scene);
  102858. /**
  102859. * Adds a new diffusion profile.
  102860. * Useful for more realistic subsurface scattering on diverse materials.
  102861. * @param color The color of the diffusion profile. Should be the average color of the material.
  102862. * @return The index of the diffusion profile for the material subsurface configuration
  102863. */
  102864. addDiffusionProfile(color: Color3): number;
  102865. /**
  102866. * Creates the sss post process
  102867. * @return The created post process
  102868. */
  102869. createPostProcess(): SubSurfaceScatteringPostProcess;
  102870. /**
  102871. * Deletes all diffusion profiles.
  102872. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  102873. */
  102874. clearAllDiffusionProfiles(): void;
  102875. /**
  102876. * Disposes this object
  102877. */
  102878. dispose(): void;
  102879. /**
  102880. * @hidden
  102881. * https://zero-radiance.github.io/post/sampling-diffusion/
  102882. *
  102883. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  102884. * ------------------------------------------------------------------------------------
  102885. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  102886. * PDF[r, phi, s] = r * R[r, phi, s]
  102887. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  102888. * ------------------------------------------------------------------------------------
  102889. * We importance sample the color channel with the widest scattering distance.
  102890. */
  102891. getDiffusionProfileParameters(color: Color3): number;
  102892. /**
  102893. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  102894. * 'u' is the random number (the value of the CDF): [0, 1).
  102895. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  102896. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  102897. */
  102898. private _sampleBurleyDiffusionProfile;
  102899. }
  102900. }
  102901. declare module BABYLON {
  102902. /**
  102903. * Renders a pre pass of the scene
  102904. * This means every mesh in the scene will be rendered to a render target texture
  102905. * And then this texture will be composited to the rendering canvas with post processes
  102906. * It is necessary for effects like subsurface scattering or deferred shading
  102907. */
  102908. export class PrePassRenderer {
  102909. /** @hidden */
  102910. static _SceneComponentInitialization: (scene: Scene) => void;
  102911. private _scene;
  102912. private _engine;
  102913. private _isDirty;
  102914. /**
  102915. * Number of textures in the multi render target texture where the scene is directly rendered
  102916. */
  102917. readonly mrtCount: number;
  102918. /**
  102919. * The render target where the scene is directly rendered
  102920. */
  102921. prePassRT: MultiRenderTarget;
  102922. private _mrtTypes;
  102923. private _multiRenderAttachments;
  102924. private _defaultAttachments;
  102925. private _clearAttachments;
  102926. private _postProcesses;
  102927. private readonly _clearColor;
  102928. /**
  102929. * Image processing post process for composition
  102930. */
  102931. imageProcessingPostProcess: ImageProcessingPostProcess;
  102932. /**
  102933. * Configuration for sub surface scattering post process
  102934. */
  102935. subSurfaceConfiguration: SubSurfaceConfiguration;
  102936. /**
  102937. * Should materials render their geometry on the MRT
  102938. */
  102939. materialsShouldRenderGeometry: boolean;
  102940. /**
  102941. * Should materials render the irradiance information on the MRT
  102942. */
  102943. materialsShouldRenderIrradiance: boolean;
  102944. private _enabled;
  102945. /**
  102946. * Indicates if the prepass is enabled
  102947. */
  102948. get enabled(): boolean;
  102949. /**
  102950. * How many samples are used for MSAA of the scene render target
  102951. */
  102952. get samples(): number;
  102953. set samples(n: number);
  102954. /**
  102955. * Instanciates a prepass renderer
  102956. * @param scene The scene
  102957. */
  102958. constructor(scene: Scene);
  102959. private _initializeAttachments;
  102960. private _createCompositionEffect;
  102961. /**
  102962. * Indicates if rendering a prepass is supported
  102963. */
  102964. get isSupported(): boolean;
  102965. /**
  102966. * Sets the proper output textures to draw in the engine.
  102967. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  102968. */
  102969. bindAttachmentsForEffect(effect: Effect): void;
  102970. /**
  102971. * @hidden
  102972. */
  102973. _beforeCameraDraw(): void;
  102974. /**
  102975. * @hidden
  102976. */
  102977. _afterCameraDraw(): void;
  102978. private _checkRTSize;
  102979. private _bindFrameBuffer;
  102980. /**
  102981. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  102982. */
  102983. clear(): void;
  102984. private _setState;
  102985. private _enable;
  102986. private _disable;
  102987. private _resetPostProcessChain;
  102988. private _bindPostProcessChain;
  102989. /**
  102990. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  102991. */
  102992. markAsDirty(): void;
  102993. private _update;
  102994. /**
  102995. * Disposes the prepass renderer.
  102996. */
  102997. dispose(): void;
  102998. }
  102999. }
  103000. declare module BABYLON {
  103001. /**
  103002. * Options for compiling materials.
  103003. */
  103004. export interface IMaterialCompilationOptions {
  103005. /**
  103006. * Defines whether clip planes are enabled.
  103007. */
  103008. clipPlane: boolean;
  103009. /**
  103010. * Defines whether instances are enabled.
  103011. */
  103012. useInstances: boolean;
  103013. }
  103014. /**
  103015. * Options passed when calling customShaderNameResolve
  103016. */
  103017. export interface ICustomShaderNameResolveOptions {
  103018. /**
  103019. * 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
  103020. */
  103021. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  103022. }
  103023. /**
  103024. * Base class for the main features of a material in Babylon.js
  103025. */
  103026. export class Material implements IAnimatable {
  103027. /**
  103028. * Returns the triangle fill mode
  103029. */
  103030. static readonly TriangleFillMode: number;
  103031. /**
  103032. * Returns the wireframe mode
  103033. */
  103034. static readonly WireFrameFillMode: number;
  103035. /**
  103036. * Returns the point fill mode
  103037. */
  103038. static readonly PointFillMode: number;
  103039. /**
  103040. * Returns the point list draw mode
  103041. */
  103042. static readonly PointListDrawMode: number;
  103043. /**
  103044. * Returns the line list draw mode
  103045. */
  103046. static readonly LineListDrawMode: number;
  103047. /**
  103048. * Returns the line loop draw mode
  103049. */
  103050. static readonly LineLoopDrawMode: number;
  103051. /**
  103052. * Returns the line strip draw mode
  103053. */
  103054. static readonly LineStripDrawMode: number;
  103055. /**
  103056. * Returns the triangle strip draw mode
  103057. */
  103058. static readonly TriangleStripDrawMode: number;
  103059. /**
  103060. * Returns the triangle fan draw mode
  103061. */
  103062. static readonly TriangleFanDrawMode: number;
  103063. /**
  103064. * Stores the clock-wise side orientation
  103065. */
  103066. static readonly ClockWiseSideOrientation: number;
  103067. /**
  103068. * Stores the counter clock-wise side orientation
  103069. */
  103070. static readonly CounterClockWiseSideOrientation: number;
  103071. /**
  103072. * The dirty texture flag value
  103073. */
  103074. static readonly TextureDirtyFlag: number;
  103075. /**
  103076. * The dirty light flag value
  103077. */
  103078. static readonly LightDirtyFlag: number;
  103079. /**
  103080. * The dirty fresnel flag value
  103081. */
  103082. static readonly FresnelDirtyFlag: number;
  103083. /**
  103084. * The dirty attribute flag value
  103085. */
  103086. static readonly AttributesDirtyFlag: number;
  103087. /**
  103088. * The dirty misc flag value
  103089. */
  103090. static readonly MiscDirtyFlag: number;
  103091. /**
  103092. * The all dirty flag value
  103093. */
  103094. static readonly AllDirtyFlag: number;
  103095. /**
  103096. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  103097. */
  103098. static readonly MATERIAL_OPAQUE: number;
  103099. /**
  103100. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  103101. */
  103102. static readonly MATERIAL_ALPHATEST: number;
  103103. /**
  103104. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103105. */
  103106. static readonly MATERIAL_ALPHABLEND: number;
  103107. /**
  103108. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103109. * They are also discarded below the alpha cutoff threshold to improve performances.
  103110. */
  103111. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  103112. /**
  103113. * The Whiteout method is used to blend normals.
  103114. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  103115. */
  103116. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  103117. /**
  103118. * The Reoriented Normal Mapping method is used to blend normals.
  103119. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  103120. */
  103121. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  103122. /**
  103123. * Custom callback helping to override the default shader used in the material.
  103124. */
  103125. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  103126. /**
  103127. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  103128. */
  103129. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  103130. /**
  103131. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  103132. * This means that the material can keep using a previous shader while a new one is being compiled.
  103133. * This is mostly used when shader parallel compilation is supported (true by default)
  103134. */
  103135. allowShaderHotSwapping: boolean;
  103136. /**
  103137. * The ID of the material
  103138. */
  103139. id: string;
  103140. /**
  103141. * Gets or sets the unique id of the material
  103142. */
  103143. uniqueId: number;
  103144. /**
  103145. * The name of the material
  103146. */
  103147. name: string;
  103148. /**
  103149. * Gets or sets user defined metadata
  103150. */
  103151. metadata: any;
  103152. /**
  103153. * For internal use only. Please do not use.
  103154. */
  103155. reservedDataStore: any;
  103156. /**
  103157. * Specifies if the ready state should be checked on each call
  103158. */
  103159. checkReadyOnEveryCall: boolean;
  103160. /**
  103161. * Specifies if the ready state should be checked once
  103162. */
  103163. checkReadyOnlyOnce: boolean;
  103164. /**
  103165. * The state of the material
  103166. */
  103167. state: string;
  103168. /**
  103169. * If the material can be rendered to several textures with MRT extension
  103170. */
  103171. get canRenderToMRT(): boolean;
  103172. /**
  103173. * The alpha value of the material
  103174. */
  103175. protected _alpha: number;
  103176. /**
  103177. * List of inspectable custom properties (used by the Inspector)
  103178. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103179. */
  103180. inspectableCustomProperties: IInspectable[];
  103181. /**
  103182. * Sets the alpha value of the material
  103183. */
  103184. set alpha(value: number);
  103185. /**
  103186. * Gets the alpha value of the material
  103187. */
  103188. get alpha(): number;
  103189. /**
  103190. * Specifies if back face culling is enabled
  103191. */
  103192. protected _backFaceCulling: boolean;
  103193. /**
  103194. * Sets the back-face culling state
  103195. */
  103196. set backFaceCulling(value: boolean);
  103197. /**
  103198. * Gets the back-face culling state
  103199. */
  103200. get backFaceCulling(): boolean;
  103201. /**
  103202. * Stores the value for side orientation
  103203. */
  103204. sideOrientation: number;
  103205. /**
  103206. * Callback triggered when the material is compiled
  103207. */
  103208. onCompiled: Nullable<(effect: Effect) => void>;
  103209. /**
  103210. * Callback triggered when an error occurs
  103211. */
  103212. onError: Nullable<(effect: Effect, errors: string) => void>;
  103213. /**
  103214. * Callback triggered to get the render target textures
  103215. */
  103216. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  103217. /**
  103218. * Gets a boolean indicating that current material needs to register RTT
  103219. */
  103220. get hasRenderTargetTextures(): boolean;
  103221. /**
  103222. * Specifies if the material should be serialized
  103223. */
  103224. doNotSerialize: boolean;
  103225. /**
  103226. * @hidden
  103227. */
  103228. _storeEffectOnSubMeshes: boolean;
  103229. /**
  103230. * Stores the animations for the material
  103231. */
  103232. animations: Nullable<Array<Animation>>;
  103233. /**
  103234. * An event triggered when the material is disposed
  103235. */
  103236. onDisposeObservable: Observable<Material>;
  103237. /**
  103238. * An observer which watches for dispose events
  103239. */
  103240. private _onDisposeObserver;
  103241. private _onUnBindObservable;
  103242. /**
  103243. * Called during a dispose event
  103244. */
  103245. set onDispose(callback: () => void);
  103246. private _onBindObservable;
  103247. /**
  103248. * An event triggered when the material is bound
  103249. */
  103250. get onBindObservable(): Observable<AbstractMesh>;
  103251. /**
  103252. * An observer which watches for bind events
  103253. */
  103254. private _onBindObserver;
  103255. /**
  103256. * Called during a bind event
  103257. */
  103258. set onBind(callback: (Mesh: AbstractMesh) => void);
  103259. /**
  103260. * An event triggered when the material is unbound
  103261. */
  103262. get onUnBindObservable(): Observable<Material>;
  103263. protected _onEffectCreatedObservable: Nullable<Observable<{
  103264. effect: Effect;
  103265. subMesh: Nullable<SubMesh>;
  103266. }>>;
  103267. /**
  103268. * An event triggered when the effect is (re)created
  103269. */
  103270. get onEffectCreatedObservable(): Observable<{
  103271. effect: Effect;
  103272. subMesh: Nullable<SubMesh>;
  103273. }>;
  103274. /**
  103275. * Stores the value of the alpha mode
  103276. */
  103277. private _alphaMode;
  103278. /**
  103279. * Sets the value of the alpha mode.
  103280. *
  103281. * | Value | Type | Description |
  103282. * | --- | --- | --- |
  103283. * | 0 | ALPHA_DISABLE | |
  103284. * | 1 | ALPHA_ADD | |
  103285. * | 2 | ALPHA_COMBINE | |
  103286. * | 3 | ALPHA_SUBTRACT | |
  103287. * | 4 | ALPHA_MULTIPLY | |
  103288. * | 5 | ALPHA_MAXIMIZED | |
  103289. * | 6 | ALPHA_ONEONE | |
  103290. * | 7 | ALPHA_PREMULTIPLIED | |
  103291. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  103292. * | 9 | ALPHA_INTERPOLATE | |
  103293. * | 10 | ALPHA_SCREENMODE | |
  103294. *
  103295. */
  103296. set alphaMode(value: number);
  103297. /**
  103298. * Gets the value of the alpha mode
  103299. */
  103300. get alphaMode(): number;
  103301. /**
  103302. * Stores the state of the need depth pre-pass value
  103303. */
  103304. private _needDepthPrePass;
  103305. /**
  103306. * Sets the need depth pre-pass value
  103307. */
  103308. set needDepthPrePass(value: boolean);
  103309. /**
  103310. * Gets the depth pre-pass value
  103311. */
  103312. get needDepthPrePass(): boolean;
  103313. /**
  103314. * Specifies if depth writing should be disabled
  103315. */
  103316. disableDepthWrite: boolean;
  103317. /**
  103318. * Specifies if color writing should be disabled
  103319. */
  103320. disableColorWrite: boolean;
  103321. /**
  103322. * Specifies if depth writing should be forced
  103323. */
  103324. forceDepthWrite: boolean;
  103325. /**
  103326. * Specifies the depth function that should be used. 0 means the default engine function
  103327. */
  103328. depthFunction: number;
  103329. /**
  103330. * Specifies if there should be a separate pass for culling
  103331. */
  103332. separateCullingPass: boolean;
  103333. /**
  103334. * Stores the state specifing if fog should be enabled
  103335. */
  103336. private _fogEnabled;
  103337. /**
  103338. * Sets the state for enabling fog
  103339. */
  103340. set fogEnabled(value: boolean);
  103341. /**
  103342. * Gets the value of the fog enabled state
  103343. */
  103344. get fogEnabled(): boolean;
  103345. /**
  103346. * Stores the size of points
  103347. */
  103348. pointSize: number;
  103349. /**
  103350. * Stores the z offset value
  103351. */
  103352. zOffset: number;
  103353. get wireframe(): boolean;
  103354. /**
  103355. * Sets the state of wireframe mode
  103356. */
  103357. set wireframe(value: boolean);
  103358. /**
  103359. * Gets the value specifying if point clouds are enabled
  103360. */
  103361. get pointsCloud(): boolean;
  103362. /**
  103363. * Sets the state of point cloud mode
  103364. */
  103365. set pointsCloud(value: boolean);
  103366. /**
  103367. * Gets the material fill mode
  103368. */
  103369. get fillMode(): number;
  103370. /**
  103371. * Sets the material fill mode
  103372. */
  103373. set fillMode(value: number);
  103374. /**
  103375. * @hidden
  103376. * Stores the effects for the material
  103377. */
  103378. _effect: Nullable<Effect>;
  103379. /**
  103380. * Specifies if uniform buffers should be used
  103381. */
  103382. private _useUBO;
  103383. /**
  103384. * Stores a reference to the scene
  103385. */
  103386. private _scene;
  103387. /**
  103388. * Stores the fill mode state
  103389. */
  103390. private _fillMode;
  103391. /**
  103392. * Specifies if the depth write state should be cached
  103393. */
  103394. private _cachedDepthWriteState;
  103395. /**
  103396. * Specifies if the color write state should be cached
  103397. */
  103398. private _cachedColorWriteState;
  103399. /**
  103400. * Specifies if the depth function state should be cached
  103401. */
  103402. private _cachedDepthFunctionState;
  103403. /**
  103404. * Stores the uniform buffer
  103405. */
  103406. protected _uniformBuffer: UniformBuffer;
  103407. /** @hidden */
  103408. _indexInSceneMaterialArray: number;
  103409. /** @hidden */
  103410. meshMap: Nullable<{
  103411. [id: string]: AbstractMesh | undefined;
  103412. }>;
  103413. /**
  103414. * Creates a material instance
  103415. * @param name defines the name of the material
  103416. * @param scene defines the scene to reference
  103417. * @param doNotAdd specifies if the material should be added to the scene
  103418. */
  103419. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  103420. /**
  103421. * Returns a string representation of the current material
  103422. * @param fullDetails defines a boolean indicating which levels of logging is desired
  103423. * @returns a string with material information
  103424. */
  103425. toString(fullDetails?: boolean): string;
  103426. /**
  103427. * Gets the class name of the material
  103428. * @returns a string with the class name of the material
  103429. */
  103430. getClassName(): string;
  103431. /**
  103432. * Specifies if updates for the material been locked
  103433. */
  103434. get isFrozen(): boolean;
  103435. /**
  103436. * Locks updates for the material
  103437. */
  103438. freeze(): void;
  103439. /**
  103440. * Unlocks updates for the material
  103441. */
  103442. unfreeze(): void;
  103443. /**
  103444. * Specifies if the material is ready to be used
  103445. * @param mesh defines the mesh to check
  103446. * @param useInstances specifies if instances should be used
  103447. * @returns a boolean indicating if the material is ready to be used
  103448. */
  103449. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  103450. /**
  103451. * Specifies that the submesh is ready to be used
  103452. * @param mesh defines the mesh to check
  103453. * @param subMesh defines which submesh to check
  103454. * @param useInstances specifies that instances should be used
  103455. * @returns a boolean indicating that the submesh is ready or not
  103456. */
  103457. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103458. /**
  103459. * Returns the material effect
  103460. * @returns the effect associated with the material
  103461. */
  103462. getEffect(): Nullable<Effect>;
  103463. /**
  103464. * Returns the current scene
  103465. * @returns a Scene
  103466. */
  103467. getScene(): Scene;
  103468. /**
  103469. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  103470. */
  103471. protected _forceAlphaTest: boolean;
  103472. /**
  103473. * The transparency mode of the material.
  103474. */
  103475. protected _transparencyMode: Nullable<number>;
  103476. /**
  103477. * Gets the current transparency mode.
  103478. */
  103479. get transparencyMode(): Nullable<number>;
  103480. /**
  103481. * Sets the transparency mode of the material.
  103482. *
  103483. * | Value | Type | Description |
  103484. * | ----- | ----------------------------------- | ----------- |
  103485. * | 0 | OPAQUE | |
  103486. * | 1 | ALPHATEST | |
  103487. * | 2 | ALPHABLEND | |
  103488. * | 3 | ALPHATESTANDBLEND | |
  103489. *
  103490. */
  103491. set transparencyMode(value: Nullable<number>);
  103492. /**
  103493. * Returns true if alpha blending should be disabled.
  103494. */
  103495. protected get _disableAlphaBlending(): boolean;
  103496. /**
  103497. * Specifies whether or not this material should be rendered in alpha blend mode.
  103498. * @returns a boolean specifying if alpha blending is needed
  103499. */
  103500. needAlphaBlending(): boolean;
  103501. /**
  103502. * Specifies if the mesh will require alpha blending
  103503. * @param mesh defines the mesh to check
  103504. * @returns a boolean specifying if alpha blending is needed for the mesh
  103505. */
  103506. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  103507. /**
  103508. * Specifies whether or not this material should be rendered in alpha test mode.
  103509. * @returns a boolean specifying if an alpha test is needed.
  103510. */
  103511. needAlphaTesting(): boolean;
  103512. /**
  103513. * Specifies if material alpha testing should be turned on for the mesh
  103514. * @param mesh defines the mesh to check
  103515. */
  103516. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  103517. /**
  103518. * Gets the texture used for the alpha test
  103519. * @returns the texture to use for alpha testing
  103520. */
  103521. getAlphaTestTexture(): Nullable<BaseTexture>;
  103522. /**
  103523. * Marks the material to indicate that it needs to be re-calculated
  103524. */
  103525. markDirty(): void;
  103526. /** @hidden */
  103527. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  103528. /**
  103529. * Binds the material to the mesh
  103530. * @param world defines the world transformation matrix
  103531. * @param mesh defines the mesh to bind the material to
  103532. */
  103533. bind(world: Matrix, mesh?: Mesh): void;
  103534. /**
  103535. * Binds the submesh to the material
  103536. * @param world defines the world transformation matrix
  103537. * @param mesh defines the mesh containing the submesh
  103538. * @param subMesh defines the submesh to bind the material to
  103539. */
  103540. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103541. /**
  103542. * Binds the world matrix to the material
  103543. * @param world defines the world transformation matrix
  103544. */
  103545. bindOnlyWorldMatrix(world: Matrix): void;
  103546. /**
  103547. * Binds the scene's uniform buffer to the effect.
  103548. * @param effect defines the effect to bind to the scene uniform buffer
  103549. * @param sceneUbo defines the uniform buffer storing scene data
  103550. */
  103551. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  103552. /**
  103553. * Binds the view matrix to the effect
  103554. * @param effect defines the effect to bind the view matrix to
  103555. */
  103556. bindView(effect: Effect): void;
  103557. /**
  103558. * Binds the view projection matrix to the effect
  103559. * @param effect defines the effect to bind the view projection matrix to
  103560. */
  103561. bindViewProjection(effect: Effect): void;
  103562. /**
  103563. * Processes to execute after binding the material to a mesh
  103564. * @param mesh defines the rendered mesh
  103565. */
  103566. protected _afterBind(mesh?: Mesh): void;
  103567. /**
  103568. * Unbinds the material from the mesh
  103569. */
  103570. unbind(): void;
  103571. /**
  103572. * Gets the active textures from the material
  103573. * @returns an array of textures
  103574. */
  103575. getActiveTextures(): BaseTexture[];
  103576. /**
  103577. * Specifies if the material uses a texture
  103578. * @param texture defines the texture to check against the material
  103579. * @returns a boolean specifying if the material uses the texture
  103580. */
  103581. hasTexture(texture: BaseTexture): boolean;
  103582. /**
  103583. * Makes a duplicate of the material, and gives it a new name
  103584. * @param name defines the new name for the duplicated material
  103585. * @returns the cloned material
  103586. */
  103587. clone(name: string): Nullable<Material>;
  103588. /**
  103589. * Gets the meshes bound to the material
  103590. * @returns an array of meshes bound to the material
  103591. */
  103592. getBindedMeshes(): AbstractMesh[];
  103593. /**
  103594. * Force shader compilation
  103595. * @param mesh defines the mesh associated with this material
  103596. * @param onCompiled defines a function to execute once the material is compiled
  103597. * @param options defines the options to configure the compilation
  103598. * @param onError defines a function to execute if the material fails compiling
  103599. */
  103600. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  103601. /**
  103602. * Force shader compilation
  103603. * @param mesh defines the mesh that will use this material
  103604. * @param options defines additional options for compiling the shaders
  103605. * @returns a promise that resolves when the compilation completes
  103606. */
  103607. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  103608. private static readonly _AllDirtyCallBack;
  103609. private static readonly _ImageProcessingDirtyCallBack;
  103610. private static readonly _TextureDirtyCallBack;
  103611. private static readonly _FresnelDirtyCallBack;
  103612. private static readonly _MiscDirtyCallBack;
  103613. private static readonly _LightsDirtyCallBack;
  103614. private static readonly _AttributeDirtyCallBack;
  103615. private static _FresnelAndMiscDirtyCallBack;
  103616. private static _TextureAndMiscDirtyCallBack;
  103617. private static readonly _DirtyCallbackArray;
  103618. private static readonly _RunDirtyCallBacks;
  103619. /**
  103620. * Marks a define in the material to indicate that it needs to be re-computed
  103621. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  103622. */
  103623. markAsDirty(flag: number): void;
  103624. /**
  103625. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  103626. * @param func defines a function which checks material defines against the submeshes
  103627. */
  103628. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  103629. /**
  103630. * Indicates that the scene should check if the rendering now needs a prepass
  103631. */
  103632. protected _markScenePrePassDirty(): void;
  103633. /**
  103634. * Indicates that we need to re-calculated for all submeshes
  103635. */
  103636. protected _markAllSubMeshesAsAllDirty(): void;
  103637. /**
  103638. * Indicates that image processing needs to be re-calculated for all submeshes
  103639. */
  103640. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  103641. /**
  103642. * Indicates that textures need to be re-calculated for all submeshes
  103643. */
  103644. protected _markAllSubMeshesAsTexturesDirty(): void;
  103645. /**
  103646. * Indicates that fresnel needs to be re-calculated for all submeshes
  103647. */
  103648. protected _markAllSubMeshesAsFresnelDirty(): void;
  103649. /**
  103650. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  103651. */
  103652. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  103653. /**
  103654. * Indicates that lights need to be re-calculated for all submeshes
  103655. */
  103656. protected _markAllSubMeshesAsLightsDirty(): void;
  103657. /**
  103658. * Indicates that attributes need to be re-calculated for all submeshes
  103659. */
  103660. protected _markAllSubMeshesAsAttributesDirty(): void;
  103661. /**
  103662. * Indicates that misc needs to be re-calculated for all submeshes
  103663. */
  103664. protected _markAllSubMeshesAsMiscDirty(): void;
  103665. /**
  103666. * Indicates that textures and misc need to be re-calculated for all submeshes
  103667. */
  103668. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  103669. /**
  103670. * Sets the required values to the prepass renderer.
  103671. * @param prePassRenderer defines the prepass renderer to setup.
  103672. * @returns true if the pre pass is needed.
  103673. */
  103674. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  103675. /**
  103676. * Disposes the material
  103677. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103678. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103679. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103680. */
  103681. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103682. /** @hidden */
  103683. private releaseVertexArrayObject;
  103684. /**
  103685. * Serializes this material
  103686. * @returns the serialized material object
  103687. */
  103688. serialize(): any;
  103689. /**
  103690. * Creates a material from parsed material data
  103691. * @param parsedMaterial defines parsed material data
  103692. * @param scene defines the hosting scene
  103693. * @param rootUrl defines the root URL to use to load textures
  103694. * @returns a new material
  103695. */
  103696. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  103697. }
  103698. }
  103699. declare module BABYLON {
  103700. /**
  103701. * A multi-material is used to apply different materials to different parts of the same object without the need of
  103702. * separate meshes. This can be use to improve performances.
  103703. * @see https://doc.babylonjs.com/how_to/multi_materials
  103704. */
  103705. export class MultiMaterial extends Material {
  103706. private _subMaterials;
  103707. /**
  103708. * Gets or Sets the list of Materials used within the multi material.
  103709. * They need to be ordered according to the submeshes order in the associated mesh
  103710. */
  103711. get subMaterials(): Nullable<Material>[];
  103712. set subMaterials(value: Nullable<Material>[]);
  103713. /**
  103714. * Function used to align with Node.getChildren()
  103715. * @returns the list of Materials used within the multi material
  103716. */
  103717. getChildren(): Nullable<Material>[];
  103718. /**
  103719. * Instantiates a new Multi Material
  103720. * A multi-material is used to apply different materials to different parts of the same object without the need of
  103721. * separate meshes. This can be use to improve performances.
  103722. * @see https://doc.babylonjs.com/how_to/multi_materials
  103723. * @param name Define the name in the scene
  103724. * @param scene Define the scene the material belongs to
  103725. */
  103726. constructor(name: string, scene: Scene);
  103727. private _hookArray;
  103728. /**
  103729. * Get one of the submaterial by its index in the submaterials array
  103730. * @param index The index to look the sub material at
  103731. * @returns The Material if the index has been defined
  103732. */
  103733. getSubMaterial(index: number): Nullable<Material>;
  103734. /**
  103735. * Get the list of active textures for the whole sub materials list.
  103736. * @returns All the textures that will be used during the rendering
  103737. */
  103738. getActiveTextures(): BaseTexture[];
  103739. /**
  103740. * Gets the current class name of the material e.g. "MultiMaterial"
  103741. * Mainly use in serialization.
  103742. * @returns the class name
  103743. */
  103744. getClassName(): string;
  103745. /**
  103746. * Checks if the material is ready to render the requested sub mesh
  103747. * @param mesh Define the mesh the submesh belongs to
  103748. * @param subMesh Define the sub mesh to look readyness for
  103749. * @param useInstances Define whether or not the material is used with instances
  103750. * @returns true if ready, otherwise false
  103751. */
  103752. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103753. /**
  103754. * Clones the current material and its related sub materials
  103755. * @param name Define the name of the newly cloned material
  103756. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  103757. * @returns the cloned material
  103758. */
  103759. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  103760. /**
  103761. * Serializes the materials into a JSON representation.
  103762. * @returns the JSON representation
  103763. */
  103764. serialize(): any;
  103765. /**
  103766. * Dispose the material and release its associated resources
  103767. * @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)
  103768. * @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)
  103769. * @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)
  103770. */
  103771. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  103772. /**
  103773. * Creates a MultiMaterial from parsed MultiMaterial data.
  103774. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  103775. * @param scene defines the hosting scene
  103776. * @returns a new MultiMaterial
  103777. */
  103778. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  103779. }
  103780. }
  103781. declare module BABYLON {
  103782. /**
  103783. * Defines a subdivision inside a mesh
  103784. */
  103785. export class SubMesh implements ICullable {
  103786. /** the material index to use */
  103787. materialIndex: number;
  103788. /** vertex index start */
  103789. verticesStart: number;
  103790. /** vertices count */
  103791. verticesCount: number;
  103792. /** index start */
  103793. indexStart: number;
  103794. /** indices count */
  103795. indexCount: number;
  103796. /** @hidden */
  103797. _materialDefines: Nullable<MaterialDefines>;
  103798. /** @hidden */
  103799. _materialEffect: Nullable<Effect>;
  103800. /** @hidden */
  103801. _effectOverride: Nullable<Effect>;
  103802. /**
  103803. * Gets material defines used by the effect associated to the sub mesh
  103804. */
  103805. get materialDefines(): Nullable<MaterialDefines>;
  103806. /**
  103807. * Sets material defines used by the effect associated to the sub mesh
  103808. */
  103809. set materialDefines(defines: Nullable<MaterialDefines>);
  103810. /**
  103811. * Gets associated effect
  103812. */
  103813. get effect(): Nullable<Effect>;
  103814. /**
  103815. * Sets associated effect (effect used to render this submesh)
  103816. * @param effect defines the effect to associate with
  103817. * @param defines defines the set of defines used to compile this effect
  103818. */
  103819. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  103820. /** @hidden */
  103821. _linesIndexCount: number;
  103822. private _mesh;
  103823. private _renderingMesh;
  103824. private _boundingInfo;
  103825. private _linesIndexBuffer;
  103826. /** @hidden */
  103827. _lastColliderWorldVertices: Nullable<Vector3[]>;
  103828. /** @hidden */
  103829. _trianglePlanes: Plane[];
  103830. /** @hidden */
  103831. _lastColliderTransformMatrix: Nullable<Matrix>;
  103832. /** @hidden */
  103833. _renderId: number;
  103834. /** @hidden */
  103835. _alphaIndex: number;
  103836. /** @hidden */
  103837. _distanceToCamera: number;
  103838. /** @hidden */
  103839. _id: number;
  103840. private _currentMaterial;
  103841. /**
  103842. * Add a new submesh to a mesh
  103843. * @param materialIndex defines the material index to use
  103844. * @param verticesStart defines vertex index start
  103845. * @param verticesCount defines vertices count
  103846. * @param indexStart defines index start
  103847. * @param indexCount defines indices count
  103848. * @param mesh defines the parent mesh
  103849. * @param renderingMesh defines an optional rendering mesh
  103850. * @param createBoundingBox defines if bounding box should be created for this submesh
  103851. * @returns the new submesh
  103852. */
  103853. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  103854. /**
  103855. * Creates a new submesh
  103856. * @param materialIndex defines the material index to use
  103857. * @param verticesStart defines vertex index start
  103858. * @param verticesCount defines vertices count
  103859. * @param indexStart defines index start
  103860. * @param indexCount defines indices count
  103861. * @param mesh defines the parent mesh
  103862. * @param renderingMesh defines an optional rendering mesh
  103863. * @param createBoundingBox defines if bounding box should be created for this submesh
  103864. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  103865. */
  103866. constructor(
  103867. /** the material index to use */
  103868. materialIndex: number,
  103869. /** vertex index start */
  103870. verticesStart: number,
  103871. /** vertices count */
  103872. verticesCount: number,
  103873. /** index start */
  103874. indexStart: number,
  103875. /** indices count */
  103876. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  103877. /**
  103878. * Returns true if this submesh covers the entire parent mesh
  103879. * @ignorenaming
  103880. */
  103881. get IsGlobal(): boolean;
  103882. /**
  103883. * Returns the submesh BoudingInfo object
  103884. * @returns current bounding info (or mesh's one if the submesh is global)
  103885. */
  103886. getBoundingInfo(): BoundingInfo;
  103887. /**
  103888. * Sets the submesh BoundingInfo
  103889. * @param boundingInfo defines the new bounding info to use
  103890. * @returns the SubMesh
  103891. */
  103892. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  103893. /**
  103894. * Returns the mesh of the current submesh
  103895. * @return the parent mesh
  103896. */
  103897. getMesh(): AbstractMesh;
  103898. /**
  103899. * Returns the rendering mesh of the submesh
  103900. * @returns the rendering mesh (could be different from parent mesh)
  103901. */
  103902. getRenderingMesh(): Mesh;
  103903. /**
  103904. * Returns the replacement mesh of the submesh
  103905. * @returns the replacement mesh (could be different from parent mesh)
  103906. */
  103907. getReplacementMesh(): Nullable<AbstractMesh>;
  103908. /**
  103909. * Returns the effective mesh of the submesh
  103910. * @returns the effective mesh (could be different from parent mesh)
  103911. */
  103912. getEffectiveMesh(): AbstractMesh;
  103913. /**
  103914. * Returns the submesh material
  103915. * @returns null or the current material
  103916. */
  103917. getMaterial(): Nullable<Material>;
  103918. private _IsMultiMaterial;
  103919. /**
  103920. * Sets a new updated BoundingInfo object to the submesh
  103921. * @param data defines an optional position array to use to determine the bounding info
  103922. * @returns the SubMesh
  103923. */
  103924. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  103925. /** @hidden */
  103926. _checkCollision(collider: Collider): boolean;
  103927. /**
  103928. * Updates the submesh BoundingInfo
  103929. * @param world defines the world matrix to use to update the bounding info
  103930. * @returns the submesh
  103931. */
  103932. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  103933. /**
  103934. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  103935. * @param frustumPlanes defines the frustum planes
  103936. * @returns true if the submesh is intersecting with the frustum
  103937. */
  103938. isInFrustum(frustumPlanes: Plane[]): boolean;
  103939. /**
  103940. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  103941. * @param frustumPlanes defines the frustum planes
  103942. * @returns true if the submesh is inside the frustum
  103943. */
  103944. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  103945. /**
  103946. * Renders the submesh
  103947. * @param enableAlphaMode defines if alpha needs to be used
  103948. * @returns the submesh
  103949. */
  103950. render(enableAlphaMode: boolean): SubMesh;
  103951. /**
  103952. * @hidden
  103953. */
  103954. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  103955. /**
  103956. * Checks if the submesh intersects with a ray
  103957. * @param ray defines the ray to test
  103958. * @returns true is the passed ray intersects the submesh bounding box
  103959. */
  103960. canIntersects(ray: Ray): boolean;
  103961. /**
  103962. * Intersects current submesh with a ray
  103963. * @param ray defines the ray to test
  103964. * @param positions defines mesh's positions array
  103965. * @param indices defines mesh's indices array
  103966. * @param fastCheck defines if the first intersection will be used (and not the closest)
  103967. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103968. * @returns intersection info or null if no intersection
  103969. */
  103970. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  103971. /** @hidden */
  103972. private _intersectLines;
  103973. /** @hidden */
  103974. private _intersectUnIndexedLines;
  103975. /** @hidden */
  103976. private _intersectTriangles;
  103977. /** @hidden */
  103978. private _intersectUnIndexedTriangles;
  103979. /** @hidden */
  103980. _rebuild(): void;
  103981. /**
  103982. * Creates a new submesh from the passed mesh
  103983. * @param newMesh defines the new hosting mesh
  103984. * @param newRenderingMesh defines an optional rendering mesh
  103985. * @returns the new submesh
  103986. */
  103987. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  103988. /**
  103989. * Release associated resources
  103990. */
  103991. dispose(): void;
  103992. /**
  103993. * Gets the class name
  103994. * @returns the string "SubMesh".
  103995. */
  103996. getClassName(): string;
  103997. /**
  103998. * Creates a new submesh from indices data
  103999. * @param materialIndex the index of the main mesh material
  104000. * @param startIndex the index where to start the copy in the mesh indices array
  104001. * @param indexCount the number of indices to copy then from the startIndex
  104002. * @param mesh the main mesh to create the submesh from
  104003. * @param renderingMesh the optional rendering mesh
  104004. * @returns a new submesh
  104005. */
  104006. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  104007. }
  104008. }
  104009. declare module BABYLON {
  104010. /**
  104011. * Class used to represent data loading progression
  104012. */
  104013. export class SceneLoaderFlags {
  104014. private static _ForceFullSceneLoadingForIncremental;
  104015. private static _ShowLoadingScreen;
  104016. private static _CleanBoneMatrixWeights;
  104017. private static _loggingLevel;
  104018. /**
  104019. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  104020. */
  104021. static get ForceFullSceneLoadingForIncremental(): boolean;
  104022. static set ForceFullSceneLoadingForIncremental(value: boolean);
  104023. /**
  104024. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  104025. */
  104026. static get ShowLoadingScreen(): boolean;
  104027. static set ShowLoadingScreen(value: boolean);
  104028. /**
  104029. * Defines the current logging level (while loading the scene)
  104030. * @ignorenaming
  104031. */
  104032. static get loggingLevel(): number;
  104033. static set loggingLevel(value: number);
  104034. /**
  104035. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  104036. */
  104037. static get CleanBoneMatrixWeights(): boolean;
  104038. static set CleanBoneMatrixWeights(value: boolean);
  104039. }
  104040. }
  104041. declare module BABYLON {
  104042. /**
  104043. * Class used to store geometry data (vertex buffers + index buffer)
  104044. */
  104045. export class Geometry implements IGetSetVerticesData {
  104046. /**
  104047. * Gets or sets the ID of the geometry
  104048. */
  104049. id: string;
  104050. /**
  104051. * Gets or sets the unique ID of the geometry
  104052. */
  104053. uniqueId: number;
  104054. /**
  104055. * Gets the delay loading state of the geometry (none by default which means not delayed)
  104056. */
  104057. delayLoadState: number;
  104058. /**
  104059. * Gets the file containing the data to load when running in delay load state
  104060. */
  104061. delayLoadingFile: Nullable<string>;
  104062. /**
  104063. * Callback called when the geometry is updated
  104064. */
  104065. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  104066. private _scene;
  104067. private _engine;
  104068. private _meshes;
  104069. private _totalVertices;
  104070. /** @hidden */
  104071. _indices: IndicesArray;
  104072. /** @hidden */
  104073. _vertexBuffers: {
  104074. [key: string]: VertexBuffer;
  104075. };
  104076. private _isDisposed;
  104077. private _extend;
  104078. private _boundingBias;
  104079. /** @hidden */
  104080. _delayInfo: Array<string>;
  104081. private _indexBuffer;
  104082. private _indexBufferIsUpdatable;
  104083. /** @hidden */
  104084. _boundingInfo: Nullable<BoundingInfo>;
  104085. /** @hidden */
  104086. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  104087. /** @hidden */
  104088. _softwareSkinningFrameId: number;
  104089. private _vertexArrayObjects;
  104090. private _updatable;
  104091. /** @hidden */
  104092. _positions: Nullable<Vector3[]>;
  104093. /**
  104094. * 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
  104095. */
  104096. get boundingBias(): Vector2;
  104097. /**
  104098. * 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
  104099. */
  104100. set boundingBias(value: Vector2);
  104101. /**
  104102. * Static function used to attach a new empty geometry to a mesh
  104103. * @param mesh defines the mesh to attach the geometry to
  104104. * @returns the new Geometry
  104105. */
  104106. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  104107. /** Get the list of meshes using this geometry */
  104108. get meshes(): Mesh[];
  104109. /**
  104110. * 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
  104111. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  104112. */
  104113. useBoundingInfoFromGeometry: boolean;
  104114. /**
  104115. * Creates a new geometry
  104116. * @param id defines the unique ID
  104117. * @param scene defines the hosting scene
  104118. * @param vertexData defines the VertexData used to get geometry data
  104119. * @param updatable defines if geometry must be updatable (false by default)
  104120. * @param mesh defines the mesh that will be associated with the geometry
  104121. */
  104122. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  104123. /**
  104124. * Gets the current extend of the geometry
  104125. */
  104126. get extend(): {
  104127. minimum: Vector3;
  104128. maximum: Vector3;
  104129. };
  104130. /**
  104131. * Gets the hosting scene
  104132. * @returns the hosting Scene
  104133. */
  104134. getScene(): Scene;
  104135. /**
  104136. * Gets the hosting engine
  104137. * @returns the hosting Engine
  104138. */
  104139. getEngine(): Engine;
  104140. /**
  104141. * Defines if the geometry is ready to use
  104142. * @returns true if the geometry is ready to be used
  104143. */
  104144. isReady(): boolean;
  104145. /**
  104146. * Gets a value indicating that the geometry should not be serialized
  104147. */
  104148. get doNotSerialize(): boolean;
  104149. /** @hidden */
  104150. _rebuild(): void;
  104151. /**
  104152. * Affects all geometry data in one call
  104153. * @param vertexData defines the geometry data
  104154. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  104155. */
  104156. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  104157. /**
  104158. * Set specific vertex data
  104159. * @param kind defines the data kind (Position, normal, etc...)
  104160. * @param data defines the vertex data to use
  104161. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  104162. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  104163. */
  104164. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  104165. /**
  104166. * Removes a specific vertex data
  104167. * @param kind defines the data kind (Position, normal, etc...)
  104168. */
  104169. removeVerticesData(kind: string): void;
  104170. /**
  104171. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  104172. * @param buffer defines the vertex buffer to use
  104173. * @param totalVertices defines the total number of vertices for position kind (could be null)
  104174. */
  104175. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  104176. /**
  104177. * Update a specific vertex buffer
  104178. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  104179. * It will do nothing if the buffer is not updatable
  104180. * @param kind defines the data kind (Position, normal, etc...)
  104181. * @param data defines the data to use
  104182. * @param offset defines the offset in the target buffer where to store the data
  104183. * @param useBytes set to true if the offset is in bytes
  104184. */
  104185. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  104186. /**
  104187. * Update a specific vertex buffer
  104188. * This function will create a new buffer if the current one is not updatable
  104189. * @param kind defines the data kind (Position, normal, etc...)
  104190. * @param data defines the data to use
  104191. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  104192. */
  104193. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  104194. private _updateBoundingInfo;
  104195. /** @hidden */
  104196. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  104197. /**
  104198. * Gets total number of vertices
  104199. * @returns the total number of vertices
  104200. */
  104201. getTotalVertices(): number;
  104202. /**
  104203. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  104204. * @param kind defines the data kind (Position, normal, etc...)
  104205. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104206. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104207. * @returns a float array containing vertex data
  104208. */
  104209. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104210. /**
  104211. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  104212. * @param kind defines the data kind (Position, normal, etc...)
  104213. * @returns true if the vertex buffer with the specified kind is updatable
  104214. */
  104215. isVertexBufferUpdatable(kind: string): boolean;
  104216. /**
  104217. * Gets a specific vertex buffer
  104218. * @param kind defines the data kind (Position, normal, etc...)
  104219. * @returns a VertexBuffer
  104220. */
  104221. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  104222. /**
  104223. * Returns all vertex buffers
  104224. * @return an object holding all vertex buffers indexed by kind
  104225. */
  104226. getVertexBuffers(): Nullable<{
  104227. [key: string]: VertexBuffer;
  104228. }>;
  104229. /**
  104230. * Gets a boolean indicating if specific vertex buffer is present
  104231. * @param kind defines the data kind (Position, normal, etc...)
  104232. * @returns true if data is present
  104233. */
  104234. isVerticesDataPresent(kind: string): boolean;
  104235. /**
  104236. * Gets a list of all attached data kinds (Position, normal, etc...)
  104237. * @returns a list of string containing all kinds
  104238. */
  104239. getVerticesDataKinds(): string[];
  104240. /**
  104241. * Update index buffer
  104242. * @param indices defines the indices to store in the index buffer
  104243. * @param offset defines the offset in the target buffer where to store the data
  104244. * @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)
  104245. */
  104246. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  104247. /**
  104248. * Creates a new index buffer
  104249. * @param indices defines the indices to store in the index buffer
  104250. * @param totalVertices defines the total number of vertices (could be null)
  104251. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  104252. */
  104253. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  104254. /**
  104255. * Return the total number of indices
  104256. * @returns the total number of indices
  104257. */
  104258. getTotalIndices(): number;
  104259. /**
  104260. * Gets the index buffer array
  104261. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104262. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104263. * @returns the index buffer array
  104264. */
  104265. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104266. /**
  104267. * Gets the index buffer
  104268. * @return the index buffer
  104269. */
  104270. getIndexBuffer(): Nullable<DataBuffer>;
  104271. /** @hidden */
  104272. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  104273. /**
  104274. * Release the associated resources for a specific mesh
  104275. * @param mesh defines the source mesh
  104276. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  104277. */
  104278. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  104279. /**
  104280. * Apply current geometry to a given mesh
  104281. * @param mesh defines the mesh to apply geometry to
  104282. */
  104283. applyToMesh(mesh: Mesh): void;
  104284. private _updateExtend;
  104285. private _applyToMesh;
  104286. private notifyUpdate;
  104287. /**
  104288. * Load the geometry if it was flagged as delay loaded
  104289. * @param scene defines the hosting scene
  104290. * @param onLoaded defines a callback called when the geometry is loaded
  104291. */
  104292. load(scene: Scene, onLoaded?: () => void): void;
  104293. private _queueLoad;
  104294. /**
  104295. * Invert the geometry to move from a right handed system to a left handed one.
  104296. */
  104297. toLeftHanded(): void;
  104298. /** @hidden */
  104299. _resetPointsArrayCache(): void;
  104300. /** @hidden */
  104301. _generatePointsArray(): boolean;
  104302. /**
  104303. * Gets a value indicating if the geometry is disposed
  104304. * @returns true if the geometry was disposed
  104305. */
  104306. isDisposed(): boolean;
  104307. private _disposeVertexArrayObjects;
  104308. /**
  104309. * Free all associated resources
  104310. */
  104311. dispose(): void;
  104312. /**
  104313. * Clone the current geometry into a new geometry
  104314. * @param id defines the unique ID of the new geometry
  104315. * @returns a new geometry object
  104316. */
  104317. copy(id: string): Geometry;
  104318. /**
  104319. * Serialize the current geometry info (and not the vertices data) into a JSON object
  104320. * @return a JSON representation of the current geometry data (without the vertices data)
  104321. */
  104322. serialize(): any;
  104323. private toNumberArray;
  104324. /**
  104325. * Serialize all vertices data into a JSON oject
  104326. * @returns a JSON representation of the current geometry data
  104327. */
  104328. serializeVerticeData(): any;
  104329. /**
  104330. * Extracts a clone of a mesh geometry
  104331. * @param mesh defines the source mesh
  104332. * @param id defines the unique ID of the new geometry object
  104333. * @returns the new geometry object
  104334. */
  104335. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  104336. /**
  104337. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  104338. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104339. * Be aware Math.random() could cause collisions, but:
  104340. * "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"
  104341. * @returns a string containing a new GUID
  104342. */
  104343. static RandomId(): string;
  104344. /** @hidden */
  104345. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  104346. private static _CleanMatricesWeights;
  104347. /**
  104348. * Create a new geometry from persisted data (Using .babylon file format)
  104349. * @param parsedVertexData defines the persisted data
  104350. * @param scene defines the hosting scene
  104351. * @param rootUrl defines the root url to use to load assets (like delayed data)
  104352. * @returns the new geometry object
  104353. */
  104354. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  104355. }
  104356. }
  104357. declare module BABYLON {
  104358. /**
  104359. * Define an interface for all classes that will get and set the data on vertices
  104360. */
  104361. export interface IGetSetVerticesData {
  104362. /**
  104363. * Gets a boolean indicating if specific vertex data is present
  104364. * @param kind defines the vertex data kind to use
  104365. * @returns true is data kind is present
  104366. */
  104367. isVerticesDataPresent(kind: string): boolean;
  104368. /**
  104369. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  104370. * @param kind defines the data kind (Position, normal, etc...)
  104371. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104372. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104373. * @returns a float array containing vertex data
  104374. */
  104375. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104376. /**
  104377. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  104378. * @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.
  104379. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104380. * @returns the indices array or an empty array if the mesh has no geometry
  104381. */
  104382. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104383. /**
  104384. * Set specific vertex data
  104385. * @param kind defines the data kind (Position, normal, etc...)
  104386. * @param data defines the vertex data to use
  104387. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  104388. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  104389. */
  104390. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  104391. /**
  104392. * Update a specific associated vertex buffer
  104393. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104394. * - VertexBuffer.PositionKind
  104395. * - VertexBuffer.UVKind
  104396. * - VertexBuffer.UV2Kind
  104397. * - VertexBuffer.UV3Kind
  104398. * - VertexBuffer.UV4Kind
  104399. * - VertexBuffer.UV5Kind
  104400. * - VertexBuffer.UV6Kind
  104401. * - VertexBuffer.ColorKind
  104402. * - VertexBuffer.MatricesIndicesKind
  104403. * - VertexBuffer.MatricesIndicesExtraKind
  104404. * - VertexBuffer.MatricesWeightsKind
  104405. * - VertexBuffer.MatricesWeightsExtraKind
  104406. * @param data defines the data source
  104407. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  104408. * @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)
  104409. */
  104410. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  104411. /**
  104412. * Creates a new index buffer
  104413. * @param indices defines the indices to store in the index buffer
  104414. * @param totalVertices defines the total number of vertices (could be null)
  104415. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  104416. */
  104417. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  104418. }
  104419. /**
  104420. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  104421. */
  104422. export class VertexData {
  104423. /**
  104424. * Mesh side orientation : usually the external or front surface
  104425. */
  104426. static readonly FRONTSIDE: number;
  104427. /**
  104428. * Mesh side orientation : usually the internal or back surface
  104429. */
  104430. static readonly BACKSIDE: number;
  104431. /**
  104432. * Mesh side orientation : both internal and external or front and back surfaces
  104433. */
  104434. static readonly DOUBLESIDE: number;
  104435. /**
  104436. * Mesh side orientation : by default, `FRONTSIDE`
  104437. */
  104438. static readonly DEFAULTSIDE: number;
  104439. /**
  104440. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  104441. */
  104442. positions: Nullable<FloatArray>;
  104443. /**
  104444. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  104445. */
  104446. normals: Nullable<FloatArray>;
  104447. /**
  104448. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  104449. */
  104450. tangents: Nullable<FloatArray>;
  104451. /**
  104452. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104453. */
  104454. uvs: Nullable<FloatArray>;
  104455. /**
  104456. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104457. */
  104458. uvs2: Nullable<FloatArray>;
  104459. /**
  104460. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104461. */
  104462. uvs3: Nullable<FloatArray>;
  104463. /**
  104464. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104465. */
  104466. uvs4: Nullable<FloatArray>;
  104467. /**
  104468. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104469. */
  104470. uvs5: Nullable<FloatArray>;
  104471. /**
  104472. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104473. */
  104474. uvs6: Nullable<FloatArray>;
  104475. /**
  104476. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  104477. */
  104478. colors: Nullable<FloatArray>;
  104479. /**
  104480. * 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).
  104481. */
  104482. matricesIndices: Nullable<FloatArray>;
  104483. /**
  104484. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  104485. */
  104486. matricesWeights: Nullable<FloatArray>;
  104487. /**
  104488. * An array extending the number of possible indices
  104489. */
  104490. matricesIndicesExtra: Nullable<FloatArray>;
  104491. /**
  104492. * An array extending the number of possible weights when the number of indices is extended
  104493. */
  104494. matricesWeightsExtra: Nullable<FloatArray>;
  104495. /**
  104496. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  104497. */
  104498. indices: Nullable<IndicesArray>;
  104499. /**
  104500. * Uses the passed data array to set the set the values for the specified kind of data
  104501. * @param data a linear array of floating numbers
  104502. * @param kind the type of data that is being set, eg positions, colors etc
  104503. */
  104504. set(data: FloatArray, kind: string): void;
  104505. /**
  104506. * Associates the vertexData to the passed Mesh.
  104507. * Sets it as updatable or not (default `false`)
  104508. * @param mesh the mesh the vertexData is applied to
  104509. * @param updatable when used and having the value true allows new data to update the vertexData
  104510. * @returns the VertexData
  104511. */
  104512. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  104513. /**
  104514. * Associates the vertexData to the passed Geometry.
  104515. * Sets it as updatable or not (default `false`)
  104516. * @param geometry the geometry the vertexData is applied to
  104517. * @param updatable when used and having the value true allows new data to update the vertexData
  104518. * @returns VertexData
  104519. */
  104520. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  104521. /**
  104522. * Updates the associated mesh
  104523. * @param mesh the mesh to be updated
  104524. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  104525. * @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
  104526. * @returns VertexData
  104527. */
  104528. updateMesh(mesh: Mesh): VertexData;
  104529. /**
  104530. * Updates the associated geometry
  104531. * @param geometry the geometry to be updated
  104532. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  104533. * @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
  104534. * @returns VertexData.
  104535. */
  104536. updateGeometry(geometry: Geometry): VertexData;
  104537. private _applyTo;
  104538. private _update;
  104539. /**
  104540. * Transforms each position and each normal of the vertexData according to the passed Matrix
  104541. * @param matrix the transforming matrix
  104542. * @returns the VertexData
  104543. */
  104544. transform(matrix: Matrix): VertexData;
  104545. /**
  104546. * Merges the passed VertexData into the current one
  104547. * @param other the VertexData to be merged into the current one
  104548. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  104549. * @returns the modified VertexData
  104550. */
  104551. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  104552. private _mergeElement;
  104553. private _validate;
  104554. /**
  104555. * Serializes the VertexData
  104556. * @returns a serialized object
  104557. */
  104558. serialize(): any;
  104559. /**
  104560. * Extracts the vertexData from a mesh
  104561. * @param mesh the mesh from which to extract the VertexData
  104562. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  104563. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  104564. * @returns the object VertexData associated to the passed mesh
  104565. */
  104566. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  104567. /**
  104568. * Extracts the vertexData from the geometry
  104569. * @param geometry the geometry from which to extract the VertexData
  104570. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  104571. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  104572. * @returns the object VertexData associated to the passed mesh
  104573. */
  104574. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  104575. private static _ExtractFrom;
  104576. /**
  104577. * Creates the VertexData for a Ribbon
  104578. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  104579. * * pathArray array of paths, each of which an array of successive Vector3
  104580. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  104581. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  104582. * * 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
  104583. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104584. * * 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)
  104585. * * 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)
  104586. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  104587. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  104588. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  104589. * @returns the VertexData of the ribbon
  104590. */
  104591. static CreateRibbon(options: {
  104592. pathArray: Vector3[][];
  104593. closeArray?: boolean;
  104594. closePath?: boolean;
  104595. offset?: number;
  104596. sideOrientation?: number;
  104597. frontUVs?: Vector4;
  104598. backUVs?: Vector4;
  104599. invertUV?: boolean;
  104600. uvs?: Vector2[];
  104601. colors?: Color4[];
  104602. }): VertexData;
  104603. /**
  104604. * Creates the VertexData for a box
  104605. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104606. * * size sets the width, height and depth of the box to the value of size, optional default 1
  104607. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  104608. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  104609. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  104610. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  104611. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  104612. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104613. * * 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)
  104614. * * 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)
  104615. * @returns the VertexData of the box
  104616. */
  104617. static CreateBox(options: {
  104618. size?: number;
  104619. width?: number;
  104620. height?: number;
  104621. depth?: number;
  104622. faceUV?: Vector4[];
  104623. faceColors?: Color4[];
  104624. sideOrientation?: number;
  104625. frontUVs?: Vector4;
  104626. backUVs?: Vector4;
  104627. }): VertexData;
  104628. /**
  104629. * Creates the VertexData for a tiled box
  104630. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104631. * * faceTiles sets the pattern, tile size and number of tiles for a face
  104632. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  104633. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  104634. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104635. * @returns the VertexData of the box
  104636. */
  104637. static CreateTiledBox(options: {
  104638. pattern?: number;
  104639. width?: number;
  104640. height?: number;
  104641. depth?: number;
  104642. tileSize?: number;
  104643. tileWidth?: number;
  104644. tileHeight?: number;
  104645. alignHorizontal?: number;
  104646. alignVertical?: number;
  104647. faceUV?: Vector4[];
  104648. faceColors?: Color4[];
  104649. sideOrientation?: number;
  104650. }): VertexData;
  104651. /**
  104652. * Creates the VertexData for a tiled plane
  104653. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104654. * * pattern a limited pattern arrangement depending on the number
  104655. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  104656. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  104657. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  104658. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104659. * * 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)
  104660. * * 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)
  104661. * @returns the VertexData of the tiled plane
  104662. */
  104663. static CreateTiledPlane(options: {
  104664. pattern?: number;
  104665. tileSize?: number;
  104666. tileWidth?: number;
  104667. tileHeight?: number;
  104668. size?: number;
  104669. width?: number;
  104670. height?: number;
  104671. alignHorizontal?: number;
  104672. alignVertical?: number;
  104673. sideOrientation?: number;
  104674. frontUVs?: Vector4;
  104675. backUVs?: Vector4;
  104676. }): VertexData;
  104677. /**
  104678. * Creates the VertexData for an ellipsoid, defaults to a sphere
  104679. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104680. * * segments sets the number of horizontal strips optional, default 32
  104681. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  104682. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  104683. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  104684. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  104685. * * 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
  104686. * * 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
  104687. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104688. * * 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)
  104689. * * 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)
  104690. * @returns the VertexData of the ellipsoid
  104691. */
  104692. static CreateSphere(options: {
  104693. segments?: number;
  104694. diameter?: number;
  104695. diameterX?: number;
  104696. diameterY?: number;
  104697. diameterZ?: number;
  104698. arc?: number;
  104699. slice?: number;
  104700. sideOrientation?: number;
  104701. frontUVs?: Vector4;
  104702. backUVs?: Vector4;
  104703. }): VertexData;
  104704. /**
  104705. * Creates the VertexData for a cylinder, cone or prism
  104706. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104707. * * height sets the height (y direction) of the cylinder, optional, default 2
  104708. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  104709. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  104710. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  104711. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  104712. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  104713. * * 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
  104714. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  104715. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  104716. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  104717. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  104718. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104719. * * 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)
  104720. * * 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)
  104721. * @returns the VertexData of the cylinder, cone or prism
  104722. */
  104723. static CreateCylinder(options: {
  104724. height?: number;
  104725. diameterTop?: number;
  104726. diameterBottom?: number;
  104727. diameter?: number;
  104728. tessellation?: number;
  104729. subdivisions?: number;
  104730. arc?: number;
  104731. faceColors?: Color4[];
  104732. faceUV?: Vector4[];
  104733. hasRings?: boolean;
  104734. enclose?: boolean;
  104735. sideOrientation?: number;
  104736. frontUVs?: Vector4;
  104737. backUVs?: Vector4;
  104738. }): VertexData;
  104739. /**
  104740. * Creates the VertexData for a torus
  104741. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104742. * * diameter the diameter of the torus, optional default 1
  104743. * * thickness the diameter of the tube forming the torus, optional default 0.5
  104744. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  104745. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104746. * * 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)
  104747. * * 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)
  104748. * @returns the VertexData of the torus
  104749. */
  104750. static CreateTorus(options: {
  104751. diameter?: number;
  104752. thickness?: number;
  104753. tessellation?: number;
  104754. sideOrientation?: number;
  104755. frontUVs?: Vector4;
  104756. backUVs?: Vector4;
  104757. }): VertexData;
  104758. /**
  104759. * Creates the VertexData of the LineSystem
  104760. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  104761. * - lines an array of lines, each line being an array of successive Vector3
  104762. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  104763. * @returns the VertexData of the LineSystem
  104764. */
  104765. static CreateLineSystem(options: {
  104766. lines: Vector3[][];
  104767. colors?: Nullable<Color4[][]>;
  104768. }): VertexData;
  104769. /**
  104770. * Create the VertexData for a DashedLines
  104771. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  104772. * - points an array successive Vector3
  104773. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  104774. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  104775. * - dashNb the intended total number of dashes, optional, default 200
  104776. * @returns the VertexData for the DashedLines
  104777. */
  104778. static CreateDashedLines(options: {
  104779. points: Vector3[];
  104780. dashSize?: number;
  104781. gapSize?: number;
  104782. dashNb?: number;
  104783. }): VertexData;
  104784. /**
  104785. * Creates the VertexData for a Ground
  104786. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  104787. * - width the width (x direction) of the ground, optional, default 1
  104788. * - height the height (z direction) of the ground, optional, default 1
  104789. * - subdivisions the number of subdivisions per side, optional, default 1
  104790. * @returns the VertexData of the Ground
  104791. */
  104792. static CreateGround(options: {
  104793. width?: number;
  104794. height?: number;
  104795. subdivisions?: number;
  104796. subdivisionsX?: number;
  104797. subdivisionsY?: number;
  104798. }): VertexData;
  104799. /**
  104800. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  104801. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  104802. * * xmin the ground minimum X coordinate, optional, default -1
  104803. * * zmin the ground minimum Z coordinate, optional, default -1
  104804. * * xmax the ground maximum X coordinate, optional, default 1
  104805. * * zmax the ground maximum Z coordinate, optional, default 1
  104806. * * 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}
  104807. * * 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}
  104808. * @returns the VertexData of the TiledGround
  104809. */
  104810. static CreateTiledGround(options: {
  104811. xmin: number;
  104812. zmin: number;
  104813. xmax: number;
  104814. zmax: number;
  104815. subdivisions?: {
  104816. w: number;
  104817. h: number;
  104818. };
  104819. precision?: {
  104820. w: number;
  104821. h: number;
  104822. };
  104823. }): VertexData;
  104824. /**
  104825. * Creates the VertexData of the Ground designed from a heightmap
  104826. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  104827. * * width the width (x direction) of the ground
  104828. * * height the height (z direction) of the ground
  104829. * * subdivisions the number of subdivisions per side
  104830. * * minHeight the minimum altitude on the ground, optional, default 0
  104831. * * maxHeight the maximum altitude on the ground, optional default 1
  104832. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  104833. * * buffer the array holding the image color data
  104834. * * bufferWidth the width of image
  104835. * * bufferHeight the height of image
  104836. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  104837. * @returns the VertexData of the Ground designed from a heightmap
  104838. */
  104839. static CreateGroundFromHeightMap(options: {
  104840. width: number;
  104841. height: number;
  104842. subdivisions: number;
  104843. minHeight: number;
  104844. maxHeight: number;
  104845. colorFilter: Color3;
  104846. buffer: Uint8Array;
  104847. bufferWidth: number;
  104848. bufferHeight: number;
  104849. alphaFilter: number;
  104850. }): VertexData;
  104851. /**
  104852. * Creates the VertexData for a Plane
  104853. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  104854. * * size sets the width and height of the plane to the value of size, optional default 1
  104855. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  104856. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  104857. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104858. * * 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)
  104859. * * 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)
  104860. * @returns the VertexData of the box
  104861. */
  104862. static CreatePlane(options: {
  104863. size?: number;
  104864. width?: number;
  104865. height?: number;
  104866. sideOrientation?: number;
  104867. frontUVs?: Vector4;
  104868. backUVs?: Vector4;
  104869. }): VertexData;
  104870. /**
  104871. * Creates the VertexData of the Disc or regular Polygon
  104872. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  104873. * * radius the radius of the disc, optional default 0.5
  104874. * * tessellation the number of polygon sides, optional, default 64
  104875. * * 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
  104876. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104877. * * 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)
  104878. * * 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)
  104879. * @returns the VertexData of the box
  104880. */
  104881. static CreateDisc(options: {
  104882. radius?: number;
  104883. tessellation?: number;
  104884. arc?: number;
  104885. sideOrientation?: number;
  104886. frontUVs?: Vector4;
  104887. backUVs?: Vector4;
  104888. }): VertexData;
  104889. /**
  104890. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  104891. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  104892. * @param polygon a mesh built from polygonTriangulation.build()
  104893. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104894. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  104895. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  104896. * @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)
  104897. * @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)
  104898. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  104899. * @returns the VertexData of the Polygon
  104900. */
  104901. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  104902. /**
  104903. * Creates the VertexData of the IcoSphere
  104904. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  104905. * * radius the radius of the IcoSphere, optional default 1
  104906. * * radiusX allows stretching in the x direction, optional, default radius
  104907. * * radiusY allows stretching in the y direction, optional, default radius
  104908. * * radiusZ allows stretching in the z direction, optional, default radius
  104909. * * flat when true creates a flat shaded mesh, optional, default true
  104910. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  104911. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104912. * * 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)
  104913. * * 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)
  104914. * @returns the VertexData of the IcoSphere
  104915. */
  104916. static CreateIcoSphere(options: {
  104917. radius?: number;
  104918. radiusX?: number;
  104919. radiusY?: number;
  104920. radiusZ?: number;
  104921. flat?: boolean;
  104922. subdivisions?: number;
  104923. sideOrientation?: number;
  104924. frontUVs?: Vector4;
  104925. backUVs?: Vector4;
  104926. }): VertexData;
  104927. /**
  104928. * Creates the VertexData for a Polyhedron
  104929. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  104930. * * type provided types are:
  104931. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  104932. * * 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)
  104933. * * size the size of the IcoSphere, optional default 1
  104934. * * sizeX allows stretching in the x direction, optional, default size
  104935. * * sizeY allows stretching in the y direction, optional, default size
  104936. * * sizeZ allows stretching in the z direction, optional, default size
  104937. * * 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
  104938. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  104939. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  104940. * * flat when true creates a flat shaded mesh, optional, default true
  104941. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  104942. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104943. * * 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)
  104944. * * 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)
  104945. * @returns the VertexData of the Polyhedron
  104946. */
  104947. static CreatePolyhedron(options: {
  104948. type?: number;
  104949. size?: number;
  104950. sizeX?: number;
  104951. sizeY?: number;
  104952. sizeZ?: number;
  104953. custom?: any;
  104954. faceUV?: Vector4[];
  104955. faceColors?: Color4[];
  104956. flat?: boolean;
  104957. sideOrientation?: number;
  104958. frontUVs?: Vector4;
  104959. backUVs?: Vector4;
  104960. }): VertexData;
  104961. /**
  104962. * Creates the VertexData for a TorusKnot
  104963. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  104964. * * radius the radius of the torus knot, optional, default 2
  104965. * * tube the thickness of the tube, optional, default 0.5
  104966. * * radialSegments the number of sides on each tube segments, optional, default 32
  104967. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  104968. * * p the number of windings around the z axis, optional, default 2
  104969. * * q the number of windings around the x axis, optional, default 3
  104970. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104971. * * 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)
  104972. * * 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)
  104973. * @returns the VertexData of the Torus Knot
  104974. */
  104975. static CreateTorusKnot(options: {
  104976. radius?: number;
  104977. tube?: number;
  104978. radialSegments?: number;
  104979. tubularSegments?: number;
  104980. p?: number;
  104981. q?: number;
  104982. sideOrientation?: number;
  104983. frontUVs?: Vector4;
  104984. backUVs?: Vector4;
  104985. }): VertexData;
  104986. /**
  104987. * Compute normals for given positions and indices
  104988. * @param positions an array of vertex positions, [...., x, y, z, ......]
  104989. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  104990. * @param normals an array of vertex normals, [...., x, y, z, ......]
  104991. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  104992. * * facetNormals : optional array of facet normals (vector3)
  104993. * * facetPositions : optional array of facet positions (vector3)
  104994. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  104995. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  104996. * * bInfo : optional bounding info, required for facetPartitioning computation
  104997. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  104998. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  104999. * * useRightHandedSystem: optional boolean to for right handed system computation
  105000. * * depthSort : optional boolean to enable the facet depth sort computation
  105001. * * distanceTo : optional Vector3 to compute the facet depth from this location
  105002. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  105003. */
  105004. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  105005. facetNormals?: any;
  105006. facetPositions?: any;
  105007. facetPartitioning?: any;
  105008. ratio?: number;
  105009. bInfo?: any;
  105010. bbSize?: Vector3;
  105011. subDiv?: any;
  105012. useRightHandedSystem?: boolean;
  105013. depthSort?: boolean;
  105014. distanceTo?: Vector3;
  105015. depthSortedFacets?: any;
  105016. }): void;
  105017. /** @hidden */
  105018. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  105019. /**
  105020. * Applies VertexData created from the imported parameters to the geometry
  105021. * @param parsedVertexData the parsed data from an imported file
  105022. * @param geometry the geometry to apply the VertexData to
  105023. */
  105024. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  105025. }
  105026. }
  105027. declare module BABYLON {
  105028. /**
  105029. * Defines a target to use with MorphTargetManager
  105030. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105031. */
  105032. export class MorphTarget implements IAnimatable {
  105033. /** defines the name of the target */
  105034. name: string;
  105035. /**
  105036. * Gets or sets the list of animations
  105037. */
  105038. animations: Animation[];
  105039. private _scene;
  105040. private _positions;
  105041. private _normals;
  105042. private _tangents;
  105043. private _uvs;
  105044. private _influence;
  105045. private _uniqueId;
  105046. /**
  105047. * Observable raised when the influence changes
  105048. */
  105049. onInfluenceChanged: Observable<boolean>;
  105050. /** @hidden */
  105051. _onDataLayoutChanged: Observable<void>;
  105052. /**
  105053. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  105054. */
  105055. get influence(): number;
  105056. set influence(influence: number);
  105057. /**
  105058. * Gets or sets the id of the morph Target
  105059. */
  105060. id: string;
  105061. private _animationPropertiesOverride;
  105062. /**
  105063. * Gets or sets the animation properties override
  105064. */
  105065. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105066. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105067. /**
  105068. * Creates a new MorphTarget
  105069. * @param name defines the name of the target
  105070. * @param influence defines the influence to use
  105071. * @param scene defines the scene the morphtarget belongs to
  105072. */
  105073. constructor(
  105074. /** defines the name of the target */
  105075. name: string, influence?: number, scene?: Nullable<Scene>);
  105076. /**
  105077. * Gets the unique ID of this manager
  105078. */
  105079. get uniqueId(): number;
  105080. /**
  105081. * Gets a boolean defining if the target contains position data
  105082. */
  105083. get hasPositions(): boolean;
  105084. /**
  105085. * Gets a boolean defining if the target contains normal data
  105086. */
  105087. get hasNormals(): boolean;
  105088. /**
  105089. * Gets a boolean defining if the target contains tangent data
  105090. */
  105091. get hasTangents(): boolean;
  105092. /**
  105093. * Gets a boolean defining if the target contains texture coordinates data
  105094. */
  105095. get hasUVs(): boolean;
  105096. /**
  105097. * Affects position data to this target
  105098. * @param data defines the position data to use
  105099. */
  105100. setPositions(data: Nullable<FloatArray>): void;
  105101. /**
  105102. * Gets the position data stored in this target
  105103. * @returns a FloatArray containing the position data (or null if not present)
  105104. */
  105105. getPositions(): Nullable<FloatArray>;
  105106. /**
  105107. * Affects normal data to this target
  105108. * @param data defines the normal data to use
  105109. */
  105110. setNormals(data: Nullable<FloatArray>): void;
  105111. /**
  105112. * Gets the normal data stored in this target
  105113. * @returns a FloatArray containing the normal data (or null if not present)
  105114. */
  105115. getNormals(): Nullable<FloatArray>;
  105116. /**
  105117. * Affects tangent data to this target
  105118. * @param data defines the tangent data to use
  105119. */
  105120. setTangents(data: Nullable<FloatArray>): void;
  105121. /**
  105122. * Gets the tangent data stored in this target
  105123. * @returns a FloatArray containing the tangent data (or null if not present)
  105124. */
  105125. getTangents(): Nullable<FloatArray>;
  105126. /**
  105127. * Affects texture coordinates data to this target
  105128. * @param data defines the texture coordinates data to use
  105129. */
  105130. setUVs(data: Nullable<FloatArray>): void;
  105131. /**
  105132. * Gets the texture coordinates data stored in this target
  105133. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  105134. */
  105135. getUVs(): Nullable<FloatArray>;
  105136. /**
  105137. * Clone the current target
  105138. * @returns a new MorphTarget
  105139. */
  105140. clone(): MorphTarget;
  105141. /**
  105142. * Serializes the current target into a Serialization object
  105143. * @returns the serialized object
  105144. */
  105145. serialize(): any;
  105146. /**
  105147. * Returns the string "MorphTarget"
  105148. * @returns "MorphTarget"
  105149. */
  105150. getClassName(): string;
  105151. /**
  105152. * Creates a new target from serialized data
  105153. * @param serializationObject defines the serialized data to use
  105154. * @returns a new MorphTarget
  105155. */
  105156. static Parse(serializationObject: any): MorphTarget;
  105157. /**
  105158. * Creates a MorphTarget from mesh data
  105159. * @param mesh defines the source mesh
  105160. * @param name defines the name to use for the new target
  105161. * @param influence defines the influence to attach to the target
  105162. * @returns a new MorphTarget
  105163. */
  105164. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  105165. }
  105166. }
  105167. declare module BABYLON {
  105168. /**
  105169. * This class is used to deform meshes using morphing between different targets
  105170. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105171. */
  105172. export class MorphTargetManager {
  105173. private _targets;
  105174. private _targetInfluenceChangedObservers;
  105175. private _targetDataLayoutChangedObservers;
  105176. private _activeTargets;
  105177. private _scene;
  105178. private _influences;
  105179. private _supportsNormals;
  105180. private _supportsTangents;
  105181. private _supportsUVs;
  105182. private _vertexCount;
  105183. private _uniqueId;
  105184. private _tempInfluences;
  105185. /**
  105186. * Gets or sets a boolean indicating if normals must be morphed
  105187. */
  105188. enableNormalMorphing: boolean;
  105189. /**
  105190. * Gets or sets a boolean indicating if tangents must be morphed
  105191. */
  105192. enableTangentMorphing: boolean;
  105193. /**
  105194. * Gets or sets a boolean indicating if UV must be morphed
  105195. */
  105196. enableUVMorphing: boolean;
  105197. /**
  105198. * Creates a new MorphTargetManager
  105199. * @param scene defines the current scene
  105200. */
  105201. constructor(scene?: Nullable<Scene>);
  105202. /**
  105203. * Gets the unique ID of this manager
  105204. */
  105205. get uniqueId(): number;
  105206. /**
  105207. * Gets the number of vertices handled by this manager
  105208. */
  105209. get vertexCount(): number;
  105210. /**
  105211. * Gets a boolean indicating if this manager supports morphing of normals
  105212. */
  105213. get supportsNormals(): boolean;
  105214. /**
  105215. * Gets a boolean indicating if this manager supports morphing of tangents
  105216. */
  105217. get supportsTangents(): boolean;
  105218. /**
  105219. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  105220. */
  105221. get supportsUVs(): boolean;
  105222. /**
  105223. * Gets the number of targets stored in this manager
  105224. */
  105225. get numTargets(): number;
  105226. /**
  105227. * Gets the number of influencers (ie. the number of targets with influences > 0)
  105228. */
  105229. get numInfluencers(): number;
  105230. /**
  105231. * Gets the list of influences (one per target)
  105232. */
  105233. get influences(): Float32Array;
  105234. /**
  105235. * Gets the active target at specified index. An active target is a target with an influence > 0
  105236. * @param index defines the index to check
  105237. * @returns the requested target
  105238. */
  105239. getActiveTarget(index: number): MorphTarget;
  105240. /**
  105241. * Gets the target at specified index
  105242. * @param index defines the index to check
  105243. * @returns the requested target
  105244. */
  105245. getTarget(index: number): MorphTarget;
  105246. /**
  105247. * Add a new target to this manager
  105248. * @param target defines the target to add
  105249. */
  105250. addTarget(target: MorphTarget): void;
  105251. /**
  105252. * Removes a target from the manager
  105253. * @param target defines the target to remove
  105254. */
  105255. removeTarget(target: MorphTarget): void;
  105256. /**
  105257. * Clone the current manager
  105258. * @returns a new MorphTargetManager
  105259. */
  105260. clone(): MorphTargetManager;
  105261. /**
  105262. * Serializes the current manager into a Serialization object
  105263. * @returns the serialized object
  105264. */
  105265. serialize(): any;
  105266. private _syncActiveTargets;
  105267. /**
  105268. * Syncrhonize the targets with all the meshes using this morph target manager
  105269. */
  105270. synchronize(): void;
  105271. /**
  105272. * Creates a new MorphTargetManager from serialized data
  105273. * @param serializationObject defines the serialized data
  105274. * @param scene defines the hosting scene
  105275. * @returns the new MorphTargetManager
  105276. */
  105277. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  105278. }
  105279. }
  105280. declare module BABYLON {
  105281. /**
  105282. * Class used to represent a specific level of detail of a mesh
  105283. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105284. */
  105285. export class MeshLODLevel {
  105286. /** Defines the distance where this level should start being displayed */
  105287. distance: number;
  105288. /** Defines the mesh to use to render this level */
  105289. mesh: Nullable<Mesh>;
  105290. /**
  105291. * Creates a new LOD level
  105292. * @param distance defines the distance where this level should star being displayed
  105293. * @param mesh defines the mesh to use to render this level
  105294. */
  105295. constructor(
  105296. /** Defines the distance where this level should start being displayed */
  105297. distance: number,
  105298. /** Defines the mesh to use to render this level */
  105299. mesh: Nullable<Mesh>);
  105300. }
  105301. }
  105302. declare module BABYLON {
  105303. /**
  105304. * Helper class used to generate a canvas to manipulate images
  105305. */
  105306. export class CanvasGenerator {
  105307. /**
  105308. * Create a new canvas (or offscreen canvas depending on the context)
  105309. * @param width defines the expected width
  105310. * @param height defines the expected height
  105311. * @return a new canvas or offscreen canvas
  105312. */
  105313. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  105314. }
  105315. }
  105316. declare module BABYLON {
  105317. /**
  105318. * Mesh representing the gorund
  105319. */
  105320. export class GroundMesh extends Mesh {
  105321. /** If octree should be generated */
  105322. generateOctree: boolean;
  105323. private _heightQuads;
  105324. /** @hidden */
  105325. _subdivisionsX: number;
  105326. /** @hidden */
  105327. _subdivisionsY: number;
  105328. /** @hidden */
  105329. _width: number;
  105330. /** @hidden */
  105331. _height: number;
  105332. /** @hidden */
  105333. _minX: number;
  105334. /** @hidden */
  105335. _maxX: number;
  105336. /** @hidden */
  105337. _minZ: number;
  105338. /** @hidden */
  105339. _maxZ: number;
  105340. constructor(name: string, scene: Scene);
  105341. /**
  105342. * "GroundMesh"
  105343. * @returns "GroundMesh"
  105344. */
  105345. getClassName(): string;
  105346. /**
  105347. * The minimum of x and y subdivisions
  105348. */
  105349. get subdivisions(): number;
  105350. /**
  105351. * X subdivisions
  105352. */
  105353. get subdivisionsX(): number;
  105354. /**
  105355. * Y subdivisions
  105356. */
  105357. get subdivisionsY(): number;
  105358. /**
  105359. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  105360. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  105361. * @param chunksCount the number of subdivisions for x and y
  105362. * @param octreeBlocksSize (Default: 32)
  105363. */
  105364. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  105365. /**
  105366. * Returns a height (y) value in the Worl system :
  105367. * the ground altitude at the coordinates (x, z) expressed in the World system.
  105368. * @param x x coordinate
  105369. * @param z z coordinate
  105370. * @returns the ground y position if (x, z) are outside the ground surface.
  105371. */
  105372. getHeightAtCoordinates(x: number, z: number): number;
  105373. /**
  105374. * Returns a normalized vector (Vector3) orthogonal to the ground
  105375. * at the ground coordinates (x, z) expressed in the World system.
  105376. * @param x x coordinate
  105377. * @param z z coordinate
  105378. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  105379. */
  105380. getNormalAtCoordinates(x: number, z: number): Vector3;
  105381. /**
  105382. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  105383. * at the ground coordinates (x, z) expressed in the World system.
  105384. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  105385. * @param x x coordinate
  105386. * @param z z coordinate
  105387. * @param ref vector to store the result
  105388. * @returns the GroundMesh.
  105389. */
  105390. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  105391. /**
  105392. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  105393. * if the ground has been updated.
  105394. * This can be used in the render loop.
  105395. * @returns the GroundMesh.
  105396. */
  105397. updateCoordinateHeights(): GroundMesh;
  105398. private _getFacetAt;
  105399. private _initHeightQuads;
  105400. private _computeHeightQuads;
  105401. /**
  105402. * Serializes this ground mesh
  105403. * @param serializationObject object to write serialization to
  105404. */
  105405. serialize(serializationObject: any): void;
  105406. /**
  105407. * Parses a serialized ground mesh
  105408. * @param parsedMesh the serialized mesh
  105409. * @param scene the scene to create the ground mesh in
  105410. * @returns the created ground mesh
  105411. */
  105412. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  105413. }
  105414. }
  105415. declare module BABYLON {
  105416. /**
  105417. * Interface for Physics-Joint data
  105418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105419. */
  105420. export interface PhysicsJointData {
  105421. /**
  105422. * The main pivot of the joint
  105423. */
  105424. mainPivot?: Vector3;
  105425. /**
  105426. * The connected pivot of the joint
  105427. */
  105428. connectedPivot?: Vector3;
  105429. /**
  105430. * The main axis of the joint
  105431. */
  105432. mainAxis?: Vector3;
  105433. /**
  105434. * The connected axis of the joint
  105435. */
  105436. connectedAxis?: Vector3;
  105437. /**
  105438. * The collision of the joint
  105439. */
  105440. collision?: boolean;
  105441. /**
  105442. * Native Oimo/Cannon/Energy data
  105443. */
  105444. nativeParams?: any;
  105445. }
  105446. /**
  105447. * This is a holder class for the physics joint created by the physics plugin
  105448. * It holds a set of functions to control the underlying joint
  105449. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105450. */
  105451. export class PhysicsJoint {
  105452. /**
  105453. * The type of the physics joint
  105454. */
  105455. type: number;
  105456. /**
  105457. * The data for the physics joint
  105458. */
  105459. jointData: PhysicsJointData;
  105460. private _physicsJoint;
  105461. protected _physicsPlugin: IPhysicsEnginePlugin;
  105462. /**
  105463. * Initializes the physics joint
  105464. * @param type The type of the physics joint
  105465. * @param jointData The data for the physics joint
  105466. */
  105467. constructor(
  105468. /**
  105469. * The type of the physics joint
  105470. */
  105471. type: number,
  105472. /**
  105473. * The data for the physics joint
  105474. */
  105475. jointData: PhysicsJointData);
  105476. /**
  105477. * Gets the physics joint
  105478. */
  105479. get physicsJoint(): any;
  105480. /**
  105481. * Sets the physics joint
  105482. */
  105483. set physicsJoint(newJoint: any);
  105484. /**
  105485. * Sets the physics plugin
  105486. */
  105487. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  105488. /**
  105489. * Execute a function that is physics-plugin specific.
  105490. * @param {Function} func the function that will be executed.
  105491. * It accepts two parameters: the physics world and the physics joint
  105492. */
  105493. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  105494. /**
  105495. * Distance-Joint type
  105496. */
  105497. static DistanceJoint: number;
  105498. /**
  105499. * Hinge-Joint type
  105500. */
  105501. static HingeJoint: number;
  105502. /**
  105503. * Ball-and-Socket joint type
  105504. */
  105505. static BallAndSocketJoint: number;
  105506. /**
  105507. * Wheel-Joint type
  105508. */
  105509. static WheelJoint: number;
  105510. /**
  105511. * Slider-Joint type
  105512. */
  105513. static SliderJoint: number;
  105514. /**
  105515. * Prismatic-Joint type
  105516. */
  105517. static PrismaticJoint: number;
  105518. /**
  105519. * Universal-Joint type
  105520. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  105521. */
  105522. static UniversalJoint: number;
  105523. /**
  105524. * Hinge-Joint 2 type
  105525. */
  105526. static Hinge2Joint: number;
  105527. /**
  105528. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  105529. */
  105530. static PointToPointJoint: number;
  105531. /**
  105532. * Spring-Joint type
  105533. */
  105534. static SpringJoint: number;
  105535. /**
  105536. * Lock-Joint type
  105537. */
  105538. static LockJoint: number;
  105539. }
  105540. /**
  105541. * A class representing a physics distance joint
  105542. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105543. */
  105544. export class DistanceJoint extends PhysicsJoint {
  105545. /**
  105546. *
  105547. * @param jointData The data for the Distance-Joint
  105548. */
  105549. constructor(jointData: DistanceJointData);
  105550. /**
  105551. * Update the predefined distance.
  105552. * @param maxDistance The maximum preferred distance
  105553. * @param minDistance The minimum preferred distance
  105554. */
  105555. updateDistance(maxDistance: number, minDistance?: number): void;
  105556. }
  105557. /**
  105558. * Represents a Motor-Enabled Joint
  105559. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105560. */
  105561. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  105562. /**
  105563. * Initializes the Motor-Enabled Joint
  105564. * @param type The type of the joint
  105565. * @param jointData The physica joint data for the joint
  105566. */
  105567. constructor(type: number, jointData: PhysicsJointData);
  105568. /**
  105569. * Set the motor values.
  105570. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105571. * @param force the force to apply
  105572. * @param maxForce max force for this motor.
  105573. */
  105574. setMotor(force?: number, maxForce?: number): void;
  105575. /**
  105576. * Set the motor's limits.
  105577. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105578. * @param upperLimit The upper limit of the motor
  105579. * @param lowerLimit The lower limit of the motor
  105580. */
  105581. setLimit(upperLimit: number, lowerLimit?: number): void;
  105582. }
  105583. /**
  105584. * This class represents a single physics Hinge-Joint
  105585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105586. */
  105587. export class HingeJoint extends MotorEnabledJoint {
  105588. /**
  105589. * Initializes the Hinge-Joint
  105590. * @param jointData The joint data for the Hinge-Joint
  105591. */
  105592. constructor(jointData: PhysicsJointData);
  105593. /**
  105594. * Set the motor values.
  105595. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105596. * @param {number} force the force to apply
  105597. * @param {number} maxForce max force for this motor.
  105598. */
  105599. setMotor(force?: number, maxForce?: number): void;
  105600. /**
  105601. * Set the motor's limits.
  105602. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105603. * @param upperLimit The upper limit of the motor
  105604. * @param lowerLimit The lower limit of the motor
  105605. */
  105606. setLimit(upperLimit: number, lowerLimit?: number): void;
  105607. }
  105608. /**
  105609. * This class represents a dual hinge physics joint (same as wheel joint)
  105610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105611. */
  105612. export class Hinge2Joint extends MotorEnabledJoint {
  105613. /**
  105614. * Initializes the Hinge2-Joint
  105615. * @param jointData The joint data for the Hinge2-Joint
  105616. */
  105617. constructor(jointData: PhysicsJointData);
  105618. /**
  105619. * Set the motor values.
  105620. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105621. * @param {number} targetSpeed the speed the motor is to reach
  105622. * @param {number} maxForce max force for this motor.
  105623. * @param {motorIndex} the motor's index, 0 or 1.
  105624. */
  105625. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  105626. /**
  105627. * Set the motor limits.
  105628. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105629. * @param {number} upperLimit the upper limit
  105630. * @param {number} lowerLimit lower limit
  105631. * @param {motorIndex} the motor's index, 0 or 1.
  105632. */
  105633. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105634. }
  105635. /**
  105636. * Interface for a motor enabled joint
  105637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105638. */
  105639. export interface IMotorEnabledJoint {
  105640. /**
  105641. * Physics joint
  105642. */
  105643. physicsJoint: any;
  105644. /**
  105645. * Sets the motor of the motor-enabled joint
  105646. * @param force The force of the motor
  105647. * @param maxForce The maximum force of the motor
  105648. * @param motorIndex The index of the motor
  105649. */
  105650. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  105651. /**
  105652. * Sets the limit of the motor
  105653. * @param upperLimit The upper limit of the motor
  105654. * @param lowerLimit The lower limit of the motor
  105655. * @param motorIndex The index of the motor
  105656. */
  105657. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105658. }
  105659. /**
  105660. * Joint data for a Distance-Joint
  105661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105662. */
  105663. export interface DistanceJointData extends PhysicsJointData {
  105664. /**
  105665. * Max distance the 2 joint objects can be apart
  105666. */
  105667. maxDistance: number;
  105668. }
  105669. /**
  105670. * Joint data from a spring joint
  105671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105672. */
  105673. export interface SpringJointData extends PhysicsJointData {
  105674. /**
  105675. * Length of the spring
  105676. */
  105677. length: number;
  105678. /**
  105679. * Stiffness of the spring
  105680. */
  105681. stiffness: number;
  105682. /**
  105683. * Damping of the spring
  105684. */
  105685. damping: number;
  105686. /** this callback will be called when applying the force to the impostors. */
  105687. forceApplicationCallback: () => void;
  105688. }
  105689. }
  105690. declare module BABYLON {
  105691. /**
  105692. * Holds the data for the raycast result
  105693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105694. */
  105695. export class PhysicsRaycastResult {
  105696. private _hasHit;
  105697. private _hitDistance;
  105698. private _hitNormalWorld;
  105699. private _hitPointWorld;
  105700. private _rayFromWorld;
  105701. private _rayToWorld;
  105702. /**
  105703. * Gets if there was a hit
  105704. */
  105705. get hasHit(): boolean;
  105706. /**
  105707. * Gets the distance from the hit
  105708. */
  105709. get hitDistance(): number;
  105710. /**
  105711. * Gets the hit normal/direction in the world
  105712. */
  105713. get hitNormalWorld(): Vector3;
  105714. /**
  105715. * Gets the hit point in the world
  105716. */
  105717. get hitPointWorld(): Vector3;
  105718. /**
  105719. * Gets the ray "start point" of the ray in the world
  105720. */
  105721. get rayFromWorld(): Vector3;
  105722. /**
  105723. * Gets the ray "end point" of the ray in the world
  105724. */
  105725. get rayToWorld(): Vector3;
  105726. /**
  105727. * Sets the hit data (normal & point in world space)
  105728. * @param hitNormalWorld defines the normal in world space
  105729. * @param hitPointWorld defines the point in world space
  105730. */
  105731. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  105732. /**
  105733. * Sets the distance from the start point to the hit point
  105734. * @param distance
  105735. */
  105736. setHitDistance(distance: number): void;
  105737. /**
  105738. * Calculates the distance manually
  105739. */
  105740. calculateHitDistance(): void;
  105741. /**
  105742. * Resets all the values to default
  105743. * @param from The from point on world space
  105744. * @param to The to point on world space
  105745. */
  105746. reset(from?: Vector3, to?: Vector3): void;
  105747. }
  105748. /**
  105749. * Interface for the size containing width and height
  105750. */
  105751. interface IXYZ {
  105752. /**
  105753. * X
  105754. */
  105755. x: number;
  105756. /**
  105757. * Y
  105758. */
  105759. y: number;
  105760. /**
  105761. * Z
  105762. */
  105763. z: number;
  105764. }
  105765. }
  105766. declare module BABYLON {
  105767. /**
  105768. * Interface used to describe a physics joint
  105769. */
  105770. export interface PhysicsImpostorJoint {
  105771. /** Defines the main impostor to which the joint is linked */
  105772. mainImpostor: PhysicsImpostor;
  105773. /** Defines the impostor that is connected to the main impostor using this joint */
  105774. connectedImpostor: PhysicsImpostor;
  105775. /** Defines the joint itself */
  105776. joint: PhysicsJoint;
  105777. }
  105778. /** @hidden */
  105779. export interface IPhysicsEnginePlugin {
  105780. world: any;
  105781. name: string;
  105782. setGravity(gravity: Vector3): void;
  105783. setTimeStep(timeStep: number): void;
  105784. getTimeStep(): number;
  105785. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  105786. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105787. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105788. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105789. removePhysicsBody(impostor: PhysicsImpostor): void;
  105790. generateJoint(joint: PhysicsImpostorJoint): void;
  105791. removeJoint(joint: PhysicsImpostorJoint): void;
  105792. isSupported(): boolean;
  105793. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105794. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105795. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  105796. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  105797. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105798. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105799. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105800. getBodyMass(impostor: PhysicsImpostor): number;
  105801. getBodyFriction(impostor: PhysicsImpostor): number;
  105802. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105803. getBodyRestitution(impostor: PhysicsImpostor): number;
  105804. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105805. getBodyPressure?(impostor: PhysicsImpostor): number;
  105806. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  105807. getBodyStiffness?(impostor: PhysicsImpostor): number;
  105808. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  105809. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  105810. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  105811. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  105812. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  105813. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  105814. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  105815. sleepBody(impostor: PhysicsImpostor): void;
  105816. wakeUpBody(impostor: PhysicsImpostor): void;
  105817. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105818. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  105819. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  105820. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105821. getRadius(impostor: PhysicsImpostor): number;
  105822. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105823. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105824. dispose(): void;
  105825. }
  105826. /**
  105827. * Interface used to define a physics engine
  105828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105829. */
  105830. export interface IPhysicsEngine {
  105831. /**
  105832. * Gets the gravity vector used by the simulation
  105833. */
  105834. gravity: Vector3;
  105835. /**
  105836. * Sets the gravity vector used by the simulation
  105837. * @param gravity defines the gravity vector to use
  105838. */
  105839. setGravity(gravity: Vector3): void;
  105840. /**
  105841. * Set the time step of the physics engine.
  105842. * Default is 1/60.
  105843. * To slow it down, enter 1/600 for example.
  105844. * To speed it up, 1/30
  105845. * @param newTimeStep the new timestep to apply to this world.
  105846. */
  105847. setTimeStep(newTimeStep: number): void;
  105848. /**
  105849. * Get the time step of the physics engine.
  105850. * @returns the current time step
  105851. */
  105852. getTimeStep(): number;
  105853. /**
  105854. * Set the sub time step of the physics engine.
  105855. * Default is 0 meaning there is no sub steps
  105856. * To increase physics resolution precision, set a small value (like 1 ms)
  105857. * @param subTimeStep defines the new sub timestep used for physics resolution.
  105858. */
  105859. setSubTimeStep(subTimeStep: number): void;
  105860. /**
  105861. * Get the sub time step of the physics engine.
  105862. * @returns the current sub time step
  105863. */
  105864. getSubTimeStep(): number;
  105865. /**
  105866. * Release all resources
  105867. */
  105868. dispose(): void;
  105869. /**
  105870. * Gets the name of the current physics plugin
  105871. * @returns the name of the plugin
  105872. */
  105873. getPhysicsPluginName(): string;
  105874. /**
  105875. * Adding a new impostor for the impostor tracking.
  105876. * This will be done by the impostor itself.
  105877. * @param impostor the impostor to add
  105878. */
  105879. addImpostor(impostor: PhysicsImpostor): void;
  105880. /**
  105881. * Remove an impostor from the engine.
  105882. * This impostor and its mesh will not longer be updated by the physics engine.
  105883. * @param impostor the impostor to remove
  105884. */
  105885. removeImpostor(impostor: PhysicsImpostor): void;
  105886. /**
  105887. * Add a joint to the physics engine
  105888. * @param mainImpostor defines the main impostor to which the joint is added.
  105889. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  105890. * @param joint defines the joint that will connect both impostors.
  105891. */
  105892. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105893. /**
  105894. * Removes a joint from the simulation
  105895. * @param mainImpostor defines the impostor used with the joint
  105896. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  105897. * @param joint defines the joint to remove
  105898. */
  105899. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105900. /**
  105901. * Gets the current plugin used to run the simulation
  105902. * @returns current plugin
  105903. */
  105904. getPhysicsPlugin(): IPhysicsEnginePlugin;
  105905. /**
  105906. * Gets the list of physic impostors
  105907. * @returns an array of PhysicsImpostor
  105908. */
  105909. getImpostors(): Array<PhysicsImpostor>;
  105910. /**
  105911. * Gets the impostor for a physics enabled object
  105912. * @param object defines the object impersonated by the impostor
  105913. * @returns the PhysicsImpostor or null if not found
  105914. */
  105915. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  105916. /**
  105917. * Gets the impostor for a physics body object
  105918. * @param body defines physics body used by the impostor
  105919. * @returns the PhysicsImpostor or null if not found
  105920. */
  105921. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  105922. /**
  105923. * Does a raycast in the physics world
  105924. * @param from when should the ray start?
  105925. * @param to when should the ray end?
  105926. * @returns PhysicsRaycastResult
  105927. */
  105928. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105929. /**
  105930. * Called by the scene. No need to call it.
  105931. * @param delta defines the timespam between frames
  105932. */
  105933. _step(delta: number): void;
  105934. }
  105935. }
  105936. declare module BABYLON {
  105937. /**
  105938. * The interface for the physics imposter parameters
  105939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105940. */
  105941. export interface PhysicsImpostorParameters {
  105942. /**
  105943. * The mass of the physics imposter
  105944. */
  105945. mass: number;
  105946. /**
  105947. * The friction of the physics imposter
  105948. */
  105949. friction?: number;
  105950. /**
  105951. * The coefficient of restitution of the physics imposter
  105952. */
  105953. restitution?: number;
  105954. /**
  105955. * The native options of the physics imposter
  105956. */
  105957. nativeOptions?: any;
  105958. /**
  105959. * Specifies if the parent should be ignored
  105960. */
  105961. ignoreParent?: boolean;
  105962. /**
  105963. * Specifies if bi-directional transformations should be disabled
  105964. */
  105965. disableBidirectionalTransformation?: boolean;
  105966. /**
  105967. * The pressure inside the physics imposter, soft object only
  105968. */
  105969. pressure?: number;
  105970. /**
  105971. * The stiffness the physics imposter, soft object only
  105972. */
  105973. stiffness?: number;
  105974. /**
  105975. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  105976. */
  105977. velocityIterations?: number;
  105978. /**
  105979. * The number of iterations used in maintaining consistent vertex positions, soft object only
  105980. */
  105981. positionIterations?: number;
  105982. /**
  105983. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  105984. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  105985. * Add to fix multiple points
  105986. */
  105987. fixedPoints?: number;
  105988. /**
  105989. * The collision margin around a soft object
  105990. */
  105991. margin?: number;
  105992. /**
  105993. * The collision margin around a soft object
  105994. */
  105995. damping?: number;
  105996. /**
  105997. * The path for a rope based on an extrusion
  105998. */
  105999. path?: any;
  106000. /**
  106001. * The shape of an extrusion used for a rope based on an extrusion
  106002. */
  106003. shape?: any;
  106004. }
  106005. /**
  106006. * Interface for a physics-enabled object
  106007. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106008. */
  106009. export interface IPhysicsEnabledObject {
  106010. /**
  106011. * The position of the physics-enabled object
  106012. */
  106013. position: Vector3;
  106014. /**
  106015. * The rotation of the physics-enabled object
  106016. */
  106017. rotationQuaternion: Nullable<Quaternion>;
  106018. /**
  106019. * The scale of the physics-enabled object
  106020. */
  106021. scaling: Vector3;
  106022. /**
  106023. * The rotation of the physics-enabled object
  106024. */
  106025. rotation?: Vector3;
  106026. /**
  106027. * The parent of the physics-enabled object
  106028. */
  106029. parent?: any;
  106030. /**
  106031. * The bounding info of the physics-enabled object
  106032. * @returns The bounding info of the physics-enabled object
  106033. */
  106034. getBoundingInfo(): BoundingInfo;
  106035. /**
  106036. * Computes the world matrix
  106037. * @param force Specifies if the world matrix should be computed by force
  106038. * @returns A world matrix
  106039. */
  106040. computeWorldMatrix(force: boolean): Matrix;
  106041. /**
  106042. * Gets the world matrix
  106043. * @returns A world matrix
  106044. */
  106045. getWorldMatrix?(): Matrix;
  106046. /**
  106047. * Gets the child meshes
  106048. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  106049. * @returns An array of abstract meshes
  106050. */
  106051. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  106052. /**
  106053. * Gets the vertex data
  106054. * @param kind The type of vertex data
  106055. * @returns A nullable array of numbers, or a float32 array
  106056. */
  106057. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  106058. /**
  106059. * Gets the indices from the mesh
  106060. * @returns A nullable array of index arrays
  106061. */
  106062. getIndices?(): Nullable<IndicesArray>;
  106063. /**
  106064. * Gets the scene from the mesh
  106065. * @returns the indices array or null
  106066. */
  106067. getScene?(): Scene;
  106068. /**
  106069. * Gets the absolute position from the mesh
  106070. * @returns the absolute position
  106071. */
  106072. getAbsolutePosition(): Vector3;
  106073. /**
  106074. * Gets the absolute pivot point from the mesh
  106075. * @returns the absolute pivot point
  106076. */
  106077. getAbsolutePivotPoint(): Vector3;
  106078. /**
  106079. * Rotates the mesh
  106080. * @param axis The axis of rotation
  106081. * @param amount The amount of rotation
  106082. * @param space The space of the rotation
  106083. * @returns The rotation transform node
  106084. */
  106085. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  106086. /**
  106087. * Translates the mesh
  106088. * @param axis The axis of translation
  106089. * @param distance The distance of translation
  106090. * @param space The space of the translation
  106091. * @returns The transform node
  106092. */
  106093. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  106094. /**
  106095. * Sets the absolute position of the mesh
  106096. * @param absolutePosition The absolute position of the mesh
  106097. * @returns The transform node
  106098. */
  106099. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  106100. /**
  106101. * Gets the class name of the mesh
  106102. * @returns The class name
  106103. */
  106104. getClassName(): string;
  106105. }
  106106. /**
  106107. * Represents a physics imposter
  106108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106109. */
  106110. export class PhysicsImpostor {
  106111. /**
  106112. * The physics-enabled object used as the physics imposter
  106113. */
  106114. object: IPhysicsEnabledObject;
  106115. /**
  106116. * The type of the physics imposter
  106117. */
  106118. type: number;
  106119. private _options;
  106120. private _scene?;
  106121. /**
  106122. * The default object size of the imposter
  106123. */
  106124. static DEFAULT_OBJECT_SIZE: Vector3;
  106125. /**
  106126. * The identity quaternion of the imposter
  106127. */
  106128. static IDENTITY_QUATERNION: Quaternion;
  106129. /** @hidden */
  106130. _pluginData: any;
  106131. private _physicsEngine;
  106132. private _physicsBody;
  106133. private _bodyUpdateRequired;
  106134. private _onBeforePhysicsStepCallbacks;
  106135. private _onAfterPhysicsStepCallbacks;
  106136. /** @hidden */
  106137. _onPhysicsCollideCallbacks: Array<{
  106138. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  106139. otherImpostors: Array<PhysicsImpostor>;
  106140. }>;
  106141. private _deltaPosition;
  106142. private _deltaRotation;
  106143. private _deltaRotationConjugated;
  106144. /** @hidden */
  106145. _isFromLine: boolean;
  106146. private _parent;
  106147. private _isDisposed;
  106148. private static _tmpVecs;
  106149. private static _tmpQuat;
  106150. /**
  106151. * Specifies if the physics imposter is disposed
  106152. */
  106153. get isDisposed(): boolean;
  106154. /**
  106155. * Gets the mass of the physics imposter
  106156. */
  106157. get mass(): number;
  106158. set mass(value: number);
  106159. /**
  106160. * Gets the coefficient of friction
  106161. */
  106162. get friction(): number;
  106163. /**
  106164. * Sets the coefficient of friction
  106165. */
  106166. set friction(value: number);
  106167. /**
  106168. * Gets the coefficient of restitution
  106169. */
  106170. get restitution(): number;
  106171. /**
  106172. * Sets the coefficient of restitution
  106173. */
  106174. set restitution(value: number);
  106175. /**
  106176. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  106177. */
  106178. get pressure(): number;
  106179. /**
  106180. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  106181. */
  106182. set pressure(value: number);
  106183. /**
  106184. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106185. */
  106186. get stiffness(): number;
  106187. /**
  106188. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106189. */
  106190. set stiffness(value: number);
  106191. /**
  106192. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106193. */
  106194. get velocityIterations(): number;
  106195. /**
  106196. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106197. */
  106198. set velocityIterations(value: number);
  106199. /**
  106200. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106201. */
  106202. get positionIterations(): number;
  106203. /**
  106204. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106205. */
  106206. set positionIterations(value: number);
  106207. /**
  106208. * The unique id of the physics imposter
  106209. * set by the physics engine when adding this impostor to the array
  106210. */
  106211. uniqueId: number;
  106212. /**
  106213. * @hidden
  106214. */
  106215. soft: boolean;
  106216. /**
  106217. * @hidden
  106218. */
  106219. segments: number;
  106220. private _joints;
  106221. /**
  106222. * Initializes the physics imposter
  106223. * @param object The physics-enabled object used as the physics imposter
  106224. * @param type The type of the physics imposter
  106225. * @param _options The options for the physics imposter
  106226. * @param _scene The Babylon scene
  106227. */
  106228. constructor(
  106229. /**
  106230. * The physics-enabled object used as the physics imposter
  106231. */
  106232. object: IPhysicsEnabledObject,
  106233. /**
  106234. * The type of the physics imposter
  106235. */
  106236. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  106237. /**
  106238. * This function will completly initialize this impostor.
  106239. * It will create a new body - but only if this mesh has no parent.
  106240. * If it has, this impostor will not be used other than to define the impostor
  106241. * of the child mesh.
  106242. * @hidden
  106243. */
  106244. _init(): void;
  106245. private _getPhysicsParent;
  106246. /**
  106247. * Should a new body be generated.
  106248. * @returns boolean specifying if body initialization is required
  106249. */
  106250. isBodyInitRequired(): boolean;
  106251. /**
  106252. * Sets the updated scaling
  106253. * @param updated Specifies if the scaling is updated
  106254. */
  106255. setScalingUpdated(): void;
  106256. /**
  106257. * Force a regeneration of this or the parent's impostor's body.
  106258. * Use under cautious - This will remove all joints already implemented.
  106259. */
  106260. forceUpdate(): void;
  106261. /**
  106262. * Gets the body that holds this impostor. Either its own, or its parent.
  106263. */
  106264. get physicsBody(): any;
  106265. /**
  106266. * Get the parent of the physics imposter
  106267. * @returns Physics imposter or null
  106268. */
  106269. get parent(): Nullable<PhysicsImpostor>;
  106270. /**
  106271. * Sets the parent of the physics imposter
  106272. */
  106273. set parent(value: Nullable<PhysicsImpostor>);
  106274. /**
  106275. * Set the physics body. Used mainly by the physics engine/plugin
  106276. */
  106277. set physicsBody(physicsBody: any);
  106278. /**
  106279. * Resets the update flags
  106280. */
  106281. resetUpdateFlags(): void;
  106282. /**
  106283. * Gets the object extend size
  106284. * @returns the object extend size
  106285. */
  106286. getObjectExtendSize(): Vector3;
  106287. /**
  106288. * Gets the object center
  106289. * @returns The object center
  106290. */
  106291. getObjectCenter(): Vector3;
  106292. /**
  106293. * Get a specific parameter from the options parameters
  106294. * @param paramName The object parameter name
  106295. * @returns The object parameter
  106296. */
  106297. getParam(paramName: string): any;
  106298. /**
  106299. * Sets a specific parameter in the options given to the physics plugin
  106300. * @param paramName The parameter name
  106301. * @param value The value of the parameter
  106302. */
  106303. setParam(paramName: string, value: number): void;
  106304. /**
  106305. * Specifically change the body's mass option. Won't recreate the physics body object
  106306. * @param mass The mass of the physics imposter
  106307. */
  106308. setMass(mass: number): void;
  106309. /**
  106310. * Gets the linear velocity
  106311. * @returns linear velocity or null
  106312. */
  106313. getLinearVelocity(): Nullable<Vector3>;
  106314. /**
  106315. * Sets the linear velocity
  106316. * @param velocity linear velocity or null
  106317. */
  106318. setLinearVelocity(velocity: Nullable<Vector3>): void;
  106319. /**
  106320. * Gets the angular velocity
  106321. * @returns angular velocity or null
  106322. */
  106323. getAngularVelocity(): Nullable<Vector3>;
  106324. /**
  106325. * Sets the angular velocity
  106326. * @param velocity The velocity or null
  106327. */
  106328. setAngularVelocity(velocity: Nullable<Vector3>): void;
  106329. /**
  106330. * Execute a function with the physics plugin native code
  106331. * Provide a function the will have two variables - the world object and the physics body object
  106332. * @param func The function to execute with the physics plugin native code
  106333. */
  106334. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  106335. /**
  106336. * Register a function that will be executed before the physics world is stepping forward
  106337. * @param func The function to execute before the physics world is stepped forward
  106338. */
  106339. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106340. /**
  106341. * Unregister a function that will be executed before the physics world is stepping forward
  106342. * @param func The function to execute before the physics world is stepped forward
  106343. */
  106344. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106345. /**
  106346. * Register a function that will be executed after the physics step
  106347. * @param func The function to execute after physics step
  106348. */
  106349. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106350. /**
  106351. * Unregisters a function that will be executed after the physics step
  106352. * @param func The function to execute after physics step
  106353. */
  106354. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106355. /**
  106356. * register a function that will be executed when this impostor collides against a different body
  106357. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  106358. * @param func Callback that is executed on collision
  106359. */
  106360. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  106361. /**
  106362. * Unregisters the physics imposter on contact
  106363. * @param collideAgainst The physics object to collide against
  106364. * @param func Callback to execute on collision
  106365. */
  106366. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  106367. private _tmpQuat;
  106368. private _tmpQuat2;
  106369. /**
  106370. * Get the parent rotation
  106371. * @returns The parent rotation
  106372. */
  106373. getParentsRotation(): Quaternion;
  106374. /**
  106375. * this function is executed by the physics engine.
  106376. */
  106377. beforeStep: () => void;
  106378. /**
  106379. * this function is executed by the physics engine
  106380. */
  106381. afterStep: () => void;
  106382. /**
  106383. * Legacy collision detection event support
  106384. */
  106385. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  106386. /**
  106387. * event and body object due to cannon's event-based architecture.
  106388. */
  106389. onCollide: (e: {
  106390. body: any;
  106391. }) => void;
  106392. /**
  106393. * Apply a force
  106394. * @param force The force to apply
  106395. * @param contactPoint The contact point for the force
  106396. * @returns The physics imposter
  106397. */
  106398. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  106399. /**
  106400. * Apply an impulse
  106401. * @param force The impulse force
  106402. * @param contactPoint The contact point for the impulse force
  106403. * @returns The physics imposter
  106404. */
  106405. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  106406. /**
  106407. * A help function to create a joint
  106408. * @param otherImpostor A physics imposter used to create a joint
  106409. * @param jointType The type of joint
  106410. * @param jointData The data for the joint
  106411. * @returns The physics imposter
  106412. */
  106413. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  106414. /**
  106415. * Add a joint to this impostor with a different impostor
  106416. * @param otherImpostor A physics imposter used to add a joint
  106417. * @param joint The joint to add
  106418. * @returns The physics imposter
  106419. */
  106420. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  106421. /**
  106422. * Add an anchor to a cloth impostor
  106423. * @param otherImpostor rigid impostor to anchor to
  106424. * @param width ratio across width from 0 to 1
  106425. * @param height ratio up height from 0 to 1
  106426. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  106427. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  106428. * @returns impostor the soft imposter
  106429. */
  106430. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  106431. /**
  106432. * Add a hook to a rope impostor
  106433. * @param otherImpostor rigid impostor to anchor to
  106434. * @param length ratio across rope from 0 to 1
  106435. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  106436. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  106437. * @returns impostor the rope imposter
  106438. */
  106439. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  106440. /**
  106441. * Will keep this body still, in a sleep mode.
  106442. * @returns the physics imposter
  106443. */
  106444. sleep(): PhysicsImpostor;
  106445. /**
  106446. * Wake the body up.
  106447. * @returns The physics imposter
  106448. */
  106449. wakeUp(): PhysicsImpostor;
  106450. /**
  106451. * Clones the physics imposter
  106452. * @param newObject The physics imposter clones to this physics-enabled object
  106453. * @returns A nullable physics imposter
  106454. */
  106455. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  106456. /**
  106457. * Disposes the physics imposter
  106458. */
  106459. dispose(): void;
  106460. /**
  106461. * Sets the delta position
  106462. * @param position The delta position amount
  106463. */
  106464. setDeltaPosition(position: Vector3): void;
  106465. /**
  106466. * Sets the delta rotation
  106467. * @param rotation The delta rotation amount
  106468. */
  106469. setDeltaRotation(rotation: Quaternion): void;
  106470. /**
  106471. * Gets the box size of the physics imposter and stores the result in the input parameter
  106472. * @param result Stores the box size
  106473. * @returns The physics imposter
  106474. */
  106475. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  106476. /**
  106477. * Gets the radius of the physics imposter
  106478. * @returns Radius of the physics imposter
  106479. */
  106480. getRadius(): number;
  106481. /**
  106482. * Sync a bone with this impostor
  106483. * @param bone The bone to sync to the impostor.
  106484. * @param boneMesh The mesh that the bone is influencing.
  106485. * @param jointPivot The pivot of the joint / bone in local space.
  106486. * @param distToJoint Optional distance from the impostor to the joint.
  106487. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  106488. */
  106489. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  106490. /**
  106491. * Sync impostor to a bone
  106492. * @param bone The bone that the impostor will be synced to.
  106493. * @param boneMesh The mesh that the bone is influencing.
  106494. * @param jointPivot The pivot of the joint / bone in local space.
  106495. * @param distToJoint Optional distance from the impostor to the joint.
  106496. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  106497. * @param boneAxis Optional vector3 axis the bone is aligned with
  106498. */
  106499. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  106500. /**
  106501. * No-Imposter type
  106502. */
  106503. static NoImpostor: number;
  106504. /**
  106505. * Sphere-Imposter type
  106506. */
  106507. static SphereImpostor: number;
  106508. /**
  106509. * Box-Imposter type
  106510. */
  106511. static BoxImpostor: number;
  106512. /**
  106513. * Plane-Imposter type
  106514. */
  106515. static PlaneImpostor: number;
  106516. /**
  106517. * Mesh-imposter type
  106518. */
  106519. static MeshImpostor: number;
  106520. /**
  106521. * Capsule-Impostor type (Ammo.js plugin only)
  106522. */
  106523. static CapsuleImpostor: number;
  106524. /**
  106525. * Cylinder-Imposter type
  106526. */
  106527. static CylinderImpostor: number;
  106528. /**
  106529. * Particle-Imposter type
  106530. */
  106531. static ParticleImpostor: number;
  106532. /**
  106533. * Heightmap-Imposter type
  106534. */
  106535. static HeightmapImpostor: number;
  106536. /**
  106537. * ConvexHull-Impostor type (Ammo.js plugin only)
  106538. */
  106539. static ConvexHullImpostor: number;
  106540. /**
  106541. * Custom-Imposter type (Ammo.js plugin only)
  106542. */
  106543. static CustomImpostor: number;
  106544. /**
  106545. * Rope-Imposter type
  106546. */
  106547. static RopeImpostor: number;
  106548. /**
  106549. * Cloth-Imposter type
  106550. */
  106551. static ClothImpostor: number;
  106552. /**
  106553. * Softbody-Imposter type
  106554. */
  106555. static SoftbodyImpostor: number;
  106556. }
  106557. }
  106558. declare module BABYLON {
  106559. /**
  106560. * @hidden
  106561. **/
  106562. export class _CreationDataStorage {
  106563. closePath?: boolean;
  106564. closeArray?: boolean;
  106565. idx: number[];
  106566. dashSize: number;
  106567. gapSize: number;
  106568. path3D: Path3D;
  106569. pathArray: Vector3[][];
  106570. arc: number;
  106571. radius: number;
  106572. cap: number;
  106573. tessellation: number;
  106574. }
  106575. /**
  106576. * @hidden
  106577. **/
  106578. class _InstanceDataStorage {
  106579. visibleInstances: any;
  106580. batchCache: _InstancesBatch;
  106581. instancesBufferSize: number;
  106582. instancesBuffer: Nullable<Buffer>;
  106583. instancesData: Float32Array;
  106584. overridenInstanceCount: number;
  106585. isFrozen: boolean;
  106586. previousBatch: Nullable<_InstancesBatch>;
  106587. hardwareInstancedRendering: boolean;
  106588. sideOrientation: number;
  106589. manualUpdate: boolean;
  106590. }
  106591. /**
  106592. * @hidden
  106593. **/
  106594. export class _InstancesBatch {
  106595. mustReturn: boolean;
  106596. visibleInstances: Nullable<InstancedMesh[]>[];
  106597. renderSelf: boolean[];
  106598. hardwareInstancedRendering: boolean[];
  106599. }
  106600. /**
  106601. * @hidden
  106602. **/
  106603. class _ThinInstanceDataStorage {
  106604. instancesCount: number;
  106605. matrixBuffer: Nullable<Buffer>;
  106606. matrixBufferSize: number;
  106607. matrixData: Nullable<Float32Array>;
  106608. boundingVectors: Array<Vector3>;
  106609. }
  106610. /**
  106611. * Class used to represent renderable models
  106612. */
  106613. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  106614. /**
  106615. * Mesh side orientation : usually the external or front surface
  106616. */
  106617. static readonly FRONTSIDE: number;
  106618. /**
  106619. * Mesh side orientation : usually the internal or back surface
  106620. */
  106621. static readonly BACKSIDE: number;
  106622. /**
  106623. * Mesh side orientation : both internal and external or front and back surfaces
  106624. */
  106625. static readonly DOUBLESIDE: number;
  106626. /**
  106627. * Mesh side orientation : by default, `FRONTSIDE`
  106628. */
  106629. static readonly DEFAULTSIDE: number;
  106630. /**
  106631. * Mesh cap setting : no cap
  106632. */
  106633. static readonly NO_CAP: number;
  106634. /**
  106635. * Mesh cap setting : one cap at the beginning of the mesh
  106636. */
  106637. static readonly CAP_START: number;
  106638. /**
  106639. * Mesh cap setting : one cap at the end of the mesh
  106640. */
  106641. static readonly CAP_END: number;
  106642. /**
  106643. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  106644. */
  106645. static readonly CAP_ALL: number;
  106646. /**
  106647. * Mesh pattern setting : no flip or rotate
  106648. */
  106649. static readonly NO_FLIP: number;
  106650. /**
  106651. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  106652. */
  106653. static readonly FLIP_TILE: number;
  106654. /**
  106655. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  106656. */
  106657. static readonly ROTATE_TILE: number;
  106658. /**
  106659. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  106660. */
  106661. static readonly FLIP_ROW: number;
  106662. /**
  106663. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  106664. */
  106665. static readonly ROTATE_ROW: number;
  106666. /**
  106667. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  106668. */
  106669. static readonly FLIP_N_ROTATE_TILE: number;
  106670. /**
  106671. * Mesh pattern setting : rotate pattern and rotate
  106672. */
  106673. static readonly FLIP_N_ROTATE_ROW: number;
  106674. /**
  106675. * Mesh tile positioning : part tiles same on left/right or top/bottom
  106676. */
  106677. static readonly CENTER: number;
  106678. /**
  106679. * Mesh tile positioning : part tiles on left
  106680. */
  106681. static readonly LEFT: number;
  106682. /**
  106683. * Mesh tile positioning : part tiles on right
  106684. */
  106685. static readonly RIGHT: number;
  106686. /**
  106687. * Mesh tile positioning : part tiles on top
  106688. */
  106689. static readonly TOP: number;
  106690. /**
  106691. * Mesh tile positioning : part tiles on bottom
  106692. */
  106693. static readonly BOTTOM: number;
  106694. /**
  106695. * Gets the default side orientation.
  106696. * @param orientation the orientation to value to attempt to get
  106697. * @returns the default orientation
  106698. * @hidden
  106699. */
  106700. static _GetDefaultSideOrientation(orientation?: number): number;
  106701. private _internalMeshDataInfo;
  106702. get computeBonesUsingShaders(): boolean;
  106703. set computeBonesUsingShaders(value: boolean);
  106704. /**
  106705. * An event triggered before rendering the mesh
  106706. */
  106707. get onBeforeRenderObservable(): Observable<Mesh>;
  106708. /**
  106709. * An event triggered before binding the mesh
  106710. */
  106711. get onBeforeBindObservable(): Observable<Mesh>;
  106712. /**
  106713. * An event triggered after rendering the mesh
  106714. */
  106715. get onAfterRenderObservable(): Observable<Mesh>;
  106716. /**
  106717. * An event triggered before drawing the mesh
  106718. */
  106719. get onBeforeDrawObservable(): Observable<Mesh>;
  106720. private _onBeforeDrawObserver;
  106721. /**
  106722. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  106723. */
  106724. set onBeforeDraw(callback: () => void);
  106725. get hasInstances(): boolean;
  106726. get hasThinInstances(): boolean;
  106727. /**
  106728. * Gets the delay loading state of the mesh (when delay loading is turned on)
  106729. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  106730. */
  106731. delayLoadState: number;
  106732. /**
  106733. * Gets the list of instances created from this mesh
  106734. * it is not supposed to be modified manually.
  106735. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  106736. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  106737. */
  106738. instances: InstancedMesh[];
  106739. /**
  106740. * Gets the file containing delay loading data for this mesh
  106741. */
  106742. delayLoadingFile: string;
  106743. /** @hidden */
  106744. _binaryInfo: any;
  106745. /**
  106746. * User defined function used to change how LOD level selection is done
  106747. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106748. */
  106749. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  106750. /**
  106751. * Gets or sets the morph target manager
  106752. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106753. */
  106754. get morphTargetManager(): Nullable<MorphTargetManager>;
  106755. set morphTargetManager(value: Nullable<MorphTargetManager>);
  106756. /** @hidden */
  106757. _creationDataStorage: Nullable<_CreationDataStorage>;
  106758. /** @hidden */
  106759. _geometry: Nullable<Geometry>;
  106760. /** @hidden */
  106761. _delayInfo: Array<string>;
  106762. /** @hidden */
  106763. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  106764. /** @hidden */
  106765. _instanceDataStorage: _InstanceDataStorage;
  106766. /** @hidden */
  106767. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  106768. private _effectiveMaterial;
  106769. /** @hidden */
  106770. _shouldGenerateFlatShading: boolean;
  106771. /** @hidden */
  106772. _originalBuilderSideOrientation: number;
  106773. /**
  106774. * Use this property to change the original side orientation defined at construction time
  106775. */
  106776. overrideMaterialSideOrientation: Nullable<number>;
  106777. /**
  106778. * Gets the source mesh (the one used to clone this one from)
  106779. */
  106780. get source(): Nullable<Mesh>;
  106781. /**
  106782. * Gets or sets a boolean indicating that this mesh does not use index buffer
  106783. */
  106784. get isUnIndexed(): boolean;
  106785. set isUnIndexed(value: boolean);
  106786. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  106787. get worldMatrixInstancedBuffer(): Float32Array;
  106788. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  106789. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  106790. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  106791. /**
  106792. * @constructor
  106793. * @param name The value used by scene.getMeshByName() to do a lookup.
  106794. * @param scene The scene to add this mesh to.
  106795. * @param parent The parent of this mesh, if it has one
  106796. * @param source An optional Mesh from which geometry is shared, cloned.
  106797. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  106798. * When false, achieved by calling a clone(), also passing False.
  106799. * This will make creation of children, recursive.
  106800. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  106801. */
  106802. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  106803. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  106804. doNotInstantiate: boolean;
  106805. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  106806. /**
  106807. * Gets the class name
  106808. * @returns the string "Mesh".
  106809. */
  106810. getClassName(): string;
  106811. /** @hidden */
  106812. get _isMesh(): boolean;
  106813. /**
  106814. * Returns a description of this mesh
  106815. * @param fullDetails define if full details about this mesh must be used
  106816. * @returns a descriptive string representing this mesh
  106817. */
  106818. toString(fullDetails?: boolean): string;
  106819. /** @hidden */
  106820. _unBindEffect(): void;
  106821. /**
  106822. * Gets a boolean indicating if this mesh has LOD
  106823. */
  106824. get hasLODLevels(): boolean;
  106825. /**
  106826. * Gets the list of MeshLODLevel associated with the current mesh
  106827. * @returns an array of MeshLODLevel
  106828. */
  106829. getLODLevels(): MeshLODLevel[];
  106830. private _sortLODLevels;
  106831. /**
  106832. * Add a mesh as LOD level triggered at the given distance.
  106833. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106834. * @param distance The distance from the center of the object to show this level
  106835. * @param mesh The mesh to be added as LOD level (can be null)
  106836. * @return This mesh (for chaining)
  106837. */
  106838. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  106839. /**
  106840. * Returns the LOD level mesh at the passed distance or null if not found.
  106841. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106842. * @param distance The distance from the center of the object to show this level
  106843. * @returns a Mesh or `null`
  106844. */
  106845. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  106846. /**
  106847. * Remove a mesh from the LOD array
  106848. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106849. * @param mesh defines the mesh to be removed
  106850. * @return This mesh (for chaining)
  106851. */
  106852. removeLODLevel(mesh: Mesh): Mesh;
  106853. /**
  106854. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  106855. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106856. * @param camera defines the camera to use to compute distance
  106857. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  106858. * @return This mesh (for chaining)
  106859. */
  106860. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  106861. /**
  106862. * Gets the mesh internal Geometry object
  106863. */
  106864. get geometry(): Nullable<Geometry>;
  106865. /**
  106866. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  106867. * @returns the total number of vertices
  106868. */
  106869. getTotalVertices(): number;
  106870. /**
  106871. * Returns the content of an associated vertex buffer
  106872. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  106873. * - VertexBuffer.PositionKind
  106874. * - VertexBuffer.UVKind
  106875. * - VertexBuffer.UV2Kind
  106876. * - VertexBuffer.UV3Kind
  106877. * - VertexBuffer.UV4Kind
  106878. * - VertexBuffer.UV5Kind
  106879. * - VertexBuffer.UV6Kind
  106880. * - VertexBuffer.ColorKind
  106881. * - VertexBuffer.MatricesIndicesKind
  106882. * - VertexBuffer.MatricesIndicesExtraKind
  106883. * - VertexBuffer.MatricesWeightsKind
  106884. * - VertexBuffer.MatricesWeightsExtraKind
  106885. * @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
  106886. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  106887. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  106888. */
  106889. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106890. /**
  106891. * Returns the mesh VertexBuffer object from the requested `kind`
  106892. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  106893. * - VertexBuffer.PositionKind
  106894. * - VertexBuffer.NormalKind
  106895. * - VertexBuffer.UVKind
  106896. * - VertexBuffer.UV2Kind
  106897. * - VertexBuffer.UV3Kind
  106898. * - VertexBuffer.UV4Kind
  106899. * - VertexBuffer.UV5Kind
  106900. * - VertexBuffer.UV6Kind
  106901. * - VertexBuffer.ColorKind
  106902. * - VertexBuffer.MatricesIndicesKind
  106903. * - VertexBuffer.MatricesIndicesExtraKind
  106904. * - VertexBuffer.MatricesWeightsKind
  106905. * - VertexBuffer.MatricesWeightsExtraKind
  106906. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  106907. */
  106908. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  106909. /**
  106910. * Tests if a specific vertex buffer is associated with this mesh
  106911. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  106912. * - VertexBuffer.PositionKind
  106913. * - VertexBuffer.NormalKind
  106914. * - VertexBuffer.UVKind
  106915. * - VertexBuffer.UV2Kind
  106916. * - VertexBuffer.UV3Kind
  106917. * - VertexBuffer.UV4Kind
  106918. * - VertexBuffer.UV5Kind
  106919. * - VertexBuffer.UV6Kind
  106920. * - VertexBuffer.ColorKind
  106921. * - VertexBuffer.MatricesIndicesKind
  106922. * - VertexBuffer.MatricesIndicesExtraKind
  106923. * - VertexBuffer.MatricesWeightsKind
  106924. * - VertexBuffer.MatricesWeightsExtraKind
  106925. * @returns a boolean
  106926. */
  106927. isVerticesDataPresent(kind: string): boolean;
  106928. /**
  106929. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  106930. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  106931. * - VertexBuffer.PositionKind
  106932. * - VertexBuffer.UVKind
  106933. * - VertexBuffer.UV2Kind
  106934. * - VertexBuffer.UV3Kind
  106935. * - VertexBuffer.UV4Kind
  106936. * - VertexBuffer.UV5Kind
  106937. * - VertexBuffer.UV6Kind
  106938. * - VertexBuffer.ColorKind
  106939. * - VertexBuffer.MatricesIndicesKind
  106940. * - VertexBuffer.MatricesIndicesExtraKind
  106941. * - VertexBuffer.MatricesWeightsKind
  106942. * - VertexBuffer.MatricesWeightsExtraKind
  106943. * @returns a boolean
  106944. */
  106945. isVertexBufferUpdatable(kind: string): boolean;
  106946. /**
  106947. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  106948. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  106949. * - VertexBuffer.PositionKind
  106950. * - VertexBuffer.NormalKind
  106951. * - VertexBuffer.UVKind
  106952. * - VertexBuffer.UV2Kind
  106953. * - VertexBuffer.UV3Kind
  106954. * - VertexBuffer.UV4Kind
  106955. * - VertexBuffer.UV5Kind
  106956. * - VertexBuffer.UV6Kind
  106957. * - VertexBuffer.ColorKind
  106958. * - VertexBuffer.MatricesIndicesKind
  106959. * - VertexBuffer.MatricesIndicesExtraKind
  106960. * - VertexBuffer.MatricesWeightsKind
  106961. * - VertexBuffer.MatricesWeightsExtraKind
  106962. * @returns an array of strings
  106963. */
  106964. getVerticesDataKinds(): string[];
  106965. /**
  106966. * Returns a positive integer : the total number of indices in this mesh geometry.
  106967. * @returns the numner of indices or zero if the mesh has no geometry.
  106968. */
  106969. getTotalIndices(): number;
  106970. /**
  106971. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  106972. * @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.
  106973. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106974. * @returns the indices array or an empty array if the mesh has no geometry
  106975. */
  106976. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106977. get isBlocked(): boolean;
  106978. /**
  106979. * Determine if the current mesh is ready to be rendered
  106980. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  106981. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  106982. * @returns true if all associated assets are ready (material, textures, shaders)
  106983. */
  106984. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  106985. /**
  106986. * 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.
  106987. */
  106988. get areNormalsFrozen(): boolean;
  106989. /**
  106990. * 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.
  106991. * @returns the current mesh
  106992. */
  106993. freezeNormals(): Mesh;
  106994. /**
  106995. * 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
  106996. * @returns the current mesh
  106997. */
  106998. unfreezeNormals(): Mesh;
  106999. /**
  107000. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  107001. */
  107002. set overridenInstanceCount(count: number);
  107003. /** @hidden */
  107004. _preActivate(): Mesh;
  107005. /** @hidden */
  107006. _preActivateForIntermediateRendering(renderId: number): Mesh;
  107007. /** @hidden */
  107008. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  107009. protected _afterComputeWorldMatrix(): void;
  107010. /** @hidden */
  107011. _postActivate(): void;
  107012. /**
  107013. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  107014. * This means the mesh underlying bounding box and sphere are recomputed.
  107015. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  107016. * @returns the current mesh
  107017. */
  107018. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  107019. /** @hidden */
  107020. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  107021. /**
  107022. * This function will subdivide the mesh into multiple submeshes
  107023. * @param count defines the expected number of submeshes
  107024. */
  107025. subdivide(count: number): void;
  107026. /**
  107027. * Copy a FloatArray into a specific associated vertex buffer
  107028. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  107029. * - VertexBuffer.PositionKind
  107030. * - VertexBuffer.UVKind
  107031. * - VertexBuffer.UV2Kind
  107032. * - VertexBuffer.UV3Kind
  107033. * - VertexBuffer.UV4Kind
  107034. * - VertexBuffer.UV5Kind
  107035. * - VertexBuffer.UV6Kind
  107036. * - VertexBuffer.ColorKind
  107037. * - VertexBuffer.MatricesIndicesKind
  107038. * - VertexBuffer.MatricesIndicesExtraKind
  107039. * - VertexBuffer.MatricesWeightsKind
  107040. * - VertexBuffer.MatricesWeightsExtraKind
  107041. * @param data defines the data source
  107042. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  107043. * @param stride defines the data stride size (can be null)
  107044. * @returns the current mesh
  107045. */
  107046. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  107047. /**
  107048. * Delete a vertex buffer associated with this mesh
  107049. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  107050. * - VertexBuffer.PositionKind
  107051. * - VertexBuffer.UVKind
  107052. * - VertexBuffer.UV2Kind
  107053. * - VertexBuffer.UV3Kind
  107054. * - VertexBuffer.UV4Kind
  107055. * - VertexBuffer.UV5Kind
  107056. * - VertexBuffer.UV6Kind
  107057. * - VertexBuffer.ColorKind
  107058. * - VertexBuffer.MatricesIndicesKind
  107059. * - VertexBuffer.MatricesIndicesExtraKind
  107060. * - VertexBuffer.MatricesWeightsKind
  107061. * - VertexBuffer.MatricesWeightsExtraKind
  107062. */
  107063. removeVerticesData(kind: string): void;
  107064. /**
  107065. * Flags an associated vertex buffer as updatable
  107066. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  107067. * - VertexBuffer.PositionKind
  107068. * - VertexBuffer.UVKind
  107069. * - VertexBuffer.UV2Kind
  107070. * - VertexBuffer.UV3Kind
  107071. * - VertexBuffer.UV4Kind
  107072. * - VertexBuffer.UV5Kind
  107073. * - VertexBuffer.UV6Kind
  107074. * - VertexBuffer.ColorKind
  107075. * - VertexBuffer.MatricesIndicesKind
  107076. * - VertexBuffer.MatricesIndicesExtraKind
  107077. * - VertexBuffer.MatricesWeightsKind
  107078. * - VertexBuffer.MatricesWeightsExtraKind
  107079. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  107080. */
  107081. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  107082. /**
  107083. * Sets the mesh global Vertex Buffer
  107084. * @param buffer defines the buffer to use
  107085. * @returns the current mesh
  107086. */
  107087. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  107088. /**
  107089. * Update a specific associated vertex buffer
  107090. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  107091. * - VertexBuffer.PositionKind
  107092. * - VertexBuffer.UVKind
  107093. * - VertexBuffer.UV2Kind
  107094. * - VertexBuffer.UV3Kind
  107095. * - VertexBuffer.UV4Kind
  107096. * - VertexBuffer.UV5Kind
  107097. * - VertexBuffer.UV6Kind
  107098. * - VertexBuffer.ColorKind
  107099. * - VertexBuffer.MatricesIndicesKind
  107100. * - VertexBuffer.MatricesIndicesExtraKind
  107101. * - VertexBuffer.MatricesWeightsKind
  107102. * - VertexBuffer.MatricesWeightsExtraKind
  107103. * @param data defines the data source
  107104. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  107105. * @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)
  107106. * @returns the current mesh
  107107. */
  107108. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  107109. /**
  107110. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  107111. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  107112. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  107113. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  107114. * @returns the current mesh
  107115. */
  107116. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  107117. /**
  107118. * Creates a un-shared specific occurence of the geometry for the mesh.
  107119. * @returns the current mesh
  107120. */
  107121. makeGeometryUnique(): Mesh;
  107122. /**
  107123. * Set the index buffer of this mesh
  107124. * @param indices defines the source data
  107125. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  107126. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  107127. * @returns the current mesh
  107128. */
  107129. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  107130. /**
  107131. * Update the current index buffer
  107132. * @param indices defines the source data
  107133. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  107134. * @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)
  107135. * @returns the current mesh
  107136. */
  107137. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  107138. /**
  107139. * Invert the geometry to move from a right handed system to a left handed one.
  107140. * @returns the current mesh
  107141. */
  107142. toLeftHanded(): Mesh;
  107143. /** @hidden */
  107144. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  107145. /** @hidden */
  107146. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  107147. /**
  107148. * Registers for this mesh a javascript function called just before the rendering process
  107149. * @param func defines the function to call before rendering this mesh
  107150. * @returns the current mesh
  107151. */
  107152. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  107153. /**
  107154. * Disposes a previously registered javascript function called before the rendering
  107155. * @param func defines the function to remove
  107156. * @returns the current mesh
  107157. */
  107158. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  107159. /**
  107160. * Registers for this mesh a javascript function called just after the rendering is complete
  107161. * @param func defines the function to call after rendering this mesh
  107162. * @returns the current mesh
  107163. */
  107164. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107165. /**
  107166. * Disposes a previously registered javascript function called after the rendering.
  107167. * @param func defines the function to remove
  107168. * @returns the current mesh
  107169. */
  107170. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107171. /** @hidden */
  107172. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  107173. /** @hidden */
  107174. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  107175. /** @hidden */
  107176. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  107177. /** @hidden */
  107178. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  107179. /** @hidden */
  107180. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  107181. /** @hidden */
  107182. _rebuild(): void;
  107183. /** @hidden */
  107184. _freeze(): void;
  107185. /** @hidden */
  107186. _unFreeze(): void;
  107187. /**
  107188. * 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
  107189. * @param subMesh defines the subMesh to render
  107190. * @param enableAlphaMode defines if alpha mode can be changed
  107191. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  107192. * @returns the current mesh
  107193. */
  107194. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  107195. private _onBeforeDraw;
  107196. /**
  107197. * Renormalize the mesh and patch it up if there are no weights
  107198. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  107199. * However in the case of zero weights then we set just a single influence to 1.
  107200. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  107201. */
  107202. cleanMatrixWeights(): void;
  107203. private normalizeSkinFourWeights;
  107204. private normalizeSkinWeightsAndExtra;
  107205. /**
  107206. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  107207. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  107208. * the user know there was an issue with importing the mesh
  107209. * @returns a validation object with skinned, valid and report string
  107210. */
  107211. validateSkinning(): {
  107212. skinned: boolean;
  107213. valid: boolean;
  107214. report: string;
  107215. };
  107216. /** @hidden */
  107217. _checkDelayState(): Mesh;
  107218. private _queueLoad;
  107219. /**
  107220. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  107221. * A mesh is in the frustum if its bounding box intersects the frustum
  107222. * @param frustumPlanes defines the frustum to test
  107223. * @returns true if the mesh is in the frustum planes
  107224. */
  107225. isInFrustum(frustumPlanes: Plane[]): boolean;
  107226. /**
  107227. * Sets the mesh material by the material or multiMaterial `id` property
  107228. * @param id is a string identifying the material or the multiMaterial
  107229. * @returns the current mesh
  107230. */
  107231. setMaterialByID(id: string): Mesh;
  107232. /**
  107233. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  107234. * @returns an array of IAnimatable
  107235. */
  107236. getAnimatables(): IAnimatable[];
  107237. /**
  107238. * Modifies the mesh geometry according to the passed transformation matrix.
  107239. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  107240. * The mesh normals are modified using the same transformation.
  107241. * Note that, under the hood, this method sets a new VertexBuffer each call.
  107242. * @param transform defines the transform matrix to use
  107243. * @see https://doc.babylonjs.com/resources/baking_transformations
  107244. * @returns the current mesh
  107245. */
  107246. bakeTransformIntoVertices(transform: Matrix): Mesh;
  107247. /**
  107248. * Modifies the mesh geometry according to its own current World Matrix.
  107249. * The mesh World Matrix is then reset.
  107250. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  107251. * Note that, under the hood, this method sets a new VertexBuffer each call.
  107252. * @see https://doc.babylonjs.com/resources/baking_transformations
  107253. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  107254. * @returns the current mesh
  107255. */
  107256. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  107257. /** @hidden */
  107258. get _positions(): Nullable<Vector3[]>;
  107259. /** @hidden */
  107260. _resetPointsArrayCache(): Mesh;
  107261. /** @hidden */
  107262. _generatePointsArray(): boolean;
  107263. /**
  107264. * Returns a new Mesh object generated from the current mesh properties.
  107265. * This method must not get confused with createInstance()
  107266. * @param name is a string, the name given to the new mesh
  107267. * @param newParent can be any Node object (default `null`)
  107268. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  107269. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  107270. * @returns a new mesh
  107271. */
  107272. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  107273. /**
  107274. * Releases resources associated with this mesh.
  107275. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107276. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107277. */
  107278. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107279. /** @hidden */
  107280. _disposeInstanceSpecificData(): void;
  107281. /** @hidden */
  107282. _disposeThinInstanceSpecificData(): void;
  107283. /**
  107284. * Modifies the mesh geometry according to a displacement map.
  107285. * 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.
  107286. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  107287. * @param url is a string, the URL from the image file is to be downloaded.
  107288. * @param minHeight is the lower limit of the displacement.
  107289. * @param maxHeight is the upper limit of the displacement.
  107290. * @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.
  107291. * @param uvOffset is an optional vector2 used to offset UV.
  107292. * @param uvScale is an optional vector2 used to scale UV.
  107293. * @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.
  107294. * @returns the Mesh.
  107295. */
  107296. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  107297. /**
  107298. * Modifies the mesh geometry according to a displacementMap buffer.
  107299. * 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.
  107300. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  107301. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  107302. * @param heightMapWidth is the width of the buffer image.
  107303. * @param heightMapHeight is the height of the buffer image.
  107304. * @param minHeight is the lower limit of the displacement.
  107305. * @param maxHeight is the upper limit of the displacement.
  107306. * @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.
  107307. * @param uvOffset is an optional vector2 used to offset UV.
  107308. * @param uvScale is an optional vector2 used to scale UV.
  107309. * @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.
  107310. * @returns the Mesh.
  107311. */
  107312. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  107313. /**
  107314. * Modify the mesh to get a flat shading rendering.
  107315. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  107316. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  107317. * @returns current mesh
  107318. */
  107319. convertToFlatShadedMesh(): Mesh;
  107320. /**
  107321. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  107322. * In other words, more vertices, no more indices and a single bigger VBO.
  107323. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  107324. * @returns current mesh
  107325. */
  107326. convertToUnIndexedMesh(): Mesh;
  107327. /**
  107328. * Inverses facet orientations.
  107329. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107330. * @param flipNormals will also inverts the normals
  107331. * @returns current mesh
  107332. */
  107333. flipFaces(flipNormals?: boolean): Mesh;
  107334. /**
  107335. * Increase the number of facets and hence vertices in a mesh
  107336. * Vertex normals are interpolated from existing vertex normals
  107337. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107338. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  107339. */
  107340. increaseVertices(numberPerEdge: number): void;
  107341. /**
  107342. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  107343. * This will undo any application of covertToFlatShadedMesh
  107344. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107345. */
  107346. forceSharedVertices(): void;
  107347. /** @hidden */
  107348. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  107349. /** @hidden */
  107350. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  107351. /**
  107352. * Creates a new InstancedMesh object from the mesh model.
  107353. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  107354. * @param name defines the name of the new instance
  107355. * @returns a new InstancedMesh
  107356. */
  107357. createInstance(name: string): InstancedMesh;
  107358. /**
  107359. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  107360. * After this call, all the mesh instances have the same submeshes than the current mesh.
  107361. * @returns the current mesh
  107362. */
  107363. synchronizeInstances(): Mesh;
  107364. /**
  107365. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  107366. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  107367. * This should be used together with the simplification to avoid disappearing triangles.
  107368. * @param successCallback an optional success callback to be called after the optimization finished.
  107369. * @returns the current mesh
  107370. */
  107371. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  107372. /**
  107373. * Serialize current mesh
  107374. * @param serializationObject defines the object which will receive the serialization data
  107375. */
  107376. serialize(serializationObject: any): void;
  107377. /** @hidden */
  107378. _syncGeometryWithMorphTargetManager(): void;
  107379. /** @hidden */
  107380. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  107381. /**
  107382. * Returns a new Mesh object parsed from the source provided.
  107383. * @param parsedMesh is the source
  107384. * @param scene defines the hosting scene
  107385. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  107386. * @returns a new Mesh
  107387. */
  107388. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  107389. /**
  107390. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  107391. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107392. * @param name defines the name of the mesh to create
  107393. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  107394. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  107395. * @param closePath creates a seam between the first and the last points of each path of the path array
  107396. * @param offset is taken in account only if the `pathArray` is containing a single path
  107397. * @param scene defines the hosting scene
  107398. * @param updatable defines if the mesh must be flagged as updatable
  107399. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107400. * @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)
  107401. * @returns a new Mesh
  107402. */
  107403. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107404. /**
  107405. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  107406. * @param name defines the name of the mesh to create
  107407. * @param radius sets the radius size (float) of the polygon (default 0.5)
  107408. * @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
  107409. * @param scene defines the hosting scene
  107410. * @param updatable defines if the mesh must be flagged as updatable
  107411. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107412. * @returns a new Mesh
  107413. */
  107414. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  107415. /**
  107416. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  107417. * @param name defines the name of the mesh to create
  107418. * @param size sets the size (float) of each box side (default 1)
  107419. * @param scene defines the hosting scene
  107420. * @param updatable defines if the mesh must be flagged as updatable
  107421. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107422. * @returns a new Mesh
  107423. */
  107424. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  107425. /**
  107426. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  107427. * @param name defines the name of the mesh to create
  107428. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  107429. * @param diameter sets the diameter size (float) of the sphere (default 1)
  107430. * @param scene defines the hosting scene
  107431. * @param updatable defines if the mesh must be flagged as updatable
  107432. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107433. * @returns a new Mesh
  107434. */
  107435. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107436. /**
  107437. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  107438. * @param name defines the name of the mesh to create
  107439. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  107440. * @param diameter sets the diameter size (float) of the sphere (default 1)
  107441. * @param scene defines the hosting scene
  107442. * @returns a new Mesh
  107443. */
  107444. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  107445. /**
  107446. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  107447. * @param name defines the name of the mesh to create
  107448. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  107449. * @param diameterTop set the top cap diameter (floats, default 1)
  107450. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  107451. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  107452. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  107453. * @param scene defines the hosting scene
  107454. * @param updatable defines if the mesh must be flagged as updatable
  107455. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107456. * @returns a new Mesh
  107457. */
  107458. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  107459. /**
  107460. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  107461. * @param name defines the name of the mesh to create
  107462. * @param diameter sets the diameter size (float) of the torus (default 1)
  107463. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  107464. * @param tessellation sets the number of torus sides (postive integer, default 16)
  107465. * @param scene defines the hosting scene
  107466. * @param updatable defines if the mesh must be flagged as updatable
  107467. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107468. * @returns a new Mesh
  107469. */
  107470. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107471. /**
  107472. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  107473. * @param name defines the name of the mesh to create
  107474. * @param radius sets the global radius size (float) of the torus knot (default 2)
  107475. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  107476. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  107477. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  107478. * @param p the number of windings on X axis (positive integers, default 2)
  107479. * @param q the number of windings on Y axis (positive integers, default 3)
  107480. * @param scene defines the hosting scene
  107481. * @param updatable defines if the mesh must be flagged as updatable
  107482. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107483. * @returns a new Mesh
  107484. */
  107485. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107486. /**
  107487. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  107488. * @param name defines the name of the mesh to create
  107489. * @param points is an array successive Vector3
  107490. * @param scene defines the hosting scene
  107491. * @param updatable defines if the mesh must be flagged as updatable
  107492. * @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).
  107493. * @returns a new Mesh
  107494. */
  107495. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  107496. /**
  107497. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  107498. * @param name defines the name of the mesh to create
  107499. * @param points is an array successive Vector3
  107500. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  107501. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107502. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  107503. * @param scene defines the hosting scene
  107504. * @param updatable defines if the mesh must be flagged as updatable
  107505. * @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)
  107506. * @returns a new Mesh
  107507. */
  107508. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  107509. /**
  107510. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  107511. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  107512. * 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.
  107513. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107514. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107515. * Remember you can only change the shape positions, not their number when updating a polygon.
  107516. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  107517. * @param name defines the name of the mesh to create
  107518. * @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
  107519. * @param scene defines the hosting scene
  107520. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  107521. * @param updatable defines if the mesh must be flagged as updatable
  107522. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107523. * @param earcutInjection can be used to inject your own earcut reference
  107524. * @returns a new Mesh
  107525. */
  107526. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  107527. /**
  107528. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  107529. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  107530. * @param name defines the name of the mesh to create
  107531. * @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
  107532. * @param depth defines the height of extrusion
  107533. * @param scene defines the hosting scene
  107534. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  107535. * @param updatable defines if the mesh must be flagged as updatable
  107536. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107537. * @param earcutInjection can be used to inject your own earcut reference
  107538. * @returns a new Mesh
  107539. */
  107540. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  107541. /**
  107542. * Creates an extruded shape mesh.
  107543. * 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
  107544. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107545. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107546. * @param name defines the name of the mesh to create
  107547. * @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
  107548. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  107549. * @param scale is the value to scale the shape
  107550. * @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
  107551. * @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
  107552. * @param scene defines the hosting scene
  107553. * @param updatable defines if the mesh must be flagged as updatable
  107554. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107555. * @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)
  107556. * @returns a new Mesh
  107557. */
  107558. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107559. /**
  107560. * Creates an custom extruded shape mesh.
  107561. * The custom extrusion is a parametric shape.
  107562. * It has no predefined shape. Its final shape will depend on the input parameters.
  107563. * Please consider using the same method from the MeshBuilder class instead
  107564. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107565. * @param name defines the name of the mesh to create
  107566. * @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
  107567. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  107568. * @param scaleFunction is a custom Javascript function called on each path point
  107569. * @param rotationFunction is a custom Javascript function called on each path point
  107570. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107571. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  107572. * @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
  107573. * @param scene defines the hosting scene
  107574. * @param updatable defines if the mesh must be flagged as updatable
  107575. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107576. * @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)
  107577. * @returns a new Mesh
  107578. */
  107579. 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;
  107580. /**
  107581. * Creates lathe mesh.
  107582. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  107583. * Please consider using the same method from the MeshBuilder class instead
  107584. * @param name defines the name of the mesh to create
  107585. * @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
  107586. * @param radius is the radius value of the lathe
  107587. * @param tessellation is the side number of the lathe.
  107588. * @param scene defines the hosting scene
  107589. * @param updatable defines if the mesh must be flagged as updatable
  107590. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107591. * @returns a new Mesh
  107592. */
  107593. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107594. /**
  107595. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  107596. * @param name defines the name of the mesh to create
  107597. * @param size sets the size (float) of both sides of the plane at once (default 1)
  107598. * @param scene defines the hosting scene
  107599. * @param updatable defines if the mesh must be flagged as updatable
  107600. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107601. * @returns a new Mesh
  107602. */
  107603. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107604. /**
  107605. * Creates a ground mesh.
  107606. * Please consider using the same method from the MeshBuilder class instead
  107607. * @param name defines the name of the mesh to create
  107608. * @param width set the width of the ground
  107609. * @param height set the height of the ground
  107610. * @param subdivisions sets the number of subdivisions per side
  107611. * @param scene defines the hosting scene
  107612. * @param updatable defines if the mesh must be flagged as updatable
  107613. * @returns a new Mesh
  107614. */
  107615. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  107616. /**
  107617. * Creates a tiled ground mesh.
  107618. * Please consider using the same method from the MeshBuilder class instead
  107619. * @param name defines the name of the mesh to create
  107620. * @param xmin set the ground minimum X coordinate
  107621. * @param zmin set the ground minimum Y coordinate
  107622. * @param xmax set the ground maximum X coordinate
  107623. * @param zmax set the ground maximum Z coordinate
  107624. * @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
  107625. * @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
  107626. * @param scene defines the hosting scene
  107627. * @param updatable defines if the mesh must be flagged as updatable
  107628. * @returns a new Mesh
  107629. */
  107630. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  107631. w: number;
  107632. h: number;
  107633. }, precision: {
  107634. w: number;
  107635. h: number;
  107636. }, scene: Scene, updatable?: boolean): Mesh;
  107637. /**
  107638. * Creates a ground mesh from a height map.
  107639. * Please consider using the same method from the MeshBuilder class instead
  107640. * @see https://doc.babylonjs.com/babylon101/height_map
  107641. * @param name defines the name of the mesh to create
  107642. * @param url sets the URL of the height map image resource
  107643. * @param width set the ground width size
  107644. * @param height set the ground height size
  107645. * @param subdivisions sets the number of subdivision per side
  107646. * @param minHeight is the minimum altitude on the ground
  107647. * @param maxHeight is the maximum altitude on the ground
  107648. * @param scene defines the hosting scene
  107649. * @param updatable defines if the mesh must be flagged as updatable
  107650. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  107651. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107652. * @returns a new Mesh
  107653. */
  107654. 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;
  107655. /**
  107656. * Creates a tube mesh.
  107657. * The tube is a parametric shape.
  107658. * It has no predefined shape. Its final shape will depend on the input parameters.
  107659. * Please consider using the same method from the MeshBuilder class instead
  107660. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107661. * @param name defines the name of the mesh to create
  107662. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  107663. * @param radius sets the tube radius size
  107664. * @param tessellation is the number of sides on the tubular surface
  107665. * @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
  107666. * @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
  107667. * @param scene defines the hosting scene
  107668. * @param updatable defines if the mesh must be flagged as updatable
  107669. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107670. * @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)
  107671. * @returns a new Mesh
  107672. */
  107673. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  107674. (i: number, distance: number): number;
  107675. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107676. /**
  107677. * Creates a polyhedron mesh.
  107678. * Please consider using the same method from the MeshBuilder class instead.
  107679. * * 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
  107680. * * The parameter `size` (positive float, default 1) sets the polygon size
  107681. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  107682. * * 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`
  107683. * * 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
  107684. * * 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)`)
  107685. * * 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
  107686. * * 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
  107687. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107688. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107690. * @param name defines the name of the mesh to create
  107691. * @param options defines the options used to create the mesh
  107692. * @param scene defines the hosting scene
  107693. * @returns a new Mesh
  107694. */
  107695. static CreatePolyhedron(name: string, options: {
  107696. type?: number;
  107697. size?: number;
  107698. sizeX?: number;
  107699. sizeY?: number;
  107700. sizeZ?: number;
  107701. custom?: any;
  107702. faceUV?: Vector4[];
  107703. faceColors?: Color4[];
  107704. updatable?: boolean;
  107705. sideOrientation?: number;
  107706. }, scene: Scene): Mesh;
  107707. /**
  107708. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107709. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107710. * * 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`)
  107711. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107712. * * 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
  107713. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107714. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107716. * @param name defines the name of the mesh
  107717. * @param options defines the options used to create the mesh
  107718. * @param scene defines the hosting scene
  107719. * @returns a new Mesh
  107720. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107721. */
  107722. static CreateIcoSphere(name: string, options: {
  107723. radius?: number;
  107724. flat?: boolean;
  107725. subdivisions?: number;
  107726. sideOrientation?: number;
  107727. updatable?: boolean;
  107728. }, scene: Scene): Mesh;
  107729. /**
  107730. * Creates a decal mesh.
  107731. * Please consider using the same method from the MeshBuilder class instead.
  107732. * A decal is a mesh usually applied as a model onto the surface of another mesh
  107733. * @param name defines the name of the mesh
  107734. * @param sourceMesh defines the mesh receiving the decal
  107735. * @param position sets the position of the decal in world coordinates
  107736. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  107737. * @param size sets the decal scaling
  107738. * @param angle sets the angle to rotate the decal
  107739. * @returns a new Mesh
  107740. */
  107741. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  107742. /**
  107743. * Prepare internal position array for software CPU skinning
  107744. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  107745. */
  107746. setPositionsForCPUSkinning(): Float32Array;
  107747. /**
  107748. * Prepare internal normal array for software CPU skinning
  107749. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  107750. */
  107751. setNormalsForCPUSkinning(): Float32Array;
  107752. /**
  107753. * Updates the vertex buffer by applying transformation from the bones
  107754. * @param skeleton defines the skeleton to apply to current mesh
  107755. * @returns the current mesh
  107756. */
  107757. applySkeleton(skeleton: Skeleton): Mesh;
  107758. /**
  107759. * 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
  107760. * @param meshes defines the list of meshes to scan
  107761. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  107762. */
  107763. static MinMax(meshes: AbstractMesh[]): {
  107764. min: Vector3;
  107765. max: Vector3;
  107766. };
  107767. /**
  107768. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  107769. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  107770. * @returns a vector3
  107771. */
  107772. static Center(meshesOrMinMaxVector: {
  107773. min: Vector3;
  107774. max: Vector3;
  107775. } | AbstractMesh[]): Vector3;
  107776. /**
  107777. * Merge the array of meshes into a single mesh for performance reasons.
  107778. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  107779. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  107780. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  107781. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  107782. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  107783. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  107784. * @returns a new mesh
  107785. */
  107786. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  107787. /** @hidden */
  107788. addInstance(instance: InstancedMesh): void;
  107789. /** @hidden */
  107790. removeInstance(instance: InstancedMesh): void;
  107791. }
  107792. }
  107793. declare module BABYLON {
  107794. /**
  107795. * This is the base class of all the camera used in the application.
  107796. * @see https://doc.babylonjs.com/features/cameras
  107797. */
  107798. export class Camera extends Node {
  107799. /** @hidden */
  107800. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  107801. /**
  107802. * This is the default projection mode used by the cameras.
  107803. * It helps recreating a feeling of perspective and better appreciate depth.
  107804. * This is the best way to simulate real life cameras.
  107805. */
  107806. static readonly PERSPECTIVE_CAMERA: number;
  107807. /**
  107808. * This helps creating camera with an orthographic mode.
  107809. * 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.
  107810. */
  107811. static readonly ORTHOGRAPHIC_CAMERA: number;
  107812. /**
  107813. * This is the default FOV mode for perspective cameras.
  107814. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  107815. */
  107816. static readonly FOVMODE_VERTICAL_FIXED: number;
  107817. /**
  107818. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  107819. */
  107820. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  107821. /**
  107822. * This specifies ther is no need for a camera rig.
  107823. * Basically only one eye is rendered corresponding to the camera.
  107824. */
  107825. static readonly RIG_MODE_NONE: number;
  107826. /**
  107827. * Simulates a camera Rig with one blue eye and one red eye.
  107828. * This can be use with 3d blue and red glasses.
  107829. */
  107830. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  107831. /**
  107832. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  107833. */
  107834. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  107835. /**
  107836. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  107837. */
  107838. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  107839. /**
  107840. * Defines that both eyes of the camera will be rendered over under each other.
  107841. */
  107842. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  107843. /**
  107844. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  107845. */
  107846. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  107847. /**
  107848. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  107849. */
  107850. static readonly RIG_MODE_VR: number;
  107851. /**
  107852. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  107853. */
  107854. static readonly RIG_MODE_WEBVR: number;
  107855. /**
  107856. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  107857. */
  107858. static readonly RIG_MODE_CUSTOM: number;
  107859. /**
  107860. * Defines if by default attaching controls should prevent the default javascript event to continue.
  107861. */
  107862. static ForceAttachControlToAlwaysPreventDefault: boolean;
  107863. /**
  107864. * Define the input manager associated with the camera.
  107865. */
  107866. inputs: CameraInputsManager<Camera>;
  107867. /** @hidden */
  107868. _position: Vector3;
  107869. /**
  107870. * Define the current local position of the camera in the scene
  107871. */
  107872. get position(): Vector3;
  107873. set position(newPosition: Vector3);
  107874. /**
  107875. * The vector the camera should consider as up.
  107876. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  107877. */
  107878. upVector: Vector3;
  107879. /**
  107880. * Define the current limit on the left side for an orthographic camera
  107881. * In scene unit
  107882. */
  107883. orthoLeft: Nullable<number>;
  107884. /**
  107885. * Define the current limit on the right side for an orthographic camera
  107886. * In scene unit
  107887. */
  107888. orthoRight: Nullable<number>;
  107889. /**
  107890. * Define the current limit on the bottom side for an orthographic camera
  107891. * In scene unit
  107892. */
  107893. orthoBottom: Nullable<number>;
  107894. /**
  107895. * Define the current limit on the top side for an orthographic camera
  107896. * In scene unit
  107897. */
  107898. orthoTop: Nullable<number>;
  107899. /**
  107900. * Field Of View is set in Radians. (default is 0.8)
  107901. */
  107902. fov: number;
  107903. /**
  107904. * Define the minimum distance the camera can see from.
  107905. * This is important to note that the depth buffer are not infinite and the closer it starts
  107906. * the more your scene might encounter depth fighting issue.
  107907. */
  107908. minZ: number;
  107909. /**
  107910. * Define the maximum distance the camera can see to.
  107911. * This is important to note that the depth buffer are not infinite and the further it end
  107912. * the more your scene might encounter depth fighting issue.
  107913. */
  107914. maxZ: number;
  107915. /**
  107916. * Define the default inertia of the camera.
  107917. * This helps giving a smooth feeling to the camera movement.
  107918. */
  107919. inertia: number;
  107920. /**
  107921. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  107922. */
  107923. mode: number;
  107924. /**
  107925. * Define whether the camera is intermediate.
  107926. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  107927. */
  107928. isIntermediate: boolean;
  107929. /**
  107930. * Define the viewport of the camera.
  107931. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  107932. */
  107933. viewport: Viewport;
  107934. /**
  107935. * Restricts the camera to viewing objects with the same layerMask.
  107936. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  107937. */
  107938. layerMask: number;
  107939. /**
  107940. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  107941. */
  107942. fovMode: number;
  107943. /**
  107944. * Rig mode of the camera.
  107945. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  107946. * This is normally controlled byt the camera themselves as internal use.
  107947. */
  107948. cameraRigMode: number;
  107949. /**
  107950. * Defines the distance between both "eyes" in case of a RIG
  107951. */
  107952. interaxialDistance: number;
  107953. /**
  107954. * Defines if stereoscopic rendering is done side by side or over under.
  107955. */
  107956. isStereoscopicSideBySide: boolean;
  107957. /**
  107958. * 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
  107959. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  107960. * else in the scene. (Eg. security camera)
  107961. *
  107962. * 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)
  107963. */
  107964. customRenderTargets: RenderTargetTexture[];
  107965. /**
  107966. * When set, the camera will render to this render target instead of the default canvas
  107967. *
  107968. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  107969. */
  107970. outputRenderTarget: Nullable<RenderTargetTexture>;
  107971. /**
  107972. * Observable triggered when the camera view matrix has changed.
  107973. */
  107974. onViewMatrixChangedObservable: Observable<Camera>;
  107975. /**
  107976. * Observable triggered when the camera Projection matrix has changed.
  107977. */
  107978. onProjectionMatrixChangedObservable: Observable<Camera>;
  107979. /**
  107980. * Observable triggered when the inputs have been processed.
  107981. */
  107982. onAfterCheckInputsObservable: Observable<Camera>;
  107983. /**
  107984. * Observable triggered when reset has been called and applied to the camera.
  107985. */
  107986. onRestoreStateObservable: Observable<Camera>;
  107987. /**
  107988. * Is this camera a part of a rig system?
  107989. */
  107990. isRigCamera: boolean;
  107991. /**
  107992. * If isRigCamera set to true this will be set with the parent camera.
  107993. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  107994. */
  107995. rigParent?: Camera;
  107996. /** @hidden */
  107997. _cameraRigParams: any;
  107998. /** @hidden */
  107999. _rigCameras: Camera[];
  108000. /** @hidden */
  108001. _rigPostProcess: Nullable<PostProcess>;
  108002. protected _webvrViewMatrix: Matrix;
  108003. /** @hidden */
  108004. _skipRendering: boolean;
  108005. /** @hidden */
  108006. _projectionMatrix: Matrix;
  108007. /** @hidden */
  108008. _postProcesses: Nullable<PostProcess>[];
  108009. /** @hidden */
  108010. _activeMeshes: SmartArray<AbstractMesh>;
  108011. protected _globalPosition: Vector3;
  108012. /** @hidden */
  108013. _computedViewMatrix: Matrix;
  108014. private _doNotComputeProjectionMatrix;
  108015. private _transformMatrix;
  108016. private _frustumPlanes;
  108017. private _refreshFrustumPlanes;
  108018. private _storedFov;
  108019. private _stateStored;
  108020. /**
  108021. * Instantiates a new camera object.
  108022. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  108023. * @see https://doc.babylonjs.com/features/cameras
  108024. * @param name Defines the name of the camera in the scene
  108025. * @param position Defines the position of the camera
  108026. * @param scene Defines the scene the camera belongs too
  108027. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  108028. */
  108029. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  108030. /**
  108031. * Store current camera state (fov, position, etc..)
  108032. * @returns the camera
  108033. */
  108034. storeState(): Camera;
  108035. /**
  108036. * Restores the camera state values if it has been stored. You must call storeState() first
  108037. */
  108038. protected _restoreStateValues(): boolean;
  108039. /**
  108040. * Restored camera state. You must call storeState() first.
  108041. * @returns true if restored and false otherwise
  108042. */
  108043. restoreState(): boolean;
  108044. /**
  108045. * Gets the class name of the camera.
  108046. * @returns the class name
  108047. */
  108048. getClassName(): string;
  108049. /** @hidden */
  108050. readonly _isCamera: boolean;
  108051. /**
  108052. * Gets a string representation of the camera useful for debug purpose.
  108053. * @param fullDetails Defines that a more verboe level of logging is required
  108054. * @returns the string representation
  108055. */
  108056. toString(fullDetails?: boolean): string;
  108057. /**
  108058. * Gets the current world space position of the camera.
  108059. */
  108060. get globalPosition(): Vector3;
  108061. /**
  108062. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  108063. * @returns the active meshe list
  108064. */
  108065. getActiveMeshes(): SmartArray<AbstractMesh>;
  108066. /**
  108067. * Check whether a mesh is part of the current active mesh list of the camera
  108068. * @param mesh Defines the mesh to check
  108069. * @returns true if active, false otherwise
  108070. */
  108071. isActiveMesh(mesh: Mesh): boolean;
  108072. /**
  108073. * Is this camera ready to be used/rendered
  108074. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  108075. * @return true if the camera is ready
  108076. */
  108077. isReady(completeCheck?: boolean): boolean;
  108078. /** @hidden */
  108079. _initCache(): void;
  108080. /** @hidden */
  108081. _updateCache(ignoreParentClass?: boolean): void;
  108082. /** @hidden */
  108083. _isSynchronized(): boolean;
  108084. /** @hidden */
  108085. _isSynchronizedViewMatrix(): boolean;
  108086. /** @hidden */
  108087. _isSynchronizedProjectionMatrix(): boolean;
  108088. /**
  108089. * Attach the input controls to a specific dom element to get the input from.
  108090. * @param element Defines the element the controls should be listened from
  108091. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108092. */
  108093. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108094. /**
  108095. * Detach the current controls from the specified dom element.
  108096. * @param element Defines the element to stop listening the inputs from
  108097. */
  108098. detachControl(element: HTMLElement): void;
  108099. /**
  108100. * Update the camera state according to the different inputs gathered during the frame.
  108101. */
  108102. update(): void;
  108103. /** @hidden */
  108104. _checkInputs(): void;
  108105. /** @hidden */
  108106. get rigCameras(): Camera[];
  108107. /**
  108108. * Gets the post process used by the rig cameras
  108109. */
  108110. get rigPostProcess(): Nullable<PostProcess>;
  108111. /**
  108112. * Internal, gets the first post proces.
  108113. * @returns the first post process to be run on this camera.
  108114. */
  108115. _getFirstPostProcess(): Nullable<PostProcess>;
  108116. private _cascadePostProcessesToRigCams;
  108117. /**
  108118. * Attach a post process to the camera.
  108119. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  108120. * @param postProcess The post process to attach to the camera
  108121. * @param insertAt The position of the post process in case several of them are in use in the scene
  108122. * @returns the position the post process has been inserted at
  108123. */
  108124. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  108125. /**
  108126. * Detach a post process to the camera.
  108127. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  108128. * @param postProcess The post process to detach from the camera
  108129. */
  108130. detachPostProcess(postProcess: PostProcess): void;
  108131. /**
  108132. * Gets the current world matrix of the camera
  108133. */
  108134. getWorldMatrix(): Matrix;
  108135. /** @hidden */
  108136. _getViewMatrix(): Matrix;
  108137. /**
  108138. * Gets the current view matrix of the camera.
  108139. * @param force forces the camera to recompute the matrix without looking at the cached state
  108140. * @returns the view matrix
  108141. */
  108142. getViewMatrix(force?: boolean): Matrix;
  108143. /**
  108144. * Freeze the projection matrix.
  108145. * It will prevent the cache check of the camera projection compute and can speed up perf
  108146. * if no parameter of the camera are meant to change
  108147. * @param projection Defines manually a projection if necessary
  108148. */
  108149. freezeProjectionMatrix(projection?: Matrix): void;
  108150. /**
  108151. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  108152. */
  108153. unfreezeProjectionMatrix(): void;
  108154. /**
  108155. * Gets the current projection matrix of the camera.
  108156. * @param force forces the camera to recompute the matrix without looking at the cached state
  108157. * @returns the projection matrix
  108158. */
  108159. getProjectionMatrix(force?: boolean): Matrix;
  108160. /**
  108161. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  108162. * @returns a Matrix
  108163. */
  108164. getTransformationMatrix(): Matrix;
  108165. private _updateFrustumPlanes;
  108166. /**
  108167. * Checks if a cullable object (mesh...) is in the camera frustum
  108168. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  108169. * @param target The object to check
  108170. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  108171. * @returns true if the object is in frustum otherwise false
  108172. */
  108173. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  108174. /**
  108175. * Checks if a cullable object (mesh...) is in the camera frustum
  108176. * Unlike isInFrustum this cheks the full bounding box
  108177. * @param target The object to check
  108178. * @returns true if the object is in frustum otherwise false
  108179. */
  108180. isCompletelyInFrustum(target: ICullable): boolean;
  108181. /**
  108182. * Gets a ray in the forward direction from the camera.
  108183. * @param length Defines the length of the ray to create
  108184. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  108185. * @param origin Defines the start point of the ray which defaults to the camera position
  108186. * @returns the forward ray
  108187. */
  108188. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  108189. /**
  108190. * Gets a ray in the forward direction from the camera.
  108191. * @param refRay the ray to (re)use when setting the values
  108192. * @param length Defines the length of the ray to create
  108193. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  108194. * @param origin Defines the start point of the ray which defaults to the camera position
  108195. * @returns the forward ray
  108196. */
  108197. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  108198. /**
  108199. * Releases resources associated with this node.
  108200. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108201. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108202. */
  108203. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108204. /** @hidden */
  108205. _isLeftCamera: boolean;
  108206. /**
  108207. * Gets the left camera of a rig setup in case of Rigged Camera
  108208. */
  108209. get isLeftCamera(): boolean;
  108210. /** @hidden */
  108211. _isRightCamera: boolean;
  108212. /**
  108213. * Gets the right camera of a rig setup in case of Rigged Camera
  108214. */
  108215. get isRightCamera(): boolean;
  108216. /**
  108217. * Gets the left camera of a rig setup in case of Rigged Camera
  108218. */
  108219. get leftCamera(): Nullable<FreeCamera>;
  108220. /**
  108221. * Gets the right camera of a rig setup in case of Rigged Camera
  108222. */
  108223. get rightCamera(): Nullable<FreeCamera>;
  108224. /**
  108225. * Gets the left camera target of a rig setup in case of Rigged Camera
  108226. * @returns the target position
  108227. */
  108228. getLeftTarget(): Nullable<Vector3>;
  108229. /**
  108230. * Gets the right camera target of a rig setup in case of Rigged Camera
  108231. * @returns the target position
  108232. */
  108233. getRightTarget(): Nullable<Vector3>;
  108234. /**
  108235. * @hidden
  108236. */
  108237. setCameraRigMode(mode: number, rigParams: any): void;
  108238. /** @hidden */
  108239. static _setStereoscopicRigMode(camera: Camera): void;
  108240. /** @hidden */
  108241. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  108242. /** @hidden */
  108243. static _setVRRigMode(camera: Camera, rigParams: any): void;
  108244. /** @hidden */
  108245. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  108246. /** @hidden */
  108247. _getVRProjectionMatrix(): Matrix;
  108248. protected _updateCameraRotationMatrix(): void;
  108249. protected _updateWebVRCameraRotationMatrix(): void;
  108250. /**
  108251. * This function MUST be overwritten by the different WebVR cameras available.
  108252. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  108253. * @hidden
  108254. */
  108255. _getWebVRProjectionMatrix(): Matrix;
  108256. /**
  108257. * This function MUST be overwritten by the different WebVR cameras available.
  108258. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  108259. * @hidden
  108260. */
  108261. _getWebVRViewMatrix(): Matrix;
  108262. /** @hidden */
  108263. setCameraRigParameter(name: string, value: any): void;
  108264. /**
  108265. * needs to be overridden by children so sub has required properties to be copied
  108266. * @hidden
  108267. */
  108268. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  108269. /**
  108270. * May need to be overridden by children
  108271. * @hidden
  108272. */
  108273. _updateRigCameras(): void;
  108274. /** @hidden */
  108275. _setupInputs(): void;
  108276. /**
  108277. * Serialiaze the camera setup to a json represention
  108278. * @returns the JSON representation
  108279. */
  108280. serialize(): any;
  108281. /**
  108282. * Clones the current camera.
  108283. * @param name The cloned camera name
  108284. * @returns the cloned camera
  108285. */
  108286. clone(name: string): Camera;
  108287. /**
  108288. * Gets the direction of the camera relative to a given local axis.
  108289. * @param localAxis Defines the reference axis to provide a relative direction.
  108290. * @return the direction
  108291. */
  108292. getDirection(localAxis: Vector3): Vector3;
  108293. /**
  108294. * Returns the current camera absolute rotation
  108295. */
  108296. get absoluteRotation(): Quaternion;
  108297. /**
  108298. * Gets the direction of the camera relative to a given local axis into a passed vector.
  108299. * @param localAxis Defines the reference axis to provide a relative direction.
  108300. * @param result Defines the vector to store the result in
  108301. */
  108302. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  108303. /**
  108304. * Gets a camera constructor for a given camera type
  108305. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  108306. * @param name The name of the camera the result will be able to instantiate
  108307. * @param scene The scene the result will construct the camera in
  108308. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  108309. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  108310. * @returns a factory method to construc the camera
  108311. */
  108312. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  108313. /**
  108314. * Compute the world matrix of the camera.
  108315. * @returns the camera world matrix
  108316. */
  108317. computeWorldMatrix(): Matrix;
  108318. /**
  108319. * Parse a JSON and creates the camera from the parsed information
  108320. * @param parsedCamera The JSON to parse
  108321. * @param scene The scene to instantiate the camera in
  108322. * @returns the newly constructed camera
  108323. */
  108324. static Parse(parsedCamera: any, scene: Scene): Camera;
  108325. }
  108326. }
  108327. declare module BABYLON {
  108328. /**
  108329. * Class containing static functions to help procedurally build meshes
  108330. */
  108331. export class DiscBuilder {
  108332. /**
  108333. * Creates a plane polygonal mesh. By default, this is a disc
  108334. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  108335. * * 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
  108336. * * 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
  108337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108340. * @param name defines the name of the mesh
  108341. * @param options defines the options used to create the mesh
  108342. * @param scene defines the hosting scene
  108343. * @returns the plane polygonal mesh
  108344. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  108345. */
  108346. static CreateDisc(name: string, options: {
  108347. radius?: number;
  108348. tessellation?: number;
  108349. arc?: number;
  108350. updatable?: boolean;
  108351. sideOrientation?: number;
  108352. frontUVs?: Vector4;
  108353. backUVs?: Vector4;
  108354. }, scene?: Nullable<Scene>): Mesh;
  108355. }
  108356. }
  108357. declare module BABYLON {
  108358. /**
  108359. * Options to be used when creating a FresnelParameters.
  108360. */
  108361. export type IFresnelParametersCreationOptions = {
  108362. /**
  108363. * Define the color used on edges (grazing angle)
  108364. */
  108365. leftColor?: Color3;
  108366. /**
  108367. * Define the color used on center
  108368. */
  108369. rightColor?: Color3;
  108370. /**
  108371. * Define bias applied to computed fresnel term
  108372. */
  108373. bias?: number;
  108374. /**
  108375. * Defined the power exponent applied to fresnel term
  108376. */
  108377. power?: number;
  108378. /**
  108379. * Define if the fresnel effect is enable or not.
  108380. */
  108381. isEnabled?: boolean;
  108382. };
  108383. /**
  108384. * Serialized format for FresnelParameters.
  108385. */
  108386. export type IFresnelParametersSerialized = {
  108387. /**
  108388. * Define the color used on edges (grazing angle) [as an array]
  108389. */
  108390. leftColor: number[];
  108391. /**
  108392. * Define the color used on center [as an array]
  108393. */
  108394. rightColor: number[];
  108395. /**
  108396. * Define bias applied to computed fresnel term
  108397. */
  108398. bias: number;
  108399. /**
  108400. * Defined the power exponent applied to fresnel term
  108401. */
  108402. power?: number;
  108403. /**
  108404. * Define if the fresnel effect is enable or not.
  108405. */
  108406. isEnabled: boolean;
  108407. };
  108408. /**
  108409. * This represents all the required information to add a fresnel effect on a material:
  108410. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108411. */
  108412. export class FresnelParameters {
  108413. private _isEnabled;
  108414. /**
  108415. * Define if the fresnel effect is enable or not.
  108416. */
  108417. get isEnabled(): boolean;
  108418. set isEnabled(value: boolean);
  108419. /**
  108420. * Define the color used on edges (grazing angle)
  108421. */
  108422. leftColor: Color3;
  108423. /**
  108424. * Define the color used on center
  108425. */
  108426. rightColor: Color3;
  108427. /**
  108428. * Define bias applied to computed fresnel term
  108429. */
  108430. bias: number;
  108431. /**
  108432. * Defined the power exponent applied to fresnel term
  108433. */
  108434. power: number;
  108435. /**
  108436. * Creates a new FresnelParameters object.
  108437. *
  108438. * @param options provide your own settings to optionally to override defaults
  108439. */
  108440. constructor(options?: IFresnelParametersCreationOptions);
  108441. /**
  108442. * Clones the current fresnel and its valuues
  108443. * @returns a clone fresnel configuration
  108444. */
  108445. clone(): FresnelParameters;
  108446. /**
  108447. * Determines equality between FresnelParameters objects
  108448. * @param otherFresnelParameters defines the second operand
  108449. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  108450. */
  108451. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  108452. /**
  108453. * Serializes the current fresnel parameters to a JSON representation.
  108454. * @return the JSON serialization
  108455. */
  108456. serialize(): IFresnelParametersSerialized;
  108457. /**
  108458. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  108459. * @param parsedFresnelParameters Define the JSON representation
  108460. * @returns the parsed parameters
  108461. */
  108462. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  108463. }
  108464. }
  108465. declare module BABYLON {
  108466. /**
  108467. * This groups all the flags used to control the materials channel.
  108468. */
  108469. export class MaterialFlags {
  108470. private static _DiffuseTextureEnabled;
  108471. /**
  108472. * Are diffuse textures enabled in the application.
  108473. */
  108474. static get DiffuseTextureEnabled(): boolean;
  108475. static set DiffuseTextureEnabled(value: boolean);
  108476. private static _DetailTextureEnabled;
  108477. /**
  108478. * Are detail textures enabled in the application.
  108479. */
  108480. static get DetailTextureEnabled(): boolean;
  108481. static set DetailTextureEnabled(value: boolean);
  108482. private static _AmbientTextureEnabled;
  108483. /**
  108484. * Are ambient textures enabled in the application.
  108485. */
  108486. static get AmbientTextureEnabled(): boolean;
  108487. static set AmbientTextureEnabled(value: boolean);
  108488. private static _OpacityTextureEnabled;
  108489. /**
  108490. * Are opacity textures enabled in the application.
  108491. */
  108492. static get OpacityTextureEnabled(): boolean;
  108493. static set OpacityTextureEnabled(value: boolean);
  108494. private static _ReflectionTextureEnabled;
  108495. /**
  108496. * Are reflection textures enabled in the application.
  108497. */
  108498. static get ReflectionTextureEnabled(): boolean;
  108499. static set ReflectionTextureEnabled(value: boolean);
  108500. private static _EmissiveTextureEnabled;
  108501. /**
  108502. * Are emissive textures enabled in the application.
  108503. */
  108504. static get EmissiveTextureEnabled(): boolean;
  108505. static set EmissiveTextureEnabled(value: boolean);
  108506. private static _SpecularTextureEnabled;
  108507. /**
  108508. * Are specular textures enabled in the application.
  108509. */
  108510. static get SpecularTextureEnabled(): boolean;
  108511. static set SpecularTextureEnabled(value: boolean);
  108512. private static _BumpTextureEnabled;
  108513. /**
  108514. * Are bump textures enabled in the application.
  108515. */
  108516. static get BumpTextureEnabled(): boolean;
  108517. static set BumpTextureEnabled(value: boolean);
  108518. private static _LightmapTextureEnabled;
  108519. /**
  108520. * Are lightmap textures enabled in the application.
  108521. */
  108522. static get LightmapTextureEnabled(): boolean;
  108523. static set LightmapTextureEnabled(value: boolean);
  108524. private static _RefractionTextureEnabled;
  108525. /**
  108526. * Are refraction textures enabled in the application.
  108527. */
  108528. static get RefractionTextureEnabled(): boolean;
  108529. static set RefractionTextureEnabled(value: boolean);
  108530. private static _ColorGradingTextureEnabled;
  108531. /**
  108532. * Are color grading textures enabled in the application.
  108533. */
  108534. static get ColorGradingTextureEnabled(): boolean;
  108535. static set ColorGradingTextureEnabled(value: boolean);
  108536. private static _FresnelEnabled;
  108537. /**
  108538. * Are fresnels enabled in the application.
  108539. */
  108540. static get FresnelEnabled(): boolean;
  108541. static set FresnelEnabled(value: boolean);
  108542. private static _ClearCoatTextureEnabled;
  108543. /**
  108544. * Are clear coat textures enabled in the application.
  108545. */
  108546. static get ClearCoatTextureEnabled(): boolean;
  108547. static set ClearCoatTextureEnabled(value: boolean);
  108548. private static _ClearCoatBumpTextureEnabled;
  108549. /**
  108550. * Are clear coat bump textures enabled in the application.
  108551. */
  108552. static get ClearCoatBumpTextureEnabled(): boolean;
  108553. static set ClearCoatBumpTextureEnabled(value: boolean);
  108554. private static _ClearCoatTintTextureEnabled;
  108555. /**
  108556. * Are clear coat tint textures enabled in the application.
  108557. */
  108558. static get ClearCoatTintTextureEnabled(): boolean;
  108559. static set ClearCoatTintTextureEnabled(value: boolean);
  108560. private static _SheenTextureEnabled;
  108561. /**
  108562. * Are sheen textures enabled in the application.
  108563. */
  108564. static get SheenTextureEnabled(): boolean;
  108565. static set SheenTextureEnabled(value: boolean);
  108566. private static _AnisotropicTextureEnabled;
  108567. /**
  108568. * Are anisotropic textures enabled in the application.
  108569. */
  108570. static get AnisotropicTextureEnabled(): boolean;
  108571. static set AnisotropicTextureEnabled(value: boolean);
  108572. private static _ThicknessTextureEnabled;
  108573. /**
  108574. * Are thickness textures enabled in the application.
  108575. */
  108576. static get ThicknessTextureEnabled(): boolean;
  108577. static set ThicknessTextureEnabled(value: boolean);
  108578. }
  108579. }
  108580. declare module BABYLON {
  108581. /** @hidden */
  108582. export var defaultFragmentDeclaration: {
  108583. name: string;
  108584. shader: string;
  108585. };
  108586. }
  108587. declare module BABYLON {
  108588. /** @hidden */
  108589. export var defaultUboDeclaration: {
  108590. name: string;
  108591. shader: string;
  108592. };
  108593. }
  108594. declare module BABYLON {
  108595. /** @hidden */
  108596. export var prePassDeclaration: {
  108597. name: string;
  108598. shader: string;
  108599. };
  108600. }
  108601. declare module BABYLON {
  108602. /** @hidden */
  108603. export var lightFragmentDeclaration: {
  108604. name: string;
  108605. shader: string;
  108606. };
  108607. }
  108608. declare module BABYLON {
  108609. /** @hidden */
  108610. export var lightUboDeclaration: {
  108611. name: string;
  108612. shader: string;
  108613. };
  108614. }
  108615. declare module BABYLON {
  108616. /** @hidden */
  108617. export var lightsFragmentFunctions: {
  108618. name: string;
  108619. shader: string;
  108620. };
  108621. }
  108622. declare module BABYLON {
  108623. /** @hidden */
  108624. export var shadowsFragmentFunctions: {
  108625. name: string;
  108626. shader: string;
  108627. };
  108628. }
  108629. declare module BABYLON {
  108630. /** @hidden */
  108631. export var fresnelFunction: {
  108632. name: string;
  108633. shader: string;
  108634. };
  108635. }
  108636. declare module BABYLON {
  108637. /** @hidden */
  108638. export var bumpFragmentMainFunctions: {
  108639. name: string;
  108640. shader: string;
  108641. };
  108642. }
  108643. declare module BABYLON {
  108644. /** @hidden */
  108645. export var bumpFragmentFunctions: {
  108646. name: string;
  108647. shader: string;
  108648. };
  108649. }
  108650. declare module BABYLON {
  108651. /** @hidden */
  108652. export var logDepthDeclaration: {
  108653. name: string;
  108654. shader: string;
  108655. };
  108656. }
  108657. declare module BABYLON {
  108658. /** @hidden */
  108659. export var bumpFragment: {
  108660. name: string;
  108661. shader: string;
  108662. };
  108663. }
  108664. declare module BABYLON {
  108665. /** @hidden */
  108666. export var depthPrePass: {
  108667. name: string;
  108668. shader: string;
  108669. };
  108670. }
  108671. declare module BABYLON {
  108672. /** @hidden */
  108673. export var lightFragment: {
  108674. name: string;
  108675. shader: string;
  108676. };
  108677. }
  108678. declare module BABYLON {
  108679. /** @hidden */
  108680. export var logDepthFragment: {
  108681. name: string;
  108682. shader: string;
  108683. };
  108684. }
  108685. declare module BABYLON {
  108686. /** @hidden */
  108687. export var defaultPixelShader: {
  108688. name: string;
  108689. shader: string;
  108690. };
  108691. }
  108692. declare module BABYLON {
  108693. /** @hidden */
  108694. export var defaultVertexDeclaration: {
  108695. name: string;
  108696. shader: string;
  108697. };
  108698. }
  108699. declare module BABYLON {
  108700. /** @hidden */
  108701. export var bumpVertexDeclaration: {
  108702. name: string;
  108703. shader: string;
  108704. };
  108705. }
  108706. declare module BABYLON {
  108707. /** @hidden */
  108708. export var bumpVertex: {
  108709. name: string;
  108710. shader: string;
  108711. };
  108712. }
  108713. declare module BABYLON {
  108714. /** @hidden */
  108715. export var fogVertex: {
  108716. name: string;
  108717. shader: string;
  108718. };
  108719. }
  108720. declare module BABYLON {
  108721. /** @hidden */
  108722. export var shadowsVertex: {
  108723. name: string;
  108724. shader: string;
  108725. };
  108726. }
  108727. declare module BABYLON {
  108728. /** @hidden */
  108729. export var pointCloudVertex: {
  108730. name: string;
  108731. shader: string;
  108732. };
  108733. }
  108734. declare module BABYLON {
  108735. /** @hidden */
  108736. export var logDepthVertex: {
  108737. name: string;
  108738. shader: string;
  108739. };
  108740. }
  108741. declare module BABYLON {
  108742. /** @hidden */
  108743. export var defaultVertexShader: {
  108744. name: string;
  108745. shader: string;
  108746. };
  108747. }
  108748. declare module BABYLON {
  108749. /**
  108750. * @hidden
  108751. */
  108752. export interface IMaterialDetailMapDefines {
  108753. DETAIL: boolean;
  108754. DETAILDIRECTUV: number;
  108755. DETAIL_NORMALBLENDMETHOD: number;
  108756. /** @hidden */
  108757. _areTexturesDirty: boolean;
  108758. }
  108759. /**
  108760. * Define the code related to the detail map parameters of a material
  108761. *
  108762. * Inspired from:
  108763. * 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
  108764. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  108765. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  108766. */
  108767. export class DetailMapConfiguration {
  108768. private _texture;
  108769. /**
  108770. * The detail texture of the material.
  108771. */
  108772. texture: Nullable<BaseTexture>;
  108773. /**
  108774. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  108775. * Bigger values mean stronger blending
  108776. */
  108777. diffuseBlendLevel: number;
  108778. /**
  108779. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  108780. * Bigger values mean stronger blending. Only used with PBR materials
  108781. */
  108782. roughnessBlendLevel: number;
  108783. /**
  108784. * Defines how strong the bump effect from the detail map is
  108785. * Bigger values mean stronger effect
  108786. */
  108787. bumpLevel: number;
  108788. private _normalBlendMethod;
  108789. /**
  108790. * The method used to blend the bump and detail normals together
  108791. */
  108792. normalBlendMethod: number;
  108793. private _isEnabled;
  108794. /**
  108795. * Enable or disable the detail map on this material
  108796. */
  108797. isEnabled: boolean;
  108798. /** @hidden */
  108799. private _internalMarkAllSubMeshesAsTexturesDirty;
  108800. /** @hidden */
  108801. _markAllSubMeshesAsTexturesDirty(): void;
  108802. /**
  108803. * Instantiate a new detail map
  108804. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108805. */
  108806. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108807. /**
  108808. * Gets whether the submesh is ready to be used or not.
  108809. * @param defines the list of "defines" to update.
  108810. * @param scene defines the scene the material belongs to.
  108811. * @returns - boolean indicating that the submesh is ready or not.
  108812. */
  108813. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  108814. /**
  108815. * Update the defines for detail map usage
  108816. * @param defines the list of "defines" to update.
  108817. * @param scene defines the scene the material belongs to.
  108818. */
  108819. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  108820. /**
  108821. * Binds the material data.
  108822. * @param uniformBuffer defines the Uniform buffer to fill in.
  108823. * @param scene defines the scene the material belongs to.
  108824. * @param isFrozen defines whether the material is frozen or not.
  108825. */
  108826. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  108827. /**
  108828. * Checks to see if a texture is used in the material.
  108829. * @param texture - Base texture to use.
  108830. * @returns - Boolean specifying if a texture is used in the material.
  108831. */
  108832. hasTexture(texture: BaseTexture): boolean;
  108833. /**
  108834. * Returns an array of the actively used textures.
  108835. * @param activeTextures Array of BaseTextures
  108836. */
  108837. getActiveTextures(activeTextures: BaseTexture[]): void;
  108838. /**
  108839. * Returns the animatable textures.
  108840. * @param animatables Array of animatable textures.
  108841. */
  108842. getAnimatables(animatables: IAnimatable[]): void;
  108843. /**
  108844. * Disposes the resources of the material.
  108845. * @param forceDisposeTextures - Forces the disposal of all textures.
  108846. */
  108847. dispose(forceDisposeTextures?: boolean): void;
  108848. /**
  108849. * Get the current class name useful for serialization or dynamic coding.
  108850. * @returns "DetailMap"
  108851. */
  108852. getClassName(): string;
  108853. /**
  108854. * Add the required uniforms to the current list.
  108855. * @param uniforms defines the current uniform list.
  108856. */
  108857. static AddUniforms(uniforms: string[]): void;
  108858. /**
  108859. * Add the required samplers to the current list.
  108860. * @param samplers defines the current sampler list.
  108861. */
  108862. static AddSamplers(samplers: string[]): void;
  108863. /**
  108864. * Add the required uniforms to the current buffer.
  108865. * @param uniformBuffer defines the current uniform buffer.
  108866. */
  108867. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108868. /**
  108869. * Makes a duplicate of the current instance into another one.
  108870. * @param detailMap define the instance where to copy the info
  108871. */
  108872. copyTo(detailMap: DetailMapConfiguration): void;
  108873. /**
  108874. * Serializes this detail map instance
  108875. * @returns - An object with the serialized instance.
  108876. */
  108877. serialize(): any;
  108878. /**
  108879. * Parses a detail map setting from a serialized object.
  108880. * @param source - Serialized object.
  108881. * @param scene Defines the scene we are parsing for
  108882. * @param rootUrl Defines the rootUrl to load from
  108883. */
  108884. parse(source: any, scene: Scene, rootUrl: string): void;
  108885. }
  108886. }
  108887. declare module BABYLON {
  108888. /** @hidden */
  108889. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  108890. MAINUV1: boolean;
  108891. MAINUV2: boolean;
  108892. DIFFUSE: boolean;
  108893. DIFFUSEDIRECTUV: number;
  108894. DETAIL: boolean;
  108895. DETAILDIRECTUV: number;
  108896. DETAIL_NORMALBLENDMETHOD: number;
  108897. AMBIENT: boolean;
  108898. AMBIENTDIRECTUV: number;
  108899. OPACITY: boolean;
  108900. OPACITYDIRECTUV: number;
  108901. OPACITYRGB: boolean;
  108902. REFLECTION: boolean;
  108903. EMISSIVE: boolean;
  108904. EMISSIVEDIRECTUV: number;
  108905. SPECULAR: boolean;
  108906. SPECULARDIRECTUV: number;
  108907. BUMP: boolean;
  108908. BUMPDIRECTUV: number;
  108909. PARALLAX: boolean;
  108910. PARALLAXOCCLUSION: boolean;
  108911. SPECULAROVERALPHA: boolean;
  108912. CLIPPLANE: boolean;
  108913. CLIPPLANE2: boolean;
  108914. CLIPPLANE3: boolean;
  108915. CLIPPLANE4: boolean;
  108916. CLIPPLANE5: boolean;
  108917. CLIPPLANE6: boolean;
  108918. ALPHATEST: boolean;
  108919. DEPTHPREPASS: boolean;
  108920. ALPHAFROMDIFFUSE: boolean;
  108921. POINTSIZE: boolean;
  108922. FOG: boolean;
  108923. SPECULARTERM: boolean;
  108924. DIFFUSEFRESNEL: boolean;
  108925. OPACITYFRESNEL: boolean;
  108926. REFLECTIONFRESNEL: boolean;
  108927. REFRACTIONFRESNEL: boolean;
  108928. EMISSIVEFRESNEL: boolean;
  108929. FRESNEL: boolean;
  108930. NORMAL: boolean;
  108931. UV1: boolean;
  108932. UV2: boolean;
  108933. VERTEXCOLOR: boolean;
  108934. VERTEXALPHA: boolean;
  108935. NUM_BONE_INFLUENCERS: number;
  108936. BonesPerMesh: number;
  108937. BONETEXTURE: boolean;
  108938. INSTANCES: boolean;
  108939. THIN_INSTANCES: boolean;
  108940. GLOSSINESS: boolean;
  108941. ROUGHNESS: boolean;
  108942. EMISSIVEASILLUMINATION: boolean;
  108943. LINKEMISSIVEWITHDIFFUSE: boolean;
  108944. REFLECTIONFRESNELFROMSPECULAR: boolean;
  108945. LIGHTMAP: boolean;
  108946. LIGHTMAPDIRECTUV: number;
  108947. OBJECTSPACE_NORMALMAP: boolean;
  108948. USELIGHTMAPASSHADOWMAP: boolean;
  108949. REFLECTIONMAP_3D: boolean;
  108950. REFLECTIONMAP_SPHERICAL: boolean;
  108951. REFLECTIONMAP_PLANAR: boolean;
  108952. REFLECTIONMAP_CUBIC: boolean;
  108953. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108954. REFLECTIONMAP_PROJECTION: boolean;
  108955. REFLECTIONMAP_SKYBOX: boolean;
  108956. REFLECTIONMAP_EXPLICIT: boolean;
  108957. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108958. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108959. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108960. INVERTCUBICMAP: boolean;
  108961. LOGARITHMICDEPTH: boolean;
  108962. REFRACTION: boolean;
  108963. REFRACTIONMAP_3D: boolean;
  108964. REFLECTIONOVERALPHA: boolean;
  108965. TWOSIDEDLIGHTING: boolean;
  108966. SHADOWFLOAT: boolean;
  108967. MORPHTARGETS: boolean;
  108968. MORPHTARGETS_NORMAL: boolean;
  108969. MORPHTARGETS_TANGENT: boolean;
  108970. MORPHTARGETS_UV: boolean;
  108971. NUM_MORPH_INFLUENCERS: number;
  108972. NONUNIFORMSCALING: boolean;
  108973. PREMULTIPLYALPHA: boolean;
  108974. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  108975. ALPHABLEND: boolean;
  108976. PREPASS: boolean;
  108977. SCENE_MRT_COUNT: number;
  108978. RGBDLIGHTMAP: boolean;
  108979. RGBDREFLECTION: boolean;
  108980. RGBDREFRACTION: boolean;
  108981. IMAGEPROCESSING: boolean;
  108982. VIGNETTE: boolean;
  108983. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108984. VIGNETTEBLENDMODEOPAQUE: boolean;
  108985. TONEMAPPING: boolean;
  108986. TONEMAPPING_ACES: boolean;
  108987. CONTRAST: boolean;
  108988. COLORCURVES: boolean;
  108989. COLORGRADING: boolean;
  108990. COLORGRADING3D: boolean;
  108991. SAMPLER3DGREENDEPTH: boolean;
  108992. SAMPLER3DBGRMAP: boolean;
  108993. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108994. MULTIVIEW: boolean;
  108995. /**
  108996. * If the reflection texture on this material is in linear color space
  108997. * @hidden
  108998. */
  108999. IS_REFLECTION_LINEAR: boolean;
  109000. /**
  109001. * If the refraction texture on this material is in linear color space
  109002. * @hidden
  109003. */
  109004. IS_REFRACTION_LINEAR: boolean;
  109005. EXPOSURE: boolean;
  109006. constructor();
  109007. setReflectionMode(modeToEnable: string): void;
  109008. }
  109009. /**
  109010. * This is the default material used in Babylon. It is the best trade off between quality
  109011. * and performances.
  109012. * @see https://doc.babylonjs.com/babylon101/materials
  109013. */
  109014. export class StandardMaterial extends PushMaterial {
  109015. private _diffuseTexture;
  109016. /**
  109017. * The basic texture of the material as viewed under a light.
  109018. */
  109019. diffuseTexture: Nullable<BaseTexture>;
  109020. private _ambientTexture;
  109021. /**
  109022. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  109023. */
  109024. ambientTexture: Nullable<BaseTexture>;
  109025. private _opacityTexture;
  109026. /**
  109027. * Define the transparency of the material from a texture.
  109028. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  109029. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  109030. */
  109031. opacityTexture: Nullable<BaseTexture>;
  109032. private _reflectionTexture;
  109033. /**
  109034. * Define the texture used to display the reflection.
  109035. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109036. */
  109037. reflectionTexture: Nullable<BaseTexture>;
  109038. private _emissiveTexture;
  109039. /**
  109040. * Define texture of the material as if self lit.
  109041. * This will be mixed in the final result even in the absence of light.
  109042. */
  109043. emissiveTexture: Nullable<BaseTexture>;
  109044. private _specularTexture;
  109045. /**
  109046. * Define how the color and intensity of the highlight given by the light in the material.
  109047. */
  109048. specularTexture: Nullable<BaseTexture>;
  109049. private _bumpTexture;
  109050. /**
  109051. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  109052. * 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.
  109053. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  109054. */
  109055. bumpTexture: Nullable<BaseTexture>;
  109056. private _lightmapTexture;
  109057. /**
  109058. * Complex lighting can be computationally expensive to compute at runtime.
  109059. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  109060. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  109061. */
  109062. lightmapTexture: Nullable<BaseTexture>;
  109063. private _refractionTexture;
  109064. /**
  109065. * Define the texture used to display the refraction.
  109066. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109067. */
  109068. refractionTexture: Nullable<BaseTexture>;
  109069. /**
  109070. * The color of the material lit by the environmental background lighting.
  109071. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  109072. */
  109073. ambientColor: Color3;
  109074. /**
  109075. * The basic color of the material as viewed under a light.
  109076. */
  109077. diffuseColor: Color3;
  109078. /**
  109079. * Define how the color and intensity of the highlight given by the light in the material.
  109080. */
  109081. specularColor: Color3;
  109082. /**
  109083. * Define the color of the material as if self lit.
  109084. * This will be mixed in the final result even in the absence of light.
  109085. */
  109086. emissiveColor: Color3;
  109087. /**
  109088. * Defines how sharp are the highlights in the material.
  109089. * The bigger the value the sharper giving a more glossy feeling to the result.
  109090. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  109091. */
  109092. specularPower: number;
  109093. private _useAlphaFromDiffuseTexture;
  109094. /**
  109095. * Does the transparency come from the diffuse texture alpha channel.
  109096. */
  109097. useAlphaFromDiffuseTexture: boolean;
  109098. private _useEmissiveAsIllumination;
  109099. /**
  109100. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  109101. */
  109102. useEmissiveAsIllumination: boolean;
  109103. private _linkEmissiveWithDiffuse;
  109104. /**
  109105. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  109106. * the emissive level when the final color is close to one.
  109107. */
  109108. linkEmissiveWithDiffuse: boolean;
  109109. private _useSpecularOverAlpha;
  109110. /**
  109111. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109112. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109113. */
  109114. useSpecularOverAlpha: boolean;
  109115. private _useReflectionOverAlpha;
  109116. /**
  109117. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109118. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109119. */
  109120. useReflectionOverAlpha: boolean;
  109121. private _disableLighting;
  109122. /**
  109123. * Does lights from the scene impacts this material.
  109124. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  109125. */
  109126. disableLighting: boolean;
  109127. private _useObjectSpaceNormalMap;
  109128. /**
  109129. * Allows using an object space normal map (instead of tangent space).
  109130. */
  109131. useObjectSpaceNormalMap: boolean;
  109132. private _useParallax;
  109133. /**
  109134. * Is parallax enabled or not.
  109135. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  109136. */
  109137. useParallax: boolean;
  109138. private _useParallaxOcclusion;
  109139. /**
  109140. * Is parallax occlusion enabled or not.
  109141. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  109142. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  109143. */
  109144. useParallaxOcclusion: boolean;
  109145. /**
  109146. * 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.
  109147. */
  109148. parallaxScaleBias: number;
  109149. private _roughness;
  109150. /**
  109151. * Helps to define how blurry the reflections should appears in the material.
  109152. */
  109153. roughness: number;
  109154. /**
  109155. * In case of refraction, define the value of the index of refraction.
  109156. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109157. */
  109158. indexOfRefraction: number;
  109159. /**
  109160. * Invert the refraction texture alongside the y axis.
  109161. * It can be useful with procedural textures or probe for instance.
  109162. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109163. */
  109164. invertRefractionY: boolean;
  109165. /**
  109166. * Defines the alpha limits in alpha test mode.
  109167. */
  109168. alphaCutOff: number;
  109169. private _useLightmapAsShadowmap;
  109170. /**
  109171. * In case of light mapping, define whether the map contains light or shadow informations.
  109172. */
  109173. useLightmapAsShadowmap: boolean;
  109174. private _diffuseFresnelParameters;
  109175. /**
  109176. * Define the diffuse fresnel parameters of the material.
  109177. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109178. */
  109179. diffuseFresnelParameters: FresnelParameters;
  109180. private _opacityFresnelParameters;
  109181. /**
  109182. * Define the opacity fresnel parameters of the material.
  109183. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109184. */
  109185. opacityFresnelParameters: FresnelParameters;
  109186. private _reflectionFresnelParameters;
  109187. /**
  109188. * Define the reflection fresnel parameters of the material.
  109189. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109190. */
  109191. reflectionFresnelParameters: FresnelParameters;
  109192. private _refractionFresnelParameters;
  109193. /**
  109194. * Define the refraction fresnel parameters of the material.
  109195. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109196. */
  109197. refractionFresnelParameters: FresnelParameters;
  109198. private _emissiveFresnelParameters;
  109199. /**
  109200. * Define the emissive fresnel parameters of the material.
  109201. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109202. */
  109203. emissiveFresnelParameters: FresnelParameters;
  109204. private _useReflectionFresnelFromSpecular;
  109205. /**
  109206. * If true automatically deducts the fresnels values from the material specularity.
  109207. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109208. */
  109209. useReflectionFresnelFromSpecular: boolean;
  109210. private _useGlossinessFromSpecularMapAlpha;
  109211. /**
  109212. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  109213. */
  109214. useGlossinessFromSpecularMapAlpha: boolean;
  109215. private _maxSimultaneousLights;
  109216. /**
  109217. * Defines the maximum number of lights that can be used in the material
  109218. */
  109219. maxSimultaneousLights: number;
  109220. private _invertNormalMapX;
  109221. /**
  109222. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109223. */
  109224. invertNormalMapX: boolean;
  109225. private _invertNormalMapY;
  109226. /**
  109227. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109228. */
  109229. invertNormalMapY: boolean;
  109230. private _twoSidedLighting;
  109231. /**
  109232. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109233. */
  109234. twoSidedLighting: boolean;
  109235. /**
  109236. * Default configuration related to image processing available in the standard Material.
  109237. */
  109238. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109239. /**
  109240. * Gets the image processing configuration used either in this material.
  109241. */
  109242. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  109243. /**
  109244. * Sets the Default image processing configuration used either in the this material.
  109245. *
  109246. * If sets to null, the scene one is in use.
  109247. */
  109248. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  109249. /**
  109250. * Keep track of the image processing observer to allow dispose and replace.
  109251. */
  109252. private _imageProcessingObserver;
  109253. /**
  109254. * Attaches a new image processing configuration to the Standard Material.
  109255. * @param configuration
  109256. */
  109257. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109258. /**
  109259. * Gets wether the color curves effect is enabled.
  109260. */
  109261. get cameraColorCurvesEnabled(): boolean;
  109262. /**
  109263. * Sets wether the color curves effect is enabled.
  109264. */
  109265. set cameraColorCurvesEnabled(value: boolean);
  109266. /**
  109267. * Gets wether the color grading effect is enabled.
  109268. */
  109269. get cameraColorGradingEnabled(): boolean;
  109270. /**
  109271. * Gets wether the color grading effect is enabled.
  109272. */
  109273. set cameraColorGradingEnabled(value: boolean);
  109274. /**
  109275. * Gets wether tonemapping is enabled or not.
  109276. */
  109277. get cameraToneMappingEnabled(): boolean;
  109278. /**
  109279. * Sets wether tonemapping is enabled or not
  109280. */
  109281. set cameraToneMappingEnabled(value: boolean);
  109282. /**
  109283. * The camera exposure used on this material.
  109284. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109285. * This corresponds to a photographic exposure.
  109286. */
  109287. get cameraExposure(): number;
  109288. /**
  109289. * The camera exposure used on this material.
  109290. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109291. * This corresponds to a photographic exposure.
  109292. */
  109293. set cameraExposure(value: number);
  109294. /**
  109295. * Gets The camera contrast used on this material.
  109296. */
  109297. get cameraContrast(): number;
  109298. /**
  109299. * Sets The camera contrast used on this material.
  109300. */
  109301. set cameraContrast(value: number);
  109302. /**
  109303. * Gets the Color Grading 2D Lookup Texture.
  109304. */
  109305. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  109306. /**
  109307. * Sets the Color Grading 2D Lookup Texture.
  109308. */
  109309. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  109310. /**
  109311. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109312. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109313. * 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;
  109314. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109315. */
  109316. get cameraColorCurves(): Nullable<ColorCurves>;
  109317. /**
  109318. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109319. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109320. * 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;
  109321. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109322. */
  109323. set cameraColorCurves(value: Nullable<ColorCurves>);
  109324. /**
  109325. * Can this material render to several textures at once
  109326. */
  109327. get canRenderToMRT(): boolean;
  109328. /**
  109329. * Defines the detail map parameters for the material.
  109330. */
  109331. readonly detailMap: DetailMapConfiguration;
  109332. protected _renderTargets: SmartArray<RenderTargetTexture>;
  109333. protected _worldViewProjectionMatrix: Matrix;
  109334. protected _globalAmbientColor: Color3;
  109335. protected _useLogarithmicDepth: boolean;
  109336. protected _rebuildInParallel: boolean;
  109337. /**
  109338. * Instantiates a new standard material.
  109339. * This is the default material used in Babylon. It is the best trade off between quality
  109340. * and performances.
  109341. * @see https://doc.babylonjs.com/babylon101/materials
  109342. * @param name Define the name of the material in the scene
  109343. * @param scene Define the scene the material belong to
  109344. */
  109345. constructor(name: string, scene: Scene);
  109346. /**
  109347. * Gets a boolean indicating that current material needs to register RTT
  109348. */
  109349. get hasRenderTargetTextures(): boolean;
  109350. /**
  109351. * Gets the current class name of the material e.g. "StandardMaterial"
  109352. * Mainly use in serialization.
  109353. * @returns the class name
  109354. */
  109355. getClassName(): string;
  109356. /**
  109357. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  109358. * You can try switching to logarithmic depth.
  109359. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  109360. */
  109361. get useLogarithmicDepth(): boolean;
  109362. set useLogarithmicDepth(value: boolean);
  109363. /**
  109364. * Specifies if the material will require alpha blending
  109365. * @returns a boolean specifying if alpha blending is needed
  109366. */
  109367. needAlphaBlending(): boolean;
  109368. /**
  109369. * Specifies if this material should be rendered in alpha test mode
  109370. * @returns a boolean specifying if an alpha test is needed.
  109371. */
  109372. needAlphaTesting(): boolean;
  109373. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  109374. /**
  109375. * Get the texture used for alpha test purpose.
  109376. * @returns the diffuse texture in case of the standard material.
  109377. */
  109378. getAlphaTestTexture(): Nullable<BaseTexture>;
  109379. /**
  109380. * Get if the submesh is ready to be used and all its information available.
  109381. * Child classes can use it to update shaders
  109382. * @param mesh defines the mesh to check
  109383. * @param subMesh defines which submesh to check
  109384. * @param useInstances specifies that instances should be used
  109385. * @returns a boolean indicating that the submesh is ready or not
  109386. */
  109387. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109388. /**
  109389. * Builds the material UBO layouts.
  109390. * Used internally during the effect preparation.
  109391. */
  109392. buildUniformLayout(): void;
  109393. /**
  109394. * Unbinds the material from the mesh
  109395. */
  109396. unbind(): void;
  109397. /**
  109398. * Binds the submesh to this material by preparing the effect and shader to draw
  109399. * @param world defines the world transformation matrix
  109400. * @param mesh defines the mesh containing the submesh
  109401. * @param subMesh defines the submesh to bind the material to
  109402. */
  109403. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109404. /**
  109405. * Get the list of animatables in the material.
  109406. * @returns the list of animatables object used in the material
  109407. */
  109408. getAnimatables(): IAnimatable[];
  109409. /**
  109410. * Gets the active textures from the material
  109411. * @returns an array of textures
  109412. */
  109413. getActiveTextures(): BaseTexture[];
  109414. /**
  109415. * Specifies if the material uses a texture
  109416. * @param texture defines the texture to check against the material
  109417. * @returns a boolean specifying if the material uses the texture
  109418. */
  109419. hasTexture(texture: BaseTexture): boolean;
  109420. /**
  109421. * Disposes the material
  109422. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109423. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109424. */
  109425. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109426. /**
  109427. * Makes a duplicate of the material, and gives it a new name
  109428. * @param name defines the new name for the duplicated material
  109429. * @returns the cloned material
  109430. */
  109431. clone(name: string): StandardMaterial;
  109432. /**
  109433. * Serializes this material in a JSON representation
  109434. * @returns the serialized material object
  109435. */
  109436. serialize(): any;
  109437. /**
  109438. * Creates a standard material from parsed material data
  109439. * @param source defines the JSON representation of the material
  109440. * @param scene defines the hosting scene
  109441. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109442. * @returns a new standard material
  109443. */
  109444. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109445. /**
  109446. * Are diffuse textures enabled in the application.
  109447. */
  109448. static get DiffuseTextureEnabled(): boolean;
  109449. static set DiffuseTextureEnabled(value: boolean);
  109450. /**
  109451. * Are detail textures enabled in the application.
  109452. */
  109453. static get DetailTextureEnabled(): boolean;
  109454. static set DetailTextureEnabled(value: boolean);
  109455. /**
  109456. * Are ambient textures enabled in the application.
  109457. */
  109458. static get AmbientTextureEnabled(): boolean;
  109459. static set AmbientTextureEnabled(value: boolean);
  109460. /**
  109461. * Are opacity textures enabled in the application.
  109462. */
  109463. static get OpacityTextureEnabled(): boolean;
  109464. static set OpacityTextureEnabled(value: boolean);
  109465. /**
  109466. * Are reflection textures enabled in the application.
  109467. */
  109468. static get ReflectionTextureEnabled(): boolean;
  109469. static set ReflectionTextureEnabled(value: boolean);
  109470. /**
  109471. * Are emissive textures enabled in the application.
  109472. */
  109473. static get EmissiveTextureEnabled(): boolean;
  109474. static set EmissiveTextureEnabled(value: boolean);
  109475. /**
  109476. * Are specular textures enabled in the application.
  109477. */
  109478. static get SpecularTextureEnabled(): boolean;
  109479. static set SpecularTextureEnabled(value: boolean);
  109480. /**
  109481. * Are bump textures enabled in the application.
  109482. */
  109483. static get BumpTextureEnabled(): boolean;
  109484. static set BumpTextureEnabled(value: boolean);
  109485. /**
  109486. * Are lightmap textures enabled in the application.
  109487. */
  109488. static get LightmapTextureEnabled(): boolean;
  109489. static set LightmapTextureEnabled(value: boolean);
  109490. /**
  109491. * Are refraction textures enabled in the application.
  109492. */
  109493. static get RefractionTextureEnabled(): boolean;
  109494. static set RefractionTextureEnabled(value: boolean);
  109495. /**
  109496. * Are color grading textures enabled in the application.
  109497. */
  109498. static get ColorGradingTextureEnabled(): boolean;
  109499. static set ColorGradingTextureEnabled(value: boolean);
  109500. /**
  109501. * Are fresnels enabled in the application.
  109502. */
  109503. static get FresnelEnabled(): boolean;
  109504. static set FresnelEnabled(value: boolean);
  109505. }
  109506. }
  109507. declare module BABYLON {
  109508. /**
  109509. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  109510. *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.
  109511. * The SPS is also a particle system. It provides some methods to manage the particles.
  109512. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  109513. *
  109514. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  109515. */
  109516. export class SolidParticleSystem implements IDisposable {
  109517. /**
  109518. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  109519. * Example : var p = SPS.particles[i];
  109520. */
  109521. particles: SolidParticle[];
  109522. /**
  109523. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  109524. */
  109525. nbParticles: number;
  109526. /**
  109527. * If the particles must ever face the camera (default false). Useful for planar particles.
  109528. */
  109529. billboard: boolean;
  109530. /**
  109531. * Recompute normals when adding a shape
  109532. */
  109533. recomputeNormals: boolean;
  109534. /**
  109535. * This a counter ofr your own usage. It's not set by any SPS functions.
  109536. */
  109537. counter: number;
  109538. /**
  109539. * The SPS name. This name is also given to the underlying mesh.
  109540. */
  109541. name: string;
  109542. /**
  109543. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  109544. */
  109545. mesh: Mesh;
  109546. /**
  109547. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  109548. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  109549. */
  109550. vars: any;
  109551. /**
  109552. * This array is populated when the SPS is set as 'pickable'.
  109553. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  109554. * Each element of this array is an object `{idx: int, faceId: int}`.
  109555. * `idx` is the picked particle index in the `SPS.particles` array
  109556. * `faceId` is the picked face index counted within this particle.
  109557. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  109558. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  109559. * Use the method SPS.pickedParticle(pickingInfo) instead.
  109560. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  109561. */
  109562. pickedParticles: {
  109563. idx: number;
  109564. faceId: number;
  109565. }[];
  109566. /**
  109567. * This array is populated when the SPS is set as 'pickable'
  109568. * Each key of this array is a submesh index.
  109569. * Each element of this array is a second array defined like this :
  109570. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  109571. * Each element of this second array is an object `{idx: int, faceId: int}`.
  109572. * `idx` is the picked particle index in the `SPS.particles` array
  109573. * `faceId` is the picked face index counted within this particle.
  109574. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  109575. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  109576. */
  109577. pickedBySubMesh: {
  109578. idx: number;
  109579. faceId: number;
  109580. }[][];
  109581. /**
  109582. * This array is populated when `enableDepthSort` is set to true.
  109583. * Each element of this array is an instance of the class DepthSortedParticle.
  109584. */
  109585. depthSortedParticles: DepthSortedParticle[];
  109586. /**
  109587. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  109588. * @hidden
  109589. */
  109590. _bSphereOnly: boolean;
  109591. /**
  109592. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  109593. * @hidden
  109594. */
  109595. _bSphereRadiusFactor: number;
  109596. private _scene;
  109597. private _positions;
  109598. private _indices;
  109599. private _normals;
  109600. private _colors;
  109601. private _uvs;
  109602. private _indices32;
  109603. private _positions32;
  109604. private _normals32;
  109605. private _fixedNormal32;
  109606. private _colors32;
  109607. private _uvs32;
  109608. private _index;
  109609. private _updatable;
  109610. private _pickable;
  109611. private _isVisibilityBoxLocked;
  109612. private _alwaysVisible;
  109613. private _depthSort;
  109614. private _expandable;
  109615. private _shapeCounter;
  109616. private _copy;
  109617. private _color;
  109618. private _computeParticleColor;
  109619. private _computeParticleTexture;
  109620. private _computeParticleRotation;
  109621. private _computeParticleVertex;
  109622. private _computeBoundingBox;
  109623. private _depthSortParticles;
  109624. private _camera;
  109625. private _mustUnrotateFixedNormals;
  109626. private _particlesIntersect;
  109627. private _needs32Bits;
  109628. private _isNotBuilt;
  109629. private _lastParticleId;
  109630. private _idxOfId;
  109631. private _multimaterialEnabled;
  109632. private _useModelMaterial;
  109633. private _indicesByMaterial;
  109634. private _materialIndexes;
  109635. private _depthSortFunction;
  109636. private _materialSortFunction;
  109637. private _materials;
  109638. private _multimaterial;
  109639. private _materialIndexesById;
  109640. private _defaultMaterial;
  109641. private _autoUpdateSubMeshes;
  109642. private _tmpVertex;
  109643. /**
  109644. * Creates a SPS (Solid Particle System) object.
  109645. * @param name (String) is the SPS name, this will be the underlying mesh name.
  109646. * @param scene (Scene) is the scene in which the SPS is added.
  109647. * @param options defines the options of the sps e.g.
  109648. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  109649. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  109650. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  109651. * * 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.
  109652. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  109653. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  109654. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  109655. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  109656. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  109657. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  109658. */
  109659. constructor(name: string, scene: Scene, options?: {
  109660. updatable?: boolean;
  109661. isPickable?: boolean;
  109662. enableDepthSort?: boolean;
  109663. particleIntersection?: boolean;
  109664. boundingSphereOnly?: boolean;
  109665. bSphereRadiusFactor?: number;
  109666. expandable?: boolean;
  109667. useModelMaterial?: boolean;
  109668. enableMultiMaterial?: boolean;
  109669. });
  109670. /**
  109671. * Builds the SPS underlying mesh. Returns a standard Mesh.
  109672. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  109673. * @returns the created mesh
  109674. */
  109675. buildMesh(): Mesh;
  109676. /**
  109677. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  109678. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  109679. * Thus the particles generated from `digest()` have their property `position` set yet.
  109680. * @param mesh ( Mesh ) is the mesh to be digested
  109681. * @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
  109682. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  109683. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  109684. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  109685. * @returns the current SPS
  109686. */
  109687. digest(mesh: Mesh, options?: {
  109688. facetNb?: number;
  109689. number?: number;
  109690. delta?: number;
  109691. storage?: [];
  109692. }): SolidParticleSystem;
  109693. /**
  109694. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  109695. * @hidden
  109696. */
  109697. private _unrotateFixedNormals;
  109698. /**
  109699. * Resets the temporary working copy particle
  109700. * @hidden
  109701. */
  109702. private _resetCopy;
  109703. /**
  109704. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  109705. * @param p the current index in the positions array to be updated
  109706. * @param ind the current index in the indices array
  109707. * @param shape a Vector3 array, the shape geometry
  109708. * @param positions the positions array to be updated
  109709. * @param meshInd the shape indices array
  109710. * @param indices the indices array to be updated
  109711. * @param meshUV the shape uv array
  109712. * @param uvs the uv array to be updated
  109713. * @param meshCol the shape color array
  109714. * @param colors the color array to be updated
  109715. * @param meshNor the shape normals array
  109716. * @param normals the normals array to be updated
  109717. * @param idx the particle index
  109718. * @param idxInShape the particle index in its shape
  109719. * @param options the addShape() method passed options
  109720. * @model the particle model
  109721. * @hidden
  109722. */
  109723. private _meshBuilder;
  109724. /**
  109725. * Returns a shape Vector3 array from positions float array
  109726. * @param positions float array
  109727. * @returns a vector3 array
  109728. * @hidden
  109729. */
  109730. private _posToShape;
  109731. /**
  109732. * Returns a shapeUV array from a float uvs (array deep copy)
  109733. * @param uvs as a float array
  109734. * @returns a shapeUV array
  109735. * @hidden
  109736. */
  109737. private _uvsToShapeUV;
  109738. /**
  109739. * Adds a new particle object in the particles array
  109740. * @param idx particle index in particles array
  109741. * @param id particle id
  109742. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  109743. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  109744. * @param model particle ModelShape object
  109745. * @param shapeId model shape identifier
  109746. * @param idxInShape index of the particle in the current model
  109747. * @param bInfo model bounding info object
  109748. * @param storage target storage array, if any
  109749. * @hidden
  109750. */
  109751. private _addParticle;
  109752. /**
  109753. * Adds some particles to the SPS from the model shape. Returns the shape id.
  109754. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  109755. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  109756. * @param nb (positive integer) the number of particles to be created from this model
  109757. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  109758. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  109759. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  109760. * @returns the number of shapes in the system
  109761. */
  109762. addShape(mesh: Mesh, nb: number, options?: {
  109763. positionFunction?: any;
  109764. vertexFunction?: any;
  109765. storage?: [];
  109766. }): number;
  109767. /**
  109768. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  109769. * @hidden
  109770. */
  109771. private _rebuildParticle;
  109772. /**
  109773. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  109774. * @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.
  109775. * @returns the SPS.
  109776. */
  109777. rebuildMesh(reset?: boolean): SolidParticleSystem;
  109778. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  109779. * Returns an array with the removed particles.
  109780. * 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.
  109781. * The SPS can't be empty so at least one particle needs to remain in place.
  109782. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  109783. * @param start index of the first particle to remove
  109784. * @param end index of the last particle to remove (included)
  109785. * @returns an array populated with the removed particles
  109786. */
  109787. removeParticles(start: number, end: number): SolidParticle[];
  109788. /**
  109789. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  109790. * @param solidParticleArray an array populated with Solid Particles objects
  109791. * @returns the SPS
  109792. */
  109793. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  109794. /**
  109795. * Creates a new particle and modifies the SPS mesh geometry :
  109796. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  109797. * - calls _addParticle() to populate the particle array
  109798. * factorized code from addShape() and insertParticlesFromArray()
  109799. * @param idx particle index in the particles array
  109800. * @param i particle index in its shape
  109801. * @param modelShape particle ModelShape object
  109802. * @param shape shape vertex array
  109803. * @param meshInd shape indices array
  109804. * @param meshUV shape uv array
  109805. * @param meshCol shape color array
  109806. * @param meshNor shape normals array
  109807. * @param bbInfo shape bounding info
  109808. * @param storage target particle storage
  109809. * @options addShape() passed options
  109810. * @hidden
  109811. */
  109812. private _insertNewParticle;
  109813. /**
  109814. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  109815. * This method calls `updateParticle()` for each particle of the SPS.
  109816. * For an animated SPS, it is usually called within the render loop.
  109817. * 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.
  109818. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  109819. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  109820. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  109821. * @returns the SPS.
  109822. */
  109823. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  109824. /**
  109825. * Disposes the SPS.
  109826. */
  109827. dispose(): void;
  109828. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  109829. * idx is the particle index in the SPS
  109830. * faceId is the picked face index counted within this particle.
  109831. * Returns null if the pickInfo can't identify a picked particle.
  109832. * @param pickingInfo (PickingInfo object)
  109833. * @returns {idx: number, faceId: number} or null
  109834. */
  109835. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  109836. idx: number;
  109837. faceId: number;
  109838. }>;
  109839. /**
  109840. * Returns a SolidParticle object from its identifier : particle.id
  109841. * @param id (integer) the particle Id
  109842. * @returns the searched particle or null if not found in the SPS.
  109843. */
  109844. getParticleById(id: number): Nullable<SolidParticle>;
  109845. /**
  109846. * Returns a new array populated with the particles having the passed shapeId.
  109847. * @param shapeId (integer) the shape identifier
  109848. * @returns a new solid particle array
  109849. */
  109850. getParticlesByShapeId(shapeId: number): SolidParticle[];
  109851. /**
  109852. * Populates the passed array "ref" with the particles having the passed shapeId.
  109853. * @param shapeId the shape identifier
  109854. * @returns the SPS
  109855. * @param ref
  109856. */
  109857. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  109858. /**
  109859. * Computes the required SubMeshes according the materials assigned to the particles.
  109860. * @returns the solid particle system.
  109861. * Does nothing if called before the SPS mesh is built.
  109862. */
  109863. computeSubMeshes(): SolidParticleSystem;
  109864. /**
  109865. * Sorts the solid particles by material when MultiMaterial is enabled.
  109866. * Updates the indices32 array.
  109867. * Updates the indicesByMaterial array.
  109868. * Updates the mesh indices array.
  109869. * @returns the SPS
  109870. * @hidden
  109871. */
  109872. private _sortParticlesByMaterial;
  109873. /**
  109874. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  109875. * @hidden
  109876. */
  109877. private _setMaterialIndexesById;
  109878. /**
  109879. * Returns an array with unique values of Materials from the passed array
  109880. * @param array the material array to be checked and filtered
  109881. * @hidden
  109882. */
  109883. private _filterUniqueMaterialId;
  109884. /**
  109885. * Sets a new Standard Material as _defaultMaterial if not already set.
  109886. * @hidden
  109887. */
  109888. private _setDefaultMaterial;
  109889. /**
  109890. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  109891. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  109892. * @returns the SPS.
  109893. */
  109894. refreshVisibleSize(): SolidParticleSystem;
  109895. /**
  109896. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  109897. * @param size the size (float) of the visibility box
  109898. * note : this doesn't lock the SPS mesh bounding box.
  109899. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  109900. */
  109901. setVisibilityBox(size: number): void;
  109902. /**
  109903. * Gets whether the SPS as always visible or not
  109904. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  109905. */
  109906. get isAlwaysVisible(): boolean;
  109907. /**
  109908. * Sets the SPS as always visible or not
  109909. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  109910. */
  109911. set isAlwaysVisible(val: boolean);
  109912. /**
  109913. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  109914. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  109915. */
  109916. set isVisibilityBoxLocked(val: boolean);
  109917. /**
  109918. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  109919. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  109920. */
  109921. get isVisibilityBoxLocked(): boolean;
  109922. /**
  109923. * Tells to `setParticles()` to compute the particle rotations or not.
  109924. * Default value : true. The SPS is faster when it's set to false.
  109925. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  109926. */
  109927. set computeParticleRotation(val: boolean);
  109928. /**
  109929. * Tells to `setParticles()` to compute the particle colors or not.
  109930. * Default value : true. The SPS is faster when it's set to false.
  109931. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  109932. */
  109933. set computeParticleColor(val: boolean);
  109934. set computeParticleTexture(val: boolean);
  109935. /**
  109936. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  109937. * Default value : false. The SPS is faster when it's set to false.
  109938. * Note : the particle custom vertex positions aren't stored values.
  109939. */
  109940. set computeParticleVertex(val: boolean);
  109941. /**
  109942. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  109943. */
  109944. set computeBoundingBox(val: boolean);
  109945. /**
  109946. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  109947. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  109948. * Default : `true`
  109949. */
  109950. set depthSortParticles(val: boolean);
  109951. /**
  109952. * Gets if `setParticles()` computes the particle rotations or not.
  109953. * Default value : true. The SPS is faster when it's set to false.
  109954. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  109955. */
  109956. get computeParticleRotation(): boolean;
  109957. /**
  109958. * Gets if `setParticles()` computes the particle colors or not.
  109959. * Default value : true. The SPS is faster when it's set to false.
  109960. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  109961. */
  109962. get computeParticleColor(): boolean;
  109963. /**
  109964. * Gets if `setParticles()` computes the particle textures or not.
  109965. * Default value : true. The SPS is faster when it's set to false.
  109966. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  109967. */
  109968. get computeParticleTexture(): boolean;
  109969. /**
  109970. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  109971. * Default value : false. The SPS is faster when it's set to false.
  109972. * Note : the particle custom vertex positions aren't stored values.
  109973. */
  109974. get computeParticleVertex(): boolean;
  109975. /**
  109976. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  109977. */
  109978. get computeBoundingBox(): boolean;
  109979. /**
  109980. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  109981. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  109982. * Default : `true`
  109983. */
  109984. get depthSortParticles(): boolean;
  109985. /**
  109986. * Gets if the SPS is created as expandable at construction time.
  109987. * Default : `false`
  109988. */
  109989. get expandable(): boolean;
  109990. /**
  109991. * Gets if the SPS supports the Multi Materials
  109992. */
  109993. get multimaterialEnabled(): boolean;
  109994. /**
  109995. * Gets if the SPS uses the model materials for its own multimaterial.
  109996. */
  109997. get useModelMaterial(): boolean;
  109998. /**
  109999. * The SPS used material array.
  110000. */
  110001. get materials(): Material[];
  110002. /**
  110003. * Sets the SPS MultiMaterial from the passed materials.
  110004. * Note : the passed array is internally copied and not used then by reference.
  110005. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  110006. */
  110007. setMultiMaterial(materials: Material[]): void;
  110008. /**
  110009. * The SPS computed multimaterial object
  110010. */
  110011. get multimaterial(): MultiMaterial;
  110012. set multimaterial(mm: MultiMaterial);
  110013. /**
  110014. * If the subMeshes must be updated on the next call to setParticles()
  110015. */
  110016. get autoUpdateSubMeshes(): boolean;
  110017. set autoUpdateSubMeshes(val: boolean);
  110018. /**
  110019. * This function does nothing. It may be overwritten to set all the particle first values.
  110020. * The SPS doesn't call this function, you may have to call it by your own.
  110021. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110022. */
  110023. initParticles(): void;
  110024. /**
  110025. * This function does nothing. It may be overwritten to recycle a particle.
  110026. * The SPS doesn't call this function, you may have to call it by your own.
  110027. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110028. * @param particle The particle to recycle
  110029. * @returns the recycled particle
  110030. */
  110031. recycleParticle(particle: SolidParticle): SolidParticle;
  110032. /**
  110033. * Updates a particle : this function should be overwritten by the user.
  110034. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  110035. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110036. * @example : just set a particle position or velocity and recycle conditions
  110037. * @param particle The particle to update
  110038. * @returns the updated particle
  110039. */
  110040. updateParticle(particle: SolidParticle): SolidParticle;
  110041. /**
  110042. * Updates a vertex of a particle : it can be overwritten by the user.
  110043. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  110044. * @param particle the current particle
  110045. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  110046. * @param pt the index of the current vertex in the particle shape
  110047. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  110048. * @example : just set a vertex particle position or color
  110049. * @returns the sps
  110050. */
  110051. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  110052. /**
  110053. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  110054. * This does nothing and may be overwritten by the user.
  110055. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110056. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110057. * @param update the boolean update value actually passed to setParticles()
  110058. */
  110059. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  110060. /**
  110061. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  110062. * This will be passed three parameters.
  110063. * This does nothing and may be overwritten by the user.
  110064. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110065. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110066. * @param update the boolean update value actually passed to setParticles()
  110067. */
  110068. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  110069. }
  110070. }
  110071. declare module BABYLON {
  110072. /**
  110073. * Represents one particle of a solid particle system.
  110074. */
  110075. export class SolidParticle {
  110076. /**
  110077. * particle global index
  110078. */
  110079. idx: number;
  110080. /**
  110081. * particle identifier
  110082. */
  110083. id: number;
  110084. /**
  110085. * The color of the particle
  110086. */
  110087. color: Nullable<Color4>;
  110088. /**
  110089. * The world space position of the particle.
  110090. */
  110091. position: Vector3;
  110092. /**
  110093. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  110094. */
  110095. rotation: Vector3;
  110096. /**
  110097. * The world space rotation quaternion of the particle.
  110098. */
  110099. rotationQuaternion: Nullable<Quaternion>;
  110100. /**
  110101. * The scaling of the particle.
  110102. */
  110103. scaling: Vector3;
  110104. /**
  110105. * The uvs of the particle.
  110106. */
  110107. uvs: Vector4;
  110108. /**
  110109. * The current speed of the particle.
  110110. */
  110111. velocity: Vector3;
  110112. /**
  110113. * The pivot point in the particle local space.
  110114. */
  110115. pivot: Vector3;
  110116. /**
  110117. * Must the particle be translated from its pivot point in its local space ?
  110118. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  110119. * Default : false
  110120. */
  110121. translateFromPivot: boolean;
  110122. /**
  110123. * Is the particle active or not ?
  110124. */
  110125. alive: boolean;
  110126. /**
  110127. * Is the particle visible or not ?
  110128. */
  110129. isVisible: boolean;
  110130. /**
  110131. * Index of this particle in the global "positions" array (Internal use)
  110132. * @hidden
  110133. */
  110134. _pos: number;
  110135. /**
  110136. * @hidden Index of this particle in the global "indices" array (Internal use)
  110137. */
  110138. _ind: number;
  110139. /**
  110140. * @hidden ModelShape of this particle (Internal use)
  110141. */
  110142. _model: ModelShape;
  110143. /**
  110144. * ModelShape id of this particle
  110145. */
  110146. shapeId: number;
  110147. /**
  110148. * Index of the particle in its shape id
  110149. */
  110150. idxInShape: number;
  110151. /**
  110152. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  110153. */
  110154. _modelBoundingInfo: BoundingInfo;
  110155. /**
  110156. * @hidden Particle BoundingInfo object (Internal use)
  110157. */
  110158. _boundingInfo: BoundingInfo;
  110159. /**
  110160. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  110161. */
  110162. _sps: SolidParticleSystem;
  110163. /**
  110164. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  110165. */
  110166. _stillInvisible: boolean;
  110167. /**
  110168. * @hidden Last computed particle rotation matrix
  110169. */
  110170. _rotationMatrix: number[];
  110171. /**
  110172. * Parent particle Id, if any.
  110173. * Default null.
  110174. */
  110175. parentId: Nullable<number>;
  110176. /**
  110177. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  110178. */
  110179. materialIndex: Nullable<number>;
  110180. /**
  110181. * Custom object or properties.
  110182. */
  110183. props: Nullable<any>;
  110184. /**
  110185. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  110186. * The possible values are :
  110187. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  110188. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110189. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  110190. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  110191. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110192. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  110193. * */
  110194. cullingStrategy: number;
  110195. /**
  110196. * @hidden Internal global position in the SPS.
  110197. */
  110198. _globalPosition: Vector3;
  110199. /**
  110200. * Creates a Solid Particle object.
  110201. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  110202. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  110203. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  110204. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  110205. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  110206. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  110207. * @param shapeId (integer) is the model shape identifier in the SPS.
  110208. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  110209. * @param sps defines the sps it is associated to
  110210. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  110211. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  110212. */
  110213. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  110214. /**
  110215. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  110216. * @param target the particle target
  110217. * @returns the current particle
  110218. */
  110219. copyToRef(target: SolidParticle): SolidParticle;
  110220. /**
  110221. * Legacy support, changed scale to scaling
  110222. */
  110223. get scale(): Vector3;
  110224. /**
  110225. * Legacy support, changed scale to scaling
  110226. */
  110227. set scale(scale: Vector3);
  110228. /**
  110229. * Legacy support, changed quaternion to rotationQuaternion
  110230. */
  110231. get quaternion(): Nullable<Quaternion>;
  110232. /**
  110233. * Legacy support, changed quaternion to rotationQuaternion
  110234. */
  110235. set quaternion(q: Nullable<Quaternion>);
  110236. /**
  110237. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  110238. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  110239. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  110240. * @returns true if it intersects
  110241. */
  110242. intersectsMesh(target: Mesh | SolidParticle): boolean;
  110243. /**
  110244. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  110245. * A particle is in the frustum if its bounding box intersects the frustum
  110246. * @param frustumPlanes defines the frustum to test
  110247. * @returns true if the particle is in the frustum planes
  110248. */
  110249. isInFrustum(frustumPlanes: Plane[]): boolean;
  110250. /**
  110251. * get the rotation matrix of the particle
  110252. * @hidden
  110253. */
  110254. getRotationMatrix(m: Matrix): void;
  110255. }
  110256. /**
  110257. * Represents the shape of the model used by one particle of a solid particle system.
  110258. * SPS internal tool, don't use it manually.
  110259. */
  110260. export class ModelShape {
  110261. /**
  110262. * The shape id
  110263. * @hidden
  110264. */
  110265. shapeID: number;
  110266. /**
  110267. * flat array of model positions (internal use)
  110268. * @hidden
  110269. */
  110270. _shape: Vector3[];
  110271. /**
  110272. * flat array of model UVs (internal use)
  110273. * @hidden
  110274. */
  110275. _shapeUV: number[];
  110276. /**
  110277. * color array of the model
  110278. * @hidden
  110279. */
  110280. _shapeColors: number[];
  110281. /**
  110282. * indices array of the model
  110283. * @hidden
  110284. */
  110285. _indices: number[];
  110286. /**
  110287. * normals array of the model
  110288. * @hidden
  110289. */
  110290. _normals: number[];
  110291. /**
  110292. * length of the shape in the model indices array (internal use)
  110293. * @hidden
  110294. */
  110295. _indicesLength: number;
  110296. /**
  110297. * Custom position function (internal use)
  110298. * @hidden
  110299. */
  110300. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  110301. /**
  110302. * Custom vertex function (internal use)
  110303. * @hidden
  110304. */
  110305. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  110306. /**
  110307. * Model material (internal use)
  110308. * @hidden
  110309. */
  110310. _material: Nullable<Material>;
  110311. /**
  110312. * 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.
  110313. * SPS internal tool, don't use it manually.
  110314. * @hidden
  110315. */
  110316. 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>);
  110317. }
  110318. /**
  110319. * Represents a Depth Sorted Particle in the solid particle system.
  110320. * @hidden
  110321. */
  110322. export class DepthSortedParticle {
  110323. /**
  110324. * Particle index
  110325. */
  110326. idx: number;
  110327. /**
  110328. * Index of the particle in the "indices" array
  110329. */
  110330. ind: number;
  110331. /**
  110332. * Length of the particle shape in the "indices" array
  110333. */
  110334. indicesLength: number;
  110335. /**
  110336. * Squared distance from the particle to the camera
  110337. */
  110338. sqDistance: number;
  110339. /**
  110340. * Material index when used with MultiMaterials
  110341. */
  110342. materialIndex: number;
  110343. /**
  110344. * Creates a new sorted particle
  110345. * @param materialIndex
  110346. */
  110347. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  110348. }
  110349. /**
  110350. * Represents a solid particle vertex
  110351. */
  110352. export class SolidParticleVertex {
  110353. /**
  110354. * Vertex position
  110355. */
  110356. position: Vector3;
  110357. /**
  110358. * Vertex color
  110359. */
  110360. color: Color4;
  110361. /**
  110362. * Vertex UV
  110363. */
  110364. uv: Vector2;
  110365. /**
  110366. * Creates a new solid particle vertex
  110367. */
  110368. constructor();
  110369. /** Vertex x coordinate */
  110370. get x(): number;
  110371. set x(val: number);
  110372. /** Vertex y coordinate */
  110373. get y(): number;
  110374. set y(val: number);
  110375. /** Vertex z coordinate */
  110376. get z(): number;
  110377. set z(val: number);
  110378. }
  110379. }
  110380. declare module BABYLON {
  110381. /**
  110382. * @hidden
  110383. */
  110384. export class _MeshCollisionData {
  110385. _checkCollisions: boolean;
  110386. _collisionMask: number;
  110387. _collisionGroup: number;
  110388. _surroundingMeshes: Nullable<AbstractMesh[]>;
  110389. _collider: Nullable<Collider>;
  110390. _oldPositionForCollisions: Vector3;
  110391. _diffPositionForCollisions: Vector3;
  110392. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  110393. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  110394. }
  110395. }
  110396. declare module BABYLON {
  110397. /** @hidden */
  110398. class _FacetDataStorage {
  110399. facetPositions: Vector3[];
  110400. facetNormals: Vector3[];
  110401. facetPartitioning: number[][];
  110402. facetNb: number;
  110403. partitioningSubdivisions: number;
  110404. partitioningBBoxRatio: number;
  110405. facetDataEnabled: boolean;
  110406. facetParameters: any;
  110407. bbSize: Vector3;
  110408. subDiv: {
  110409. max: number;
  110410. X: number;
  110411. Y: number;
  110412. Z: number;
  110413. };
  110414. facetDepthSort: boolean;
  110415. facetDepthSortEnabled: boolean;
  110416. depthSortedIndices: IndicesArray;
  110417. depthSortedFacets: {
  110418. ind: number;
  110419. sqDistance: number;
  110420. }[];
  110421. facetDepthSortFunction: (f1: {
  110422. ind: number;
  110423. sqDistance: number;
  110424. }, f2: {
  110425. ind: number;
  110426. sqDistance: number;
  110427. }) => number;
  110428. facetDepthSortFrom: Vector3;
  110429. facetDepthSortOrigin: Vector3;
  110430. invertedMatrix: Matrix;
  110431. }
  110432. /**
  110433. * @hidden
  110434. **/
  110435. class _InternalAbstractMeshDataInfo {
  110436. _hasVertexAlpha: boolean;
  110437. _useVertexColors: boolean;
  110438. _numBoneInfluencers: number;
  110439. _applyFog: boolean;
  110440. _receiveShadows: boolean;
  110441. _facetData: _FacetDataStorage;
  110442. _visibility: number;
  110443. _skeleton: Nullable<Skeleton>;
  110444. _layerMask: number;
  110445. _computeBonesUsingShaders: boolean;
  110446. _isActive: boolean;
  110447. _onlyForInstances: boolean;
  110448. _isActiveIntermediate: boolean;
  110449. _onlyForInstancesIntermediate: boolean;
  110450. _actAsRegularMesh: boolean;
  110451. }
  110452. /**
  110453. * Class used to store all common mesh properties
  110454. */
  110455. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  110456. /** No occlusion */
  110457. static OCCLUSION_TYPE_NONE: number;
  110458. /** Occlusion set to optimisitic */
  110459. static OCCLUSION_TYPE_OPTIMISTIC: number;
  110460. /** Occlusion set to strict */
  110461. static OCCLUSION_TYPE_STRICT: number;
  110462. /** Use an accurante occlusion algorithm */
  110463. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  110464. /** Use a conservative occlusion algorithm */
  110465. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  110466. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  110467. * Test order :
  110468. * Is the bounding sphere outside the frustum ?
  110469. * If not, are the bounding box vertices outside the frustum ?
  110470. * It not, then the cullable object is in the frustum.
  110471. */
  110472. static readonly CULLINGSTRATEGY_STANDARD: number;
  110473. /** Culling strategy : Bounding Sphere Only.
  110474. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  110475. * It's also less accurate than the standard because some not visible objects can still be selected.
  110476. * Test : is the bounding sphere outside the frustum ?
  110477. * If not, then the cullable object is in the frustum.
  110478. */
  110479. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  110480. /** Culling strategy : Optimistic Inclusion.
  110481. * This in an inclusion test first, then the standard exclusion test.
  110482. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  110483. * 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.
  110484. * Anyway, it's as accurate as the standard strategy.
  110485. * Test :
  110486. * Is the cullable object bounding sphere center in the frustum ?
  110487. * If not, apply the default culling strategy.
  110488. */
  110489. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  110490. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  110491. * This in an inclusion test first, then the bounding sphere only exclusion test.
  110492. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  110493. * 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.
  110494. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  110495. * Test :
  110496. * Is the cullable object bounding sphere center in the frustum ?
  110497. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  110498. */
  110499. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  110500. /**
  110501. * No billboard
  110502. */
  110503. static get BILLBOARDMODE_NONE(): number;
  110504. /** Billboard on X axis */
  110505. static get BILLBOARDMODE_X(): number;
  110506. /** Billboard on Y axis */
  110507. static get BILLBOARDMODE_Y(): number;
  110508. /** Billboard on Z axis */
  110509. static get BILLBOARDMODE_Z(): number;
  110510. /** Billboard on all axes */
  110511. static get BILLBOARDMODE_ALL(): number;
  110512. /** Billboard on using position instead of orientation */
  110513. static get BILLBOARDMODE_USE_POSITION(): number;
  110514. /** @hidden */
  110515. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  110516. /**
  110517. * The culling strategy to use to check whether the mesh must be rendered or not.
  110518. * This value can be changed at any time and will be used on the next render mesh selection.
  110519. * The possible values are :
  110520. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  110521. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110522. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  110523. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  110524. * Please read each static variable documentation to get details about the culling process.
  110525. * */
  110526. cullingStrategy: number;
  110527. /**
  110528. * Gets the number of facets in the mesh
  110529. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  110530. */
  110531. get facetNb(): number;
  110532. /**
  110533. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  110534. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  110535. */
  110536. get partitioningSubdivisions(): number;
  110537. set partitioningSubdivisions(nb: number);
  110538. /**
  110539. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  110540. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  110541. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  110542. */
  110543. get partitioningBBoxRatio(): number;
  110544. set partitioningBBoxRatio(ratio: number);
  110545. /**
  110546. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  110547. * Works only for updatable meshes.
  110548. * Doesn't work with multi-materials
  110549. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  110550. */
  110551. get mustDepthSortFacets(): boolean;
  110552. set mustDepthSortFacets(sort: boolean);
  110553. /**
  110554. * The location (Vector3) where the facet depth sort must be computed from.
  110555. * By default, the active camera position.
  110556. * Used only when facet depth sort is enabled
  110557. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  110558. */
  110559. get facetDepthSortFrom(): Vector3;
  110560. set facetDepthSortFrom(location: Vector3);
  110561. /**
  110562. * gets a boolean indicating if facetData is enabled
  110563. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  110564. */
  110565. get isFacetDataEnabled(): boolean;
  110566. /** @hidden */
  110567. _updateNonUniformScalingState(value: boolean): boolean;
  110568. /**
  110569. * An event triggered when this mesh collides with another one
  110570. */
  110571. onCollideObservable: Observable<AbstractMesh>;
  110572. /** Set a function to call when this mesh collides with another one */
  110573. set onCollide(callback: () => void);
  110574. /**
  110575. * An event triggered when the collision's position changes
  110576. */
  110577. onCollisionPositionChangeObservable: Observable<Vector3>;
  110578. /** Set a function to call when the collision's position changes */
  110579. set onCollisionPositionChange(callback: () => void);
  110580. /**
  110581. * An event triggered when material is changed
  110582. */
  110583. onMaterialChangedObservable: Observable<AbstractMesh>;
  110584. /**
  110585. * Gets or sets the orientation for POV movement & rotation
  110586. */
  110587. definedFacingForward: boolean;
  110588. /** @hidden */
  110589. _occlusionQuery: Nullable<WebGLQuery>;
  110590. /** @hidden */
  110591. _renderingGroup: Nullable<RenderingGroup>;
  110592. /**
  110593. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  110594. */
  110595. get visibility(): number;
  110596. /**
  110597. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  110598. */
  110599. set visibility(value: number);
  110600. /** Gets or sets the alpha index used to sort transparent meshes
  110601. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  110602. */
  110603. alphaIndex: number;
  110604. /**
  110605. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  110606. */
  110607. isVisible: boolean;
  110608. /**
  110609. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  110610. */
  110611. isPickable: boolean;
  110612. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  110613. showSubMeshesBoundingBox: boolean;
  110614. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  110615. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110616. */
  110617. isBlocker: boolean;
  110618. /**
  110619. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  110620. */
  110621. enablePointerMoveEvents: boolean;
  110622. /**
  110623. * Specifies the rendering group id for this mesh (0 by default)
  110624. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  110625. */
  110626. renderingGroupId: number;
  110627. private _material;
  110628. /** Gets or sets current material */
  110629. get material(): Nullable<Material>;
  110630. set material(value: Nullable<Material>);
  110631. /**
  110632. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  110633. * @see https://doc.babylonjs.com/babylon101/shadows
  110634. */
  110635. get receiveShadows(): boolean;
  110636. set receiveShadows(value: boolean);
  110637. /** Defines color to use when rendering outline */
  110638. outlineColor: Color3;
  110639. /** Define width to use when rendering outline */
  110640. outlineWidth: number;
  110641. /** Defines color to use when rendering overlay */
  110642. overlayColor: Color3;
  110643. /** Defines alpha to use when rendering overlay */
  110644. overlayAlpha: number;
  110645. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  110646. get hasVertexAlpha(): boolean;
  110647. set hasVertexAlpha(value: boolean);
  110648. /** 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) */
  110649. get useVertexColors(): boolean;
  110650. set useVertexColors(value: boolean);
  110651. /**
  110652. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  110653. */
  110654. get computeBonesUsingShaders(): boolean;
  110655. set computeBonesUsingShaders(value: boolean);
  110656. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  110657. get numBoneInfluencers(): number;
  110658. set numBoneInfluencers(value: number);
  110659. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  110660. get applyFog(): boolean;
  110661. set applyFog(value: boolean);
  110662. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  110663. useOctreeForRenderingSelection: boolean;
  110664. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  110665. useOctreeForPicking: boolean;
  110666. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  110667. useOctreeForCollisions: boolean;
  110668. /**
  110669. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  110670. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  110671. */
  110672. get layerMask(): number;
  110673. set layerMask(value: number);
  110674. /**
  110675. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  110676. */
  110677. alwaysSelectAsActiveMesh: boolean;
  110678. /**
  110679. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  110680. */
  110681. doNotSyncBoundingInfo: boolean;
  110682. /**
  110683. * Gets or sets the current action manager
  110684. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  110685. */
  110686. actionManager: Nullable<AbstractActionManager>;
  110687. private _meshCollisionData;
  110688. /**
  110689. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  110690. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110691. */
  110692. ellipsoid: Vector3;
  110693. /**
  110694. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  110695. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110696. */
  110697. ellipsoidOffset: Vector3;
  110698. /**
  110699. * Gets or sets a collision mask used to mask collisions (default is -1).
  110700. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  110701. */
  110702. get collisionMask(): number;
  110703. set collisionMask(mask: number);
  110704. /**
  110705. * Gets or sets the current collision group mask (-1 by default).
  110706. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  110707. */
  110708. get collisionGroup(): number;
  110709. set collisionGroup(mask: number);
  110710. /**
  110711. * Gets or sets current surrounding meshes (null by default).
  110712. *
  110713. * By default collision detection is tested against every mesh in the scene.
  110714. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  110715. * meshes will be tested for the collision.
  110716. *
  110717. * Note: if set to an empty array no collision will happen when this mesh is moved.
  110718. */
  110719. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  110720. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  110721. /**
  110722. * Defines edge width used when edgesRenderer is enabled
  110723. * @see https://www.babylonjs-playground.com/#10OJSG#13
  110724. */
  110725. edgesWidth: number;
  110726. /**
  110727. * Defines edge color used when edgesRenderer is enabled
  110728. * @see https://www.babylonjs-playground.com/#10OJSG#13
  110729. */
  110730. edgesColor: Color4;
  110731. /** @hidden */
  110732. _edgesRenderer: Nullable<IEdgesRenderer>;
  110733. /** @hidden */
  110734. _masterMesh: Nullable<AbstractMesh>;
  110735. /** @hidden */
  110736. _boundingInfo: Nullable<BoundingInfo>;
  110737. /** @hidden */
  110738. _renderId: number;
  110739. /**
  110740. * Gets or sets the list of subMeshes
  110741. * @see https://doc.babylonjs.com/how_to/multi_materials
  110742. */
  110743. subMeshes: SubMesh[];
  110744. /** @hidden */
  110745. _intersectionsInProgress: AbstractMesh[];
  110746. /** @hidden */
  110747. _unIndexed: boolean;
  110748. /** @hidden */
  110749. _lightSources: Light[];
  110750. /** Gets the list of lights affecting that mesh */
  110751. get lightSources(): Light[];
  110752. /** @hidden */
  110753. get _positions(): Nullable<Vector3[]>;
  110754. /** @hidden */
  110755. _waitingData: {
  110756. lods: Nullable<any>;
  110757. actions: Nullable<any>;
  110758. freezeWorldMatrix: Nullable<boolean>;
  110759. };
  110760. /** @hidden */
  110761. _bonesTransformMatrices: Nullable<Float32Array>;
  110762. /** @hidden */
  110763. _transformMatrixTexture: Nullable<RawTexture>;
  110764. /**
  110765. * Gets or sets a skeleton to apply skining transformations
  110766. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110767. */
  110768. set skeleton(value: Nullable<Skeleton>);
  110769. get skeleton(): Nullable<Skeleton>;
  110770. /**
  110771. * An event triggered when the mesh is rebuilt.
  110772. */
  110773. onRebuildObservable: Observable<AbstractMesh>;
  110774. /**
  110775. * Creates a new AbstractMesh
  110776. * @param name defines the name of the mesh
  110777. * @param scene defines the hosting scene
  110778. */
  110779. constructor(name: string, scene?: Nullable<Scene>);
  110780. /**
  110781. * Returns the string "AbstractMesh"
  110782. * @returns "AbstractMesh"
  110783. */
  110784. getClassName(): string;
  110785. /**
  110786. * Gets a string representation of the current mesh
  110787. * @param fullDetails defines a boolean indicating if full details must be included
  110788. * @returns a string representation of the current mesh
  110789. */
  110790. toString(fullDetails?: boolean): string;
  110791. /**
  110792. * @hidden
  110793. */
  110794. protected _getEffectiveParent(): Nullable<Node>;
  110795. /** @hidden */
  110796. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  110797. /** @hidden */
  110798. _rebuild(): void;
  110799. /** @hidden */
  110800. _resyncLightSources(): void;
  110801. /** @hidden */
  110802. _resyncLightSource(light: Light): void;
  110803. /** @hidden */
  110804. _unBindEffect(): void;
  110805. /** @hidden */
  110806. _removeLightSource(light: Light, dispose: boolean): void;
  110807. private _markSubMeshesAsDirty;
  110808. /** @hidden */
  110809. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  110810. /** @hidden */
  110811. _markSubMeshesAsAttributesDirty(): void;
  110812. /** @hidden */
  110813. _markSubMeshesAsMiscDirty(): void;
  110814. /**
  110815. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  110816. */
  110817. get scaling(): Vector3;
  110818. set scaling(newScaling: Vector3);
  110819. /**
  110820. * Returns true if the mesh is blocked. Implemented by child classes
  110821. */
  110822. get isBlocked(): boolean;
  110823. /**
  110824. * Returns the mesh itself by default. Implemented by child classes
  110825. * @param camera defines the camera to use to pick the right LOD level
  110826. * @returns the currentAbstractMesh
  110827. */
  110828. getLOD(camera: Camera): Nullable<AbstractMesh>;
  110829. /**
  110830. * Returns 0 by default. Implemented by child classes
  110831. * @returns an integer
  110832. */
  110833. getTotalVertices(): number;
  110834. /**
  110835. * Returns a positive integer : the total number of indices in this mesh geometry.
  110836. * @returns the numner of indices or zero if the mesh has no geometry.
  110837. */
  110838. getTotalIndices(): number;
  110839. /**
  110840. * Returns null by default. Implemented by child classes
  110841. * @returns null
  110842. */
  110843. getIndices(): Nullable<IndicesArray>;
  110844. /**
  110845. * Returns the array of the requested vertex data kind. Implemented by child classes
  110846. * @param kind defines the vertex data kind to use
  110847. * @returns null
  110848. */
  110849. getVerticesData(kind: string): Nullable<FloatArray>;
  110850. /**
  110851. * Sets the vertex data of the mesh geometry for the requested `kind`.
  110852. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  110853. * Note that a new underlying VertexBuffer object is created each call.
  110854. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  110855. * @param kind defines vertex data kind:
  110856. * * VertexBuffer.PositionKind
  110857. * * VertexBuffer.UVKind
  110858. * * VertexBuffer.UV2Kind
  110859. * * VertexBuffer.UV3Kind
  110860. * * VertexBuffer.UV4Kind
  110861. * * VertexBuffer.UV5Kind
  110862. * * VertexBuffer.UV6Kind
  110863. * * VertexBuffer.ColorKind
  110864. * * VertexBuffer.MatricesIndicesKind
  110865. * * VertexBuffer.MatricesIndicesExtraKind
  110866. * * VertexBuffer.MatricesWeightsKind
  110867. * * VertexBuffer.MatricesWeightsExtraKind
  110868. * @param data defines the data source
  110869. * @param updatable defines if the data must be flagged as updatable (or static)
  110870. * @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
  110871. * @returns the current mesh
  110872. */
  110873. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  110874. /**
  110875. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  110876. * If the mesh has no geometry, it is simply returned as it is.
  110877. * @param kind defines vertex data kind:
  110878. * * VertexBuffer.PositionKind
  110879. * * VertexBuffer.UVKind
  110880. * * VertexBuffer.UV2Kind
  110881. * * VertexBuffer.UV3Kind
  110882. * * VertexBuffer.UV4Kind
  110883. * * VertexBuffer.UV5Kind
  110884. * * VertexBuffer.UV6Kind
  110885. * * VertexBuffer.ColorKind
  110886. * * VertexBuffer.MatricesIndicesKind
  110887. * * VertexBuffer.MatricesIndicesExtraKind
  110888. * * VertexBuffer.MatricesWeightsKind
  110889. * * VertexBuffer.MatricesWeightsExtraKind
  110890. * @param data defines the data source
  110891. * @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
  110892. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  110893. * @returns the current mesh
  110894. */
  110895. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  110896. /**
  110897. * Sets the mesh indices,
  110898. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  110899. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  110900. * @param totalVertices Defines the total number of vertices
  110901. * @returns the current mesh
  110902. */
  110903. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  110904. /**
  110905. * Gets a boolean indicating if specific vertex data is present
  110906. * @param kind defines the vertex data kind to use
  110907. * @returns true is data kind is present
  110908. */
  110909. isVerticesDataPresent(kind: string): boolean;
  110910. /**
  110911. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  110912. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  110913. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  110914. * @returns a BoundingInfo
  110915. */
  110916. getBoundingInfo(): BoundingInfo;
  110917. /**
  110918. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  110919. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  110920. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  110921. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  110922. * @returns the current mesh
  110923. */
  110924. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  110925. /**
  110926. * Overwrite the current bounding info
  110927. * @param boundingInfo defines the new bounding info
  110928. * @returns the current mesh
  110929. */
  110930. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  110931. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  110932. get useBones(): boolean;
  110933. /** @hidden */
  110934. _preActivate(): void;
  110935. /** @hidden */
  110936. _preActivateForIntermediateRendering(renderId: number): void;
  110937. /** @hidden */
  110938. _activate(renderId: number, intermediateRendering: boolean): boolean;
  110939. /** @hidden */
  110940. _postActivate(): void;
  110941. /** @hidden */
  110942. _freeze(): void;
  110943. /** @hidden */
  110944. _unFreeze(): void;
  110945. /**
  110946. * Gets the current world matrix
  110947. * @returns a Matrix
  110948. */
  110949. getWorldMatrix(): Matrix;
  110950. /** @hidden */
  110951. _getWorldMatrixDeterminant(): number;
  110952. /**
  110953. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  110954. */
  110955. get isAnInstance(): boolean;
  110956. /**
  110957. * Gets a boolean indicating if this mesh has instances
  110958. */
  110959. get hasInstances(): boolean;
  110960. /**
  110961. * Gets a boolean indicating if this mesh has thin instances
  110962. */
  110963. get hasThinInstances(): boolean;
  110964. /**
  110965. * Perform relative position change from the point of view of behind the front of the mesh.
  110966. * This is performed taking into account the meshes current rotation, so you do not have to care.
  110967. * Supports definition of mesh facing forward or backward
  110968. * @param amountRight defines the distance on the right axis
  110969. * @param amountUp defines the distance on the up axis
  110970. * @param amountForward defines the distance on the forward axis
  110971. * @returns the current mesh
  110972. */
  110973. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  110974. /**
  110975. * Calculate relative position change from the point of view of behind the front of the mesh.
  110976. * This is performed taking into account the meshes current rotation, so you do not have to care.
  110977. * Supports definition of mesh facing forward or backward
  110978. * @param amountRight defines the distance on the right axis
  110979. * @param amountUp defines the distance on the up axis
  110980. * @param amountForward defines the distance on the forward axis
  110981. * @returns the new displacement vector
  110982. */
  110983. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  110984. /**
  110985. * Perform relative rotation change from the point of view of behind the front of the mesh.
  110986. * Supports definition of mesh facing forward or backward
  110987. * @param flipBack defines the flip
  110988. * @param twirlClockwise defines the twirl
  110989. * @param tiltRight defines the tilt
  110990. * @returns the current mesh
  110991. */
  110992. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  110993. /**
  110994. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  110995. * Supports definition of mesh facing forward or backward.
  110996. * @param flipBack defines the flip
  110997. * @param twirlClockwise defines the twirl
  110998. * @param tiltRight defines the tilt
  110999. * @returns the new rotation vector
  111000. */
  111001. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  111002. /**
  111003. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  111004. * This means the mesh underlying bounding box and sphere are recomputed.
  111005. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  111006. * @returns the current mesh
  111007. */
  111008. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  111009. /** @hidden */
  111010. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  111011. /** @hidden */
  111012. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  111013. /** @hidden */
  111014. _updateBoundingInfo(): AbstractMesh;
  111015. /** @hidden */
  111016. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  111017. /** @hidden */
  111018. protected _afterComputeWorldMatrix(): void;
  111019. /** @hidden */
  111020. get _effectiveMesh(): AbstractMesh;
  111021. /**
  111022. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  111023. * A mesh is in the frustum if its bounding box intersects the frustum
  111024. * @param frustumPlanes defines the frustum to test
  111025. * @returns true if the mesh is in the frustum planes
  111026. */
  111027. isInFrustum(frustumPlanes: Plane[]): boolean;
  111028. /**
  111029. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  111030. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  111031. * @param frustumPlanes defines the frustum to test
  111032. * @returns true if the mesh is completely in the frustum planes
  111033. */
  111034. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  111035. /**
  111036. * True if the mesh intersects another mesh or a SolidParticle object
  111037. * @param mesh defines a target mesh or SolidParticle to test
  111038. * @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)
  111039. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  111040. * @returns true if there is an intersection
  111041. */
  111042. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  111043. /**
  111044. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  111045. * @param point defines the point to test
  111046. * @returns true if there is an intersection
  111047. */
  111048. intersectsPoint(point: Vector3): boolean;
  111049. /**
  111050. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  111051. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111052. */
  111053. get checkCollisions(): boolean;
  111054. set checkCollisions(collisionEnabled: boolean);
  111055. /**
  111056. * Gets Collider object used to compute collisions (not physics)
  111057. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111058. */
  111059. get collider(): Nullable<Collider>;
  111060. /**
  111061. * Move the mesh using collision engine
  111062. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111063. * @param displacement defines the requested displacement vector
  111064. * @returns the current mesh
  111065. */
  111066. moveWithCollisions(displacement: Vector3): AbstractMesh;
  111067. private _onCollisionPositionChange;
  111068. /** @hidden */
  111069. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  111070. /** @hidden */
  111071. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  111072. /** @hidden */
  111073. _checkCollision(collider: Collider): AbstractMesh;
  111074. /** @hidden */
  111075. _generatePointsArray(): boolean;
  111076. /**
  111077. * Checks if the passed Ray intersects with the mesh
  111078. * @param ray defines the ray to use
  111079. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  111080. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111081. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  111082. * @returns the picking info
  111083. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  111084. */
  111085. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  111086. /**
  111087. * Clones the current mesh
  111088. * @param name defines the mesh name
  111089. * @param newParent defines the new mesh parent
  111090. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  111091. * @returns the new mesh
  111092. */
  111093. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  111094. /**
  111095. * Disposes all the submeshes of the current meshnp
  111096. * @returns the current mesh
  111097. */
  111098. releaseSubMeshes(): AbstractMesh;
  111099. /**
  111100. * Releases resources associated with this abstract mesh.
  111101. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111102. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111103. */
  111104. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111105. /**
  111106. * Adds the passed mesh as a child to the current mesh
  111107. * @param mesh defines the child mesh
  111108. * @returns the current mesh
  111109. */
  111110. addChild(mesh: AbstractMesh): AbstractMesh;
  111111. /**
  111112. * Removes the passed mesh from the current mesh children list
  111113. * @param mesh defines the child mesh
  111114. * @returns the current mesh
  111115. */
  111116. removeChild(mesh: AbstractMesh): AbstractMesh;
  111117. /** @hidden */
  111118. private _initFacetData;
  111119. /**
  111120. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  111121. * This method can be called within the render loop.
  111122. * 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
  111123. * @returns the current mesh
  111124. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111125. */
  111126. updateFacetData(): AbstractMesh;
  111127. /**
  111128. * Returns the facetLocalNormals array.
  111129. * The normals are expressed in the mesh local spac
  111130. * @returns an array of Vector3
  111131. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111132. */
  111133. getFacetLocalNormals(): Vector3[];
  111134. /**
  111135. * Returns the facetLocalPositions array.
  111136. * The facet positions are expressed in the mesh local space
  111137. * @returns an array of Vector3
  111138. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111139. */
  111140. getFacetLocalPositions(): Vector3[];
  111141. /**
  111142. * Returns the facetLocalPartioning array
  111143. * @returns an array of array of numbers
  111144. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111145. */
  111146. getFacetLocalPartitioning(): number[][];
  111147. /**
  111148. * Returns the i-th facet position in the world system.
  111149. * This method allocates a new Vector3 per call
  111150. * @param i defines the facet index
  111151. * @returns a new Vector3
  111152. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111153. */
  111154. getFacetPosition(i: number): Vector3;
  111155. /**
  111156. * Sets the reference Vector3 with the i-th facet position in the world system
  111157. * @param i defines the facet index
  111158. * @param ref defines the target vector
  111159. * @returns the current mesh
  111160. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111161. */
  111162. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  111163. /**
  111164. * Returns the i-th facet normal in the world system.
  111165. * This method allocates a new Vector3 per call
  111166. * @param i defines the facet index
  111167. * @returns a new Vector3
  111168. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111169. */
  111170. getFacetNormal(i: number): Vector3;
  111171. /**
  111172. * Sets the reference Vector3 with the i-th facet normal in the world system
  111173. * @param i defines the facet index
  111174. * @param ref defines the target vector
  111175. * @returns the current mesh
  111176. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111177. */
  111178. getFacetNormalToRef(i: number, ref: Vector3): this;
  111179. /**
  111180. * 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)
  111181. * @param x defines x coordinate
  111182. * @param y defines y coordinate
  111183. * @param z defines z coordinate
  111184. * @returns the array of facet indexes
  111185. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111186. */
  111187. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  111188. /**
  111189. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  111190. * @param projected sets as the (x,y,z) world projection on the facet
  111191. * @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
  111192. * @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
  111193. * @param x defines x coordinate
  111194. * @param y defines y coordinate
  111195. * @param z defines z coordinate
  111196. * @returns the face index if found (or null instead)
  111197. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111198. */
  111199. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111200. /**
  111201. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  111202. * @param projected sets as the (x,y,z) local projection on the facet
  111203. * @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
  111204. * @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
  111205. * @param x defines x coordinate
  111206. * @param y defines y coordinate
  111207. * @param z defines z coordinate
  111208. * @returns the face index if found (or null instead)
  111209. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111210. */
  111211. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111212. /**
  111213. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  111214. * @returns the parameters
  111215. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111216. */
  111217. getFacetDataParameters(): any;
  111218. /**
  111219. * Disables the feature FacetData and frees the related memory
  111220. * @returns the current mesh
  111221. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111222. */
  111223. disableFacetData(): AbstractMesh;
  111224. /**
  111225. * Updates the AbstractMesh indices array
  111226. * @param indices defines the data source
  111227. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  111228. * @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)
  111229. * @returns the current mesh
  111230. */
  111231. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  111232. /**
  111233. * Creates new normals data for the mesh
  111234. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  111235. * @returns the current mesh
  111236. */
  111237. createNormals(updatable: boolean): AbstractMesh;
  111238. /**
  111239. * Align the mesh with a normal
  111240. * @param normal defines the normal to use
  111241. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  111242. * @returns the current mesh
  111243. */
  111244. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  111245. /** @hidden */
  111246. _checkOcclusionQuery(): boolean;
  111247. /**
  111248. * Disables the mesh edge rendering mode
  111249. * @returns the currentAbstractMesh
  111250. */
  111251. disableEdgesRendering(): AbstractMesh;
  111252. /**
  111253. * Enables the edge rendering mode on the mesh.
  111254. * This mode makes the mesh edges visible
  111255. * @param epsilon defines the maximal distance between two angles to detect a face
  111256. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  111257. * @returns the currentAbstractMesh
  111258. * @see https://www.babylonjs-playground.com/#19O9TU#0
  111259. */
  111260. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  111261. /**
  111262. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  111263. * @returns an array of particle systems in the scene that use the mesh as an emitter
  111264. */
  111265. getConnectedParticleSystems(): IParticleSystem[];
  111266. }
  111267. }
  111268. declare module BABYLON {
  111269. /**
  111270. * Interface used to define ActionEvent
  111271. */
  111272. export interface IActionEvent {
  111273. /** The mesh or sprite that triggered the action */
  111274. source: any;
  111275. /** The X mouse cursor position at the time of the event */
  111276. pointerX: number;
  111277. /** The Y mouse cursor position at the time of the event */
  111278. pointerY: number;
  111279. /** The mesh that is currently pointed at (can be null) */
  111280. meshUnderPointer: Nullable<AbstractMesh>;
  111281. /** the original (browser) event that triggered the ActionEvent */
  111282. sourceEvent?: any;
  111283. /** additional data for the event */
  111284. additionalData?: any;
  111285. }
  111286. /**
  111287. * ActionEvent is the event being sent when an action is triggered.
  111288. */
  111289. export class ActionEvent implements IActionEvent {
  111290. /** The mesh or sprite that triggered the action */
  111291. source: any;
  111292. /** The X mouse cursor position at the time of the event */
  111293. pointerX: number;
  111294. /** The Y mouse cursor position at the time of the event */
  111295. pointerY: number;
  111296. /** The mesh that is currently pointed at (can be null) */
  111297. meshUnderPointer: Nullable<AbstractMesh>;
  111298. /** the original (browser) event that triggered the ActionEvent */
  111299. sourceEvent?: any;
  111300. /** additional data for the event */
  111301. additionalData?: any;
  111302. /**
  111303. * Creates a new ActionEvent
  111304. * @param source The mesh or sprite that triggered the action
  111305. * @param pointerX The X mouse cursor position at the time of the event
  111306. * @param pointerY The Y mouse cursor position at the time of the event
  111307. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  111308. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  111309. * @param additionalData additional data for the event
  111310. */
  111311. constructor(
  111312. /** The mesh or sprite that triggered the action */
  111313. source: any,
  111314. /** The X mouse cursor position at the time of the event */
  111315. pointerX: number,
  111316. /** The Y mouse cursor position at the time of the event */
  111317. pointerY: number,
  111318. /** The mesh that is currently pointed at (can be null) */
  111319. meshUnderPointer: Nullable<AbstractMesh>,
  111320. /** the original (browser) event that triggered the ActionEvent */
  111321. sourceEvent?: any,
  111322. /** additional data for the event */
  111323. additionalData?: any);
  111324. /**
  111325. * Helper function to auto-create an ActionEvent from a source mesh.
  111326. * @param source The source mesh that triggered the event
  111327. * @param evt The original (browser) event
  111328. * @param additionalData additional data for the event
  111329. * @returns the new ActionEvent
  111330. */
  111331. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  111332. /**
  111333. * Helper function to auto-create an ActionEvent from a source sprite
  111334. * @param source The source sprite that triggered the event
  111335. * @param scene Scene associated with the sprite
  111336. * @param evt The original (browser) event
  111337. * @param additionalData additional data for the event
  111338. * @returns the new ActionEvent
  111339. */
  111340. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  111341. /**
  111342. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  111343. * @param scene the scene where the event occurred
  111344. * @param evt The original (browser) event
  111345. * @returns the new ActionEvent
  111346. */
  111347. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  111348. /**
  111349. * Helper function to auto-create an ActionEvent from a primitive
  111350. * @param prim defines the target primitive
  111351. * @param pointerPos defines the pointer position
  111352. * @param evt The original (browser) event
  111353. * @param additionalData additional data for the event
  111354. * @returns the new ActionEvent
  111355. */
  111356. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  111357. }
  111358. }
  111359. declare module BABYLON {
  111360. /**
  111361. * Abstract class used to decouple action Manager from scene and meshes.
  111362. * Do not instantiate.
  111363. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  111364. */
  111365. export abstract class AbstractActionManager implements IDisposable {
  111366. /** Gets the list of active triggers */
  111367. static Triggers: {
  111368. [key: string]: number;
  111369. };
  111370. /** Gets the cursor to use when hovering items */
  111371. hoverCursor: string;
  111372. /** Gets the list of actions */
  111373. actions: IAction[];
  111374. /**
  111375. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  111376. */
  111377. isRecursive: boolean;
  111378. /**
  111379. * Releases all associated resources
  111380. */
  111381. abstract dispose(): void;
  111382. /**
  111383. * Does this action manager has pointer triggers
  111384. */
  111385. abstract get hasPointerTriggers(): boolean;
  111386. /**
  111387. * Does this action manager has pick triggers
  111388. */
  111389. abstract get hasPickTriggers(): boolean;
  111390. /**
  111391. * Process a specific trigger
  111392. * @param trigger defines the trigger to process
  111393. * @param evt defines the event details to be processed
  111394. */
  111395. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  111396. /**
  111397. * Does this action manager handles actions of any of the given triggers
  111398. * @param triggers defines the triggers to be tested
  111399. * @return a boolean indicating whether one (or more) of the triggers is handled
  111400. */
  111401. abstract hasSpecificTriggers(triggers: number[]): boolean;
  111402. /**
  111403. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  111404. * speed.
  111405. * @param triggerA defines the trigger to be tested
  111406. * @param triggerB defines the trigger to be tested
  111407. * @return a boolean indicating whether one (or more) of the triggers is handled
  111408. */
  111409. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  111410. /**
  111411. * Does this action manager handles actions of a given trigger
  111412. * @param trigger defines the trigger to be tested
  111413. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  111414. * @return whether the trigger is handled
  111415. */
  111416. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  111417. /**
  111418. * Serialize this manager to a JSON object
  111419. * @param name defines the property name to store this manager
  111420. * @returns a JSON representation of this manager
  111421. */
  111422. abstract serialize(name: string): any;
  111423. /**
  111424. * Registers an action to this action manager
  111425. * @param action defines the action to be registered
  111426. * @return the action amended (prepared) after registration
  111427. */
  111428. abstract registerAction(action: IAction): Nullable<IAction>;
  111429. /**
  111430. * Unregisters an action to this action manager
  111431. * @param action defines the action to be unregistered
  111432. * @return a boolean indicating whether the action has been unregistered
  111433. */
  111434. abstract unregisterAction(action: IAction): Boolean;
  111435. /**
  111436. * Does exist one action manager with at least one trigger
  111437. **/
  111438. static get HasTriggers(): boolean;
  111439. /**
  111440. * Does exist one action manager with at least one pick trigger
  111441. **/
  111442. static get HasPickTriggers(): boolean;
  111443. /**
  111444. * Does exist one action manager that handles actions of a given trigger
  111445. * @param trigger defines the trigger to be tested
  111446. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  111447. **/
  111448. static HasSpecificTrigger(trigger: number): boolean;
  111449. }
  111450. }
  111451. declare module BABYLON {
  111452. /**
  111453. * Defines how a node can be built from a string name.
  111454. */
  111455. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  111456. /**
  111457. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  111458. */
  111459. export class Node implements IBehaviorAware<Node> {
  111460. /** @hidden */
  111461. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  111462. private static _NodeConstructors;
  111463. /**
  111464. * Add a new node constructor
  111465. * @param type defines the type name of the node to construct
  111466. * @param constructorFunc defines the constructor function
  111467. */
  111468. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  111469. /**
  111470. * Returns a node constructor based on type name
  111471. * @param type defines the type name
  111472. * @param name defines the new node name
  111473. * @param scene defines the hosting scene
  111474. * @param options defines optional options to transmit to constructors
  111475. * @returns the new constructor or null
  111476. */
  111477. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  111478. /**
  111479. * Gets or sets the name of the node
  111480. */
  111481. name: string;
  111482. /**
  111483. * Gets or sets the id of the node
  111484. */
  111485. id: string;
  111486. /**
  111487. * Gets or sets the unique id of the node
  111488. */
  111489. uniqueId: number;
  111490. /**
  111491. * Gets or sets a string used to store user defined state for the node
  111492. */
  111493. state: string;
  111494. /**
  111495. * Gets or sets an object used to store user defined information for the node
  111496. */
  111497. metadata: any;
  111498. /**
  111499. * For internal use only. Please do not use.
  111500. */
  111501. reservedDataStore: any;
  111502. /**
  111503. * List of inspectable custom properties (used by the Inspector)
  111504. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  111505. */
  111506. inspectableCustomProperties: IInspectable[];
  111507. private _doNotSerialize;
  111508. /**
  111509. * Gets or sets a boolean used to define if the node must be serialized
  111510. */
  111511. get doNotSerialize(): boolean;
  111512. set doNotSerialize(value: boolean);
  111513. /** @hidden */
  111514. _isDisposed: boolean;
  111515. /**
  111516. * Gets a list of Animations associated with the node
  111517. */
  111518. animations: Animation[];
  111519. protected _ranges: {
  111520. [name: string]: Nullable<AnimationRange>;
  111521. };
  111522. /**
  111523. * Callback raised when the node is ready to be used
  111524. */
  111525. onReady: Nullable<(node: Node) => void>;
  111526. private _isEnabled;
  111527. private _isParentEnabled;
  111528. private _isReady;
  111529. /** @hidden */
  111530. _currentRenderId: number;
  111531. private _parentUpdateId;
  111532. /** @hidden */
  111533. _childUpdateId: number;
  111534. /** @hidden */
  111535. _waitingParentId: Nullable<string>;
  111536. /** @hidden */
  111537. _scene: Scene;
  111538. /** @hidden */
  111539. _cache: any;
  111540. private _parentNode;
  111541. private _children;
  111542. /** @hidden */
  111543. _worldMatrix: Matrix;
  111544. /** @hidden */
  111545. _worldMatrixDeterminant: number;
  111546. /** @hidden */
  111547. _worldMatrixDeterminantIsDirty: boolean;
  111548. /** @hidden */
  111549. private _sceneRootNodesIndex;
  111550. /**
  111551. * Gets a boolean indicating if the node has been disposed
  111552. * @returns true if the node was disposed
  111553. */
  111554. isDisposed(): boolean;
  111555. /**
  111556. * Gets or sets the parent of the node (without keeping the current position in the scene)
  111557. * @see https://doc.babylonjs.com/how_to/parenting
  111558. */
  111559. set parent(parent: Nullable<Node>);
  111560. get parent(): Nullable<Node>;
  111561. /** @hidden */
  111562. _addToSceneRootNodes(): void;
  111563. /** @hidden */
  111564. _removeFromSceneRootNodes(): void;
  111565. private _animationPropertiesOverride;
  111566. /**
  111567. * Gets or sets the animation properties override
  111568. */
  111569. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111570. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111571. /**
  111572. * Gets a string idenfifying the name of the class
  111573. * @returns "Node" string
  111574. */
  111575. getClassName(): string;
  111576. /** @hidden */
  111577. readonly _isNode: boolean;
  111578. /**
  111579. * An event triggered when the mesh is disposed
  111580. */
  111581. onDisposeObservable: Observable<Node>;
  111582. private _onDisposeObserver;
  111583. /**
  111584. * Sets a callback that will be raised when the node will be disposed
  111585. */
  111586. set onDispose(callback: () => void);
  111587. /**
  111588. * Creates a new Node
  111589. * @param name the name and id to be given to this node
  111590. * @param scene the scene this node will be added to
  111591. */
  111592. constructor(name: string, scene?: Nullable<Scene>);
  111593. /**
  111594. * Gets the scene of the node
  111595. * @returns a scene
  111596. */
  111597. getScene(): Scene;
  111598. /**
  111599. * Gets the engine of the node
  111600. * @returns a Engine
  111601. */
  111602. getEngine(): Engine;
  111603. private _behaviors;
  111604. /**
  111605. * Attach a behavior to the node
  111606. * @see https://doc.babylonjs.com/features/behaviour
  111607. * @param behavior defines the behavior to attach
  111608. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  111609. * @returns the current Node
  111610. */
  111611. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  111612. /**
  111613. * Remove an attached behavior
  111614. * @see https://doc.babylonjs.com/features/behaviour
  111615. * @param behavior defines the behavior to attach
  111616. * @returns the current Node
  111617. */
  111618. removeBehavior(behavior: Behavior<Node>): Node;
  111619. /**
  111620. * Gets the list of attached behaviors
  111621. * @see https://doc.babylonjs.com/features/behaviour
  111622. */
  111623. get behaviors(): Behavior<Node>[];
  111624. /**
  111625. * Gets an attached behavior by name
  111626. * @param name defines the name of the behavior to look for
  111627. * @see https://doc.babylonjs.com/features/behaviour
  111628. * @returns null if behavior was not found else the requested behavior
  111629. */
  111630. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  111631. /**
  111632. * Returns the latest update of the World matrix
  111633. * @returns a Matrix
  111634. */
  111635. getWorldMatrix(): Matrix;
  111636. /** @hidden */
  111637. _getWorldMatrixDeterminant(): number;
  111638. /**
  111639. * Returns directly the latest state of the mesh World matrix.
  111640. * A Matrix is returned.
  111641. */
  111642. get worldMatrixFromCache(): Matrix;
  111643. /** @hidden */
  111644. _initCache(): void;
  111645. /** @hidden */
  111646. updateCache(force?: boolean): void;
  111647. /** @hidden */
  111648. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  111649. /** @hidden */
  111650. _updateCache(ignoreParentClass?: boolean): void;
  111651. /** @hidden */
  111652. _isSynchronized(): boolean;
  111653. /** @hidden */
  111654. _markSyncedWithParent(): void;
  111655. /** @hidden */
  111656. isSynchronizedWithParent(): boolean;
  111657. /** @hidden */
  111658. isSynchronized(): boolean;
  111659. /**
  111660. * Is this node ready to be used/rendered
  111661. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  111662. * @return true if the node is ready
  111663. */
  111664. isReady(completeCheck?: boolean): boolean;
  111665. /**
  111666. * Is this node enabled?
  111667. * 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
  111668. * @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
  111669. * @return whether this node (and its parent) is enabled
  111670. */
  111671. isEnabled(checkAncestors?: boolean): boolean;
  111672. /** @hidden */
  111673. protected _syncParentEnabledState(): void;
  111674. /**
  111675. * Set the enabled state of this node
  111676. * @param value defines the new enabled state
  111677. */
  111678. setEnabled(value: boolean): void;
  111679. /**
  111680. * Is this node a descendant of the given node?
  111681. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  111682. * @param ancestor defines the parent node to inspect
  111683. * @returns a boolean indicating if this node is a descendant of the given node
  111684. */
  111685. isDescendantOf(ancestor: Node): boolean;
  111686. /** @hidden */
  111687. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  111688. /**
  111689. * Will return all nodes that have this node as ascendant
  111690. * @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
  111691. * @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
  111692. * @return all children nodes of all types
  111693. */
  111694. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  111695. /**
  111696. * Get all child-meshes of this node
  111697. * @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)
  111698. * @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
  111699. * @returns an array of AbstractMesh
  111700. */
  111701. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  111702. /**
  111703. * Get all direct children of this node
  111704. * @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
  111705. * @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)
  111706. * @returns an array of Node
  111707. */
  111708. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  111709. /** @hidden */
  111710. _setReady(state: boolean): void;
  111711. /**
  111712. * Get an animation by name
  111713. * @param name defines the name of the animation to look for
  111714. * @returns null if not found else the requested animation
  111715. */
  111716. getAnimationByName(name: string): Nullable<Animation>;
  111717. /**
  111718. * Creates an animation range for this node
  111719. * @param name defines the name of the range
  111720. * @param from defines the starting key
  111721. * @param to defines the end key
  111722. */
  111723. createAnimationRange(name: string, from: number, to: number): void;
  111724. /**
  111725. * Delete a specific animation range
  111726. * @param name defines the name of the range to delete
  111727. * @param deleteFrames defines if animation frames from the range must be deleted as well
  111728. */
  111729. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  111730. /**
  111731. * Get an animation range by name
  111732. * @param name defines the name of the animation range to look for
  111733. * @returns null if not found else the requested animation range
  111734. */
  111735. getAnimationRange(name: string): Nullable<AnimationRange>;
  111736. /**
  111737. * Gets the list of all animation ranges defined on this node
  111738. * @returns an array
  111739. */
  111740. getAnimationRanges(): Nullable<AnimationRange>[];
  111741. /**
  111742. * Will start the animation sequence
  111743. * @param name defines the range frames for animation sequence
  111744. * @param loop defines if the animation should loop (false by default)
  111745. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  111746. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  111747. * @returns the object created for this animation. If range does not exist, it will return null
  111748. */
  111749. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  111750. /**
  111751. * Serialize animation ranges into a JSON compatible object
  111752. * @returns serialization object
  111753. */
  111754. serializeAnimationRanges(): any;
  111755. /**
  111756. * Computes the world matrix of the node
  111757. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  111758. * @returns the world matrix
  111759. */
  111760. computeWorldMatrix(force?: boolean): Matrix;
  111761. /**
  111762. * Releases resources associated with this node.
  111763. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111764. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111765. */
  111766. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111767. /**
  111768. * Parse animation range data from a serialization object and store them into a given node
  111769. * @param node defines where to store the animation ranges
  111770. * @param parsedNode defines the serialization object to read data from
  111771. * @param scene defines the hosting scene
  111772. */
  111773. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  111774. /**
  111775. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  111776. * @param includeDescendants Include bounding info from descendants as well (true by default)
  111777. * @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
  111778. * @returns the new bounding vectors
  111779. */
  111780. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  111781. min: Vector3;
  111782. max: Vector3;
  111783. };
  111784. }
  111785. }
  111786. declare module BABYLON {
  111787. /**
  111788. * @hidden
  111789. */
  111790. export class _IAnimationState {
  111791. key: number;
  111792. repeatCount: number;
  111793. workValue?: any;
  111794. loopMode?: number;
  111795. offsetValue?: any;
  111796. highLimitValue?: any;
  111797. }
  111798. /**
  111799. * Class used to store any kind of animation
  111800. */
  111801. export class Animation {
  111802. /**Name of the animation */
  111803. name: string;
  111804. /**Property to animate */
  111805. targetProperty: string;
  111806. /**The frames per second of the animation */
  111807. framePerSecond: number;
  111808. /**The data type of the animation */
  111809. dataType: number;
  111810. /**The loop mode of the animation */
  111811. loopMode?: number | undefined;
  111812. /**Specifies if blending should be enabled */
  111813. enableBlending?: boolean | undefined;
  111814. /**
  111815. * Use matrix interpolation instead of using direct key value when animating matrices
  111816. */
  111817. static AllowMatricesInterpolation: boolean;
  111818. /**
  111819. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  111820. */
  111821. static AllowMatrixDecomposeForInterpolation: boolean;
  111822. /** Define the Url to load snippets */
  111823. static SnippetUrl: string;
  111824. /** Snippet ID if the animation was created from the snippet server */
  111825. snippetId: string;
  111826. /**
  111827. * Stores the key frames of the animation
  111828. */
  111829. private _keys;
  111830. /**
  111831. * Stores the easing function of the animation
  111832. */
  111833. private _easingFunction;
  111834. /**
  111835. * @hidden Internal use only
  111836. */
  111837. _runtimeAnimations: RuntimeAnimation[];
  111838. /**
  111839. * The set of event that will be linked to this animation
  111840. */
  111841. private _events;
  111842. /**
  111843. * Stores an array of target property paths
  111844. */
  111845. targetPropertyPath: string[];
  111846. /**
  111847. * Stores the blending speed of the animation
  111848. */
  111849. blendingSpeed: number;
  111850. /**
  111851. * Stores the animation ranges for the animation
  111852. */
  111853. private _ranges;
  111854. /**
  111855. * @hidden Internal use
  111856. */
  111857. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  111858. /**
  111859. * Sets up an animation
  111860. * @param property The property to animate
  111861. * @param animationType The animation type to apply
  111862. * @param framePerSecond The frames per second of the animation
  111863. * @param easingFunction The easing function used in the animation
  111864. * @returns The created animation
  111865. */
  111866. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  111867. /**
  111868. * Create and start an animation on a node
  111869. * @param name defines the name of the global animation that will be run on all nodes
  111870. * @param node defines the root node where the animation will take place
  111871. * @param targetProperty defines property to animate
  111872. * @param framePerSecond defines the number of frame per second yo use
  111873. * @param totalFrame defines the number of frames in total
  111874. * @param from defines the initial value
  111875. * @param to defines the final value
  111876. * @param loopMode defines which loop mode you want to use (off by default)
  111877. * @param easingFunction defines the easing function to use (linear by default)
  111878. * @param onAnimationEnd defines the callback to call when animation end
  111879. * @returns the animatable created for this animation
  111880. */
  111881. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  111882. /**
  111883. * Create and start an animation on a node and its descendants
  111884. * @param name defines the name of the global animation that will be run on all nodes
  111885. * @param node defines the root node where the animation will take place
  111886. * @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
  111887. * @param targetProperty defines property to animate
  111888. * @param framePerSecond defines the number of frame per second to use
  111889. * @param totalFrame defines the number of frames in total
  111890. * @param from defines the initial value
  111891. * @param to defines the final value
  111892. * @param loopMode defines which loop mode you want to use (off by default)
  111893. * @param easingFunction defines the easing function to use (linear by default)
  111894. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  111895. * @returns the list of animatables created for all nodes
  111896. * @example https://www.babylonjs-playground.com/#MH0VLI
  111897. */
  111898. 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[]>;
  111899. /**
  111900. * Creates a new animation, merges it with the existing animations and starts it
  111901. * @param name Name of the animation
  111902. * @param node Node which contains the scene that begins the animations
  111903. * @param targetProperty Specifies which property to animate
  111904. * @param framePerSecond The frames per second of the animation
  111905. * @param totalFrame The total number of frames
  111906. * @param from The frame at the beginning of the animation
  111907. * @param to The frame at the end of the animation
  111908. * @param loopMode Specifies the loop mode of the animation
  111909. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  111910. * @param onAnimationEnd Callback to run once the animation is complete
  111911. * @returns Nullable animation
  111912. */
  111913. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  111914. /**
  111915. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  111916. * @param sourceAnimation defines the Animation containing keyframes to convert
  111917. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  111918. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  111919. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  111920. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  111921. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  111922. */
  111923. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  111924. /**
  111925. * Transition property of an host to the target Value
  111926. * @param property The property to transition
  111927. * @param targetValue The target Value of the property
  111928. * @param host The object where the property to animate belongs
  111929. * @param scene Scene used to run the animation
  111930. * @param frameRate Framerate (in frame/s) to use
  111931. * @param transition The transition type we want to use
  111932. * @param duration The duration of the animation, in milliseconds
  111933. * @param onAnimationEnd Callback trigger at the end of the animation
  111934. * @returns Nullable animation
  111935. */
  111936. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  111937. /**
  111938. * Return the array of runtime animations currently using this animation
  111939. */
  111940. get runtimeAnimations(): RuntimeAnimation[];
  111941. /**
  111942. * Specifies if any of the runtime animations are currently running
  111943. */
  111944. get hasRunningRuntimeAnimations(): boolean;
  111945. /**
  111946. * Initializes the animation
  111947. * @param name Name of the animation
  111948. * @param targetProperty Property to animate
  111949. * @param framePerSecond The frames per second of the animation
  111950. * @param dataType The data type of the animation
  111951. * @param loopMode The loop mode of the animation
  111952. * @param enableBlending Specifies if blending should be enabled
  111953. */
  111954. constructor(
  111955. /**Name of the animation */
  111956. name: string,
  111957. /**Property to animate */
  111958. targetProperty: string,
  111959. /**The frames per second of the animation */
  111960. framePerSecond: number,
  111961. /**The data type of the animation */
  111962. dataType: number,
  111963. /**The loop mode of the animation */
  111964. loopMode?: number | undefined,
  111965. /**Specifies if blending should be enabled */
  111966. enableBlending?: boolean | undefined);
  111967. /**
  111968. * Converts the animation to a string
  111969. * @param fullDetails support for multiple levels of logging within scene loading
  111970. * @returns String form of the animation
  111971. */
  111972. toString(fullDetails?: boolean): string;
  111973. /**
  111974. * Add an event to this animation
  111975. * @param event Event to add
  111976. */
  111977. addEvent(event: AnimationEvent): void;
  111978. /**
  111979. * Remove all events found at the given frame
  111980. * @param frame The frame to remove events from
  111981. */
  111982. removeEvents(frame: number): void;
  111983. /**
  111984. * Retrieves all the events from the animation
  111985. * @returns Events from the animation
  111986. */
  111987. getEvents(): AnimationEvent[];
  111988. /**
  111989. * Creates an animation range
  111990. * @param name Name of the animation range
  111991. * @param from Starting frame of the animation range
  111992. * @param to Ending frame of the animation
  111993. */
  111994. createRange(name: string, from: number, to: number): void;
  111995. /**
  111996. * Deletes an animation range by name
  111997. * @param name Name of the animation range to delete
  111998. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  111999. */
  112000. deleteRange(name: string, deleteFrames?: boolean): void;
  112001. /**
  112002. * Gets the animation range by name, or null if not defined
  112003. * @param name Name of the animation range
  112004. * @returns Nullable animation range
  112005. */
  112006. getRange(name: string): Nullable<AnimationRange>;
  112007. /**
  112008. * Gets the key frames from the animation
  112009. * @returns The key frames of the animation
  112010. */
  112011. getKeys(): Array<IAnimationKey>;
  112012. /**
  112013. * Gets the highest frame rate of the animation
  112014. * @returns Highest frame rate of the animation
  112015. */
  112016. getHighestFrame(): number;
  112017. /**
  112018. * Gets the easing function of the animation
  112019. * @returns Easing function of the animation
  112020. */
  112021. getEasingFunction(): IEasingFunction;
  112022. /**
  112023. * Sets the easing function of the animation
  112024. * @param easingFunction A custom mathematical formula for animation
  112025. */
  112026. setEasingFunction(easingFunction: EasingFunction): void;
  112027. /**
  112028. * Interpolates a scalar linearly
  112029. * @param startValue Start value of the animation curve
  112030. * @param endValue End value of the animation curve
  112031. * @param gradient Scalar amount to interpolate
  112032. * @returns Interpolated scalar value
  112033. */
  112034. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  112035. /**
  112036. * Interpolates a scalar cubically
  112037. * @param startValue Start value of the animation curve
  112038. * @param outTangent End tangent of the animation
  112039. * @param endValue End value of the animation curve
  112040. * @param inTangent Start tangent of the animation curve
  112041. * @param gradient Scalar amount to interpolate
  112042. * @returns Interpolated scalar value
  112043. */
  112044. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  112045. /**
  112046. * Interpolates a quaternion using a spherical linear interpolation
  112047. * @param startValue Start value of the animation curve
  112048. * @param endValue End value of the animation curve
  112049. * @param gradient Scalar amount to interpolate
  112050. * @returns Interpolated quaternion value
  112051. */
  112052. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  112053. /**
  112054. * Interpolates a quaternion cubically
  112055. * @param startValue Start value of the animation curve
  112056. * @param outTangent End tangent of the animation curve
  112057. * @param endValue End value of the animation curve
  112058. * @param inTangent Start tangent of the animation curve
  112059. * @param gradient Scalar amount to interpolate
  112060. * @returns Interpolated quaternion value
  112061. */
  112062. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  112063. /**
  112064. * Interpolates a Vector3 linearl
  112065. * @param startValue Start value of the animation curve
  112066. * @param endValue End value of the animation curve
  112067. * @param gradient Scalar amount to interpolate
  112068. * @returns Interpolated scalar value
  112069. */
  112070. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  112071. /**
  112072. * Interpolates a Vector3 cubically
  112073. * @param startValue Start value of the animation curve
  112074. * @param outTangent End tangent of the animation
  112075. * @param endValue End value of the animation curve
  112076. * @param inTangent Start tangent of the animation curve
  112077. * @param gradient Scalar amount to interpolate
  112078. * @returns InterpolatedVector3 value
  112079. */
  112080. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  112081. /**
  112082. * Interpolates a Vector2 linearly
  112083. * @param startValue Start value of the animation curve
  112084. * @param endValue End value of the animation curve
  112085. * @param gradient Scalar amount to interpolate
  112086. * @returns Interpolated Vector2 value
  112087. */
  112088. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  112089. /**
  112090. * Interpolates a Vector2 cubically
  112091. * @param startValue Start value of the animation curve
  112092. * @param outTangent End tangent of the animation
  112093. * @param endValue End value of the animation curve
  112094. * @param inTangent Start tangent of the animation curve
  112095. * @param gradient Scalar amount to interpolate
  112096. * @returns Interpolated Vector2 value
  112097. */
  112098. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  112099. /**
  112100. * Interpolates a size linearly
  112101. * @param startValue Start value of the animation curve
  112102. * @param endValue End value of the animation curve
  112103. * @param gradient Scalar amount to interpolate
  112104. * @returns Interpolated Size value
  112105. */
  112106. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  112107. /**
  112108. * Interpolates a Color3 linearly
  112109. * @param startValue Start value of the animation curve
  112110. * @param endValue End value of the animation curve
  112111. * @param gradient Scalar amount to interpolate
  112112. * @returns Interpolated Color3 value
  112113. */
  112114. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  112115. /**
  112116. * Interpolates a Color4 linearly
  112117. * @param startValue Start value of the animation curve
  112118. * @param endValue End value of the animation curve
  112119. * @param gradient Scalar amount to interpolate
  112120. * @returns Interpolated Color3 value
  112121. */
  112122. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  112123. /**
  112124. * @hidden Internal use only
  112125. */
  112126. _getKeyValue(value: any): any;
  112127. /**
  112128. * @hidden Internal use only
  112129. */
  112130. _interpolate(currentFrame: number, state: _IAnimationState): any;
  112131. /**
  112132. * Defines the function to use to interpolate matrices
  112133. * @param startValue defines the start matrix
  112134. * @param endValue defines the end matrix
  112135. * @param gradient defines the gradient between both matrices
  112136. * @param result defines an optional target matrix where to store the interpolation
  112137. * @returns the interpolated matrix
  112138. */
  112139. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  112140. /**
  112141. * Makes a copy of the animation
  112142. * @returns Cloned animation
  112143. */
  112144. clone(): Animation;
  112145. /**
  112146. * Sets the key frames of the animation
  112147. * @param values The animation key frames to set
  112148. */
  112149. setKeys(values: Array<IAnimationKey>): void;
  112150. /**
  112151. * Serializes the animation to an object
  112152. * @returns Serialized object
  112153. */
  112154. serialize(): any;
  112155. /**
  112156. * Float animation type
  112157. */
  112158. static readonly ANIMATIONTYPE_FLOAT: number;
  112159. /**
  112160. * Vector3 animation type
  112161. */
  112162. static readonly ANIMATIONTYPE_VECTOR3: number;
  112163. /**
  112164. * Quaternion animation type
  112165. */
  112166. static readonly ANIMATIONTYPE_QUATERNION: number;
  112167. /**
  112168. * Matrix animation type
  112169. */
  112170. static readonly ANIMATIONTYPE_MATRIX: number;
  112171. /**
  112172. * Color3 animation type
  112173. */
  112174. static readonly ANIMATIONTYPE_COLOR3: number;
  112175. /**
  112176. * Color3 animation type
  112177. */
  112178. static readonly ANIMATIONTYPE_COLOR4: number;
  112179. /**
  112180. * Vector2 animation type
  112181. */
  112182. static readonly ANIMATIONTYPE_VECTOR2: number;
  112183. /**
  112184. * Size animation type
  112185. */
  112186. static readonly ANIMATIONTYPE_SIZE: number;
  112187. /**
  112188. * Relative Loop Mode
  112189. */
  112190. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  112191. /**
  112192. * Cycle Loop Mode
  112193. */
  112194. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  112195. /**
  112196. * Constant Loop Mode
  112197. */
  112198. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  112199. /** @hidden */
  112200. static _UniversalLerp(left: any, right: any, amount: number): any;
  112201. /**
  112202. * Parses an animation object and creates an animation
  112203. * @param parsedAnimation Parsed animation object
  112204. * @returns Animation object
  112205. */
  112206. static Parse(parsedAnimation: any): Animation;
  112207. /**
  112208. * Appends the serialized animations from the source animations
  112209. * @param source Source containing the animations
  112210. * @param destination Target to store the animations
  112211. */
  112212. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  112213. /**
  112214. * Creates a new animation or an array of animations from a snippet saved in a remote file
  112215. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  112216. * @param url defines the url to load from
  112217. * @returns a promise that will resolve to the new animation or an array of animations
  112218. */
  112219. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  112220. /**
  112221. * Creates an animation or an array of animations from a snippet saved by the Inspector
  112222. * @param snippetId defines the snippet to load
  112223. * @returns a promise that will resolve to the new animation or a new array of animations
  112224. */
  112225. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  112226. }
  112227. }
  112228. declare module BABYLON {
  112229. /**
  112230. * Interface containing an array of animations
  112231. */
  112232. export interface IAnimatable {
  112233. /**
  112234. * Array of animations
  112235. */
  112236. animations: Nullable<Array<Animation>>;
  112237. }
  112238. }
  112239. declare module BABYLON {
  112240. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  112241. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112242. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112243. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112244. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112245. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112246. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112247. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112248. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112249. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112250. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112251. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112252. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112253. /**
  112254. * Decorator used to define property that can be serialized as reference to a camera
  112255. * @param sourceName defines the name of the property to decorate
  112256. */
  112257. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112258. /**
  112259. * Class used to help serialization objects
  112260. */
  112261. export class SerializationHelper {
  112262. /** @hidden */
  112263. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  112264. /** @hidden */
  112265. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  112266. /** @hidden */
  112267. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  112268. /** @hidden */
  112269. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  112270. /**
  112271. * Appends the serialized animations from the source animations
  112272. * @param source Source containing the animations
  112273. * @param destination Target to store the animations
  112274. */
  112275. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  112276. /**
  112277. * Static function used to serialized a specific entity
  112278. * @param entity defines the entity to serialize
  112279. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  112280. * @returns a JSON compatible object representing the serialization of the entity
  112281. */
  112282. static Serialize<T>(entity: T, serializationObject?: any): any;
  112283. /**
  112284. * Creates a new entity from a serialization data object
  112285. * @param creationFunction defines a function used to instanciated the new entity
  112286. * @param source defines the source serialization data
  112287. * @param scene defines the hosting scene
  112288. * @param rootUrl defines the root url for resources
  112289. * @returns a new entity
  112290. */
  112291. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  112292. /**
  112293. * Clones an object
  112294. * @param creationFunction defines the function used to instanciate the new object
  112295. * @param source defines the source object
  112296. * @returns the cloned object
  112297. */
  112298. static Clone<T>(creationFunction: () => T, source: T): T;
  112299. /**
  112300. * Instanciates a new object based on a source one (some data will be shared between both object)
  112301. * @param creationFunction defines the function used to instanciate the new object
  112302. * @param source defines the source object
  112303. * @returns the new object
  112304. */
  112305. static Instanciate<T>(creationFunction: () => T, source: T): T;
  112306. }
  112307. }
  112308. declare module BABYLON {
  112309. /**
  112310. * Base class of all the textures in babylon.
  112311. * It groups all the common properties the materials, post process, lights... might need
  112312. * in order to make a correct use of the texture.
  112313. */
  112314. export class BaseTexture implements IAnimatable {
  112315. /**
  112316. * Default anisotropic filtering level for the application.
  112317. * It is set to 4 as a good tradeoff between perf and quality.
  112318. */
  112319. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  112320. /**
  112321. * Gets or sets the unique id of the texture
  112322. */
  112323. uniqueId: number;
  112324. /**
  112325. * Define the name of the texture.
  112326. */
  112327. name: string;
  112328. /**
  112329. * Gets or sets an object used to store user defined information.
  112330. */
  112331. metadata: any;
  112332. /**
  112333. * For internal use only. Please do not use.
  112334. */
  112335. reservedDataStore: any;
  112336. private _hasAlpha;
  112337. /**
  112338. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  112339. */
  112340. set hasAlpha(value: boolean);
  112341. get hasAlpha(): boolean;
  112342. /**
  112343. * Defines if the alpha value should be determined via the rgb values.
  112344. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  112345. */
  112346. getAlphaFromRGB: boolean;
  112347. /**
  112348. * Intensity or strength of the texture.
  112349. * It is commonly used by materials to fine tune the intensity of the texture
  112350. */
  112351. level: number;
  112352. /**
  112353. * Define the UV chanel to use starting from 0 and defaulting to 0.
  112354. * This is part of the texture as textures usually maps to one uv set.
  112355. */
  112356. coordinatesIndex: number;
  112357. private _coordinatesMode;
  112358. /**
  112359. * How a texture is mapped.
  112360. *
  112361. * | Value | Type | Description |
  112362. * | ----- | ----------------------------------- | ----------- |
  112363. * | 0 | EXPLICIT_MODE | |
  112364. * | 1 | SPHERICAL_MODE | |
  112365. * | 2 | PLANAR_MODE | |
  112366. * | 3 | CUBIC_MODE | |
  112367. * | 4 | PROJECTION_MODE | |
  112368. * | 5 | SKYBOX_MODE | |
  112369. * | 6 | INVCUBIC_MODE | |
  112370. * | 7 | EQUIRECTANGULAR_MODE | |
  112371. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  112372. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  112373. */
  112374. set coordinatesMode(value: number);
  112375. get coordinatesMode(): number;
  112376. /**
  112377. * | Value | Type | Description |
  112378. * | ----- | ------------------ | ----------- |
  112379. * | 0 | CLAMP_ADDRESSMODE | |
  112380. * | 1 | WRAP_ADDRESSMODE | |
  112381. * | 2 | MIRROR_ADDRESSMODE | |
  112382. */
  112383. wrapU: number;
  112384. /**
  112385. * | Value | Type | Description |
  112386. * | ----- | ------------------ | ----------- |
  112387. * | 0 | CLAMP_ADDRESSMODE | |
  112388. * | 1 | WRAP_ADDRESSMODE | |
  112389. * | 2 | MIRROR_ADDRESSMODE | |
  112390. */
  112391. wrapV: number;
  112392. /**
  112393. * | Value | Type | Description |
  112394. * | ----- | ------------------ | ----------- |
  112395. * | 0 | CLAMP_ADDRESSMODE | |
  112396. * | 1 | WRAP_ADDRESSMODE | |
  112397. * | 2 | MIRROR_ADDRESSMODE | |
  112398. */
  112399. wrapR: number;
  112400. /**
  112401. * With compliant hardware and browser (supporting anisotropic filtering)
  112402. * this defines the level of anisotropic filtering in the texture.
  112403. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  112404. */
  112405. anisotropicFilteringLevel: number;
  112406. /**
  112407. * Define if the texture is a cube texture or if false a 2d texture.
  112408. */
  112409. get isCube(): boolean;
  112410. set isCube(value: boolean);
  112411. /**
  112412. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  112413. */
  112414. get is3D(): boolean;
  112415. set is3D(value: boolean);
  112416. /**
  112417. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  112418. */
  112419. get is2DArray(): boolean;
  112420. set is2DArray(value: boolean);
  112421. /**
  112422. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  112423. * HDR texture are usually stored in linear space.
  112424. * This only impacts the PBR and Background materials
  112425. */
  112426. gammaSpace: boolean;
  112427. /**
  112428. * Gets or sets whether or not the texture contains RGBD data.
  112429. */
  112430. get isRGBD(): boolean;
  112431. set isRGBD(value: boolean);
  112432. /**
  112433. * Is Z inverted in the texture (useful in a cube texture).
  112434. */
  112435. invertZ: boolean;
  112436. /**
  112437. * Are mip maps generated for this texture or not.
  112438. */
  112439. get noMipmap(): boolean;
  112440. /**
  112441. * @hidden
  112442. */
  112443. lodLevelInAlpha: boolean;
  112444. /**
  112445. * With prefiltered texture, defined the offset used during the prefiltering steps.
  112446. */
  112447. get lodGenerationOffset(): number;
  112448. set lodGenerationOffset(value: number);
  112449. /**
  112450. * With prefiltered texture, defined the scale used during the prefiltering steps.
  112451. */
  112452. get lodGenerationScale(): number;
  112453. set lodGenerationScale(value: number);
  112454. /**
  112455. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  112456. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  112457. * average roughness values.
  112458. */
  112459. get linearSpecularLOD(): boolean;
  112460. set linearSpecularLOD(value: boolean);
  112461. /**
  112462. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  112463. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  112464. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  112465. */
  112466. get irradianceTexture(): Nullable<BaseTexture>;
  112467. set irradianceTexture(value: Nullable<BaseTexture>);
  112468. /**
  112469. * Define if the texture is a render target.
  112470. */
  112471. isRenderTarget: boolean;
  112472. /**
  112473. * Define the unique id of the texture in the scene.
  112474. */
  112475. get uid(): string;
  112476. /** @hidden */
  112477. _prefiltered: boolean;
  112478. /**
  112479. * Return a string representation of the texture.
  112480. * @returns the texture as a string
  112481. */
  112482. toString(): string;
  112483. /**
  112484. * Get the class name of the texture.
  112485. * @returns "BaseTexture"
  112486. */
  112487. getClassName(): string;
  112488. /**
  112489. * Define the list of animation attached to the texture.
  112490. */
  112491. animations: Animation[];
  112492. /**
  112493. * An event triggered when the texture is disposed.
  112494. */
  112495. onDisposeObservable: Observable<BaseTexture>;
  112496. private _onDisposeObserver;
  112497. /**
  112498. * Callback triggered when the texture has been disposed.
  112499. * Kept for back compatibility, you can use the onDisposeObservable instead.
  112500. */
  112501. set onDispose(callback: () => void);
  112502. /**
  112503. * Define the current state of the loading sequence when in delayed load mode.
  112504. */
  112505. delayLoadState: number;
  112506. private _scene;
  112507. private _engine;
  112508. /** @hidden */
  112509. _texture: Nullable<InternalTexture>;
  112510. private _uid;
  112511. /**
  112512. * Define if the texture is preventinga material to render or not.
  112513. * If not and the texture is not ready, the engine will use a default black texture instead.
  112514. */
  112515. get isBlocking(): boolean;
  112516. /**
  112517. * Instantiates a new BaseTexture.
  112518. * Base class of all the textures in babylon.
  112519. * It groups all the common properties the materials, post process, lights... might need
  112520. * in order to make a correct use of the texture.
  112521. * @param sceneOrEngine Define the scene or engine the texture blongs to
  112522. */
  112523. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  112524. /**
  112525. * Get the scene the texture belongs to.
  112526. * @returns the scene or null if undefined
  112527. */
  112528. getScene(): Nullable<Scene>;
  112529. /** @hidden */
  112530. protected _getEngine(): Nullable<ThinEngine>;
  112531. /**
  112532. * Get the texture transform matrix used to offset tile the texture for istance.
  112533. * @returns the transformation matrix
  112534. */
  112535. getTextureMatrix(): Matrix;
  112536. /**
  112537. * Get the texture reflection matrix used to rotate/transform the reflection.
  112538. * @returns the reflection matrix
  112539. */
  112540. getReflectionTextureMatrix(): Matrix;
  112541. /**
  112542. * Get the underlying lower level texture from Babylon.
  112543. * @returns the insternal texture
  112544. */
  112545. getInternalTexture(): Nullable<InternalTexture>;
  112546. /**
  112547. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  112548. * @returns true if ready or not blocking
  112549. */
  112550. isReadyOrNotBlocking(): boolean;
  112551. /**
  112552. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  112553. * @returns true if fully ready
  112554. */
  112555. isReady(): boolean;
  112556. private _cachedSize;
  112557. /**
  112558. * Get the size of the texture.
  112559. * @returns the texture size.
  112560. */
  112561. getSize(): ISize;
  112562. /**
  112563. * Get the base size of the texture.
  112564. * It can be different from the size if the texture has been resized for POT for instance
  112565. * @returns the base size
  112566. */
  112567. getBaseSize(): ISize;
  112568. /**
  112569. * Update the sampling mode of the texture.
  112570. * Default is Trilinear mode.
  112571. *
  112572. * | Value | Type | Description |
  112573. * | ----- | ------------------ | ----------- |
  112574. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  112575. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  112576. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  112577. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  112578. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  112579. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  112580. * | 7 | NEAREST_LINEAR | |
  112581. * | 8 | NEAREST_NEAREST | |
  112582. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  112583. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  112584. * | 11 | LINEAR_LINEAR | |
  112585. * | 12 | LINEAR_NEAREST | |
  112586. *
  112587. * > _mag_: magnification filter (close to the viewer)
  112588. * > _min_: minification filter (far from the viewer)
  112589. * > _mip_: filter used between mip map levels
  112590. *@param samplingMode Define the new sampling mode of the texture
  112591. */
  112592. updateSamplingMode(samplingMode: number): void;
  112593. /**
  112594. * Scales the texture if is `canRescale()`
  112595. * @param ratio the resize factor we want to use to rescale
  112596. */
  112597. scale(ratio: number): void;
  112598. /**
  112599. * Get if the texture can rescale.
  112600. */
  112601. get canRescale(): boolean;
  112602. /** @hidden */
  112603. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  112604. /** @hidden */
  112605. _rebuild(): void;
  112606. /**
  112607. * Triggers the load sequence in delayed load mode.
  112608. */
  112609. delayLoad(): void;
  112610. /**
  112611. * Clones the texture.
  112612. * @returns the cloned texture
  112613. */
  112614. clone(): Nullable<BaseTexture>;
  112615. /**
  112616. * Get the texture underlying type (INT, FLOAT...)
  112617. */
  112618. get textureType(): number;
  112619. /**
  112620. * Get the texture underlying format (RGB, RGBA...)
  112621. */
  112622. get textureFormat(): number;
  112623. /**
  112624. * Indicates that textures need to be re-calculated for all materials
  112625. */
  112626. protected _markAllSubMeshesAsTexturesDirty(): void;
  112627. /**
  112628. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  112629. * This will returns an RGBA array buffer containing either in values (0-255) or
  112630. * float values (0-1) depending of the underlying buffer type.
  112631. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  112632. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  112633. * @param buffer defines a user defined buffer to fill with data (can be null)
  112634. * @returns The Array buffer containing the pixels data.
  112635. */
  112636. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  112637. /**
  112638. * Release and destroy the underlying lower level texture aka internalTexture.
  112639. */
  112640. releaseInternalTexture(): void;
  112641. /** @hidden */
  112642. get _lodTextureHigh(): Nullable<BaseTexture>;
  112643. /** @hidden */
  112644. get _lodTextureMid(): Nullable<BaseTexture>;
  112645. /** @hidden */
  112646. get _lodTextureLow(): Nullable<BaseTexture>;
  112647. /**
  112648. * Dispose the texture and release its associated resources.
  112649. */
  112650. dispose(): void;
  112651. /**
  112652. * Serialize the texture into a JSON representation that can be parsed later on.
  112653. * @returns the JSON representation of the texture
  112654. */
  112655. serialize(): any;
  112656. /**
  112657. * Helper function to be called back once a list of texture contains only ready textures.
  112658. * @param textures Define the list of textures to wait for
  112659. * @param callback Define the callback triggered once the entire list will be ready
  112660. */
  112661. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  112662. private static _isScene;
  112663. }
  112664. }
  112665. declare module BABYLON {
  112666. /**
  112667. * Options to be used when creating an effect.
  112668. */
  112669. export interface IEffectCreationOptions {
  112670. /**
  112671. * Atrributes that will be used in the shader.
  112672. */
  112673. attributes: string[];
  112674. /**
  112675. * Uniform varible names that will be set in the shader.
  112676. */
  112677. uniformsNames: string[];
  112678. /**
  112679. * Uniform buffer variable names that will be set in the shader.
  112680. */
  112681. uniformBuffersNames: string[];
  112682. /**
  112683. * Sampler texture variable names that will be set in the shader.
  112684. */
  112685. samplers: string[];
  112686. /**
  112687. * Define statements that will be set in the shader.
  112688. */
  112689. defines: any;
  112690. /**
  112691. * Possible fallbacks for this effect to improve performance when needed.
  112692. */
  112693. fallbacks: Nullable<IEffectFallbacks>;
  112694. /**
  112695. * Callback that will be called when the shader is compiled.
  112696. */
  112697. onCompiled: Nullable<(effect: Effect) => void>;
  112698. /**
  112699. * Callback that will be called if an error occurs during shader compilation.
  112700. */
  112701. onError: Nullable<(effect: Effect, errors: string) => void>;
  112702. /**
  112703. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  112704. */
  112705. indexParameters?: any;
  112706. /**
  112707. * Max number of lights that can be used in the shader.
  112708. */
  112709. maxSimultaneousLights?: number;
  112710. /**
  112711. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  112712. */
  112713. transformFeedbackVaryings?: Nullable<string[]>;
  112714. /**
  112715. * 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
  112716. */
  112717. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  112718. /**
  112719. * Is this effect rendering to several color attachments ?
  112720. */
  112721. multiTarget?: boolean;
  112722. }
  112723. /**
  112724. * Effect containing vertex and fragment shader that can be executed on an object.
  112725. */
  112726. export class Effect implements IDisposable {
  112727. /**
  112728. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  112729. */
  112730. static ShadersRepository: string;
  112731. /**
  112732. * Enable logging of the shader code when a compilation error occurs
  112733. */
  112734. static LogShaderCodeOnCompilationError: boolean;
  112735. /**
  112736. * Name of the effect.
  112737. */
  112738. name: any;
  112739. /**
  112740. * String container all the define statements that should be set on the shader.
  112741. */
  112742. defines: string;
  112743. /**
  112744. * Callback that will be called when the shader is compiled.
  112745. */
  112746. onCompiled: Nullable<(effect: Effect) => void>;
  112747. /**
  112748. * Callback that will be called if an error occurs during shader compilation.
  112749. */
  112750. onError: Nullable<(effect: Effect, errors: string) => void>;
  112751. /**
  112752. * Callback that will be called when effect is bound.
  112753. */
  112754. onBind: Nullable<(effect: Effect) => void>;
  112755. /**
  112756. * Unique ID of the effect.
  112757. */
  112758. uniqueId: number;
  112759. /**
  112760. * Observable that will be called when the shader is compiled.
  112761. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  112762. */
  112763. onCompileObservable: Observable<Effect>;
  112764. /**
  112765. * Observable that will be called if an error occurs during shader compilation.
  112766. */
  112767. onErrorObservable: Observable<Effect>;
  112768. /** @hidden */
  112769. _onBindObservable: Nullable<Observable<Effect>>;
  112770. /**
  112771. * @hidden
  112772. * Specifies if the effect was previously ready
  112773. */
  112774. _wasPreviouslyReady: boolean;
  112775. /**
  112776. * Observable that will be called when effect is bound.
  112777. */
  112778. get onBindObservable(): Observable<Effect>;
  112779. /** @hidden */
  112780. _bonesComputationForcedToCPU: boolean;
  112781. /** @hidden */
  112782. _multiTarget: boolean;
  112783. private static _uniqueIdSeed;
  112784. private _engine;
  112785. private _uniformBuffersNames;
  112786. private _uniformBuffersNamesList;
  112787. private _uniformsNames;
  112788. private _samplerList;
  112789. private _samplers;
  112790. private _isReady;
  112791. private _compilationError;
  112792. private _allFallbacksProcessed;
  112793. private _attributesNames;
  112794. private _attributes;
  112795. private _attributeLocationByName;
  112796. private _uniforms;
  112797. /**
  112798. * Key for the effect.
  112799. * @hidden
  112800. */
  112801. _key: string;
  112802. private _indexParameters;
  112803. private _fallbacks;
  112804. private _vertexSourceCode;
  112805. private _fragmentSourceCode;
  112806. private _vertexSourceCodeOverride;
  112807. private _fragmentSourceCodeOverride;
  112808. private _transformFeedbackVaryings;
  112809. /**
  112810. * Compiled shader to webGL program.
  112811. * @hidden
  112812. */
  112813. _pipelineContext: Nullable<IPipelineContext>;
  112814. private _valueCache;
  112815. private static _baseCache;
  112816. /**
  112817. * Instantiates an effect.
  112818. * An effect can be used to create/manage/execute vertex and fragment shaders.
  112819. * @param baseName Name of the effect.
  112820. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  112821. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  112822. * @param samplers List of sampler variables that will be passed to the shader.
  112823. * @param engine Engine to be used to render the effect
  112824. * @param defines Define statements to be added to the shader.
  112825. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  112826. * @param onCompiled Callback that will be called when the shader is compiled.
  112827. * @param onError Callback that will be called if an error occurs during shader compilation.
  112828. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  112829. */
  112830. 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);
  112831. private _useFinalCode;
  112832. /**
  112833. * Unique key for this effect
  112834. */
  112835. get key(): string;
  112836. /**
  112837. * If the effect has been compiled and prepared.
  112838. * @returns if the effect is compiled and prepared.
  112839. */
  112840. isReady(): boolean;
  112841. private _isReadyInternal;
  112842. /**
  112843. * The engine the effect was initialized with.
  112844. * @returns the engine.
  112845. */
  112846. getEngine(): Engine;
  112847. /**
  112848. * The pipeline context for this effect
  112849. * @returns the associated pipeline context
  112850. */
  112851. getPipelineContext(): Nullable<IPipelineContext>;
  112852. /**
  112853. * The set of names of attribute variables for the shader.
  112854. * @returns An array of attribute names.
  112855. */
  112856. getAttributesNames(): string[];
  112857. /**
  112858. * Returns the attribute at the given index.
  112859. * @param index The index of the attribute.
  112860. * @returns The location of the attribute.
  112861. */
  112862. getAttributeLocation(index: number): number;
  112863. /**
  112864. * Returns the attribute based on the name of the variable.
  112865. * @param name of the attribute to look up.
  112866. * @returns the attribute location.
  112867. */
  112868. getAttributeLocationByName(name: string): number;
  112869. /**
  112870. * The number of attributes.
  112871. * @returns the numnber of attributes.
  112872. */
  112873. getAttributesCount(): number;
  112874. /**
  112875. * Gets the index of a uniform variable.
  112876. * @param uniformName of the uniform to look up.
  112877. * @returns the index.
  112878. */
  112879. getUniformIndex(uniformName: string): number;
  112880. /**
  112881. * Returns the attribute based on the name of the variable.
  112882. * @param uniformName of the uniform to look up.
  112883. * @returns the location of the uniform.
  112884. */
  112885. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  112886. /**
  112887. * Returns an array of sampler variable names
  112888. * @returns The array of sampler variable names.
  112889. */
  112890. getSamplers(): string[];
  112891. /**
  112892. * Returns an array of uniform variable names
  112893. * @returns The array of uniform variable names.
  112894. */
  112895. getUniformNames(): string[];
  112896. /**
  112897. * Returns an array of uniform buffer variable names
  112898. * @returns The array of uniform buffer variable names.
  112899. */
  112900. getUniformBuffersNames(): string[];
  112901. /**
  112902. * Returns the index parameters used to create the effect
  112903. * @returns The index parameters object
  112904. */
  112905. getIndexParameters(): any;
  112906. /**
  112907. * The error from the last compilation.
  112908. * @returns the error string.
  112909. */
  112910. getCompilationError(): string;
  112911. /**
  112912. * Gets a boolean indicating that all fallbacks were used during compilation
  112913. * @returns true if all fallbacks were used
  112914. */
  112915. allFallbacksProcessed(): boolean;
  112916. /**
  112917. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  112918. * @param func The callback to be used.
  112919. */
  112920. executeWhenCompiled(func: (effect: Effect) => void): void;
  112921. private _checkIsReady;
  112922. private _loadShader;
  112923. /**
  112924. * Gets the vertex shader source code of this effect
  112925. */
  112926. get vertexSourceCode(): string;
  112927. /**
  112928. * Gets the fragment shader source code of this effect
  112929. */
  112930. get fragmentSourceCode(): string;
  112931. /**
  112932. * Recompiles the webGL program
  112933. * @param vertexSourceCode The source code for the vertex shader.
  112934. * @param fragmentSourceCode The source code for the fragment shader.
  112935. * @param onCompiled Callback called when completed.
  112936. * @param onError Callback called on error.
  112937. * @hidden
  112938. */
  112939. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  112940. /**
  112941. * Prepares the effect
  112942. * @hidden
  112943. */
  112944. _prepareEffect(): void;
  112945. private _getShaderCodeAndErrorLine;
  112946. private _processCompilationErrors;
  112947. /**
  112948. * Checks if the effect is supported. (Must be called after compilation)
  112949. */
  112950. get isSupported(): boolean;
  112951. /**
  112952. * Binds a texture to the engine to be used as output of the shader.
  112953. * @param channel Name of the output variable.
  112954. * @param texture Texture to bind.
  112955. * @hidden
  112956. */
  112957. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  112958. /**
  112959. * Sets a texture on the engine to be used in the shader.
  112960. * @param channel Name of the sampler variable.
  112961. * @param texture Texture to set.
  112962. */
  112963. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  112964. /**
  112965. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  112966. * @param channel Name of the sampler variable.
  112967. * @param texture Texture to set.
  112968. */
  112969. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  112970. /**
  112971. * Sets an array of textures on the engine to be used in the shader.
  112972. * @param channel Name of the variable.
  112973. * @param textures Textures to set.
  112974. */
  112975. setTextureArray(channel: string, textures: BaseTexture[]): void;
  112976. /**
  112977. * 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)
  112978. * @param channel Name of the sampler variable.
  112979. * @param postProcess Post process to get the input texture from.
  112980. */
  112981. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  112982. /**
  112983. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  112984. * 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)
  112985. * @param channel Name of the sampler variable.
  112986. * @param postProcess Post process to get the output texture from.
  112987. */
  112988. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  112989. /** @hidden */
  112990. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  112991. /** @hidden */
  112992. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  112993. /** @hidden */
  112994. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  112995. /** @hidden */
  112996. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  112997. /**
  112998. * Binds a buffer to a uniform.
  112999. * @param buffer Buffer to bind.
  113000. * @param name Name of the uniform variable to bind to.
  113001. */
  113002. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  113003. /**
  113004. * Binds block to a uniform.
  113005. * @param blockName Name of the block to bind.
  113006. * @param index Index to bind.
  113007. */
  113008. bindUniformBlock(blockName: string, index: number): void;
  113009. /**
  113010. * Sets an interger value on a uniform variable.
  113011. * @param uniformName Name of the variable.
  113012. * @param value Value to be set.
  113013. * @returns this effect.
  113014. */
  113015. setInt(uniformName: string, value: number): Effect;
  113016. /**
  113017. * Sets an int array on a uniform variable.
  113018. * @param uniformName Name of the variable.
  113019. * @param array array to be set.
  113020. * @returns this effect.
  113021. */
  113022. setIntArray(uniformName: string, array: Int32Array): Effect;
  113023. /**
  113024. * 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)
  113025. * @param uniformName Name of the variable.
  113026. * @param array array to be set.
  113027. * @returns this effect.
  113028. */
  113029. setIntArray2(uniformName: string, array: Int32Array): Effect;
  113030. /**
  113031. * 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)
  113032. * @param uniformName Name of the variable.
  113033. * @param array array to be set.
  113034. * @returns this effect.
  113035. */
  113036. setIntArray3(uniformName: string, array: Int32Array): Effect;
  113037. /**
  113038. * 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)
  113039. * @param uniformName Name of the variable.
  113040. * @param array array to be set.
  113041. * @returns this effect.
  113042. */
  113043. setIntArray4(uniformName: string, array: Int32Array): Effect;
  113044. /**
  113045. * Sets an float array on a uniform variable.
  113046. * @param uniformName Name of the variable.
  113047. * @param array array to be set.
  113048. * @returns this effect.
  113049. */
  113050. setFloatArray(uniformName: string, array: Float32Array): Effect;
  113051. /**
  113052. * 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)
  113053. * @param uniformName Name of the variable.
  113054. * @param array array to be set.
  113055. * @returns this effect.
  113056. */
  113057. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  113058. /**
  113059. * 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)
  113060. * @param uniformName Name of the variable.
  113061. * @param array array to be set.
  113062. * @returns this effect.
  113063. */
  113064. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  113065. /**
  113066. * 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)
  113067. * @param uniformName Name of the variable.
  113068. * @param array array to be set.
  113069. * @returns this effect.
  113070. */
  113071. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  113072. /**
  113073. * Sets an array on a uniform variable.
  113074. * @param uniformName Name of the variable.
  113075. * @param array array to be set.
  113076. * @returns this effect.
  113077. */
  113078. setArray(uniformName: string, array: number[]): Effect;
  113079. /**
  113080. * 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)
  113081. * @param uniformName Name of the variable.
  113082. * @param array array to be set.
  113083. * @returns this effect.
  113084. */
  113085. setArray2(uniformName: string, array: number[]): Effect;
  113086. /**
  113087. * 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)
  113088. * @param uniformName Name of the variable.
  113089. * @param array array to be set.
  113090. * @returns this effect.
  113091. */
  113092. setArray3(uniformName: string, array: number[]): Effect;
  113093. /**
  113094. * 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)
  113095. * @param uniformName Name of the variable.
  113096. * @param array array to be set.
  113097. * @returns this effect.
  113098. */
  113099. setArray4(uniformName: string, array: number[]): Effect;
  113100. /**
  113101. * Sets matrices on a uniform variable.
  113102. * @param uniformName Name of the variable.
  113103. * @param matrices matrices to be set.
  113104. * @returns this effect.
  113105. */
  113106. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  113107. /**
  113108. * Sets matrix on a uniform variable.
  113109. * @param uniformName Name of the variable.
  113110. * @param matrix matrix to be set.
  113111. * @returns this effect.
  113112. */
  113113. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  113114. /**
  113115. * 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)
  113116. * @param uniformName Name of the variable.
  113117. * @param matrix matrix to be set.
  113118. * @returns this effect.
  113119. */
  113120. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  113121. /**
  113122. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  113123. * @param uniformName Name of the variable.
  113124. * @param matrix matrix to be set.
  113125. * @returns this effect.
  113126. */
  113127. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  113128. /**
  113129. * Sets a float on a uniform variable.
  113130. * @param uniformName Name of the variable.
  113131. * @param value value to be set.
  113132. * @returns this effect.
  113133. */
  113134. setFloat(uniformName: string, value: number): Effect;
  113135. /**
  113136. * Sets a boolean on a uniform variable.
  113137. * @param uniformName Name of the variable.
  113138. * @param bool value to be set.
  113139. * @returns this effect.
  113140. */
  113141. setBool(uniformName: string, bool: boolean): Effect;
  113142. /**
  113143. * Sets a Vector2 on a uniform variable.
  113144. * @param uniformName Name of the variable.
  113145. * @param vector2 vector2 to be set.
  113146. * @returns this effect.
  113147. */
  113148. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  113149. /**
  113150. * Sets a float2 on a uniform variable.
  113151. * @param uniformName Name of the variable.
  113152. * @param x First float in float2.
  113153. * @param y Second float in float2.
  113154. * @returns this effect.
  113155. */
  113156. setFloat2(uniformName: string, x: number, y: number): Effect;
  113157. /**
  113158. * Sets a Vector3 on a uniform variable.
  113159. * @param uniformName Name of the variable.
  113160. * @param vector3 Value to be set.
  113161. * @returns this effect.
  113162. */
  113163. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  113164. /**
  113165. * Sets a float3 on a uniform variable.
  113166. * @param uniformName Name of the variable.
  113167. * @param x First float in float3.
  113168. * @param y Second float in float3.
  113169. * @param z Third float in float3.
  113170. * @returns this effect.
  113171. */
  113172. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  113173. /**
  113174. * Sets a Vector4 on a uniform variable.
  113175. * @param uniformName Name of the variable.
  113176. * @param vector4 Value to be set.
  113177. * @returns this effect.
  113178. */
  113179. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  113180. /**
  113181. * Sets a float4 on a uniform variable.
  113182. * @param uniformName Name of the variable.
  113183. * @param x First float in float4.
  113184. * @param y Second float in float4.
  113185. * @param z Third float in float4.
  113186. * @param w Fourth float in float4.
  113187. * @returns this effect.
  113188. */
  113189. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  113190. /**
  113191. * Sets a Color3 on a uniform variable.
  113192. * @param uniformName Name of the variable.
  113193. * @param color3 Value to be set.
  113194. * @returns this effect.
  113195. */
  113196. setColor3(uniformName: string, color3: IColor3Like): Effect;
  113197. /**
  113198. * Sets a Color4 on a uniform variable.
  113199. * @param uniformName Name of the variable.
  113200. * @param color3 Value to be set.
  113201. * @param alpha Alpha value to be set.
  113202. * @returns this effect.
  113203. */
  113204. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  113205. /**
  113206. * Sets a Color4 on a uniform variable
  113207. * @param uniformName defines the name of the variable
  113208. * @param color4 defines the value to be set
  113209. * @returns this effect.
  113210. */
  113211. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  113212. /** Release all associated resources */
  113213. dispose(): void;
  113214. /**
  113215. * This function will add a new shader to the shader store
  113216. * @param name the name of the shader
  113217. * @param pixelShader optional pixel shader content
  113218. * @param vertexShader optional vertex shader content
  113219. */
  113220. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  113221. /**
  113222. * Store of each shader (The can be looked up using effect.key)
  113223. */
  113224. static ShadersStore: {
  113225. [key: string]: string;
  113226. };
  113227. /**
  113228. * Store of each included file for a shader (The can be looked up using effect.key)
  113229. */
  113230. static IncludesShadersStore: {
  113231. [key: string]: string;
  113232. };
  113233. /**
  113234. * Resets the cache of effects.
  113235. */
  113236. static ResetCache(): void;
  113237. }
  113238. }
  113239. declare module BABYLON {
  113240. /**
  113241. * Interface used to describe the capabilities of the engine relatively to the current browser
  113242. */
  113243. export interface EngineCapabilities {
  113244. /** Maximum textures units per fragment shader */
  113245. maxTexturesImageUnits: number;
  113246. /** Maximum texture units per vertex shader */
  113247. maxVertexTextureImageUnits: number;
  113248. /** Maximum textures units in the entire pipeline */
  113249. maxCombinedTexturesImageUnits: number;
  113250. /** Maximum texture size */
  113251. maxTextureSize: number;
  113252. /** Maximum texture samples */
  113253. maxSamples?: number;
  113254. /** Maximum cube texture size */
  113255. maxCubemapTextureSize: number;
  113256. /** Maximum render texture size */
  113257. maxRenderTextureSize: number;
  113258. /** Maximum number of vertex attributes */
  113259. maxVertexAttribs: number;
  113260. /** Maximum number of varyings */
  113261. maxVaryingVectors: number;
  113262. /** Maximum number of uniforms per vertex shader */
  113263. maxVertexUniformVectors: number;
  113264. /** Maximum number of uniforms per fragment shader */
  113265. maxFragmentUniformVectors: number;
  113266. /** Defines if standard derivates (dx/dy) are supported */
  113267. standardDerivatives: boolean;
  113268. /** Defines if s3tc texture compression is supported */
  113269. s3tc?: WEBGL_compressed_texture_s3tc;
  113270. /** Defines if pvrtc texture compression is supported */
  113271. pvrtc: any;
  113272. /** Defines if etc1 texture compression is supported */
  113273. etc1: any;
  113274. /** Defines if etc2 texture compression is supported */
  113275. etc2: any;
  113276. /** Defines if astc texture compression is supported */
  113277. astc: any;
  113278. /** Defines if float textures are supported */
  113279. textureFloat: boolean;
  113280. /** Defines if vertex array objects are supported */
  113281. vertexArrayObject: boolean;
  113282. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  113283. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  113284. /** Gets the maximum level of anisotropy supported */
  113285. maxAnisotropy: number;
  113286. /** Defines if instancing is supported */
  113287. instancedArrays: boolean;
  113288. /** Defines if 32 bits indices are supported */
  113289. uintIndices: boolean;
  113290. /** Defines if high precision shaders are supported */
  113291. highPrecisionShaderSupported: boolean;
  113292. /** Defines if depth reading in the fragment shader is supported */
  113293. fragmentDepthSupported: boolean;
  113294. /** Defines if float texture linear filtering is supported*/
  113295. textureFloatLinearFiltering: boolean;
  113296. /** Defines if rendering to float textures is supported */
  113297. textureFloatRender: boolean;
  113298. /** Defines if half float textures are supported*/
  113299. textureHalfFloat: boolean;
  113300. /** Defines if half float texture linear filtering is supported*/
  113301. textureHalfFloatLinearFiltering: boolean;
  113302. /** Defines if rendering to half float textures is supported */
  113303. textureHalfFloatRender: boolean;
  113304. /** Defines if textureLOD shader command is supported */
  113305. textureLOD: boolean;
  113306. /** Defines if draw buffers extension is supported */
  113307. drawBuffersExtension: boolean;
  113308. /** Defines if depth textures are supported */
  113309. depthTextureExtension: boolean;
  113310. /** Defines if float color buffer are supported */
  113311. colorBufferFloat: boolean;
  113312. /** Gets disjoint timer query extension (null if not supported) */
  113313. timerQuery?: EXT_disjoint_timer_query;
  113314. /** Defines if timestamp can be used with timer query */
  113315. canUseTimestampForTimerQuery: boolean;
  113316. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  113317. multiview?: any;
  113318. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  113319. oculusMultiview?: any;
  113320. /** Function used to let the system compiles shaders in background */
  113321. parallelShaderCompile?: {
  113322. COMPLETION_STATUS_KHR: number;
  113323. };
  113324. /** Max number of texture samples for MSAA */
  113325. maxMSAASamples: number;
  113326. /** Defines if the blend min max extension is supported */
  113327. blendMinMax: boolean;
  113328. }
  113329. }
  113330. declare module BABYLON {
  113331. /**
  113332. * @hidden
  113333. **/
  113334. export class DepthCullingState {
  113335. private _isDepthTestDirty;
  113336. private _isDepthMaskDirty;
  113337. private _isDepthFuncDirty;
  113338. private _isCullFaceDirty;
  113339. private _isCullDirty;
  113340. private _isZOffsetDirty;
  113341. private _isFrontFaceDirty;
  113342. private _depthTest;
  113343. private _depthMask;
  113344. private _depthFunc;
  113345. private _cull;
  113346. private _cullFace;
  113347. private _zOffset;
  113348. private _frontFace;
  113349. /**
  113350. * Initializes the state.
  113351. */
  113352. constructor();
  113353. get isDirty(): boolean;
  113354. get zOffset(): number;
  113355. set zOffset(value: number);
  113356. get cullFace(): Nullable<number>;
  113357. set cullFace(value: Nullable<number>);
  113358. get cull(): Nullable<boolean>;
  113359. set cull(value: Nullable<boolean>);
  113360. get depthFunc(): Nullable<number>;
  113361. set depthFunc(value: Nullable<number>);
  113362. get depthMask(): boolean;
  113363. set depthMask(value: boolean);
  113364. get depthTest(): boolean;
  113365. set depthTest(value: boolean);
  113366. get frontFace(): Nullable<number>;
  113367. set frontFace(value: Nullable<number>);
  113368. reset(): void;
  113369. apply(gl: WebGLRenderingContext): void;
  113370. }
  113371. }
  113372. declare module BABYLON {
  113373. /**
  113374. * @hidden
  113375. **/
  113376. export class StencilState {
  113377. /** 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 */
  113378. static readonly ALWAYS: number;
  113379. /** Passed to stencilOperation to specify that stencil value must be kept */
  113380. static readonly KEEP: number;
  113381. /** Passed to stencilOperation to specify that stencil value must be replaced */
  113382. static readonly REPLACE: number;
  113383. private _isStencilTestDirty;
  113384. private _isStencilMaskDirty;
  113385. private _isStencilFuncDirty;
  113386. private _isStencilOpDirty;
  113387. private _stencilTest;
  113388. private _stencilMask;
  113389. private _stencilFunc;
  113390. private _stencilFuncRef;
  113391. private _stencilFuncMask;
  113392. private _stencilOpStencilFail;
  113393. private _stencilOpDepthFail;
  113394. private _stencilOpStencilDepthPass;
  113395. get isDirty(): boolean;
  113396. get stencilFunc(): number;
  113397. set stencilFunc(value: number);
  113398. get stencilFuncRef(): number;
  113399. set stencilFuncRef(value: number);
  113400. get stencilFuncMask(): number;
  113401. set stencilFuncMask(value: number);
  113402. get stencilOpStencilFail(): number;
  113403. set stencilOpStencilFail(value: number);
  113404. get stencilOpDepthFail(): number;
  113405. set stencilOpDepthFail(value: number);
  113406. get stencilOpStencilDepthPass(): number;
  113407. set stencilOpStencilDepthPass(value: number);
  113408. get stencilMask(): number;
  113409. set stencilMask(value: number);
  113410. get stencilTest(): boolean;
  113411. set stencilTest(value: boolean);
  113412. constructor();
  113413. reset(): void;
  113414. apply(gl: WebGLRenderingContext): void;
  113415. }
  113416. }
  113417. declare module BABYLON {
  113418. /**
  113419. * @hidden
  113420. **/
  113421. export class AlphaState {
  113422. private _isAlphaBlendDirty;
  113423. private _isBlendFunctionParametersDirty;
  113424. private _isBlendEquationParametersDirty;
  113425. private _isBlendConstantsDirty;
  113426. private _alphaBlend;
  113427. private _blendFunctionParameters;
  113428. private _blendEquationParameters;
  113429. private _blendConstants;
  113430. /**
  113431. * Initializes the state.
  113432. */
  113433. constructor();
  113434. get isDirty(): boolean;
  113435. get alphaBlend(): boolean;
  113436. set alphaBlend(value: boolean);
  113437. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  113438. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  113439. setAlphaEquationParameters(rgb: number, alpha: number): void;
  113440. reset(): void;
  113441. apply(gl: WebGLRenderingContext): void;
  113442. }
  113443. }
  113444. declare module BABYLON {
  113445. /** @hidden */
  113446. export class WebGL2ShaderProcessor implements IShaderProcessor {
  113447. attributeProcessor(attribute: string): string;
  113448. varyingProcessor(varying: string, isFragment: boolean): string;
  113449. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  113450. }
  113451. }
  113452. declare module BABYLON {
  113453. /**
  113454. * Interface for attribute information associated with buffer instanciation
  113455. */
  113456. export interface InstancingAttributeInfo {
  113457. /**
  113458. * Name of the GLSL attribute
  113459. * if attribute index is not specified, this is used to retrieve the index from the effect
  113460. */
  113461. attributeName: string;
  113462. /**
  113463. * Index/offset of the attribute in the vertex shader
  113464. * if not specified, this will be computes from the name.
  113465. */
  113466. index?: number;
  113467. /**
  113468. * size of the attribute, 1, 2, 3 or 4
  113469. */
  113470. attributeSize: number;
  113471. /**
  113472. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  113473. */
  113474. offset: number;
  113475. /**
  113476. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  113477. * default to 1
  113478. */
  113479. divisor?: number;
  113480. /**
  113481. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  113482. * default is FLOAT
  113483. */
  113484. attributeType?: number;
  113485. /**
  113486. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  113487. */
  113488. normalized?: boolean;
  113489. }
  113490. }
  113491. declare module BABYLON {
  113492. interface ThinEngine {
  113493. /**
  113494. * Update a video texture
  113495. * @param texture defines the texture to update
  113496. * @param video defines the video element to use
  113497. * @param invertY defines if data must be stored with Y axis inverted
  113498. */
  113499. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  113500. }
  113501. }
  113502. declare module BABYLON {
  113503. interface ThinEngine {
  113504. /**
  113505. * Creates a dynamic texture
  113506. * @param width defines the width of the texture
  113507. * @param height defines the height of the texture
  113508. * @param generateMipMaps defines if the engine should generate the mip levels
  113509. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  113510. * @returns the dynamic texture inside an InternalTexture
  113511. */
  113512. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  113513. /**
  113514. * Update the content of a dynamic texture
  113515. * @param texture defines the texture to update
  113516. * @param canvas defines the canvas containing the source
  113517. * @param invertY defines if data must be stored with Y axis inverted
  113518. * @param premulAlpha defines if alpha is stored as premultiplied
  113519. * @param format defines the format of the data
  113520. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  113521. */
  113522. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  113523. }
  113524. }
  113525. declare module BABYLON {
  113526. /**
  113527. * Settings for finer control over video usage
  113528. */
  113529. export interface VideoTextureSettings {
  113530. /**
  113531. * Applies `autoplay` to video, if specified
  113532. */
  113533. autoPlay?: boolean;
  113534. /**
  113535. * Applies `loop` to video, if specified
  113536. */
  113537. loop?: boolean;
  113538. /**
  113539. * Automatically updates internal texture from video at every frame in the render loop
  113540. */
  113541. autoUpdateTexture: boolean;
  113542. /**
  113543. * Image src displayed during the video loading or until the user interacts with the video.
  113544. */
  113545. poster?: string;
  113546. }
  113547. /**
  113548. * If you want to display a video in your scene, this is the special texture for that.
  113549. * This special texture works similar to other textures, with the exception of a few parameters.
  113550. * @see https://doc.babylonjs.com/how_to/video_texture
  113551. */
  113552. export class VideoTexture extends Texture {
  113553. /**
  113554. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  113555. */
  113556. readonly autoUpdateTexture: boolean;
  113557. /**
  113558. * The video instance used by the texture internally
  113559. */
  113560. readonly video: HTMLVideoElement;
  113561. private _onUserActionRequestedObservable;
  113562. /**
  113563. * Event triggerd when a dom action is required by the user to play the video.
  113564. * This happens due to recent changes in browser policies preventing video to auto start.
  113565. */
  113566. get onUserActionRequestedObservable(): Observable<Texture>;
  113567. private _generateMipMaps;
  113568. private _stillImageCaptured;
  113569. private _displayingPosterTexture;
  113570. private _settings;
  113571. private _createInternalTextureOnEvent;
  113572. private _frameId;
  113573. private _currentSrc;
  113574. /**
  113575. * Creates a video texture.
  113576. * If you want to display a video in your scene, this is the special texture for that.
  113577. * This special texture works similar to other textures, with the exception of a few parameters.
  113578. * @see https://doc.babylonjs.com/how_to/video_texture
  113579. * @param name optional name, will detect from video source, if not defined
  113580. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  113581. * @param scene is obviously the current scene.
  113582. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  113583. * @param invertY is false by default but can be used to invert video on Y axis
  113584. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  113585. * @param settings allows finer control over video usage
  113586. */
  113587. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  113588. private _getName;
  113589. private _getVideo;
  113590. private _createInternalTexture;
  113591. private reset;
  113592. /**
  113593. * @hidden Internal method to initiate `update`.
  113594. */
  113595. _rebuild(): void;
  113596. /**
  113597. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  113598. */
  113599. update(): void;
  113600. /**
  113601. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  113602. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  113603. */
  113604. updateTexture(isVisible: boolean): void;
  113605. protected _updateInternalTexture: () => void;
  113606. /**
  113607. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  113608. * @param url New url.
  113609. */
  113610. updateURL(url: string): void;
  113611. /**
  113612. * Clones the texture.
  113613. * @returns the cloned texture
  113614. */
  113615. clone(): VideoTexture;
  113616. /**
  113617. * Dispose the texture and release its associated resources.
  113618. */
  113619. dispose(): void;
  113620. /**
  113621. * Creates a video texture straight from a stream.
  113622. * @param scene Define the scene the texture should be created in
  113623. * @param stream Define the stream the texture should be created from
  113624. * @returns The created video texture as a promise
  113625. */
  113626. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  113627. /**
  113628. * Creates a video texture straight from your WebCam video feed.
  113629. * @param scene Define the scene the texture should be created in
  113630. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  113631. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  113632. * @returns The created video texture as a promise
  113633. */
  113634. static CreateFromWebCamAsync(scene: Scene, constraints: {
  113635. minWidth: number;
  113636. maxWidth: number;
  113637. minHeight: number;
  113638. maxHeight: number;
  113639. deviceId: string;
  113640. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  113641. /**
  113642. * Creates a video texture straight from your WebCam video feed.
  113643. * @param scene Define the scene the texture should be created in
  113644. * @param onReady Define a callback to triggered once the texture will be ready
  113645. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  113646. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  113647. */
  113648. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  113649. minWidth: number;
  113650. maxWidth: number;
  113651. minHeight: number;
  113652. maxHeight: number;
  113653. deviceId: string;
  113654. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  113655. }
  113656. }
  113657. declare module BABYLON {
  113658. /**
  113659. * Defines the interface used by objects working like Scene
  113660. * @hidden
  113661. */
  113662. export interface ISceneLike {
  113663. _addPendingData(data: any): void;
  113664. _removePendingData(data: any): void;
  113665. offlineProvider: IOfflineProvider;
  113666. }
  113667. /** Interface defining initialization parameters for Engine class */
  113668. export interface EngineOptions extends WebGLContextAttributes {
  113669. /**
  113670. * Defines if the engine should no exceed a specified device ratio
  113671. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  113672. */
  113673. limitDeviceRatio?: number;
  113674. /**
  113675. * Defines if webvr should be enabled automatically
  113676. * @see https://doc.babylonjs.com/how_to/webvr_camera
  113677. */
  113678. autoEnableWebVR?: boolean;
  113679. /**
  113680. * Defines if webgl2 should be turned off even if supported
  113681. * @see https://doc.babylonjs.com/features/webgl2
  113682. */
  113683. disableWebGL2Support?: boolean;
  113684. /**
  113685. * Defines if webaudio should be initialized as well
  113686. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  113687. */
  113688. audioEngine?: boolean;
  113689. /**
  113690. * Defines if animations should run using a deterministic lock step
  113691. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113692. */
  113693. deterministicLockstep?: boolean;
  113694. /** Defines the maximum steps to use with deterministic lock step mode */
  113695. lockstepMaxSteps?: number;
  113696. /** Defines the seconds between each deterministic lock step */
  113697. timeStep?: number;
  113698. /**
  113699. * Defines that engine should ignore context lost events
  113700. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  113701. */
  113702. doNotHandleContextLost?: boolean;
  113703. /**
  113704. * Defines that engine should ignore modifying touch action attribute and style
  113705. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  113706. */
  113707. doNotHandleTouchAction?: boolean;
  113708. /**
  113709. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  113710. */
  113711. useHighPrecisionFloats?: boolean;
  113712. /**
  113713. * Make the canvas XR Compatible for XR sessions
  113714. */
  113715. xrCompatible?: boolean;
  113716. /**
  113717. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  113718. */
  113719. useHighPrecisionMatrix?: boolean;
  113720. }
  113721. /**
  113722. * The base engine class (root of all engines)
  113723. */
  113724. export class ThinEngine {
  113725. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  113726. static ExceptionList: ({
  113727. key: string;
  113728. capture: string;
  113729. captureConstraint: number;
  113730. targets: string[];
  113731. } | {
  113732. key: string;
  113733. capture: null;
  113734. captureConstraint: null;
  113735. targets: string[];
  113736. })[];
  113737. /** @hidden */
  113738. static _TextureLoaders: IInternalTextureLoader[];
  113739. /**
  113740. * Returns the current npm package of the sdk
  113741. */
  113742. static get NpmPackage(): string;
  113743. /**
  113744. * Returns the current version of the framework
  113745. */
  113746. static get Version(): string;
  113747. /**
  113748. * Returns a string describing the current engine
  113749. */
  113750. get description(): string;
  113751. /**
  113752. * Gets or sets the epsilon value used by collision engine
  113753. */
  113754. static CollisionsEpsilon: number;
  113755. /**
  113756. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  113757. */
  113758. static get ShadersRepository(): string;
  113759. static set ShadersRepository(value: string);
  113760. /** @hidden */
  113761. _shaderProcessor: IShaderProcessor;
  113762. /**
  113763. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  113764. */
  113765. forcePOTTextures: boolean;
  113766. /**
  113767. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  113768. */
  113769. isFullscreen: boolean;
  113770. /**
  113771. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  113772. */
  113773. cullBackFaces: boolean;
  113774. /**
  113775. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  113776. */
  113777. renderEvenInBackground: boolean;
  113778. /**
  113779. * Gets or sets a boolean indicating that cache can be kept between frames
  113780. */
  113781. preventCacheWipeBetweenFrames: boolean;
  113782. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  113783. validateShaderPrograms: boolean;
  113784. /**
  113785. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  113786. * This can provide greater z depth for distant objects.
  113787. */
  113788. useReverseDepthBuffer: boolean;
  113789. /**
  113790. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  113791. */
  113792. disableUniformBuffers: boolean;
  113793. /** @hidden */
  113794. _uniformBuffers: UniformBuffer[];
  113795. /**
  113796. * Gets a boolean indicating that the engine supports uniform buffers
  113797. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  113798. */
  113799. get supportsUniformBuffers(): boolean;
  113800. /** @hidden */
  113801. _gl: WebGLRenderingContext;
  113802. /** @hidden */
  113803. _webGLVersion: number;
  113804. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  113805. protected _windowIsBackground: boolean;
  113806. protected _creationOptions: EngineOptions;
  113807. protected _highPrecisionShadersAllowed: boolean;
  113808. /** @hidden */
  113809. get _shouldUseHighPrecisionShader(): boolean;
  113810. /**
  113811. * Gets a boolean indicating that only power of 2 textures are supported
  113812. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  113813. */
  113814. get needPOTTextures(): boolean;
  113815. /** @hidden */
  113816. _badOS: boolean;
  113817. /** @hidden */
  113818. _badDesktopOS: boolean;
  113819. private _hardwareScalingLevel;
  113820. /** @hidden */
  113821. _caps: EngineCapabilities;
  113822. private _isStencilEnable;
  113823. private _glVersion;
  113824. private _glRenderer;
  113825. private _glVendor;
  113826. /** @hidden */
  113827. _videoTextureSupported: boolean;
  113828. protected _renderingQueueLaunched: boolean;
  113829. protected _activeRenderLoops: (() => void)[];
  113830. /**
  113831. * Observable signaled when a context lost event is raised
  113832. */
  113833. onContextLostObservable: Observable<ThinEngine>;
  113834. /**
  113835. * Observable signaled when a context restored event is raised
  113836. */
  113837. onContextRestoredObservable: Observable<ThinEngine>;
  113838. private _onContextLost;
  113839. private _onContextRestored;
  113840. protected _contextWasLost: boolean;
  113841. /** @hidden */
  113842. _doNotHandleContextLost: boolean;
  113843. /**
  113844. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  113845. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  113846. */
  113847. get doNotHandleContextLost(): boolean;
  113848. set doNotHandleContextLost(value: boolean);
  113849. /**
  113850. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  113851. */
  113852. disableVertexArrayObjects: boolean;
  113853. /** @hidden */
  113854. protected _colorWrite: boolean;
  113855. /** @hidden */
  113856. protected _colorWriteChanged: boolean;
  113857. /** @hidden */
  113858. protected _depthCullingState: DepthCullingState;
  113859. /** @hidden */
  113860. protected _stencilState: StencilState;
  113861. /** @hidden */
  113862. _alphaState: AlphaState;
  113863. /** @hidden */
  113864. _alphaMode: number;
  113865. /** @hidden */
  113866. _alphaEquation: number;
  113867. /** @hidden */
  113868. _internalTexturesCache: InternalTexture[];
  113869. /** @hidden */
  113870. protected _activeChannel: number;
  113871. private _currentTextureChannel;
  113872. /** @hidden */
  113873. protected _boundTexturesCache: {
  113874. [key: string]: Nullable<InternalTexture>;
  113875. };
  113876. /** @hidden */
  113877. protected _currentEffect: Nullable<Effect>;
  113878. /** @hidden */
  113879. protected _currentProgram: Nullable<WebGLProgram>;
  113880. private _compiledEffects;
  113881. private _vertexAttribArraysEnabled;
  113882. /** @hidden */
  113883. protected _cachedViewport: Nullable<IViewportLike>;
  113884. private _cachedVertexArrayObject;
  113885. /** @hidden */
  113886. protected _cachedVertexBuffers: any;
  113887. /** @hidden */
  113888. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  113889. /** @hidden */
  113890. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  113891. /** @hidden */
  113892. _currentRenderTarget: Nullable<InternalTexture>;
  113893. private _uintIndicesCurrentlySet;
  113894. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  113895. /** @hidden */
  113896. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  113897. /** @hidden */
  113898. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  113899. private _currentBufferPointers;
  113900. private _currentInstanceLocations;
  113901. private _currentInstanceBuffers;
  113902. private _textureUnits;
  113903. /** @hidden */
  113904. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  113905. /** @hidden */
  113906. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  113907. /** @hidden */
  113908. _boundRenderFunction: any;
  113909. private _vaoRecordInProgress;
  113910. private _mustWipeVertexAttributes;
  113911. private _emptyTexture;
  113912. private _emptyCubeTexture;
  113913. private _emptyTexture3D;
  113914. private _emptyTexture2DArray;
  113915. /** @hidden */
  113916. _frameHandler: number;
  113917. private _nextFreeTextureSlots;
  113918. private _maxSimultaneousTextures;
  113919. private _activeRequests;
  113920. /** @hidden */
  113921. _transformTextureUrl: Nullable<(url: string) => string>;
  113922. protected get _supportsHardwareTextureRescaling(): boolean;
  113923. private _framebufferDimensionsObject;
  113924. /**
  113925. * sets the object from which width and height will be taken from when getting render width and height
  113926. * Will fallback to the gl object
  113927. * @param dimensions the framebuffer width and height that will be used.
  113928. */
  113929. set framebufferDimensionsObject(dimensions: Nullable<{
  113930. framebufferWidth: number;
  113931. framebufferHeight: number;
  113932. }>);
  113933. /**
  113934. * Gets the current viewport
  113935. */
  113936. get currentViewport(): Nullable<IViewportLike>;
  113937. /**
  113938. * Gets the default empty texture
  113939. */
  113940. get emptyTexture(): InternalTexture;
  113941. /**
  113942. * Gets the default empty 3D texture
  113943. */
  113944. get emptyTexture3D(): InternalTexture;
  113945. /**
  113946. * Gets the default empty 2D array texture
  113947. */
  113948. get emptyTexture2DArray(): InternalTexture;
  113949. /**
  113950. * Gets the default empty cube texture
  113951. */
  113952. get emptyCubeTexture(): InternalTexture;
  113953. /**
  113954. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  113955. */
  113956. readonly premultipliedAlpha: boolean;
  113957. /**
  113958. * Observable event triggered before each texture is initialized
  113959. */
  113960. onBeforeTextureInitObservable: Observable<Texture>;
  113961. /**
  113962. * Creates a new engine
  113963. * @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
  113964. * @param antialias defines enable antialiasing (default: false)
  113965. * @param options defines further options to be sent to the getContext() function
  113966. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  113967. */
  113968. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  113969. private _rebuildInternalTextures;
  113970. private _rebuildEffects;
  113971. /**
  113972. * Gets a boolean indicating if all created effects are ready
  113973. * @returns true if all effects are ready
  113974. */
  113975. areAllEffectsReady(): boolean;
  113976. protected _rebuildBuffers(): void;
  113977. protected _initGLContext(): void;
  113978. /**
  113979. * Gets version of the current webGL context
  113980. */
  113981. get webGLVersion(): number;
  113982. /**
  113983. * Gets a string idenfifying the name of the class
  113984. * @returns "Engine" string
  113985. */
  113986. getClassName(): string;
  113987. /**
  113988. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  113989. */
  113990. get isStencilEnable(): boolean;
  113991. /** @hidden */
  113992. _prepareWorkingCanvas(): void;
  113993. /**
  113994. * Reset the texture cache to empty state
  113995. */
  113996. resetTextureCache(): void;
  113997. /**
  113998. * Gets an object containing information about the current webGL context
  113999. * @returns an object containing the vender, the renderer and the version of the current webGL context
  114000. */
  114001. getGlInfo(): {
  114002. vendor: string;
  114003. renderer: string;
  114004. version: string;
  114005. };
  114006. /**
  114007. * Defines the hardware scaling level.
  114008. * By default the hardware scaling level is computed from the window device ratio.
  114009. * 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.
  114010. * @param level defines the level to use
  114011. */
  114012. setHardwareScalingLevel(level: number): void;
  114013. /**
  114014. * Gets the current hardware scaling level.
  114015. * By default the hardware scaling level is computed from the window device ratio.
  114016. * 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.
  114017. * @returns a number indicating the current hardware scaling level
  114018. */
  114019. getHardwareScalingLevel(): number;
  114020. /**
  114021. * Gets the list of loaded textures
  114022. * @returns an array containing all loaded textures
  114023. */
  114024. getLoadedTexturesCache(): InternalTexture[];
  114025. /**
  114026. * Gets the object containing all engine capabilities
  114027. * @returns the EngineCapabilities object
  114028. */
  114029. getCaps(): EngineCapabilities;
  114030. /**
  114031. * stop executing a render loop function and remove it from the execution array
  114032. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  114033. */
  114034. stopRenderLoop(renderFunction?: () => void): void;
  114035. /** @hidden */
  114036. _renderLoop(): void;
  114037. /**
  114038. * Gets the HTML canvas attached with the current webGL context
  114039. * @returns a HTML canvas
  114040. */
  114041. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  114042. /**
  114043. * Gets host window
  114044. * @returns the host window object
  114045. */
  114046. getHostWindow(): Nullable<Window>;
  114047. /**
  114048. * Gets the current render width
  114049. * @param useScreen defines if screen size must be used (or the current render target if any)
  114050. * @returns a number defining the current render width
  114051. */
  114052. getRenderWidth(useScreen?: boolean): number;
  114053. /**
  114054. * Gets the current render height
  114055. * @param useScreen defines if screen size must be used (or the current render target if any)
  114056. * @returns a number defining the current render height
  114057. */
  114058. getRenderHeight(useScreen?: boolean): number;
  114059. /**
  114060. * Can be used to override the current requestAnimationFrame requester.
  114061. * @hidden
  114062. */
  114063. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  114064. /**
  114065. * Register and execute a render loop. The engine can have more than one render function
  114066. * @param renderFunction defines the function to continuously execute
  114067. */
  114068. runRenderLoop(renderFunction: () => void): void;
  114069. /**
  114070. * Clear the current render buffer or the current render target (if any is set up)
  114071. * @param color defines the color to use
  114072. * @param backBuffer defines if the back buffer must be cleared
  114073. * @param depth defines if the depth buffer must be cleared
  114074. * @param stencil defines if the stencil buffer must be cleared
  114075. */
  114076. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  114077. private _viewportCached;
  114078. /** @hidden */
  114079. _viewport(x: number, y: number, width: number, height: number): void;
  114080. /**
  114081. * Set the WebGL's viewport
  114082. * @param viewport defines the viewport element to be used
  114083. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  114084. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  114085. */
  114086. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  114087. /**
  114088. * Begin a new frame
  114089. */
  114090. beginFrame(): void;
  114091. /**
  114092. * Enf the current frame
  114093. */
  114094. endFrame(): void;
  114095. /**
  114096. * Resize the view according to the canvas' size
  114097. */
  114098. resize(): void;
  114099. /**
  114100. * Force a specific size of the canvas
  114101. * @param width defines the new canvas' width
  114102. * @param height defines the new canvas' height
  114103. * @returns true if the size was changed
  114104. */
  114105. setSize(width: number, height: number): boolean;
  114106. /**
  114107. * Binds the frame buffer to the specified texture.
  114108. * @param texture The texture to render to or null for the default canvas
  114109. * @param faceIndex The face of the texture to render to in case of cube texture
  114110. * @param requiredWidth The width of the target to render to
  114111. * @param requiredHeight The height of the target to render to
  114112. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  114113. * @param lodLevel defines the lod level to bind to the frame buffer
  114114. * @param layer defines the 2d array index to bind to frame buffer to
  114115. */
  114116. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  114117. /** @hidden */
  114118. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  114119. /**
  114120. * Unbind the current render target texture from the webGL context
  114121. * @param texture defines the render target texture to unbind
  114122. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114123. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114124. */
  114125. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  114126. /**
  114127. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  114128. */
  114129. flushFramebuffer(): void;
  114130. /**
  114131. * Unbind the current render target and bind the default framebuffer
  114132. */
  114133. restoreDefaultFramebuffer(): void;
  114134. /** @hidden */
  114135. protected _resetVertexBufferBinding(): void;
  114136. /**
  114137. * Creates a vertex buffer
  114138. * @param data the data for the vertex buffer
  114139. * @returns the new WebGL static buffer
  114140. */
  114141. createVertexBuffer(data: DataArray): DataBuffer;
  114142. private _createVertexBuffer;
  114143. /**
  114144. * Creates a dynamic vertex buffer
  114145. * @param data the data for the dynamic vertex buffer
  114146. * @returns the new WebGL dynamic buffer
  114147. */
  114148. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  114149. protected _resetIndexBufferBinding(): void;
  114150. /**
  114151. * Creates a new index buffer
  114152. * @param indices defines the content of the index buffer
  114153. * @param updatable defines if the index buffer must be updatable
  114154. * @returns a new webGL buffer
  114155. */
  114156. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  114157. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  114158. /**
  114159. * Bind a webGL buffer to the webGL context
  114160. * @param buffer defines the buffer to bind
  114161. */
  114162. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  114163. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  114164. private bindBuffer;
  114165. /**
  114166. * update the bound buffer with the given data
  114167. * @param data defines the data to update
  114168. */
  114169. updateArrayBuffer(data: Float32Array): void;
  114170. private _vertexAttribPointer;
  114171. /** @hidden */
  114172. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  114173. private _bindVertexBuffersAttributes;
  114174. /**
  114175. * Records a vertex array object
  114176. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114177. * @param vertexBuffers defines the list of vertex buffers to store
  114178. * @param indexBuffer defines the index buffer to store
  114179. * @param effect defines the effect to store
  114180. * @returns the new vertex array object
  114181. */
  114182. recordVertexArrayObject(vertexBuffers: {
  114183. [key: string]: VertexBuffer;
  114184. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  114185. /**
  114186. * Bind a specific vertex array object
  114187. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114188. * @param vertexArrayObject defines the vertex array object to bind
  114189. * @param indexBuffer defines the index buffer to bind
  114190. */
  114191. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  114192. /**
  114193. * Bind webGl buffers directly to the webGL context
  114194. * @param vertexBuffer defines the vertex buffer to bind
  114195. * @param indexBuffer defines the index buffer to bind
  114196. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  114197. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  114198. * @param effect defines the effect associated with the vertex buffer
  114199. */
  114200. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  114201. private _unbindVertexArrayObject;
  114202. /**
  114203. * Bind a list of vertex buffers to the webGL context
  114204. * @param vertexBuffers defines the list of vertex buffers to bind
  114205. * @param indexBuffer defines the index buffer to bind
  114206. * @param effect defines the effect associated with the vertex buffers
  114207. */
  114208. bindBuffers(vertexBuffers: {
  114209. [key: string]: Nullable<VertexBuffer>;
  114210. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  114211. /**
  114212. * Unbind all instance attributes
  114213. */
  114214. unbindInstanceAttributes(): void;
  114215. /**
  114216. * Release and free the memory of a vertex array object
  114217. * @param vao defines the vertex array object to delete
  114218. */
  114219. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  114220. /** @hidden */
  114221. _releaseBuffer(buffer: DataBuffer): boolean;
  114222. protected _deleteBuffer(buffer: DataBuffer): void;
  114223. /**
  114224. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  114225. * @param instancesBuffer defines the webGL buffer to update and bind
  114226. * @param data defines the data to store in the buffer
  114227. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  114228. */
  114229. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  114230. /**
  114231. * Bind the content of a webGL buffer used with instantiation
  114232. * @param instancesBuffer defines the webGL buffer to bind
  114233. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  114234. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  114235. */
  114236. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  114237. /**
  114238. * Disable the instance attribute corresponding to the name in parameter
  114239. * @param name defines the name of the attribute to disable
  114240. */
  114241. disableInstanceAttributeByName(name: string): void;
  114242. /**
  114243. * Disable the instance attribute corresponding to the location in parameter
  114244. * @param attributeLocation defines the attribute location of the attribute to disable
  114245. */
  114246. disableInstanceAttribute(attributeLocation: number): void;
  114247. /**
  114248. * Disable the attribute corresponding to the location in parameter
  114249. * @param attributeLocation defines the attribute location of the attribute to disable
  114250. */
  114251. disableAttributeByIndex(attributeLocation: number): void;
  114252. /**
  114253. * Send a draw order
  114254. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  114255. * @param indexStart defines the starting index
  114256. * @param indexCount defines the number of index to draw
  114257. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114258. */
  114259. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  114260. /**
  114261. * Draw a list of points
  114262. * @param verticesStart defines the index of first vertex to draw
  114263. * @param verticesCount defines the count of vertices to draw
  114264. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114265. */
  114266. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114267. /**
  114268. * Draw a list of unindexed primitives
  114269. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  114270. * @param verticesStart defines the index of first vertex to draw
  114271. * @param verticesCount defines the count of vertices to draw
  114272. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114273. */
  114274. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114275. /**
  114276. * Draw a list of indexed primitives
  114277. * @param fillMode defines the primitive to use
  114278. * @param indexStart defines the starting index
  114279. * @param indexCount defines the number of index to draw
  114280. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114281. */
  114282. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  114283. /**
  114284. * Draw a list of unindexed primitives
  114285. * @param fillMode defines the primitive to use
  114286. * @param verticesStart defines the index of first vertex to draw
  114287. * @param verticesCount defines the count of vertices to draw
  114288. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114289. */
  114290. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114291. private _drawMode;
  114292. /** @hidden */
  114293. protected _reportDrawCall(): void;
  114294. /** @hidden */
  114295. _releaseEffect(effect: Effect): void;
  114296. /** @hidden */
  114297. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114298. /**
  114299. * Create a new effect (used to store vertex/fragment shaders)
  114300. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  114301. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  114302. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  114303. * @param samplers defines an array of string used to represent textures
  114304. * @param defines defines the string containing the defines to use to compile the shaders
  114305. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  114306. * @param onCompiled defines a function to call when the effect creation is successful
  114307. * @param onError defines a function to call when the effect creation has failed
  114308. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  114309. * @returns the new Effect
  114310. */
  114311. 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;
  114312. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  114313. private _compileShader;
  114314. private _compileRawShader;
  114315. /** @hidden */
  114316. _getShaderSource(shader: WebGLShader): Nullable<string>;
  114317. /**
  114318. * Directly creates a webGL program
  114319. * @param pipelineContext defines the pipeline context to attach to
  114320. * @param vertexCode defines the vertex shader code to use
  114321. * @param fragmentCode defines the fragment shader code to use
  114322. * @param context defines the webGL context to use (if not set, the current one will be used)
  114323. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  114324. * @returns the new webGL program
  114325. */
  114326. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114327. /**
  114328. * Creates a webGL program
  114329. * @param pipelineContext defines the pipeline context to attach to
  114330. * @param vertexCode defines the vertex shader code to use
  114331. * @param fragmentCode defines the fragment shader code to use
  114332. * @param defines defines the string containing the defines to use to compile the shaders
  114333. * @param context defines the webGL context to use (if not set, the current one will be used)
  114334. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  114335. * @returns the new webGL program
  114336. */
  114337. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114338. /**
  114339. * Creates a new pipeline context
  114340. * @returns the new pipeline
  114341. */
  114342. createPipelineContext(): IPipelineContext;
  114343. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114344. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  114345. /** @hidden */
  114346. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  114347. /** @hidden */
  114348. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  114349. /** @hidden */
  114350. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  114351. /**
  114352. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  114353. * @param pipelineContext defines the pipeline context to use
  114354. * @param uniformsNames defines the list of uniform names
  114355. * @returns an array of webGL uniform locations
  114356. */
  114357. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  114358. /**
  114359. * Gets the lsit of active attributes for a given webGL program
  114360. * @param pipelineContext defines the pipeline context to use
  114361. * @param attributesNames defines the list of attribute names to get
  114362. * @returns an array of indices indicating the offset of each attribute
  114363. */
  114364. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  114365. /**
  114366. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  114367. * @param effect defines the effect to activate
  114368. */
  114369. enableEffect(effect: Nullable<Effect>): void;
  114370. /**
  114371. * Set the value of an uniform to a number (int)
  114372. * @param uniform defines the webGL uniform location where to store the value
  114373. * @param value defines the int number to store
  114374. */
  114375. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  114376. /**
  114377. * Set the value of an uniform to an array of int32
  114378. * @param uniform defines the webGL uniform location where to store the value
  114379. * @param array defines the array of int32 to store
  114380. */
  114381. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114382. /**
  114383. * Set the value of an uniform to an array of int32 (stored as vec2)
  114384. * @param uniform defines the webGL uniform location where to store the value
  114385. * @param array defines the array of int32 to store
  114386. */
  114387. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114388. /**
  114389. * Set the value of an uniform to an array of int32 (stored as vec3)
  114390. * @param uniform defines the webGL uniform location where to store the value
  114391. * @param array defines the array of int32 to store
  114392. */
  114393. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114394. /**
  114395. * Set the value of an uniform to an array of int32 (stored as vec4)
  114396. * @param uniform defines the webGL uniform location where to store the value
  114397. * @param array defines the array of int32 to store
  114398. */
  114399. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114400. /**
  114401. * Set the value of an uniform to an array of number
  114402. * @param uniform defines the webGL uniform location where to store the value
  114403. * @param array defines the array of number to store
  114404. */
  114405. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114406. /**
  114407. * Set the value of an uniform to an array of number (stored as vec2)
  114408. * @param uniform defines the webGL uniform location where to store the value
  114409. * @param array defines the array of number to store
  114410. */
  114411. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114412. /**
  114413. * Set the value of an uniform to an array of number (stored as vec3)
  114414. * @param uniform defines the webGL uniform location where to store the value
  114415. * @param array defines the array of number to store
  114416. */
  114417. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114418. /**
  114419. * Set the value of an uniform to an array of number (stored as vec4)
  114420. * @param uniform defines the webGL uniform location where to store the value
  114421. * @param array defines the array of number to store
  114422. */
  114423. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114424. /**
  114425. * Set the value of an uniform to an array of float32 (stored as matrices)
  114426. * @param uniform defines the webGL uniform location where to store the value
  114427. * @param matrices defines the array of float32 to store
  114428. */
  114429. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  114430. /**
  114431. * Set the value of an uniform to a matrix (3x3)
  114432. * @param uniform defines the webGL uniform location where to store the value
  114433. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  114434. */
  114435. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  114436. /**
  114437. * Set the value of an uniform to a matrix (2x2)
  114438. * @param uniform defines the webGL uniform location where to store the value
  114439. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  114440. */
  114441. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  114442. /**
  114443. * Set the value of an uniform to a number (float)
  114444. * @param uniform defines the webGL uniform location where to store the value
  114445. * @param value defines the float number to store
  114446. */
  114447. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  114448. /**
  114449. * Set the value of an uniform to a vec2
  114450. * @param uniform defines the webGL uniform location where to store the value
  114451. * @param x defines the 1st component of the value
  114452. * @param y defines the 2nd component of the value
  114453. */
  114454. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  114455. /**
  114456. * Set the value of an uniform to a vec3
  114457. * @param uniform defines the webGL uniform location where to store the value
  114458. * @param x defines the 1st component of the value
  114459. * @param y defines the 2nd component of the value
  114460. * @param z defines the 3rd component of the value
  114461. */
  114462. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  114463. /**
  114464. * Set the value of an uniform to a vec4
  114465. * @param uniform defines the webGL uniform location where to store the value
  114466. * @param x defines the 1st component of the value
  114467. * @param y defines the 2nd component of the value
  114468. * @param z defines the 3rd component of the value
  114469. * @param w defines the 4th component of the value
  114470. */
  114471. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  114472. /**
  114473. * Apply all cached states (depth, culling, stencil and alpha)
  114474. */
  114475. applyStates(): void;
  114476. /**
  114477. * Enable or disable color writing
  114478. * @param enable defines the state to set
  114479. */
  114480. setColorWrite(enable: boolean): void;
  114481. /**
  114482. * Gets a boolean indicating if color writing is enabled
  114483. * @returns the current color writing state
  114484. */
  114485. getColorWrite(): boolean;
  114486. /**
  114487. * Gets the depth culling state manager
  114488. */
  114489. get depthCullingState(): DepthCullingState;
  114490. /**
  114491. * Gets the alpha state manager
  114492. */
  114493. get alphaState(): AlphaState;
  114494. /**
  114495. * Gets the stencil state manager
  114496. */
  114497. get stencilState(): StencilState;
  114498. /**
  114499. * Clears the list of texture accessible through engine.
  114500. * This can help preventing texture load conflict due to name collision.
  114501. */
  114502. clearInternalTexturesCache(): void;
  114503. /**
  114504. * Force the entire cache to be cleared
  114505. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  114506. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  114507. */
  114508. wipeCaches(bruteForce?: boolean): void;
  114509. /** @hidden */
  114510. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  114511. min: number;
  114512. mag: number;
  114513. };
  114514. /** @hidden */
  114515. _createTexture(): WebGLTexture;
  114516. /**
  114517. * Usually called from Texture.ts.
  114518. * Passed information to create a WebGLTexture
  114519. * @param url defines a value which contains one of the following:
  114520. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  114521. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  114522. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  114523. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  114524. * @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)
  114525. * @param scene needed for loading to the correct scene
  114526. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  114527. * @param onLoad optional callback to be called upon successful completion
  114528. * @param onError optional callback to be called upon failure
  114529. * @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
  114530. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  114531. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  114532. * @param forcedExtension defines the extension to use to pick the right loader
  114533. * @param mimeType defines an optional mime type
  114534. * @returns a InternalTexture for assignment back into BABYLON.Texture
  114535. */
  114536. 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;
  114537. /**
  114538. * Loads an image as an HTMLImageElement.
  114539. * @param input url string, ArrayBuffer, or Blob to load
  114540. * @param onLoad callback called when the image successfully loads
  114541. * @param onError callback called when the image fails to load
  114542. * @param offlineProvider offline provider for caching
  114543. * @param mimeType optional mime type
  114544. * @returns the HTMLImageElement of the loaded image
  114545. * @hidden
  114546. */
  114547. 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>;
  114548. /**
  114549. * @hidden
  114550. */
  114551. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  114552. private _unpackFlipYCached;
  114553. /**
  114554. * In case you are sharing the context with other applications, it might
  114555. * be interested to not cache the unpack flip y state to ensure a consistent
  114556. * value would be set.
  114557. */
  114558. enableUnpackFlipYCached: boolean;
  114559. /** @hidden */
  114560. _unpackFlipY(value: boolean): void;
  114561. /** @hidden */
  114562. _getUnpackAlignement(): number;
  114563. private _getTextureTarget;
  114564. /**
  114565. * Update the sampling mode of a given texture
  114566. * @param samplingMode defines the required sampling mode
  114567. * @param texture defines the texture to update
  114568. * @param generateMipMaps defines whether to generate mipmaps for the texture
  114569. */
  114570. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  114571. /**
  114572. * Update the sampling mode of a given texture
  114573. * @param texture defines the texture to update
  114574. * @param wrapU defines the texture wrap mode of the u coordinates
  114575. * @param wrapV defines the texture wrap mode of the v coordinates
  114576. * @param wrapR defines the texture wrap mode of the r coordinates
  114577. */
  114578. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  114579. /** @hidden */
  114580. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  114581. width: number;
  114582. height: number;
  114583. layers?: number;
  114584. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  114585. /** @hidden */
  114586. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114587. /** @hidden */
  114588. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  114589. /**
  114590. * Update a portion of an internal texture
  114591. * @param texture defines the texture to update
  114592. * @param imageData defines the data to store into the texture
  114593. * @param xOffset defines the x coordinates of the update rectangle
  114594. * @param yOffset defines the y coordinates of the update rectangle
  114595. * @param width defines the width of the update rectangle
  114596. * @param height defines the height of the update rectangle
  114597. * @param faceIndex defines the face index if texture is a cube (0 by default)
  114598. * @param lod defines the lod level to update (0 by default)
  114599. */
  114600. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  114601. /** @hidden */
  114602. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114603. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  114604. private _prepareWebGLTexture;
  114605. /** @hidden */
  114606. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  114607. private _getDepthStencilBuffer;
  114608. /** @hidden */
  114609. _releaseFramebufferObjects(texture: InternalTexture): void;
  114610. /** @hidden */
  114611. _releaseTexture(texture: InternalTexture): void;
  114612. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  114613. protected _setProgram(program: WebGLProgram): void;
  114614. protected _boundUniforms: {
  114615. [key: number]: WebGLUniformLocation;
  114616. };
  114617. /**
  114618. * Binds an effect to the webGL context
  114619. * @param effect defines the effect to bind
  114620. */
  114621. bindSamplers(effect: Effect): void;
  114622. private _activateCurrentTexture;
  114623. /** @hidden */
  114624. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  114625. /** @hidden */
  114626. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  114627. /**
  114628. * Unbind all textures from the webGL context
  114629. */
  114630. unbindAllTextures(): void;
  114631. /**
  114632. * Sets a texture to the according uniform.
  114633. * @param channel The texture channel
  114634. * @param uniform The uniform to set
  114635. * @param texture The texture to apply
  114636. */
  114637. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  114638. private _bindSamplerUniformToChannel;
  114639. private _getTextureWrapMode;
  114640. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  114641. /**
  114642. * Sets an array of texture to the webGL context
  114643. * @param channel defines the channel where the texture array must be set
  114644. * @param uniform defines the associated uniform location
  114645. * @param textures defines the array of textures to bind
  114646. */
  114647. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  114648. /** @hidden */
  114649. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  114650. private _setTextureParameterFloat;
  114651. private _setTextureParameterInteger;
  114652. /**
  114653. * Unbind all vertex attributes from the webGL context
  114654. */
  114655. unbindAllAttributes(): void;
  114656. /**
  114657. * 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
  114658. */
  114659. releaseEffects(): void;
  114660. /**
  114661. * Dispose and release all associated resources
  114662. */
  114663. dispose(): void;
  114664. /**
  114665. * Attach a new callback raised when context lost event is fired
  114666. * @param callback defines the callback to call
  114667. */
  114668. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  114669. /**
  114670. * Attach a new callback raised when context restored event is fired
  114671. * @param callback defines the callback to call
  114672. */
  114673. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  114674. /**
  114675. * Get the current error code of the webGL context
  114676. * @returns the error code
  114677. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  114678. */
  114679. getError(): number;
  114680. private _canRenderToFloatFramebuffer;
  114681. private _canRenderToHalfFloatFramebuffer;
  114682. private _canRenderToFramebuffer;
  114683. /** @hidden */
  114684. _getWebGLTextureType(type: number): number;
  114685. /** @hidden */
  114686. _getInternalFormat(format: number): number;
  114687. /** @hidden */
  114688. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  114689. /** @hidden */
  114690. _getRGBAMultiSampleBufferFormat(type: number): number;
  114691. /** @hidden */
  114692. _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;
  114693. /**
  114694. * Loads a file from a url
  114695. * @param url url to load
  114696. * @param onSuccess callback called when the file successfully loads
  114697. * @param onProgress callback called while file is loading (if the server supports this mode)
  114698. * @param offlineProvider defines the offline provider for caching
  114699. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114700. * @param onError callback called when the file fails to load
  114701. * @returns a file request object
  114702. * @hidden
  114703. */
  114704. 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;
  114705. /**
  114706. * Reads pixels from the current frame buffer. Please note that this function can be slow
  114707. * @param x defines the x coordinate of the rectangle where pixels must be read
  114708. * @param y defines the y coordinate of the rectangle where pixels must be read
  114709. * @param width defines the width of the rectangle where pixels must be read
  114710. * @param height defines the height of the rectangle where pixels must be read
  114711. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  114712. * @returns a Uint8Array containing RGBA colors
  114713. */
  114714. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  114715. private static _isSupported;
  114716. /**
  114717. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  114718. * @returns true if the engine can be created
  114719. * @ignorenaming
  114720. */
  114721. static isSupported(): boolean;
  114722. /**
  114723. * Find the next highest power of two.
  114724. * @param x Number to start search from.
  114725. * @return Next highest power of two.
  114726. */
  114727. static CeilingPOT(x: number): number;
  114728. /**
  114729. * Find the next lowest power of two.
  114730. * @param x Number to start search from.
  114731. * @return Next lowest power of two.
  114732. */
  114733. static FloorPOT(x: number): number;
  114734. /**
  114735. * Find the nearest power of two.
  114736. * @param x Number to start search from.
  114737. * @return Next nearest power of two.
  114738. */
  114739. static NearestPOT(x: number): number;
  114740. /**
  114741. * Get the closest exponent of two
  114742. * @param value defines the value to approximate
  114743. * @param max defines the maximum value to return
  114744. * @param mode defines how to define the closest value
  114745. * @returns closest exponent of two of the given value
  114746. */
  114747. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  114748. /**
  114749. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  114750. * @param func - the function to be called
  114751. * @param requester - the object that will request the next frame. Falls back to window.
  114752. * @returns frame number
  114753. */
  114754. static QueueNewFrame(func: () => void, requester?: any): number;
  114755. /**
  114756. * Gets host document
  114757. * @returns the host document object
  114758. */
  114759. getHostDocument(): Nullable<Document>;
  114760. }
  114761. }
  114762. declare module BABYLON {
  114763. /**
  114764. * Class representing spherical harmonics coefficients to the 3rd degree
  114765. */
  114766. export class SphericalHarmonics {
  114767. /**
  114768. * Defines whether or not the harmonics have been prescaled for rendering.
  114769. */
  114770. preScaled: boolean;
  114771. /**
  114772. * The l0,0 coefficients of the spherical harmonics
  114773. */
  114774. l00: Vector3;
  114775. /**
  114776. * The l1,-1 coefficients of the spherical harmonics
  114777. */
  114778. l1_1: Vector3;
  114779. /**
  114780. * The l1,0 coefficients of the spherical harmonics
  114781. */
  114782. l10: Vector3;
  114783. /**
  114784. * The l1,1 coefficients of the spherical harmonics
  114785. */
  114786. l11: Vector3;
  114787. /**
  114788. * The l2,-2 coefficients of the spherical harmonics
  114789. */
  114790. l2_2: Vector3;
  114791. /**
  114792. * The l2,-1 coefficients of the spherical harmonics
  114793. */
  114794. l2_1: Vector3;
  114795. /**
  114796. * The l2,0 coefficients of the spherical harmonics
  114797. */
  114798. l20: Vector3;
  114799. /**
  114800. * The l2,1 coefficients of the spherical harmonics
  114801. */
  114802. l21: Vector3;
  114803. /**
  114804. * The l2,2 coefficients of the spherical harmonics
  114805. */
  114806. l22: Vector3;
  114807. /**
  114808. * Adds a light to the spherical harmonics
  114809. * @param direction the direction of the light
  114810. * @param color the color of the light
  114811. * @param deltaSolidAngle the delta solid angle of the light
  114812. */
  114813. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  114814. /**
  114815. * Scales the spherical harmonics by the given amount
  114816. * @param scale the amount to scale
  114817. */
  114818. scaleInPlace(scale: number): void;
  114819. /**
  114820. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  114821. *
  114822. * ```
  114823. * E_lm = A_l * L_lm
  114824. * ```
  114825. *
  114826. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  114827. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  114828. * the scaling factors are given in equation 9.
  114829. */
  114830. convertIncidentRadianceToIrradiance(): void;
  114831. /**
  114832. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  114833. *
  114834. * ```
  114835. * L = (1/pi) * E * rho
  114836. * ```
  114837. *
  114838. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  114839. */
  114840. convertIrradianceToLambertianRadiance(): void;
  114841. /**
  114842. * Integrates the reconstruction coefficients directly in to the SH preventing further
  114843. * required operations at run time.
  114844. *
  114845. * This is simply done by scaling back the SH with Ylm constants parameter.
  114846. * The trigonometric part being applied by the shader at run time.
  114847. */
  114848. preScaleForRendering(): void;
  114849. /**
  114850. * Constructs a spherical harmonics from an array.
  114851. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  114852. * @returns the spherical harmonics
  114853. */
  114854. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  114855. /**
  114856. * Gets the spherical harmonics from polynomial
  114857. * @param polynomial the spherical polynomial
  114858. * @returns the spherical harmonics
  114859. */
  114860. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  114861. }
  114862. /**
  114863. * Class representing spherical polynomial coefficients to the 3rd degree
  114864. */
  114865. export class SphericalPolynomial {
  114866. private _harmonics;
  114867. /**
  114868. * The spherical harmonics used to create the polynomials.
  114869. */
  114870. get preScaledHarmonics(): SphericalHarmonics;
  114871. /**
  114872. * The x coefficients of the spherical polynomial
  114873. */
  114874. x: Vector3;
  114875. /**
  114876. * The y coefficients of the spherical polynomial
  114877. */
  114878. y: Vector3;
  114879. /**
  114880. * The z coefficients of the spherical polynomial
  114881. */
  114882. z: Vector3;
  114883. /**
  114884. * The xx coefficients of the spherical polynomial
  114885. */
  114886. xx: Vector3;
  114887. /**
  114888. * The yy coefficients of the spherical polynomial
  114889. */
  114890. yy: Vector3;
  114891. /**
  114892. * The zz coefficients of the spherical polynomial
  114893. */
  114894. zz: Vector3;
  114895. /**
  114896. * The xy coefficients of the spherical polynomial
  114897. */
  114898. xy: Vector3;
  114899. /**
  114900. * The yz coefficients of the spherical polynomial
  114901. */
  114902. yz: Vector3;
  114903. /**
  114904. * The zx coefficients of the spherical polynomial
  114905. */
  114906. zx: Vector3;
  114907. /**
  114908. * Adds an ambient color to the spherical polynomial
  114909. * @param color the color to add
  114910. */
  114911. addAmbient(color: Color3): void;
  114912. /**
  114913. * Scales the spherical polynomial by the given amount
  114914. * @param scale the amount to scale
  114915. */
  114916. scaleInPlace(scale: number): void;
  114917. /**
  114918. * Gets the spherical polynomial from harmonics
  114919. * @param harmonics the spherical harmonics
  114920. * @returns the spherical polynomial
  114921. */
  114922. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  114923. /**
  114924. * Constructs a spherical polynomial from an array.
  114925. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  114926. * @returns the spherical polynomial
  114927. */
  114928. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  114929. }
  114930. }
  114931. declare module BABYLON {
  114932. /**
  114933. * Defines the source of the internal texture
  114934. */
  114935. export enum InternalTextureSource {
  114936. /**
  114937. * The source of the texture data is unknown
  114938. */
  114939. Unknown = 0,
  114940. /**
  114941. * Texture data comes from an URL
  114942. */
  114943. Url = 1,
  114944. /**
  114945. * Texture data is only used for temporary storage
  114946. */
  114947. Temp = 2,
  114948. /**
  114949. * Texture data comes from raw data (ArrayBuffer)
  114950. */
  114951. Raw = 3,
  114952. /**
  114953. * Texture content is dynamic (video or dynamic texture)
  114954. */
  114955. Dynamic = 4,
  114956. /**
  114957. * Texture content is generated by rendering to it
  114958. */
  114959. RenderTarget = 5,
  114960. /**
  114961. * Texture content is part of a multi render target process
  114962. */
  114963. MultiRenderTarget = 6,
  114964. /**
  114965. * Texture data comes from a cube data file
  114966. */
  114967. Cube = 7,
  114968. /**
  114969. * Texture data comes from a raw cube data
  114970. */
  114971. CubeRaw = 8,
  114972. /**
  114973. * Texture data come from a prefiltered cube data file
  114974. */
  114975. CubePrefiltered = 9,
  114976. /**
  114977. * Texture content is raw 3D data
  114978. */
  114979. Raw3D = 10,
  114980. /**
  114981. * Texture content is raw 2D array data
  114982. */
  114983. Raw2DArray = 11,
  114984. /**
  114985. * Texture content is a depth texture
  114986. */
  114987. Depth = 12,
  114988. /**
  114989. * Texture data comes from a raw cube data encoded with RGBD
  114990. */
  114991. CubeRawRGBD = 13
  114992. }
  114993. /**
  114994. * Class used to store data associated with WebGL texture data for the engine
  114995. * This class should not be used directly
  114996. */
  114997. export class InternalTexture {
  114998. /** @hidden */
  114999. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  115000. /**
  115001. * Defines if the texture is ready
  115002. */
  115003. isReady: boolean;
  115004. /**
  115005. * Defines if the texture is a cube texture
  115006. */
  115007. isCube: boolean;
  115008. /**
  115009. * Defines if the texture contains 3D data
  115010. */
  115011. is3D: boolean;
  115012. /**
  115013. * Defines if the texture contains 2D array data
  115014. */
  115015. is2DArray: boolean;
  115016. /**
  115017. * Defines if the texture contains multiview data
  115018. */
  115019. isMultiview: boolean;
  115020. /**
  115021. * Gets the URL used to load this texture
  115022. */
  115023. url: string;
  115024. /**
  115025. * Gets the sampling mode of the texture
  115026. */
  115027. samplingMode: number;
  115028. /**
  115029. * Gets a boolean indicating if the texture needs mipmaps generation
  115030. */
  115031. generateMipMaps: boolean;
  115032. /**
  115033. * Gets the number of samples used by the texture (WebGL2+ only)
  115034. */
  115035. samples: number;
  115036. /**
  115037. * Gets the type of the texture (int, float...)
  115038. */
  115039. type: number;
  115040. /**
  115041. * Gets the format of the texture (RGB, RGBA...)
  115042. */
  115043. format: number;
  115044. /**
  115045. * Observable called when the texture is loaded
  115046. */
  115047. onLoadedObservable: Observable<InternalTexture>;
  115048. /**
  115049. * Gets the width of the texture
  115050. */
  115051. width: number;
  115052. /**
  115053. * Gets the height of the texture
  115054. */
  115055. height: number;
  115056. /**
  115057. * Gets the depth of the texture
  115058. */
  115059. depth: number;
  115060. /**
  115061. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  115062. */
  115063. baseWidth: number;
  115064. /**
  115065. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  115066. */
  115067. baseHeight: number;
  115068. /**
  115069. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  115070. */
  115071. baseDepth: number;
  115072. /**
  115073. * Gets a boolean indicating if the texture is inverted on Y axis
  115074. */
  115075. invertY: boolean;
  115076. /** @hidden */
  115077. _invertVScale: boolean;
  115078. /** @hidden */
  115079. _associatedChannel: number;
  115080. /** @hidden */
  115081. _source: InternalTextureSource;
  115082. /** @hidden */
  115083. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  115084. /** @hidden */
  115085. _bufferView: Nullable<ArrayBufferView>;
  115086. /** @hidden */
  115087. _bufferViewArray: Nullable<ArrayBufferView[]>;
  115088. /** @hidden */
  115089. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  115090. /** @hidden */
  115091. _size: number;
  115092. /** @hidden */
  115093. _extension: string;
  115094. /** @hidden */
  115095. _files: Nullable<string[]>;
  115096. /** @hidden */
  115097. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115098. /** @hidden */
  115099. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115100. /** @hidden */
  115101. _framebuffer: Nullable<WebGLFramebuffer>;
  115102. /** @hidden */
  115103. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  115104. /** @hidden */
  115105. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  115106. /** @hidden */
  115107. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  115108. /** @hidden */
  115109. _attachments: Nullable<number[]>;
  115110. /** @hidden */
  115111. _textureArray: Nullable<InternalTexture[]>;
  115112. /** @hidden */
  115113. _cachedCoordinatesMode: Nullable<number>;
  115114. /** @hidden */
  115115. _cachedWrapU: Nullable<number>;
  115116. /** @hidden */
  115117. _cachedWrapV: Nullable<number>;
  115118. /** @hidden */
  115119. _cachedWrapR: Nullable<number>;
  115120. /** @hidden */
  115121. _cachedAnisotropicFilteringLevel: Nullable<number>;
  115122. /** @hidden */
  115123. _isDisabled: boolean;
  115124. /** @hidden */
  115125. _compression: Nullable<string>;
  115126. /** @hidden */
  115127. _generateStencilBuffer: boolean;
  115128. /** @hidden */
  115129. _generateDepthBuffer: boolean;
  115130. /** @hidden */
  115131. _comparisonFunction: number;
  115132. /** @hidden */
  115133. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  115134. /** @hidden */
  115135. _lodGenerationScale: number;
  115136. /** @hidden */
  115137. _lodGenerationOffset: number;
  115138. /** @hidden */
  115139. _depthStencilTexture: Nullable<InternalTexture>;
  115140. /** @hidden */
  115141. _colorTextureArray: Nullable<WebGLTexture>;
  115142. /** @hidden */
  115143. _depthStencilTextureArray: Nullable<WebGLTexture>;
  115144. /** @hidden */
  115145. _lodTextureHigh: Nullable<BaseTexture>;
  115146. /** @hidden */
  115147. _lodTextureMid: Nullable<BaseTexture>;
  115148. /** @hidden */
  115149. _lodTextureLow: Nullable<BaseTexture>;
  115150. /** @hidden */
  115151. _isRGBD: boolean;
  115152. /** @hidden */
  115153. _linearSpecularLOD: boolean;
  115154. /** @hidden */
  115155. _irradianceTexture: Nullable<BaseTexture>;
  115156. /** @hidden */
  115157. _webGLTexture: Nullable<WebGLTexture>;
  115158. /** @hidden */
  115159. _references: number;
  115160. private _engine;
  115161. /**
  115162. * Gets the Engine the texture belongs to.
  115163. * @returns The babylon engine
  115164. */
  115165. getEngine(): ThinEngine;
  115166. /**
  115167. * Gets the data source type of the texture
  115168. */
  115169. get source(): InternalTextureSource;
  115170. /**
  115171. * Creates a new InternalTexture
  115172. * @param engine defines the engine to use
  115173. * @param source defines the type of data that will be used
  115174. * @param delayAllocation if the texture allocation should be delayed (default: false)
  115175. */
  115176. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  115177. /**
  115178. * Increments the number of references (ie. the number of Texture that point to it)
  115179. */
  115180. incrementReferences(): void;
  115181. /**
  115182. * Change the size of the texture (not the size of the content)
  115183. * @param width defines the new width
  115184. * @param height defines the new height
  115185. * @param depth defines the new depth (1 by default)
  115186. */
  115187. updateSize(width: int, height: int, depth?: int): void;
  115188. /** @hidden */
  115189. _rebuild(): void;
  115190. /** @hidden */
  115191. _swapAndDie(target: InternalTexture): void;
  115192. /**
  115193. * Dispose the current allocated resources
  115194. */
  115195. dispose(): void;
  115196. }
  115197. }
  115198. declare module BABYLON {
  115199. /**
  115200. * Class used to work with sound analyzer using fast fourier transform (FFT)
  115201. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115202. */
  115203. export class Analyser {
  115204. /**
  115205. * Gets or sets the smoothing
  115206. * @ignorenaming
  115207. */
  115208. SMOOTHING: number;
  115209. /**
  115210. * Gets or sets the FFT table size
  115211. * @ignorenaming
  115212. */
  115213. FFT_SIZE: number;
  115214. /**
  115215. * Gets or sets the bar graph amplitude
  115216. * @ignorenaming
  115217. */
  115218. BARGRAPHAMPLITUDE: number;
  115219. /**
  115220. * Gets or sets the position of the debug canvas
  115221. * @ignorenaming
  115222. */
  115223. DEBUGCANVASPOS: {
  115224. x: number;
  115225. y: number;
  115226. };
  115227. /**
  115228. * Gets or sets the debug canvas size
  115229. * @ignorenaming
  115230. */
  115231. DEBUGCANVASSIZE: {
  115232. width: number;
  115233. height: number;
  115234. };
  115235. private _byteFreqs;
  115236. private _byteTime;
  115237. private _floatFreqs;
  115238. private _webAudioAnalyser;
  115239. private _debugCanvas;
  115240. private _debugCanvasContext;
  115241. private _scene;
  115242. private _registerFunc;
  115243. private _audioEngine;
  115244. /**
  115245. * Creates a new analyser
  115246. * @param scene defines hosting scene
  115247. */
  115248. constructor(scene: Scene);
  115249. /**
  115250. * Get the number of data values you will have to play with for the visualization
  115251. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  115252. * @returns a number
  115253. */
  115254. getFrequencyBinCount(): number;
  115255. /**
  115256. * Gets the current frequency data as a byte array
  115257. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  115258. * @returns a Uint8Array
  115259. */
  115260. getByteFrequencyData(): Uint8Array;
  115261. /**
  115262. * Gets the current waveform as a byte array
  115263. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  115264. * @returns a Uint8Array
  115265. */
  115266. getByteTimeDomainData(): Uint8Array;
  115267. /**
  115268. * Gets the current frequency data as a float array
  115269. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  115270. * @returns a Float32Array
  115271. */
  115272. getFloatFrequencyData(): Float32Array;
  115273. /**
  115274. * Renders the debug canvas
  115275. */
  115276. drawDebugCanvas(): void;
  115277. /**
  115278. * Stops rendering the debug canvas and removes it
  115279. */
  115280. stopDebugCanvas(): void;
  115281. /**
  115282. * Connects two audio nodes
  115283. * @param inputAudioNode defines first node to connect
  115284. * @param outputAudioNode defines second node to connect
  115285. */
  115286. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  115287. /**
  115288. * Releases all associated resources
  115289. */
  115290. dispose(): void;
  115291. }
  115292. }
  115293. declare module BABYLON {
  115294. /**
  115295. * This represents an audio engine and it is responsible
  115296. * to play, synchronize and analyse sounds throughout the application.
  115297. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115298. */
  115299. export interface IAudioEngine extends IDisposable {
  115300. /**
  115301. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  115302. */
  115303. readonly canUseWebAudio: boolean;
  115304. /**
  115305. * Gets the current AudioContext if available.
  115306. */
  115307. readonly audioContext: Nullable<AudioContext>;
  115308. /**
  115309. * The master gain node defines the global audio volume of your audio engine.
  115310. */
  115311. readonly masterGain: GainNode;
  115312. /**
  115313. * Gets whether or not mp3 are supported by your browser.
  115314. */
  115315. readonly isMP3supported: boolean;
  115316. /**
  115317. * Gets whether or not ogg are supported by your browser.
  115318. */
  115319. readonly isOGGsupported: boolean;
  115320. /**
  115321. * Defines if Babylon should emit a warning if WebAudio is not supported.
  115322. * @ignoreNaming
  115323. */
  115324. WarnedWebAudioUnsupported: boolean;
  115325. /**
  115326. * Defines if the audio engine relies on a custom unlocked button.
  115327. * In this case, the embedded button will not be displayed.
  115328. */
  115329. useCustomUnlockedButton: boolean;
  115330. /**
  115331. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  115332. */
  115333. readonly unlocked: boolean;
  115334. /**
  115335. * Event raised when audio has been unlocked on the browser.
  115336. */
  115337. onAudioUnlockedObservable: Observable<AudioEngine>;
  115338. /**
  115339. * Event raised when audio has been locked on the browser.
  115340. */
  115341. onAudioLockedObservable: Observable<AudioEngine>;
  115342. /**
  115343. * Flags the audio engine in Locked state.
  115344. * This happens due to new browser policies preventing audio to autoplay.
  115345. */
  115346. lock(): void;
  115347. /**
  115348. * Unlocks the audio engine once a user action has been done on the dom.
  115349. * This is helpful to resume play once browser policies have been satisfied.
  115350. */
  115351. unlock(): void;
  115352. /**
  115353. * Gets the global volume sets on the master gain.
  115354. * @returns the global volume if set or -1 otherwise
  115355. */
  115356. getGlobalVolume(): number;
  115357. /**
  115358. * Sets the global volume of your experience (sets on the master gain).
  115359. * @param newVolume Defines the new global volume of the application
  115360. */
  115361. setGlobalVolume(newVolume: number): void;
  115362. /**
  115363. * Connect the audio engine to an audio analyser allowing some amazing
  115364. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  115365. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  115366. * @param analyser The analyser to connect to the engine
  115367. */
  115368. connectToAnalyser(analyser: Analyser): void;
  115369. }
  115370. /**
  115371. * This represents the default audio engine used in babylon.
  115372. * It is responsible to play, synchronize and analyse sounds throughout the application.
  115373. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115374. */
  115375. export class AudioEngine implements IAudioEngine {
  115376. private _audioContext;
  115377. private _audioContextInitialized;
  115378. private _muteButton;
  115379. private _hostElement;
  115380. /**
  115381. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  115382. */
  115383. canUseWebAudio: boolean;
  115384. /**
  115385. * The master gain node defines the global audio volume of your audio engine.
  115386. */
  115387. masterGain: GainNode;
  115388. /**
  115389. * Defines if Babylon should emit a warning if WebAudio is not supported.
  115390. * @ignoreNaming
  115391. */
  115392. WarnedWebAudioUnsupported: boolean;
  115393. /**
  115394. * Gets whether or not mp3 are supported by your browser.
  115395. */
  115396. isMP3supported: boolean;
  115397. /**
  115398. * Gets whether or not ogg are supported by your browser.
  115399. */
  115400. isOGGsupported: boolean;
  115401. /**
  115402. * Gets whether audio has been unlocked on the device.
  115403. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  115404. * a user interaction has happened.
  115405. */
  115406. unlocked: boolean;
  115407. /**
  115408. * Defines if the audio engine relies on a custom unlocked button.
  115409. * In this case, the embedded button will not be displayed.
  115410. */
  115411. useCustomUnlockedButton: boolean;
  115412. /**
  115413. * Event raised when audio has been unlocked on the browser.
  115414. */
  115415. onAudioUnlockedObservable: Observable<AudioEngine>;
  115416. /**
  115417. * Event raised when audio has been locked on the browser.
  115418. */
  115419. onAudioLockedObservable: Observable<AudioEngine>;
  115420. /**
  115421. * Gets the current AudioContext if available.
  115422. */
  115423. get audioContext(): Nullable<AudioContext>;
  115424. private _connectedAnalyser;
  115425. /**
  115426. * Instantiates a new audio engine.
  115427. *
  115428. * There should be only one per page as some browsers restrict the number
  115429. * of audio contexts you can create.
  115430. * @param hostElement defines the host element where to display the mute icon if necessary
  115431. */
  115432. constructor(hostElement?: Nullable<HTMLElement>);
  115433. /**
  115434. * Flags the audio engine in Locked state.
  115435. * This happens due to new browser policies preventing audio to autoplay.
  115436. */
  115437. lock(): void;
  115438. /**
  115439. * Unlocks the audio engine once a user action has been done on the dom.
  115440. * This is helpful to resume play once browser policies have been satisfied.
  115441. */
  115442. unlock(): void;
  115443. private _resumeAudioContext;
  115444. private _initializeAudioContext;
  115445. private _tryToRun;
  115446. private _triggerRunningState;
  115447. private _triggerSuspendedState;
  115448. private _displayMuteButton;
  115449. private _moveButtonToTopLeft;
  115450. private _onResize;
  115451. private _hideMuteButton;
  115452. /**
  115453. * Destroy and release the resources associated with the audio ccontext.
  115454. */
  115455. dispose(): void;
  115456. /**
  115457. * Gets the global volume sets on the master gain.
  115458. * @returns the global volume if set or -1 otherwise
  115459. */
  115460. getGlobalVolume(): number;
  115461. /**
  115462. * Sets the global volume of your experience (sets on the master gain).
  115463. * @param newVolume Defines the new global volume of the application
  115464. */
  115465. setGlobalVolume(newVolume: number): void;
  115466. /**
  115467. * Connect the audio engine to an audio analyser allowing some amazing
  115468. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  115469. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  115470. * @param analyser The analyser to connect to the engine
  115471. */
  115472. connectToAnalyser(analyser: Analyser): void;
  115473. }
  115474. }
  115475. declare module BABYLON {
  115476. /**
  115477. * Interface used to present a loading screen while loading a scene
  115478. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115479. */
  115480. export interface ILoadingScreen {
  115481. /**
  115482. * Function called to display the loading screen
  115483. */
  115484. displayLoadingUI: () => void;
  115485. /**
  115486. * Function called to hide the loading screen
  115487. */
  115488. hideLoadingUI: () => void;
  115489. /**
  115490. * Gets or sets the color to use for the background
  115491. */
  115492. loadingUIBackgroundColor: string;
  115493. /**
  115494. * Gets or sets the text to display while loading
  115495. */
  115496. loadingUIText: string;
  115497. }
  115498. /**
  115499. * Class used for the default loading screen
  115500. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115501. */
  115502. export class DefaultLoadingScreen implements ILoadingScreen {
  115503. private _renderingCanvas;
  115504. private _loadingText;
  115505. private _loadingDivBackgroundColor;
  115506. private _loadingDiv;
  115507. private _loadingTextDiv;
  115508. /** Gets or sets the logo url to use for the default loading screen */
  115509. static DefaultLogoUrl: string;
  115510. /** Gets or sets the spinner url to use for the default loading screen */
  115511. static DefaultSpinnerUrl: string;
  115512. /**
  115513. * Creates a new default loading screen
  115514. * @param _renderingCanvas defines the canvas used to render the scene
  115515. * @param _loadingText defines the default text to display
  115516. * @param _loadingDivBackgroundColor defines the default background color
  115517. */
  115518. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  115519. /**
  115520. * Function called to display the loading screen
  115521. */
  115522. displayLoadingUI(): void;
  115523. /**
  115524. * Function called to hide the loading screen
  115525. */
  115526. hideLoadingUI(): void;
  115527. /**
  115528. * Gets or sets the text to display while loading
  115529. */
  115530. set loadingUIText(text: string);
  115531. get loadingUIText(): string;
  115532. /**
  115533. * Gets or sets the color to use for the background
  115534. */
  115535. get loadingUIBackgroundColor(): string;
  115536. set loadingUIBackgroundColor(color: string);
  115537. private _resizeLoadingUI;
  115538. }
  115539. }
  115540. declare module BABYLON {
  115541. /**
  115542. * Interface for any object that can request an animation frame
  115543. */
  115544. export interface ICustomAnimationFrameRequester {
  115545. /**
  115546. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  115547. */
  115548. renderFunction?: Function;
  115549. /**
  115550. * Called to request the next frame to render to
  115551. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  115552. */
  115553. requestAnimationFrame: Function;
  115554. /**
  115555. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  115556. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  115557. */
  115558. requestID?: number;
  115559. }
  115560. }
  115561. declare module BABYLON {
  115562. /**
  115563. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  115564. */
  115565. export class PerformanceMonitor {
  115566. private _enabled;
  115567. private _rollingFrameTime;
  115568. private _lastFrameTimeMs;
  115569. /**
  115570. * constructor
  115571. * @param frameSampleSize The number of samples required to saturate the sliding window
  115572. */
  115573. constructor(frameSampleSize?: number);
  115574. /**
  115575. * Samples current frame
  115576. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  115577. */
  115578. sampleFrame(timeMs?: number): void;
  115579. /**
  115580. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  115581. */
  115582. get averageFrameTime(): number;
  115583. /**
  115584. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  115585. */
  115586. get averageFrameTimeVariance(): number;
  115587. /**
  115588. * Returns the frame time of the most recent frame
  115589. */
  115590. get instantaneousFrameTime(): number;
  115591. /**
  115592. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  115593. */
  115594. get averageFPS(): number;
  115595. /**
  115596. * Returns the average framerate in frames per second using the most recent frame time
  115597. */
  115598. get instantaneousFPS(): number;
  115599. /**
  115600. * Returns true if enough samples have been taken to completely fill the sliding window
  115601. */
  115602. get isSaturated(): boolean;
  115603. /**
  115604. * Enables contributions to the sliding window sample set
  115605. */
  115606. enable(): void;
  115607. /**
  115608. * Disables contributions to the sliding window sample set
  115609. * Samples will not be interpolated over the disabled period
  115610. */
  115611. disable(): void;
  115612. /**
  115613. * Returns true if sampling is enabled
  115614. */
  115615. get isEnabled(): boolean;
  115616. /**
  115617. * Resets performance monitor
  115618. */
  115619. reset(): void;
  115620. }
  115621. /**
  115622. * RollingAverage
  115623. *
  115624. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  115625. */
  115626. export class RollingAverage {
  115627. /**
  115628. * Current average
  115629. */
  115630. average: number;
  115631. /**
  115632. * Current variance
  115633. */
  115634. variance: number;
  115635. protected _samples: Array<number>;
  115636. protected _sampleCount: number;
  115637. protected _pos: number;
  115638. protected _m2: number;
  115639. /**
  115640. * constructor
  115641. * @param length The number of samples required to saturate the sliding window
  115642. */
  115643. constructor(length: number);
  115644. /**
  115645. * Adds a sample to the sample set
  115646. * @param v The sample value
  115647. */
  115648. add(v: number): void;
  115649. /**
  115650. * Returns previously added values or null if outside of history or outside the sliding window domain
  115651. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  115652. * @return Value previously recorded with add() or null if outside of range
  115653. */
  115654. history(i: number): number;
  115655. /**
  115656. * Returns true if enough samples have been taken to completely fill the sliding window
  115657. * @return true if sample-set saturated
  115658. */
  115659. isSaturated(): boolean;
  115660. /**
  115661. * Resets the rolling average (equivalent to 0 samples taken so far)
  115662. */
  115663. reset(): void;
  115664. /**
  115665. * Wraps a value around the sample range boundaries
  115666. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  115667. * @return Wrapped position in sample range
  115668. */
  115669. protected _wrapPosition(i: number): number;
  115670. }
  115671. }
  115672. declare module BABYLON {
  115673. /**
  115674. * This class is used to track a performance counter which is number based.
  115675. * The user has access to many properties which give statistics of different nature.
  115676. *
  115677. * The implementer can track two kinds of Performance Counter: time and count.
  115678. * 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.
  115679. * 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.
  115680. */
  115681. export class PerfCounter {
  115682. /**
  115683. * Gets or sets a global boolean to turn on and off all the counters
  115684. */
  115685. static Enabled: boolean;
  115686. /**
  115687. * Returns the smallest value ever
  115688. */
  115689. get min(): number;
  115690. /**
  115691. * Returns the biggest value ever
  115692. */
  115693. get max(): number;
  115694. /**
  115695. * Returns the average value since the performance counter is running
  115696. */
  115697. get average(): number;
  115698. /**
  115699. * Returns the average value of the last second the counter was monitored
  115700. */
  115701. get lastSecAverage(): number;
  115702. /**
  115703. * Returns the current value
  115704. */
  115705. get current(): number;
  115706. /**
  115707. * Gets the accumulated total
  115708. */
  115709. get total(): number;
  115710. /**
  115711. * Gets the total value count
  115712. */
  115713. get count(): number;
  115714. /**
  115715. * Creates a new counter
  115716. */
  115717. constructor();
  115718. /**
  115719. * Call this method to start monitoring a new frame.
  115720. * 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.
  115721. */
  115722. fetchNewFrame(): void;
  115723. /**
  115724. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  115725. * @param newCount the count value to add to the monitored count
  115726. * @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.
  115727. */
  115728. addCount(newCount: number, fetchResult: boolean): void;
  115729. /**
  115730. * Start monitoring this performance counter
  115731. */
  115732. beginMonitoring(): void;
  115733. /**
  115734. * Compute the time lapsed since the previous beginMonitoring() call.
  115735. * @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
  115736. */
  115737. endMonitoring(newFrame?: boolean): void;
  115738. private _fetchResult;
  115739. private _startMonitoringTime;
  115740. private _min;
  115741. private _max;
  115742. private _average;
  115743. private _current;
  115744. private _totalValueCount;
  115745. private _totalAccumulated;
  115746. private _lastSecAverage;
  115747. private _lastSecAccumulated;
  115748. private _lastSecTime;
  115749. private _lastSecValueCount;
  115750. }
  115751. }
  115752. declare module BABYLON {
  115753. interface ThinEngine {
  115754. /**
  115755. * Sets alpha constants used by some alpha blending modes
  115756. * @param r defines the red component
  115757. * @param g defines the green component
  115758. * @param b defines the blue component
  115759. * @param a defines the alpha component
  115760. */
  115761. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  115762. /**
  115763. * Sets the current alpha mode
  115764. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  115765. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  115766. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  115767. */
  115768. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  115769. /**
  115770. * Gets the current alpha mode
  115771. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  115772. * @returns the current alpha mode
  115773. */
  115774. getAlphaMode(): number;
  115775. /**
  115776. * Sets the current alpha equation
  115777. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  115778. */
  115779. setAlphaEquation(equation: number): void;
  115780. /**
  115781. * Gets the current alpha equation.
  115782. * @returns the current alpha equation
  115783. */
  115784. getAlphaEquation(): number;
  115785. }
  115786. }
  115787. declare module BABYLON {
  115788. interface ThinEngine {
  115789. /** @hidden */
  115790. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  115791. }
  115792. }
  115793. declare module BABYLON {
  115794. /**
  115795. * Defines the interface used by display changed events
  115796. */
  115797. export interface IDisplayChangedEventArgs {
  115798. /** Gets the vrDisplay object (if any) */
  115799. vrDisplay: Nullable<any>;
  115800. /** Gets a boolean indicating if webVR is supported */
  115801. vrSupported: boolean;
  115802. }
  115803. /**
  115804. * Defines the interface used by objects containing a viewport (like a camera)
  115805. */
  115806. interface IViewportOwnerLike {
  115807. /**
  115808. * Gets or sets the viewport
  115809. */
  115810. viewport: IViewportLike;
  115811. }
  115812. /**
  115813. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  115814. */
  115815. export class Engine extends ThinEngine {
  115816. /** Defines that alpha blending is disabled */
  115817. static readonly ALPHA_DISABLE: number;
  115818. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  115819. static readonly ALPHA_ADD: number;
  115820. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  115821. static readonly ALPHA_COMBINE: number;
  115822. /** Defines that alpha blending to DEST - SRC * DEST */
  115823. static readonly ALPHA_SUBTRACT: number;
  115824. /** Defines that alpha blending to SRC * DEST */
  115825. static readonly ALPHA_MULTIPLY: number;
  115826. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  115827. static readonly ALPHA_MAXIMIZED: number;
  115828. /** Defines that alpha blending to SRC + DEST */
  115829. static readonly ALPHA_ONEONE: number;
  115830. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  115831. static readonly ALPHA_PREMULTIPLIED: number;
  115832. /**
  115833. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  115834. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  115835. */
  115836. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  115837. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  115838. static readonly ALPHA_INTERPOLATE: number;
  115839. /**
  115840. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  115841. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  115842. */
  115843. static readonly ALPHA_SCREENMODE: number;
  115844. /** Defines that the ressource is not delayed*/
  115845. static readonly DELAYLOADSTATE_NONE: number;
  115846. /** Defines that the ressource was successfully delay loaded */
  115847. static readonly DELAYLOADSTATE_LOADED: number;
  115848. /** Defines that the ressource is currently delay loading */
  115849. static readonly DELAYLOADSTATE_LOADING: number;
  115850. /** Defines that the ressource is delayed and has not started loading */
  115851. static readonly DELAYLOADSTATE_NOTLOADED: number;
  115852. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  115853. static readonly NEVER: number;
  115854. /** 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 */
  115855. static readonly ALWAYS: number;
  115856. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  115857. static readonly LESS: number;
  115858. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  115859. static readonly EQUAL: number;
  115860. /** 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 */
  115861. static readonly LEQUAL: number;
  115862. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  115863. static readonly GREATER: number;
  115864. /** 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 */
  115865. static readonly GEQUAL: number;
  115866. /** 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 */
  115867. static readonly NOTEQUAL: number;
  115868. /** Passed to stencilOperation to specify that stencil value must be kept */
  115869. static readonly KEEP: number;
  115870. /** Passed to stencilOperation to specify that stencil value must be replaced */
  115871. static readonly REPLACE: number;
  115872. /** Passed to stencilOperation to specify that stencil value must be incremented */
  115873. static readonly INCR: number;
  115874. /** Passed to stencilOperation to specify that stencil value must be decremented */
  115875. static readonly DECR: number;
  115876. /** Passed to stencilOperation to specify that stencil value must be inverted */
  115877. static readonly INVERT: number;
  115878. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  115879. static readonly INCR_WRAP: number;
  115880. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  115881. static readonly DECR_WRAP: number;
  115882. /** Texture is not repeating outside of 0..1 UVs */
  115883. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  115884. /** Texture is repeating outside of 0..1 UVs */
  115885. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  115886. /** Texture is repeating and mirrored */
  115887. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  115888. /** ALPHA */
  115889. static readonly TEXTUREFORMAT_ALPHA: number;
  115890. /** LUMINANCE */
  115891. static readonly TEXTUREFORMAT_LUMINANCE: number;
  115892. /** LUMINANCE_ALPHA */
  115893. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  115894. /** RGB */
  115895. static readonly TEXTUREFORMAT_RGB: number;
  115896. /** RGBA */
  115897. static readonly TEXTUREFORMAT_RGBA: number;
  115898. /** RED */
  115899. static readonly TEXTUREFORMAT_RED: number;
  115900. /** RED (2nd reference) */
  115901. static readonly TEXTUREFORMAT_R: number;
  115902. /** RG */
  115903. static readonly TEXTUREFORMAT_RG: number;
  115904. /** RED_INTEGER */
  115905. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  115906. /** RED_INTEGER (2nd reference) */
  115907. static readonly TEXTUREFORMAT_R_INTEGER: number;
  115908. /** RG_INTEGER */
  115909. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  115910. /** RGB_INTEGER */
  115911. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  115912. /** RGBA_INTEGER */
  115913. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  115914. /** UNSIGNED_BYTE */
  115915. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  115916. /** UNSIGNED_BYTE (2nd reference) */
  115917. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  115918. /** FLOAT */
  115919. static readonly TEXTURETYPE_FLOAT: number;
  115920. /** HALF_FLOAT */
  115921. static readonly TEXTURETYPE_HALF_FLOAT: number;
  115922. /** BYTE */
  115923. static readonly TEXTURETYPE_BYTE: number;
  115924. /** SHORT */
  115925. static readonly TEXTURETYPE_SHORT: number;
  115926. /** UNSIGNED_SHORT */
  115927. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  115928. /** INT */
  115929. static readonly TEXTURETYPE_INT: number;
  115930. /** UNSIGNED_INT */
  115931. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  115932. /** UNSIGNED_SHORT_4_4_4_4 */
  115933. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  115934. /** UNSIGNED_SHORT_5_5_5_1 */
  115935. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  115936. /** UNSIGNED_SHORT_5_6_5 */
  115937. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  115938. /** UNSIGNED_INT_2_10_10_10_REV */
  115939. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  115940. /** UNSIGNED_INT_24_8 */
  115941. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  115942. /** UNSIGNED_INT_10F_11F_11F_REV */
  115943. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  115944. /** UNSIGNED_INT_5_9_9_9_REV */
  115945. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  115946. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  115947. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  115948. /** nearest is mag = nearest and min = nearest and mip = linear */
  115949. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  115950. /** Bilinear is mag = linear and min = linear and mip = nearest */
  115951. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  115952. /** Trilinear is mag = linear and min = linear and mip = linear */
  115953. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  115954. /** nearest is mag = nearest and min = nearest and mip = linear */
  115955. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  115956. /** Bilinear is mag = linear and min = linear and mip = nearest */
  115957. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  115958. /** Trilinear is mag = linear and min = linear and mip = linear */
  115959. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  115960. /** mag = nearest and min = nearest and mip = nearest */
  115961. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  115962. /** mag = nearest and min = linear and mip = nearest */
  115963. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  115964. /** mag = nearest and min = linear and mip = linear */
  115965. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  115966. /** mag = nearest and min = linear and mip = none */
  115967. static readonly TEXTURE_NEAREST_LINEAR: number;
  115968. /** mag = nearest and min = nearest and mip = none */
  115969. static readonly TEXTURE_NEAREST_NEAREST: number;
  115970. /** mag = linear and min = nearest and mip = nearest */
  115971. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  115972. /** mag = linear and min = nearest and mip = linear */
  115973. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  115974. /** mag = linear and min = linear and mip = none */
  115975. static readonly TEXTURE_LINEAR_LINEAR: number;
  115976. /** mag = linear and min = nearest and mip = none */
  115977. static readonly TEXTURE_LINEAR_NEAREST: number;
  115978. /** Explicit coordinates mode */
  115979. static readonly TEXTURE_EXPLICIT_MODE: number;
  115980. /** Spherical coordinates mode */
  115981. static readonly TEXTURE_SPHERICAL_MODE: number;
  115982. /** Planar coordinates mode */
  115983. static readonly TEXTURE_PLANAR_MODE: number;
  115984. /** Cubic coordinates mode */
  115985. static readonly TEXTURE_CUBIC_MODE: number;
  115986. /** Projection coordinates mode */
  115987. static readonly TEXTURE_PROJECTION_MODE: number;
  115988. /** Skybox coordinates mode */
  115989. static readonly TEXTURE_SKYBOX_MODE: number;
  115990. /** Inverse Cubic coordinates mode */
  115991. static readonly TEXTURE_INVCUBIC_MODE: number;
  115992. /** Equirectangular coordinates mode */
  115993. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  115994. /** Equirectangular Fixed coordinates mode */
  115995. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  115996. /** Equirectangular Fixed Mirrored coordinates mode */
  115997. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  115998. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  115999. static readonly SCALEMODE_FLOOR: number;
  116000. /** Defines that texture rescaling will look for the nearest power of 2 size */
  116001. static readonly SCALEMODE_NEAREST: number;
  116002. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  116003. static readonly SCALEMODE_CEILING: number;
  116004. /**
  116005. * Returns the current npm package of the sdk
  116006. */
  116007. static get NpmPackage(): string;
  116008. /**
  116009. * Returns the current version of the framework
  116010. */
  116011. static get Version(): string;
  116012. /** Gets the list of created engines */
  116013. static get Instances(): Engine[];
  116014. /**
  116015. * Gets the latest created engine
  116016. */
  116017. static get LastCreatedEngine(): Nullable<Engine>;
  116018. /**
  116019. * Gets the latest created scene
  116020. */
  116021. static get LastCreatedScene(): Nullable<Scene>;
  116022. /**
  116023. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  116024. * @param flag defines which part of the materials must be marked as dirty
  116025. * @param predicate defines a predicate used to filter which materials should be affected
  116026. */
  116027. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  116028. /**
  116029. * Method called to create the default loading screen.
  116030. * This can be overriden in your own app.
  116031. * @param canvas The rendering canvas element
  116032. * @returns The loading screen
  116033. */
  116034. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  116035. /**
  116036. * Method called to create the default rescale post process on each engine.
  116037. */
  116038. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  116039. /**
  116040. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  116041. **/
  116042. enableOfflineSupport: boolean;
  116043. /**
  116044. * 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)
  116045. **/
  116046. disableManifestCheck: boolean;
  116047. /**
  116048. * Gets the list of created scenes
  116049. */
  116050. scenes: Scene[];
  116051. /**
  116052. * Event raised when a new scene is created
  116053. */
  116054. onNewSceneAddedObservable: Observable<Scene>;
  116055. /**
  116056. * Gets the list of created postprocesses
  116057. */
  116058. postProcesses: PostProcess[];
  116059. /**
  116060. * Gets a boolean indicating if the pointer is currently locked
  116061. */
  116062. isPointerLock: boolean;
  116063. /**
  116064. * Observable event triggered each time the rendering canvas is resized
  116065. */
  116066. onResizeObservable: Observable<Engine>;
  116067. /**
  116068. * Observable event triggered each time the canvas loses focus
  116069. */
  116070. onCanvasBlurObservable: Observable<Engine>;
  116071. /**
  116072. * Observable event triggered each time the canvas gains focus
  116073. */
  116074. onCanvasFocusObservable: Observable<Engine>;
  116075. /**
  116076. * Observable event triggered each time the canvas receives pointerout event
  116077. */
  116078. onCanvasPointerOutObservable: Observable<PointerEvent>;
  116079. /**
  116080. * Observable raised when the engine begins a new frame
  116081. */
  116082. onBeginFrameObservable: Observable<Engine>;
  116083. /**
  116084. * If set, will be used to request the next animation frame for the render loop
  116085. */
  116086. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  116087. /**
  116088. * Observable raised when the engine ends the current frame
  116089. */
  116090. onEndFrameObservable: Observable<Engine>;
  116091. /**
  116092. * Observable raised when the engine is about to compile a shader
  116093. */
  116094. onBeforeShaderCompilationObservable: Observable<Engine>;
  116095. /**
  116096. * Observable raised when the engine has jsut compiled a shader
  116097. */
  116098. onAfterShaderCompilationObservable: Observable<Engine>;
  116099. /**
  116100. * Gets the audio engine
  116101. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116102. * @ignorenaming
  116103. */
  116104. static audioEngine: IAudioEngine;
  116105. /**
  116106. * Default AudioEngine factory responsible of creating the Audio Engine.
  116107. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  116108. */
  116109. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  116110. /**
  116111. * Default offline support factory responsible of creating a tool used to store data locally.
  116112. * By default, this will create a Database object if the workload has been embedded.
  116113. */
  116114. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  116115. private _loadingScreen;
  116116. private _pointerLockRequested;
  116117. private _rescalePostProcess;
  116118. private _deterministicLockstep;
  116119. private _lockstepMaxSteps;
  116120. private _timeStep;
  116121. protected get _supportsHardwareTextureRescaling(): boolean;
  116122. private _fps;
  116123. private _deltaTime;
  116124. /** @hidden */
  116125. _drawCalls: PerfCounter;
  116126. /** 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 */
  116127. canvasTabIndex: number;
  116128. /**
  116129. * Turn this value on if you want to pause FPS computation when in background
  116130. */
  116131. disablePerformanceMonitorInBackground: boolean;
  116132. private _performanceMonitor;
  116133. /**
  116134. * Gets the performance monitor attached to this engine
  116135. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116136. */
  116137. get performanceMonitor(): PerformanceMonitor;
  116138. private _onFocus;
  116139. private _onBlur;
  116140. private _onCanvasPointerOut;
  116141. private _onCanvasBlur;
  116142. private _onCanvasFocus;
  116143. private _onFullscreenChange;
  116144. private _onPointerLockChange;
  116145. /**
  116146. * Gets the HTML element used to attach event listeners
  116147. * @returns a HTML element
  116148. */
  116149. getInputElement(): Nullable<HTMLElement>;
  116150. /**
  116151. * Creates a new engine
  116152. * @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
  116153. * @param antialias defines enable antialiasing (default: false)
  116154. * @param options defines further options to be sent to the getContext() function
  116155. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  116156. */
  116157. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  116158. /**
  116159. * Gets current aspect ratio
  116160. * @param viewportOwner defines the camera to use to get the aspect ratio
  116161. * @param useScreen defines if screen size must be used (or the current render target if any)
  116162. * @returns a number defining the aspect ratio
  116163. */
  116164. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  116165. /**
  116166. * Gets current screen aspect ratio
  116167. * @returns a number defining the aspect ratio
  116168. */
  116169. getScreenAspectRatio(): number;
  116170. /**
  116171. * Gets the client rect of the HTML canvas attached with the current webGL context
  116172. * @returns a client rectanglee
  116173. */
  116174. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  116175. /**
  116176. * Gets the client rect of the HTML element used for events
  116177. * @returns a client rectanglee
  116178. */
  116179. getInputElementClientRect(): Nullable<ClientRect>;
  116180. /**
  116181. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  116182. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116183. * @returns true if engine is in deterministic lock step mode
  116184. */
  116185. isDeterministicLockStep(): boolean;
  116186. /**
  116187. * Gets the max steps when engine is running in deterministic lock step
  116188. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116189. * @returns the max steps
  116190. */
  116191. getLockstepMaxSteps(): number;
  116192. /**
  116193. * Returns the time in ms between steps when using deterministic lock step.
  116194. * @returns time step in (ms)
  116195. */
  116196. getTimeStep(): number;
  116197. /**
  116198. * Force the mipmap generation for the given render target texture
  116199. * @param texture defines the render target texture to use
  116200. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  116201. */
  116202. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  116203. /** States */
  116204. /**
  116205. * Set various states to the webGL context
  116206. * @param culling defines backface culling state
  116207. * @param zOffset defines the value to apply to zOffset (0 by default)
  116208. * @param force defines if states must be applied even if cache is up to date
  116209. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  116210. */
  116211. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  116212. /**
  116213. * Set the z offset to apply to current rendering
  116214. * @param value defines the offset to apply
  116215. */
  116216. setZOffset(value: number): void;
  116217. /**
  116218. * Gets the current value of the zOffset
  116219. * @returns the current zOffset state
  116220. */
  116221. getZOffset(): number;
  116222. /**
  116223. * Enable or disable depth buffering
  116224. * @param enable defines the state to set
  116225. */
  116226. setDepthBuffer(enable: boolean): void;
  116227. /**
  116228. * Gets a boolean indicating if depth writing is enabled
  116229. * @returns the current depth writing state
  116230. */
  116231. getDepthWrite(): boolean;
  116232. /**
  116233. * Enable or disable depth writing
  116234. * @param enable defines the state to set
  116235. */
  116236. setDepthWrite(enable: boolean): void;
  116237. /**
  116238. * Gets a boolean indicating if stencil buffer is enabled
  116239. * @returns the current stencil buffer state
  116240. */
  116241. getStencilBuffer(): boolean;
  116242. /**
  116243. * Enable or disable the stencil buffer
  116244. * @param enable defines if the stencil buffer must be enabled or disabled
  116245. */
  116246. setStencilBuffer(enable: boolean): void;
  116247. /**
  116248. * Gets the current stencil mask
  116249. * @returns a number defining the new stencil mask to use
  116250. */
  116251. getStencilMask(): number;
  116252. /**
  116253. * Sets the current stencil mask
  116254. * @param mask defines the new stencil mask to use
  116255. */
  116256. setStencilMask(mask: number): void;
  116257. /**
  116258. * Gets the current stencil function
  116259. * @returns a number defining the stencil function to use
  116260. */
  116261. getStencilFunction(): number;
  116262. /**
  116263. * Gets the current stencil reference value
  116264. * @returns a number defining the stencil reference value to use
  116265. */
  116266. getStencilFunctionReference(): number;
  116267. /**
  116268. * Gets the current stencil mask
  116269. * @returns a number defining the stencil mask to use
  116270. */
  116271. getStencilFunctionMask(): number;
  116272. /**
  116273. * Sets the current stencil function
  116274. * @param stencilFunc defines the new stencil function to use
  116275. */
  116276. setStencilFunction(stencilFunc: number): void;
  116277. /**
  116278. * Sets the current stencil reference
  116279. * @param reference defines the new stencil reference to use
  116280. */
  116281. setStencilFunctionReference(reference: number): void;
  116282. /**
  116283. * Sets the current stencil mask
  116284. * @param mask defines the new stencil mask to use
  116285. */
  116286. setStencilFunctionMask(mask: number): void;
  116287. /**
  116288. * Gets the current stencil operation when stencil fails
  116289. * @returns a number defining stencil operation to use when stencil fails
  116290. */
  116291. getStencilOperationFail(): number;
  116292. /**
  116293. * Gets the current stencil operation when depth fails
  116294. * @returns a number defining stencil operation to use when depth fails
  116295. */
  116296. getStencilOperationDepthFail(): number;
  116297. /**
  116298. * Gets the current stencil operation when stencil passes
  116299. * @returns a number defining stencil operation to use when stencil passes
  116300. */
  116301. getStencilOperationPass(): number;
  116302. /**
  116303. * Sets the stencil operation to use when stencil fails
  116304. * @param operation defines the stencil operation to use when stencil fails
  116305. */
  116306. setStencilOperationFail(operation: number): void;
  116307. /**
  116308. * Sets the stencil operation to use when depth fails
  116309. * @param operation defines the stencil operation to use when depth fails
  116310. */
  116311. setStencilOperationDepthFail(operation: number): void;
  116312. /**
  116313. * Sets the stencil operation to use when stencil passes
  116314. * @param operation defines the stencil operation to use when stencil passes
  116315. */
  116316. setStencilOperationPass(operation: number): void;
  116317. /**
  116318. * Sets a boolean indicating if the dithering state is enabled or disabled
  116319. * @param value defines the dithering state
  116320. */
  116321. setDitheringState(value: boolean): void;
  116322. /**
  116323. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  116324. * @param value defines the rasterizer state
  116325. */
  116326. setRasterizerState(value: boolean): void;
  116327. /**
  116328. * Gets the current depth function
  116329. * @returns a number defining the depth function
  116330. */
  116331. getDepthFunction(): Nullable<number>;
  116332. /**
  116333. * Sets the current depth function
  116334. * @param depthFunc defines the function to use
  116335. */
  116336. setDepthFunction(depthFunc: number): void;
  116337. /**
  116338. * Sets the current depth function to GREATER
  116339. */
  116340. setDepthFunctionToGreater(): void;
  116341. /**
  116342. * Sets the current depth function to GEQUAL
  116343. */
  116344. setDepthFunctionToGreaterOrEqual(): void;
  116345. /**
  116346. * Sets the current depth function to LESS
  116347. */
  116348. setDepthFunctionToLess(): void;
  116349. /**
  116350. * Sets the current depth function to LEQUAL
  116351. */
  116352. setDepthFunctionToLessOrEqual(): void;
  116353. private _cachedStencilBuffer;
  116354. private _cachedStencilFunction;
  116355. private _cachedStencilMask;
  116356. private _cachedStencilOperationPass;
  116357. private _cachedStencilOperationFail;
  116358. private _cachedStencilOperationDepthFail;
  116359. private _cachedStencilReference;
  116360. /**
  116361. * Caches the the state of the stencil buffer
  116362. */
  116363. cacheStencilState(): void;
  116364. /**
  116365. * Restores the state of the stencil buffer
  116366. */
  116367. restoreStencilState(): void;
  116368. /**
  116369. * Directly set the WebGL Viewport
  116370. * @param x defines the x coordinate of the viewport (in screen space)
  116371. * @param y defines the y coordinate of the viewport (in screen space)
  116372. * @param width defines the width of the viewport (in screen space)
  116373. * @param height defines the height of the viewport (in screen space)
  116374. * @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
  116375. */
  116376. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  116377. /**
  116378. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  116379. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  116380. * @param y defines the y-coordinate of the corner of the clear rectangle
  116381. * @param width defines the width of the clear rectangle
  116382. * @param height defines the height of the clear rectangle
  116383. * @param clearColor defines the clear color
  116384. */
  116385. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  116386. /**
  116387. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  116388. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  116389. * @param y defines the y-coordinate of the corner of the clear rectangle
  116390. * @param width defines the width of the clear rectangle
  116391. * @param height defines the height of the clear rectangle
  116392. */
  116393. enableScissor(x: number, y: number, width: number, height: number): void;
  116394. /**
  116395. * Disable previously set scissor test rectangle
  116396. */
  116397. disableScissor(): void;
  116398. protected _reportDrawCall(): void;
  116399. /**
  116400. * Initializes a webVR display and starts listening to display change events
  116401. * The onVRDisplayChangedObservable will be notified upon these changes
  116402. * @returns The onVRDisplayChangedObservable
  116403. */
  116404. initWebVR(): Observable<IDisplayChangedEventArgs>;
  116405. /** @hidden */
  116406. _prepareVRComponent(): void;
  116407. /** @hidden */
  116408. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  116409. /** @hidden */
  116410. _submitVRFrame(): void;
  116411. /**
  116412. * Call this function to leave webVR mode
  116413. * Will do nothing if webVR is not supported or if there is no webVR device
  116414. * @see https://doc.babylonjs.com/how_to/webvr_camera
  116415. */
  116416. disableVR(): void;
  116417. /**
  116418. * Gets a boolean indicating that the system is in VR mode and is presenting
  116419. * @returns true if VR mode is engaged
  116420. */
  116421. isVRPresenting(): boolean;
  116422. /** @hidden */
  116423. _requestVRFrame(): void;
  116424. /** @hidden */
  116425. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  116426. /**
  116427. * Gets the source code of the vertex shader associated with a specific webGL program
  116428. * @param program defines the program to use
  116429. * @returns a string containing the source code of the vertex shader associated with the program
  116430. */
  116431. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  116432. /**
  116433. * Gets the source code of the fragment shader associated with a specific webGL program
  116434. * @param program defines the program to use
  116435. * @returns a string containing the source code of the fragment shader associated with the program
  116436. */
  116437. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  116438. /**
  116439. * Sets a depth stencil texture from a render target to the according uniform.
  116440. * @param channel The texture channel
  116441. * @param uniform The uniform to set
  116442. * @param texture The render target texture containing the depth stencil texture to apply
  116443. */
  116444. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  116445. /**
  116446. * Sets a texture to the webGL context from a postprocess
  116447. * @param channel defines the channel to use
  116448. * @param postProcess defines the source postprocess
  116449. */
  116450. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  116451. /**
  116452. * Binds the output of the passed in post process to the texture channel specified
  116453. * @param channel The channel the texture should be bound to
  116454. * @param postProcess The post process which's output should be bound
  116455. */
  116456. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  116457. protected _rebuildBuffers(): void;
  116458. /** @hidden */
  116459. _renderFrame(): void;
  116460. _renderLoop(): void;
  116461. /** @hidden */
  116462. _renderViews(): boolean;
  116463. /**
  116464. * Toggle full screen mode
  116465. * @param requestPointerLock defines if a pointer lock should be requested from the user
  116466. */
  116467. switchFullscreen(requestPointerLock: boolean): void;
  116468. /**
  116469. * Enters full screen mode
  116470. * @param requestPointerLock defines if a pointer lock should be requested from the user
  116471. */
  116472. enterFullscreen(requestPointerLock: boolean): void;
  116473. /**
  116474. * Exits full screen mode
  116475. */
  116476. exitFullscreen(): void;
  116477. /**
  116478. * Enters Pointerlock mode
  116479. */
  116480. enterPointerlock(): void;
  116481. /**
  116482. * Exits Pointerlock mode
  116483. */
  116484. exitPointerlock(): void;
  116485. /**
  116486. * Begin a new frame
  116487. */
  116488. beginFrame(): void;
  116489. /**
  116490. * Enf the current frame
  116491. */
  116492. endFrame(): void;
  116493. resize(): void;
  116494. /**
  116495. * Force a specific size of the canvas
  116496. * @param width defines the new canvas' width
  116497. * @param height defines the new canvas' height
  116498. * @returns true if the size was changed
  116499. */
  116500. setSize(width: number, height: number): boolean;
  116501. /**
  116502. * Updates a dynamic vertex buffer.
  116503. * @param vertexBuffer the vertex buffer to update
  116504. * @param data the data used to update the vertex buffer
  116505. * @param byteOffset the byte offset of the data
  116506. * @param byteLength the byte length of the data
  116507. */
  116508. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  116509. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  116510. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116511. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116512. _releaseTexture(texture: InternalTexture): void;
  116513. /**
  116514. * @hidden
  116515. * Rescales a texture
  116516. * @param source input texutre
  116517. * @param destination destination texture
  116518. * @param scene scene to use to render the resize
  116519. * @param internalFormat format to use when resizing
  116520. * @param onComplete callback to be called when resize has completed
  116521. */
  116522. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116523. /**
  116524. * Gets the current framerate
  116525. * @returns a number representing the framerate
  116526. */
  116527. getFps(): number;
  116528. /**
  116529. * Gets the time spent between current and previous frame
  116530. * @returns a number representing the delta time in ms
  116531. */
  116532. getDeltaTime(): number;
  116533. private _measureFps;
  116534. /** @hidden */
  116535. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  116536. /**
  116537. * Update a dynamic index buffer
  116538. * @param indexBuffer defines the target index buffer
  116539. * @param indices defines the data to update
  116540. * @param offset defines the offset in the target index buffer where update should start
  116541. */
  116542. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  116543. /**
  116544. * Updates the sample count of a render target texture
  116545. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  116546. * @param texture defines the texture to update
  116547. * @param samples defines the sample count to set
  116548. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  116549. */
  116550. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  116551. /**
  116552. * Updates a depth texture Comparison Mode and Function.
  116553. * If the comparison Function is equal to 0, the mode will be set to none.
  116554. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  116555. * @param texture The texture to set the comparison function for
  116556. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  116557. */
  116558. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  116559. /**
  116560. * Creates a webGL buffer to use with instanciation
  116561. * @param capacity defines the size of the buffer
  116562. * @returns the webGL buffer
  116563. */
  116564. createInstancesBuffer(capacity: number): DataBuffer;
  116565. /**
  116566. * Delete a webGL buffer used with instanciation
  116567. * @param buffer defines the webGL buffer to delete
  116568. */
  116569. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  116570. private _clientWaitAsync;
  116571. /** @hidden */
  116572. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  116573. dispose(): void;
  116574. private _disableTouchAction;
  116575. /**
  116576. * Display the loading screen
  116577. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116578. */
  116579. displayLoadingUI(): void;
  116580. /**
  116581. * Hide the loading screen
  116582. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116583. */
  116584. hideLoadingUI(): void;
  116585. /**
  116586. * Gets the current loading screen object
  116587. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116588. */
  116589. get loadingScreen(): ILoadingScreen;
  116590. /**
  116591. * Sets the current loading screen object
  116592. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116593. */
  116594. set loadingScreen(loadingScreen: ILoadingScreen);
  116595. /**
  116596. * Sets the current loading screen text
  116597. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116598. */
  116599. set loadingUIText(text: string);
  116600. /**
  116601. * Sets the current loading screen background color
  116602. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116603. */
  116604. set loadingUIBackgroundColor(color: string);
  116605. /** Pointerlock and fullscreen */
  116606. /**
  116607. * Ask the browser to promote the current element to pointerlock mode
  116608. * @param element defines the DOM element to promote
  116609. */
  116610. static _RequestPointerlock(element: HTMLElement): void;
  116611. /**
  116612. * Asks the browser to exit pointerlock mode
  116613. */
  116614. static _ExitPointerlock(): void;
  116615. /**
  116616. * Ask the browser to promote the current element to fullscreen rendering mode
  116617. * @param element defines the DOM element to promote
  116618. */
  116619. static _RequestFullscreen(element: HTMLElement): void;
  116620. /**
  116621. * Asks the browser to exit fullscreen mode
  116622. */
  116623. static _ExitFullscreen(): void;
  116624. }
  116625. }
  116626. declare module BABYLON {
  116627. /**
  116628. * The engine store class is responsible to hold all the instances of Engine and Scene created
  116629. * during the life time of the application.
  116630. */
  116631. export class EngineStore {
  116632. /** Gets the list of created engines */
  116633. static Instances: Engine[];
  116634. /** @hidden */
  116635. static _LastCreatedScene: Nullable<Scene>;
  116636. /**
  116637. * Gets the latest created engine
  116638. */
  116639. static get LastCreatedEngine(): Nullable<Engine>;
  116640. /**
  116641. * Gets the latest created scene
  116642. */
  116643. static get LastCreatedScene(): Nullable<Scene>;
  116644. /**
  116645. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  116646. * @ignorenaming
  116647. */
  116648. static UseFallbackTexture: boolean;
  116649. /**
  116650. * Texture content used if a texture cannot loaded
  116651. * @ignorenaming
  116652. */
  116653. static FallbackTexture: string;
  116654. }
  116655. }
  116656. declare module BABYLON {
  116657. /**
  116658. * Helper class that provides a small promise polyfill
  116659. */
  116660. export class PromisePolyfill {
  116661. /**
  116662. * Static function used to check if the polyfill is required
  116663. * If this is the case then the function will inject the polyfill to window.Promise
  116664. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  116665. */
  116666. static Apply(force?: boolean): void;
  116667. }
  116668. }
  116669. declare module BABYLON {
  116670. /**
  116671. * Interface for screenshot methods with describe argument called `size` as object with options
  116672. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  116673. */
  116674. export interface IScreenshotSize {
  116675. /**
  116676. * number in pixels for canvas height
  116677. */
  116678. height?: number;
  116679. /**
  116680. * multiplier allowing render at a higher or lower resolution
  116681. * If value is defined then height and width will be ignored and taken from camera
  116682. */
  116683. precision?: number;
  116684. /**
  116685. * number in pixels for canvas width
  116686. */
  116687. width?: number;
  116688. }
  116689. }
  116690. declare module BABYLON {
  116691. interface IColor4Like {
  116692. r: float;
  116693. g: float;
  116694. b: float;
  116695. a: float;
  116696. }
  116697. /**
  116698. * Class containing a set of static utilities functions
  116699. */
  116700. export class Tools {
  116701. /**
  116702. * Gets or sets the base URL to use to load assets
  116703. */
  116704. static get BaseUrl(): string;
  116705. static set BaseUrl(value: string);
  116706. /**
  116707. * Enable/Disable Custom HTTP Request Headers globally.
  116708. * default = false
  116709. * @see CustomRequestHeaders
  116710. */
  116711. static UseCustomRequestHeaders: boolean;
  116712. /**
  116713. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  116714. * i.e. when loading files, where the server/service expects an Authorization header
  116715. */
  116716. static CustomRequestHeaders: {
  116717. [key: string]: string;
  116718. };
  116719. /**
  116720. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  116721. */
  116722. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  116723. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  116724. /**
  116725. * Default behaviour for cors in the application.
  116726. * It can be a string if the expected behavior is identical in the entire app.
  116727. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  116728. */
  116729. static get CorsBehavior(): string | ((url: string | string[]) => string);
  116730. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  116731. /**
  116732. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  116733. * @ignorenaming
  116734. */
  116735. static get UseFallbackTexture(): boolean;
  116736. static set UseFallbackTexture(value: boolean);
  116737. /**
  116738. * Use this object to register external classes like custom textures or material
  116739. * to allow the laoders to instantiate them
  116740. */
  116741. static get RegisteredExternalClasses(): {
  116742. [key: string]: Object;
  116743. };
  116744. static set RegisteredExternalClasses(classes: {
  116745. [key: string]: Object;
  116746. });
  116747. /**
  116748. * Texture content used if a texture cannot loaded
  116749. * @ignorenaming
  116750. */
  116751. static get fallbackTexture(): string;
  116752. static set fallbackTexture(value: string);
  116753. /**
  116754. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  116755. * @param u defines the coordinate on X axis
  116756. * @param v defines the coordinate on Y axis
  116757. * @param width defines the width of the source data
  116758. * @param height defines the height of the source data
  116759. * @param pixels defines the source byte array
  116760. * @param color defines the output color
  116761. */
  116762. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  116763. /**
  116764. * Interpolates between a and b via alpha
  116765. * @param a The lower value (returned when alpha = 0)
  116766. * @param b The upper value (returned when alpha = 1)
  116767. * @param alpha The interpolation-factor
  116768. * @return The mixed value
  116769. */
  116770. static Mix(a: number, b: number, alpha: number): number;
  116771. /**
  116772. * Tries to instantiate a new object from a given class name
  116773. * @param className defines the class name to instantiate
  116774. * @returns the new object or null if the system was not able to do the instantiation
  116775. */
  116776. static Instantiate(className: string): any;
  116777. /**
  116778. * Provides a slice function that will work even on IE
  116779. * @param data defines the array to slice
  116780. * @param start defines the start of the data (optional)
  116781. * @param end defines the end of the data (optional)
  116782. * @returns the new sliced array
  116783. */
  116784. static Slice<T>(data: T, start?: number, end?: number): T;
  116785. /**
  116786. * Polyfill for setImmediate
  116787. * @param action defines the action to execute after the current execution block
  116788. */
  116789. static SetImmediate(action: () => void): void;
  116790. /**
  116791. * Function indicating if a number is an exponent of 2
  116792. * @param value defines the value to test
  116793. * @returns true if the value is an exponent of 2
  116794. */
  116795. static IsExponentOfTwo(value: number): boolean;
  116796. private static _tmpFloatArray;
  116797. /**
  116798. * Returns the nearest 32-bit single precision float representation of a Number
  116799. * @param value A Number. If the parameter is of a different type, it will get converted
  116800. * to a number or to NaN if it cannot be converted
  116801. * @returns number
  116802. */
  116803. static FloatRound(value: number): number;
  116804. /**
  116805. * Extracts the filename from a path
  116806. * @param path defines the path to use
  116807. * @returns the filename
  116808. */
  116809. static GetFilename(path: string): string;
  116810. /**
  116811. * Extracts the "folder" part of a path (everything before the filename).
  116812. * @param uri The URI to extract the info from
  116813. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  116814. * @returns The "folder" part of the path
  116815. */
  116816. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  116817. /**
  116818. * Extracts text content from a DOM element hierarchy
  116819. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  116820. */
  116821. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  116822. /**
  116823. * Convert an angle in radians to degrees
  116824. * @param angle defines the angle to convert
  116825. * @returns the angle in degrees
  116826. */
  116827. static ToDegrees(angle: number): number;
  116828. /**
  116829. * Convert an angle in degrees to radians
  116830. * @param angle defines the angle to convert
  116831. * @returns the angle in radians
  116832. */
  116833. static ToRadians(angle: number): number;
  116834. /**
  116835. * Returns an array if obj is not an array
  116836. * @param obj defines the object to evaluate as an array
  116837. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  116838. * @returns either obj directly if obj is an array or a new array containing obj
  116839. */
  116840. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  116841. /**
  116842. * Gets the pointer prefix to use
  116843. * @param engine defines the engine we are finding the prefix for
  116844. * @returns "pointer" if touch is enabled. Else returns "mouse"
  116845. */
  116846. static GetPointerPrefix(engine: Engine): string;
  116847. /**
  116848. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  116849. * @param url define the url we are trying
  116850. * @param element define the dom element where to configure the cors policy
  116851. */
  116852. static SetCorsBehavior(url: string | string[], element: {
  116853. crossOrigin: string | null;
  116854. }): void;
  116855. /**
  116856. * Removes unwanted characters from an url
  116857. * @param url defines the url to clean
  116858. * @returns the cleaned url
  116859. */
  116860. static CleanUrl(url: string): string;
  116861. /**
  116862. * Gets or sets a function used to pre-process url before using them to load assets
  116863. */
  116864. static get PreprocessUrl(): (url: string) => string;
  116865. static set PreprocessUrl(processor: (url: string) => string);
  116866. /**
  116867. * Loads an image as an HTMLImageElement.
  116868. * @param input url string, ArrayBuffer, or Blob to load
  116869. * @param onLoad callback called when the image successfully loads
  116870. * @param onError callback called when the image fails to load
  116871. * @param offlineProvider offline provider for caching
  116872. * @param mimeType optional mime type
  116873. * @returns the HTMLImageElement of the loaded image
  116874. */
  116875. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  116876. /**
  116877. * Loads a file from a url
  116878. * @param url url string, ArrayBuffer, or Blob to load
  116879. * @param onSuccess callback called when the file successfully loads
  116880. * @param onProgress callback called while file is loading (if the server supports this mode)
  116881. * @param offlineProvider defines the offline provider for caching
  116882. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116883. * @param onError callback called when the file fails to load
  116884. * @returns a file request object
  116885. */
  116886. 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;
  116887. /**
  116888. * Loads a file from a url
  116889. * @param url the file url to load
  116890. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116891. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  116892. */
  116893. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  116894. /**
  116895. * Load a script (identified by an url). When the url returns, the
  116896. * content of this file is added into a new script element, attached to the DOM (body element)
  116897. * @param scriptUrl defines the url of the script to laod
  116898. * @param onSuccess defines the callback called when the script is loaded
  116899. * @param onError defines the callback to call if an error occurs
  116900. * @param scriptId defines the id of the script element
  116901. */
  116902. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  116903. /**
  116904. * Load an asynchronous script (identified by an url). When the url returns, the
  116905. * content of this file is added into a new script element, attached to the DOM (body element)
  116906. * @param scriptUrl defines the url of the script to laod
  116907. * @param scriptId defines the id of the script element
  116908. * @returns a promise request object
  116909. */
  116910. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  116911. /**
  116912. * Loads a file from a blob
  116913. * @param fileToLoad defines the blob to use
  116914. * @param callback defines the callback to call when data is loaded
  116915. * @param progressCallback defines the callback to call during loading process
  116916. * @returns a file request object
  116917. */
  116918. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  116919. /**
  116920. * Reads a file from a File object
  116921. * @param file defines the file to load
  116922. * @param onSuccess defines the callback to call when data is loaded
  116923. * @param onProgress defines the callback to call during loading process
  116924. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116925. * @param onError defines the callback to call when an error occurs
  116926. * @returns a file request object
  116927. */
  116928. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  116929. /**
  116930. * Creates a data url from a given string content
  116931. * @param content defines the content to convert
  116932. * @returns the new data url link
  116933. */
  116934. static FileAsURL(content: string): string;
  116935. /**
  116936. * Format the given number to a specific decimal format
  116937. * @param value defines the number to format
  116938. * @param decimals defines the number of decimals to use
  116939. * @returns the formatted string
  116940. */
  116941. static Format(value: number, decimals?: number): string;
  116942. /**
  116943. * Tries to copy an object by duplicating every property
  116944. * @param source defines the source object
  116945. * @param destination defines the target object
  116946. * @param doNotCopyList defines a list of properties to avoid
  116947. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  116948. */
  116949. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  116950. /**
  116951. * Gets a boolean indicating if the given object has no own property
  116952. * @param obj defines the object to test
  116953. * @returns true if object has no own property
  116954. */
  116955. static IsEmpty(obj: any): boolean;
  116956. /**
  116957. * Function used to register events at window level
  116958. * @param windowElement defines the Window object to use
  116959. * @param events defines the events to register
  116960. */
  116961. static RegisterTopRootEvents(windowElement: Window, events: {
  116962. name: string;
  116963. handler: Nullable<(e: FocusEvent) => any>;
  116964. }[]): void;
  116965. /**
  116966. * Function used to unregister events from window level
  116967. * @param windowElement defines the Window object to use
  116968. * @param events defines the events to unregister
  116969. */
  116970. static UnregisterTopRootEvents(windowElement: Window, events: {
  116971. name: string;
  116972. handler: Nullable<(e: FocusEvent) => any>;
  116973. }[]): void;
  116974. /**
  116975. * @ignore
  116976. */
  116977. static _ScreenshotCanvas: HTMLCanvasElement;
  116978. /**
  116979. * Dumps the current bound framebuffer
  116980. * @param width defines the rendering width
  116981. * @param height defines the rendering height
  116982. * @param engine defines the hosting engine
  116983. * @param successCallback defines the callback triggered once the data are available
  116984. * @param mimeType defines the mime type of the result
  116985. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  116986. */
  116987. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  116988. /**
  116989. * Converts the canvas data to blob.
  116990. * This acts as a polyfill for browsers not supporting the to blob function.
  116991. * @param canvas Defines the canvas to extract the data from
  116992. * @param successCallback Defines the callback triggered once the data are available
  116993. * @param mimeType Defines the mime type of the result
  116994. */
  116995. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  116996. /**
  116997. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  116998. * @param successCallback defines the callback triggered once the data are available
  116999. * @param mimeType defines the mime type of the result
  117000. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  117001. */
  117002. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  117003. /**
  117004. * Downloads a blob in the browser
  117005. * @param blob defines the blob to download
  117006. * @param fileName defines the name of the downloaded file
  117007. */
  117008. static Download(blob: Blob, fileName: string): void;
  117009. /**
  117010. * Captures a screenshot of the current rendering
  117011. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117012. * @param engine defines the rendering engine
  117013. * @param camera defines the source camera
  117014. * @param size This parameter can be set to a single number or to an object with the
  117015. * following (optional) properties: precision, width, height. If a single number is passed,
  117016. * it will be used for both width and height. If an object is passed, the screenshot size
  117017. * will be derived from the parameters. The precision property is a multiplier allowing
  117018. * rendering at a higher or lower resolution
  117019. * @param successCallback defines the callback receives a single parameter which contains the
  117020. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  117021. * src parameter of an <img> to display it
  117022. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  117023. * Check your browser for supported MIME types
  117024. */
  117025. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  117026. /**
  117027. * Captures a screenshot of the current rendering
  117028. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117029. * @param engine defines the rendering engine
  117030. * @param camera defines the source camera
  117031. * @param size This parameter can be set to a single number or to an object with the
  117032. * following (optional) properties: precision, width, height. If a single number is passed,
  117033. * it will be used for both width and height. If an object is passed, the screenshot size
  117034. * will be derived from the parameters. The precision property is a multiplier allowing
  117035. * rendering at a higher or lower resolution
  117036. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  117037. * Check your browser for supported MIME types
  117038. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  117039. * to the src parameter of an <img> to display it
  117040. */
  117041. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  117042. /**
  117043. * Generates an image screenshot from the specified camera.
  117044. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117045. * @param engine The engine to use for rendering
  117046. * @param camera The camera to use for rendering
  117047. * @param size This parameter can be set to a single number or to an object with the
  117048. * following (optional) properties: precision, width, height. If a single number is passed,
  117049. * it will be used for both width and height. If an object is passed, the screenshot size
  117050. * will be derived from the parameters. The precision property is a multiplier allowing
  117051. * rendering at a higher or lower resolution
  117052. * @param successCallback The callback receives a single parameter which contains the
  117053. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  117054. * src parameter of an <img> to display it
  117055. * @param mimeType The MIME type of the screenshot image (default: image/png).
  117056. * Check your browser for supported MIME types
  117057. * @param samples Texture samples (default: 1)
  117058. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  117059. * @param fileName A name for for the downloaded file.
  117060. */
  117061. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  117062. /**
  117063. * Generates an image screenshot from the specified camera.
  117064. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117065. * @param engine The engine to use for rendering
  117066. * @param camera The camera to use for rendering
  117067. * @param size This parameter can be set to a single number or to an object with the
  117068. * following (optional) properties: precision, width, height. If a single number is passed,
  117069. * it will be used for both width and height. If an object is passed, the screenshot size
  117070. * will be derived from the parameters. The precision property is a multiplier allowing
  117071. * rendering at a higher or lower resolution
  117072. * @param mimeType The MIME type of the screenshot image (default: image/png).
  117073. * Check your browser for supported MIME types
  117074. * @param samples Texture samples (default: 1)
  117075. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  117076. * @param fileName A name for for the downloaded file.
  117077. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  117078. * to the src parameter of an <img> to display it
  117079. */
  117080. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  117081. /**
  117082. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  117083. * Be aware Math.random() could cause collisions, but:
  117084. * "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"
  117085. * @returns a pseudo random id
  117086. */
  117087. static RandomId(): string;
  117088. /**
  117089. * Test if the given uri is a base64 string
  117090. * @param uri The uri to test
  117091. * @return True if the uri is a base64 string or false otherwise
  117092. */
  117093. static IsBase64(uri: string): boolean;
  117094. /**
  117095. * Decode the given base64 uri.
  117096. * @param uri The uri to decode
  117097. * @return The decoded base64 data.
  117098. */
  117099. static DecodeBase64(uri: string): ArrayBuffer;
  117100. /**
  117101. * Gets the absolute url.
  117102. * @param url the input url
  117103. * @return the absolute url
  117104. */
  117105. static GetAbsoluteUrl(url: string): string;
  117106. /**
  117107. * No log
  117108. */
  117109. static readonly NoneLogLevel: number;
  117110. /**
  117111. * Only message logs
  117112. */
  117113. static readonly MessageLogLevel: number;
  117114. /**
  117115. * Only warning logs
  117116. */
  117117. static readonly WarningLogLevel: number;
  117118. /**
  117119. * Only error logs
  117120. */
  117121. static readonly ErrorLogLevel: number;
  117122. /**
  117123. * All logs
  117124. */
  117125. static readonly AllLogLevel: number;
  117126. /**
  117127. * Gets a value indicating the number of loading errors
  117128. * @ignorenaming
  117129. */
  117130. static get errorsCount(): number;
  117131. /**
  117132. * Callback called when a new log is added
  117133. */
  117134. static OnNewCacheEntry: (entry: string) => void;
  117135. /**
  117136. * Log a message to the console
  117137. * @param message defines the message to log
  117138. */
  117139. static Log(message: string): void;
  117140. /**
  117141. * Write a warning message to the console
  117142. * @param message defines the message to log
  117143. */
  117144. static Warn(message: string): void;
  117145. /**
  117146. * Write an error message to the console
  117147. * @param message defines the message to log
  117148. */
  117149. static Error(message: string): void;
  117150. /**
  117151. * Gets current log cache (list of logs)
  117152. */
  117153. static get LogCache(): string;
  117154. /**
  117155. * Clears the log cache
  117156. */
  117157. static ClearLogCache(): void;
  117158. /**
  117159. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  117160. */
  117161. static set LogLevels(level: number);
  117162. /**
  117163. * Checks if the window object exists
  117164. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  117165. */
  117166. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  117167. /**
  117168. * No performance log
  117169. */
  117170. static readonly PerformanceNoneLogLevel: number;
  117171. /**
  117172. * Use user marks to log performance
  117173. */
  117174. static readonly PerformanceUserMarkLogLevel: number;
  117175. /**
  117176. * Log performance to the console
  117177. */
  117178. static readonly PerformanceConsoleLogLevel: number;
  117179. private static _performance;
  117180. /**
  117181. * Sets the current performance log level
  117182. */
  117183. static set PerformanceLogLevel(level: number);
  117184. private static _StartPerformanceCounterDisabled;
  117185. private static _EndPerformanceCounterDisabled;
  117186. private static _StartUserMark;
  117187. private static _EndUserMark;
  117188. private static _StartPerformanceConsole;
  117189. private static _EndPerformanceConsole;
  117190. /**
  117191. * Starts a performance counter
  117192. */
  117193. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117194. /**
  117195. * Ends a specific performance coutner
  117196. */
  117197. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117198. /**
  117199. * Gets either window.performance.now() if supported or Date.now() else
  117200. */
  117201. static get Now(): number;
  117202. /**
  117203. * This method will return the name of the class used to create the instance of the given object.
  117204. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  117205. * @param object the object to get the class name from
  117206. * @param isType defines if the object is actually a type
  117207. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  117208. */
  117209. static GetClassName(object: any, isType?: boolean): string;
  117210. /**
  117211. * Gets the first element of an array satisfying a given predicate
  117212. * @param array defines the array to browse
  117213. * @param predicate defines the predicate to use
  117214. * @returns null if not found or the element
  117215. */
  117216. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  117217. /**
  117218. * This method will return the name of the full name of the class, including its owning module (if any).
  117219. * 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).
  117220. * @param object the object to get the class name from
  117221. * @param isType defines if the object is actually a type
  117222. * @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.
  117223. * @ignorenaming
  117224. */
  117225. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  117226. /**
  117227. * Returns a promise that resolves after the given amount of time.
  117228. * @param delay Number of milliseconds to delay
  117229. * @returns Promise that resolves after the given amount of time
  117230. */
  117231. static DelayAsync(delay: number): Promise<void>;
  117232. /**
  117233. * Utility function to detect if the current user agent is Safari
  117234. * @returns whether or not the current user agent is safari
  117235. */
  117236. static IsSafari(): boolean;
  117237. }
  117238. /**
  117239. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  117240. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  117241. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  117242. * @param name The name of the class, case should be preserved
  117243. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  117244. */
  117245. export function className(name: string, module?: string): (target: Object) => void;
  117246. /**
  117247. * An implementation of a loop for asynchronous functions.
  117248. */
  117249. export class AsyncLoop {
  117250. /**
  117251. * Defines the number of iterations for the loop
  117252. */
  117253. iterations: number;
  117254. /**
  117255. * Defines the current index of the loop.
  117256. */
  117257. index: number;
  117258. private _done;
  117259. private _fn;
  117260. private _successCallback;
  117261. /**
  117262. * Constructor.
  117263. * @param iterations the number of iterations.
  117264. * @param func the function to run each iteration
  117265. * @param successCallback the callback that will be called upon succesful execution
  117266. * @param offset starting offset.
  117267. */
  117268. constructor(
  117269. /**
  117270. * Defines the number of iterations for the loop
  117271. */
  117272. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  117273. /**
  117274. * Execute the next iteration. Must be called after the last iteration was finished.
  117275. */
  117276. executeNext(): void;
  117277. /**
  117278. * Break the loop and run the success callback.
  117279. */
  117280. breakLoop(): void;
  117281. /**
  117282. * Create and run an async loop.
  117283. * @param iterations the number of iterations.
  117284. * @param fn the function to run each iteration
  117285. * @param successCallback the callback that will be called upon succesful execution
  117286. * @param offset starting offset.
  117287. * @returns the created async loop object
  117288. */
  117289. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  117290. /**
  117291. * A for-loop that will run a given number of iterations synchronous and the rest async.
  117292. * @param iterations total number of iterations
  117293. * @param syncedIterations number of synchronous iterations in each async iteration.
  117294. * @param fn the function to call each iteration.
  117295. * @param callback a success call back that will be called when iterating stops.
  117296. * @param breakFunction a break condition (optional)
  117297. * @param timeout timeout settings for the setTimeout function. default - 0.
  117298. * @returns the created async loop object
  117299. */
  117300. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  117301. }
  117302. }
  117303. declare module BABYLON {
  117304. /**
  117305. * This class implement a typical dictionary using a string as key and the generic type T as value.
  117306. * The underlying implementation relies on an associative array to ensure the best performances.
  117307. * The value can be anything including 'null' but except 'undefined'
  117308. */
  117309. export class StringDictionary<T> {
  117310. /**
  117311. * This will clear this dictionary and copy the content from the 'source' one.
  117312. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  117313. * @param source the dictionary to take the content from and copy to this dictionary
  117314. */
  117315. copyFrom(source: StringDictionary<T>): void;
  117316. /**
  117317. * Get a value based from its key
  117318. * @param key the given key to get the matching value from
  117319. * @return the value if found, otherwise undefined is returned
  117320. */
  117321. get(key: string): T | undefined;
  117322. /**
  117323. * Get a value from its key or add it if it doesn't exist.
  117324. * This method will ensure you that a given key/data will be present in the dictionary.
  117325. * @param key the given key to get the matching value from
  117326. * @param factory the factory that will create the value if the key is not present in the dictionary.
  117327. * The factory will only be invoked if there's no data for the given key.
  117328. * @return the value corresponding to the key.
  117329. */
  117330. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  117331. /**
  117332. * Get a value from its key if present in the dictionary otherwise add it
  117333. * @param key the key to get the value from
  117334. * @param val if there's no such key/value pair in the dictionary add it with this value
  117335. * @return the value corresponding to the key
  117336. */
  117337. getOrAdd(key: string, val: T): T;
  117338. /**
  117339. * Check if there's a given key in the dictionary
  117340. * @param key the key to check for
  117341. * @return true if the key is present, false otherwise
  117342. */
  117343. contains(key: string): boolean;
  117344. /**
  117345. * Add a new key and its corresponding value
  117346. * @param key the key to add
  117347. * @param value the value corresponding to the key
  117348. * @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
  117349. */
  117350. add(key: string, value: T): boolean;
  117351. /**
  117352. * Update a specific value associated to a key
  117353. * @param key defines the key to use
  117354. * @param value defines the value to store
  117355. * @returns true if the value was updated (or false if the key was not found)
  117356. */
  117357. set(key: string, value: T): boolean;
  117358. /**
  117359. * Get the element of the given key and remove it from the dictionary
  117360. * @param key defines the key to search
  117361. * @returns the value associated with the key or null if not found
  117362. */
  117363. getAndRemove(key: string): Nullable<T>;
  117364. /**
  117365. * Remove a key/value from the dictionary.
  117366. * @param key the key to remove
  117367. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  117368. */
  117369. remove(key: string): boolean;
  117370. /**
  117371. * Clear the whole content of the dictionary
  117372. */
  117373. clear(): void;
  117374. /**
  117375. * Gets the current count
  117376. */
  117377. get count(): number;
  117378. /**
  117379. * Execute a callback on each key/val of the dictionary.
  117380. * Note that you can remove any element in this dictionary in the callback implementation
  117381. * @param callback the callback to execute on a given key/value pair
  117382. */
  117383. forEach(callback: (key: string, val: T) => void): void;
  117384. /**
  117385. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  117386. * If the callback returns null or undefined the method will iterate to the next key/value pair
  117387. * Note that you can remove any element in this dictionary in the callback implementation
  117388. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  117389. * @returns the first item
  117390. */
  117391. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  117392. private _count;
  117393. private _data;
  117394. }
  117395. }
  117396. declare module BABYLON {
  117397. /** @hidden */
  117398. export interface ICollisionCoordinator {
  117399. createCollider(): Collider;
  117400. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  117401. init(scene: Scene): void;
  117402. }
  117403. /** @hidden */
  117404. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  117405. private _scene;
  117406. private _scaledPosition;
  117407. private _scaledVelocity;
  117408. private _finalPosition;
  117409. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  117410. createCollider(): Collider;
  117411. init(scene: Scene): void;
  117412. private _collideWithWorld;
  117413. }
  117414. }
  117415. declare module BABYLON {
  117416. /**
  117417. * Class used to manage all inputs for the scene.
  117418. */
  117419. export class InputManager {
  117420. /** The distance in pixel that you have to move to prevent some events */
  117421. static DragMovementThreshold: number;
  117422. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  117423. static LongPressDelay: number;
  117424. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  117425. static DoubleClickDelay: number;
  117426. /** If you need to check double click without raising a single click at first click, enable this flag */
  117427. static ExclusiveDoubleClickMode: boolean;
  117428. /** 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. */
  117429. private _alreadyAttached;
  117430. private _wheelEventName;
  117431. private _onPointerMove;
  117432. private _onPointerDown;
  117433. private _onPointerUp;
  117434. private _initClickEvent;
  117435. private _initActionManager;
  117436. private _delayedSimpleClick;
  117437. private _delayedSimpleClickTimeout;
  117438. private _previousDelayedSimpleClickTimeout;
  117439. private _meshPickProceed;
  117440. private _previousButtonPressed;
  117441. private _currentPickResult;
  117442. private _previousPickResult;
  117443. private _totalPointersPressed;
  117444. private _doubleClickOccured;
  117445. private _pointerOverMesh;
  117446. private _pickedDownMesh;
  117447. private _pickedUpMesh;
  117448. private _pointerX;
  117449. private _pointerY;
  117450. private _unTranslatedPointerX;
  117451. private _unTranslatedPointerY;
  117452. private _startingPointerPosition;
  117453. private _previousStartingPointerPosition;
  117454. private _startingPointerTime;
  117455. private _previousStartingPointerTime;
  117456. private _pointerCaptures;
  117457. private _onKeyDown;
  117458. private _onKeyUp;
  117459. private _onCanvasFocusObserver;
  117460. private _onCanvasBlurObserver;
  117461. private _scene;
  117462. /**
  117463. * Creates a new InputManager
  117464. * @param scene defines the hosting scene
  117465. */
  117466. constructor(scene: Scene);
  117467. /**
  117468. * Gets the mesh that is currently under the pointer
  117469. */
  117470. get meshUnderPointer(): Nullable<AbstractMesh>;
  117471. /**
  117472. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  117473. */
  117474. get unTranslatedPointer(): Vector2;
  117475. /**
  117476. * Gets or sets the current on-screen X position of the pointer
  117477. */
  117478. get pointerX(): number;
  117479. set pointerX(value: number);
  117480. /**
  117481. * Gets or sets the current on-screen Y position of the pointer
  117482. */
  117483. get pointerY(): number;
  117484. set pointerY(value: number);
  117485. private _updatePointerPosition;
  117486. private _processPointerMove;
  117487. private _setRayOnPointerInfo;
  117488. private _checkPrePointerObservable;
  117489. /**
  117490. * Use this method to simulate a pointer move on a mesh
  117491. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117492. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117493. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117494. */
  117495. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  117496. /**
  117497. * Use this method to simulate a pointer down on a mesh
  117498. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117499. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117500. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117501. */
  117502. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  117503. private _processPointerDown;
  117504. /** @hidden */
  117505. _isPointerSwiping(): boolean;
  117506. /**
  117507. * Use this method to simulate a pointer up on a mesh
  117508. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117509. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117510. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117511. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117512. */
  117513. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  117514. private _processPointerUp;
  117515. /**
  117516. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117517. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117518. * @returns true if the pointer was captured
  117519. */
  117520. isPointerCaptured(pointerId?: number): boolean;
  117521. /**
  117522. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117523. * @param attachUp defines if you want to attach events to pointerup
  117524. * @param attachDown defines if you want to attach events to pointerdown
  117525. * @param attachMove defines if you want to attach events to pointermove
  117526. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  117527. */
  117528. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  117529. /**
  117530. * Detaches all event handlers
  117531. */
  117532. detachControl(): void;
  117533. /**
  117534. * Force the value of meshUnderPointer
  117535. * @param mesh defines the mesh to use
  117536. */
  117537. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  117538. /**
  117539. * Gets the mesh under the pointer
  117540. * @returns a Mesh or null if no mesh is under the pointer
  117541. */
  117542. getPointerOverMesh(): Nullable<AbstractMesh>;
  117543. }
  117544. }
  117545. declare module BABYLON {
  117546. /**
  117547. * This class defines the direct association between an animation and a target
  117548. */
  117549. export class TargetedAnimation {
  117550. /**
  117551. * Animation to perform
  117552. */
  117553. animation: Animation;
  117554. /**
  117555. * Target to animate
  117556. */
  117557. target: any;
  117558. /**
  117559. * Returns the string "TargetedAnimation"
  117560. * @returns "TargetedAnimation"
  117561. */
  117562. getClassName(): string;
  117563. /**
  117564. * Serialize the object
  117565. * @returns the JSON object representing the current entity
  117566. */
  117567. serialize(): any;
  117568. }
  117569. /**
  117570. * Use this class to create coordinated animations on multiple targets
  117571. */
  117572. export class AnimationGroup implements IDisposable {
  117573. /** The name of the animation group */
  117574. name: string;
  117575. private _scene;
  117576. private _targetedAnimations;
  117577. private _animatables;
  117578. private _from;
  117579. private _to;
  117580. private _isStarted;
  117581. private _isPaused;
  117582. private _speedRatio;
  117583. private _loopAnimation;
  117584. private _isAdditive;
  117585. /**
  117586. * Gets or sets the unique id of the node
  117587. */
  117588. uniqueId: number;
  117589. /**
  117590. * This observable will notify when one animation have ended
  117591. */
  117592. onAnimationEndObservable: Observable<TargetedAnimation>;
  117593. /**
  117594. * Observer raised when one animation loops
  117595. */
  117596. onAnimationLoopObservable: Observable<TargetedAnimation>;
  117597. /**
  117598. * Observer raised when all animations have looped
  117599. */
  117600. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  117601. /**
  117602. * This observable will notify when all animations have ended.
  117603. */
  117604. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  117605. /**
  117606. * This observable will notify when all animations have paused.
  117607. */
  117608. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  117609. /**
  117610. * This observable will notify when all animations are playing.
  117611. */
  117612. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  117613. /**
  117614. * Gets the first frame
  117615. */
  117616. get from(): number;
  117617. /**
  117618. * Gets the last frame
  117619. */
  117620. get to(): number;
  117621. /**
  117622. * Define if the animations are started
  117623. */
  117624. get isStarted(): boolean;
  117625. /**
  117626. * Gets a value indicating that the current group is playing
  117627. */
  117628. get isPlaying(): boolean;
  117629. /**
  117630. * Gets or sets the speed ratio to use for all animations
  117631. */
  117632. get speedRatio(): number;
  117633. /**
  117634. * Gets or sets the speed ratio to use for all animations
  117635. */
  117636. set speedRatio(value: number);
  117637. /**
  117638. * Gets or sets if all animations should loop or not
  117639. */
  117640. get loopAnimation(): boolean;
  117641. set loopAnimation(value: boolean);
  117642. /**
  117643. * Gets or sets if all animations should be evaluated additively
  117644. */
  117645. get isAdditive(): boolean;
  117646. set isAdditive(value: boolean);
  117647. /**
  117648. * Gets the targeted animations for this animation group
  117649. */
  117650. get targetedAnimations(): Array<TargetedAnimation>;
  117651. /**
  117652. * returning the list of animatables controlled by this animation group.
  117653. */
  117654. get animatables(): Array<Animatable>;
  117655. /**
  117656. * Gets the list of target animations
  117657. */
  117658. get children(): TargetedAnimation[];
  117659. /**
  117660. * Instantiates a new Animation Group.
  117661. * This helps managing several animations at once.
  117662. * @see https://doc.babylonjs.com/how_to/group
  117663. * @param name Defines the name of the group
  117664. * @param scene Defines the scene the group belongs to
  117665. */
  117666. constructor(
  117667. /** The name of the animation group */
  117668. name: string, scene?: Nullable<Scene>);
  117669. /**
  117670. * Add an animation (with its target) in the group
  117671. * @param animation defines the animation we want to add
  117672. * @param target defines the target of the animation
  117673. * @returns the TargetedAnimation object
  117674. */
  117675. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  117676. /**
  117677. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  117678. * It can add constant keys at begin or end
  117679. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  117680. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  117681. * @returns the animation group
  117682. */
  117683. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  117684. private _animationLoopCount;
  117685. private _animationLoopFlags;
  117686. private _processLoop;
  117687. /**
  117688. * Start all animations on given targets
  117689. * @param loop defines if animations must loop
  117690. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  117691. * @param from defines the from key (optional)
  117692. * @param to defines the to key (optional)
  117693. * @param isAdditive defines the additive state for the resulting animatables (optional)
  117694. * @returns the current animation group
  117695. */
  117696. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  117697. /**
  117698. * Pause all animations
  117699. * @returns the animation group
  117700. */
  117701. pause(): AnimationGroup;
  117702. /**
  117703. * Play all animations to initial state
  117704. * This function will start() the animations if they were not started or will restart() them if they were paused
  117705. * @param loop defines if animations must loop
  117706. * @returns the animation group
  117707. */
  117708. play(loop?: boolean): AnimationGroup;
  117709. /**
  117710. * Reset all animations to initial state
  117711. * @returns the animation group
  117712. */
  117713. reset(): AnimationGroup;
  117714. /**
  117715. * Restart animations from key 0
  117716. * @returns the animation group
  117717. */
  117718. restart(): AnimationGroup;
  117719. /**
  117720. * Stop all animations
  117721. * @returns the animation group
  117722. */
  117723. stop(): AnimationGroup;
  117724. /**
  117725. * Set animation weight for all animatables
  117726. * @param weight defines the weight to use
  117727. * @return the animationGroup
  117728. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  117729. */
  117730. setWeightForAllAnimatables(weight: number): AnimationGroup;
  117731. /**
  117732. * Synchronize and normalize all animatables with a source animatable
  117733. * @param root defines the root animatable to synchronize with
  117734. * @return the animationGroup
  117735. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  117736. */
  117737. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  117738. /**
  117739. * Goes to a specific frame in this animation group
  117740. * @param frame the frame number to go to
  117741. * @return the animationGroup
  117742. */
  117743. goToFrame(frame: number): AnimationGroup;
  117744. /**
  117745. * Dispose all associated resources
  117746. */
  117747. dispose(): void;
  117748. private _checkAnimationGroupEnded;
  117749. /**
  117750. * Clone the current animation group and returns a copy
  117751. * @param newName defines the name of the new group
  117752. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  117753. * @returns the new aniamtion group
  117754. */
  117755. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  117756. /**
  117757. * Serializes the animationGroup to an object
  117758. * @returns Serialized object
  117759. */
  117760. serialize(): any;
  117761. /**
  117762. * Returns a new AnimationGroup object parsed from the source provided.
  117763. * @param parsedAnimationGroup defines the source
  117764. * @param scene defines the scene that will receive the animationGroup
  117765. * @returns a new AnimationGroup
  117766. */
  117767. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  117768. /**
  117769. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  117770. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  117771. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  117772. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  117773. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  117774. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  117775. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  117776. */
  117777. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  117778. /**
  117779. * Returns the string "AnimationGroup"
  117780. * @returns "AnimationGroup"
  117781. */
  117782. getClassName(): string;
  117783. /**
  117784. * Creates a detailled string about the object
  117785. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  117786. * @returns a string representing the object
  117787. */
  117788. toString(fullDetails?: boolean): string;
  117789. }
  117790. }
  117791. declare module BABYLON {
  117792. /**
  117793. * Define an interface for all classes that will hold resources
  117794. */
  117795. export interface IDisposable {
  117796. /**
  117797. * Releases all held resources
  117798. */
  117799. dispose(): void;
  117800. }
  117801. /** Interface defining initialization parameters for Scene class */
  117802. export interface SceneOptions {
  117803. /**
  117804. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  117805. * It will improve performance when the number of geometries becomes important.
  117806. */
  117807. useGeometryUniqueIdsMap?: boolean;
  117808. /**
  117809. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  117810. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  117811. */
  117812. useMaterialMeshMap?: boolean;
  117813. /**
  117814. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  117815. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  117816. */
  117817. useClonedMeshMap?: boolean;
  117818. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  117819. virtual?: boolean;
  117820. }
  117821. /**
  117822. * Represents a scene to be rendered by the engine.
  117823. * @see https://doc.babylonjs.com/features/scene
  117824. */
  117825. export class Scene extends AbstractScene implements IAnimatable {
  117826. /** The fog is deactivated */
  117827. static readonly FOGMODE_NONE: number;
  117828. /** The fog density is following an exponential function */
  117829. static readonly FOGMODE_EXP: number;
  117830. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  117831. static readonly FOGMODE_EXP2: number;
  117832. /** The fog density is following a linear function. */
  117833. static readonly FOGMODE_LINEAR: number;
  117834. /**
  117835. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  117836. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117837. */
  117838. static MinDeltaTime: number;
  117839. /**
  117840. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  117841. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117842. */
  117843. static MaxDeltaTime: number;
  117844. /**
  117845. * Factory used to create the default material.
  117846. * @param name The name of the material to create
  117847. * @param scene The scene to create the material for
  117848. * @returns The default material
  117849. */
  117850. static DefaultMaterialFactory(scene: Scene): Material;
  117851. /**
  117852. * Factory used to create the a collision coordinator.
  117853. * @returns The collision coordinator
  117854. */
  117855. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  117856. /** @hidden */
  117857. _inputManager: InputManager;
  117858. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  117859. cameraToUseForPointers: Nullable<Camera>;
  117860. /** @hidden */
  117861. readonly _isScene: boolean;
  117862. /** @hidden */
  117863. _blockEntityCollection: boolean;
  117864. /**
  117865. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  117866. */
  117867. autoClear: boolean;
  117868. /**
  117869. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  117870. */
  117871. autoClearDepthAndStencil: boolean;
  117872. /**
  117873. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  117874. */
  117875. clearColor: Color4;
  117876. /**
  117877. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  117878. */
  117879. ambientColor: Color3;
  117880. /**
  117881. * This is use to store the default BRDF lookup for PBR materials in your scene.
  117882. * It should only be one of the following (if not the default embedded one):
  117883. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  117884. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  117885. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  117886. * The material properties need to be setup according to the type of texture in use.
  117887. */
  117888. environmentBRDFTexture: BaseTexture;
  117889. /** @hidden */
  117890. protected _environmentTexture: Nullable<BaseTexture>;
  117891. /**
  117892. * Texture used in all pbr material as the reflection texture.
  117893. * As in the majority of the scene they are the same (exception for multi room and so on),
  117894. * this is easier to reference from here than from all the materials.
  117895. */
  117896. get environmentTexture(): Nullable<BaseTexture>;
  117897. /**
  117898. * Texture used in all pbr material as the reflection texture.
  117899. * As in the majority of the scene they are the same (exception for multi room and so on),
  117900. * this is easier to set here than in all the materials.
  117901. */
  117902. set environmentTexture(value: Nullable<BaseTexture>);
  117903. /** @hidden */
  117904. protected _environmentIntensity: number;
  117905. /**
  117906. * Intensity of the environment in all pbr material.
  117907. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  117908. * As in the majority of the scene they are the same (exception for multi room and so on),
  117909. * this is easier to reference from here than from all the materials.
  117910. */
  117911. get environmentIntensity(): number;
  117912. /**
  117913. * Intensity of the environment in all pbr material.
  117914. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  117915. * As in the majority of the scene they are the same (exception for multi room and so on),
  117916. * this is easier to set here than in all the materials.
  117917. */
  117918. set environmentIntensity(value: number);
  117919. /** @hidden */
  117920. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  117921. /**
  117922. * Default image processing configuration used either in the rendering
  117923. * Forward main pass or through the imageProcessingPostProcess if present.
  117924. * As in the majority of the scene they are the same (exception for multi camera),
  117925. * this is easier to reference from here than from all the materials and post process.
  117926. *
  117927. * No setter as we it is a shared configuration, you can set the values instead.
  117928. */
  117929. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  117930. private _forceWireframe;
  117931. /**
  117932. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  117933. */
  117934. set forceWireframe(value: boolean);
  117935. get forceWireframe(): boolean;
  117936. private _skipFrustumClipping;
  117937. /**
  117938. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  117939. */
  117940. set skipFrustumClipping(value: boolean);
  117941. get skipFrustumClipping(): boolean;
  117942. private _forcePointsCloud;
  117943. /**
  117944. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  117945. */
  117946. set forcePointsCloud(value: boolean);
  117947. get forcePointsCloud(): boolean;
  117948. /**
  117949. * Gets or sets the active clipplane 1
  117950. */
  117951. clipPlane: Nullable<Plane>;
  117952. /**
  117953. * Gets or sets the active clipplane 2
  117954. */
  117955. clipPlane2: Nullable<Plane>;
  117956. /**
  117957. * Gets or sets the active clipplane 3
  117958. */
  117959. clipPlane3: Nullable<Plane>;
  117960. /**
  117961. * Gets or sets the active clipplane 4
  117962. */
  117963. clipPlane4: Nullable<Plane>;
  117964. /**
  117965. * Gets or sets the active clipplane 5
  117966. */
  117967. clipPlane5: Nullable<Plane>;
  117968. /**
  117969. * Gets or sets the active clipplane 6
  117970. */
  117971. clipPlane6: Nullable<Plane>;
  117972. /**
  117973. * Gets or sets a boolean indicating if animations are enabled
  117974. */
  117975. animationsEnabled: boolean;
  117976. private _animationPropertiesOverride;
  117977. /**
  117978. * Gets or sets the animation properties override
  117979. */
  117980. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  117981. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  117982. /**
  117983. * Gets or sets a boolean indicating if a constant deltatime has to be used
  117984. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  117985. */
  117986. useConstantAnimationDeltaTime: boolean;
  117987. /**
  117988. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  117989. * Please note that it requires to run a ray cast through the scene on every frame
  117990. */
  117991. constantlyUpdateMeshUnderPointer: boolean;
  117992. /**
  117993. * Defines the HTML cursor to use when hovering over interactive elements
  117994. */
  117995. hoverCursor: string;
  117996. /**
  117997. * Defines the HTML default cursor to use (empty by default)
  117998. */
  117999. defaultCursor: string;
  118000. /**
  118001. * Defines whether cursors are handled by the scene.
  118002. */
  118003. doNotHandleCursors: boolean;
  118004. /**
  118005. * This is used to call preventDefault() on pointer down
  118006. * in order to block unwanted artifacts like system double clicks
  118007. */
  118008. preventDefaultOnPointerDown: boolean;
  118009. /**
  118010. * This is used to call preventDefault() on pointer up
  118011. * in order to block unwanted artifacts like system double clicks
  118012. */
  118013. preventDefaultOnPointerUp: boolean;
  118014. /**
  118015. * Gets or sets user defined metadata
  118016. */
  118017. metadata: any;
  118018. /**
  118019. * For internal use only. Please do not use.
  118020. */
  118021. reservedDataStore: any;
  118022. /**
  118023. * Gets the name of the plugin used to load this scene (null by default)
  118024. */
  118025. loadingPluginName: string;
  118026. /**
  118027. * Use this array to add regular expressions used to disable offline support for specific urls
  118028. */
  118029. disableOfflineSupportExceptionRules: RegExp[];
  118030. /**
  118031. * An event triggered when the scene is disposed.
  118032. */
  118033. onDisposeObservable: Observable<Scene>;
  118034. private _onDisposeObserver;
  118035. /** Sets a function to be executed when this scene is disposed. */
  118036. set onDispose(callback: () => void);
  118037. /**
  118038. * An event triggered before rendering the scene (right after animations and physics)
  118039. */
  118040. onBeforeRenderObservable: Observable<Scene>;
  118041. private _onBeforeRenderObserver;
  118042. /** Sets a function to be executed before rendering this scene */
  118043. set beforeRender(callback: Nullable<() => void>);
  118044. /**
  118045. * An event triggered after rendering the scene
  118046. */
  118047. onAfterRenderObservable: Observable<Scene>;
  118048. /**
  118049. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  118050. */
  118051. onAfterRenderCameraObservable: Observable<Camera>;
  118052. private _onAfterRenderObserver;
  118053. /** Sets a function to be executed after rendering this scene */
  118054. set afterRender(callback: Nullable<() => void>);
  118055. /**
  118056. * An event triggered before animating the scene
  118057. */
  118058. onBeforeAnimationsObservable: Observable<Scene>;
  118059. /**
  118060. * An event triggered after animations processing
  118061. */
  118062. onAfterAnimationsObservable: Observable<Scene>;
  118063. /**
  118064. * An event triggered before draw calls are ready to be sent
  118065. */
  118066. onBeforeDrawPhaseObservable: Observable<Scene>;
  118067. /**
  118068. * An event triggered after draw calls have been sent
  118069. */
  118070. onAfterDrawPhaseObservable: Observable<Scene>;
  118071. /**
  118072. * An event triggered when the scene is ready
  118073. */
  118074. onReadyObservable: Observable<Scene>;
  118075. /**
  118076. * An event triggered before rendering a camera
  118077. */
  118078. onBeforeCameraRenderObservable: Observable<Camera>;
  118079. private _onBeforeCameraRenderObserver;
  118080. /** Sets a function to be executed before rendering a camera*/
  118081. set beforeCameraRender(callback: () => void);
  118082. /**
  118083. * An event triggered after rendering a camera
  118084. */
  118085. onAfterCameraRenderObservable: Observable<Camera>;
  118086. private _onAfterCameraRenderObserver;
  118087. /** Sets a function to be executed after rendering a camera*/
  118088. set afterCameraRender(callback: () => void);
  118089. /**
  118090. * An event triggered when active meshes evaluation is about to start
  118091. */
  118092. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  118093. /**
  118094. * An event triggered when active meshes evaluation is done
  118095. */
  118096. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  118097. /**
  118098. * An event triggered when particles rendering is about to start
  118099. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  118100. */
  118101. onBeforeParticlesRenderingObservable: Observable<Scene>;
  118102. /**
  118103. * An event triggered when particles rendering is done
  118104. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  118105. */
  118106. onAfterParticlesRenderingObservable: Observable<Scene>;
  118107. /**
  118108. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  118109. */
  118110. onDataLoadedObservable: Observable<Scene>;
  118111. /**
  118112. * An event triggered when a camera is created
  118113. */
  118114. onNewCameraAddedObservable: Observable<Camera>;
  118115. /**
  118116. * An event triggered when a camera is removed
  118117. */
  118118. onCameraRemovedObservable: Observable<Camera>;
  118119. /**
  118120. * An event triggered when a light is created
  118121. */
  118122. onNewLightAddedObservable: Observable<Light>;
  118123. /**
  118124. * An event triggered when a light is removed
  118125. */
  118126. onLightRemovedObservable: Observable<Light>;
  118127. /**
  118128. * An event triggered when a geometry is created
  118129. */
  118130. onNewGeometryAddedObservable: Observable<Geometry>;
  118131. /**
  118132. * An event triggered when a geometry is removed
  118133. */
  118134. onGeometryRemovedObservable: Observable<Geometry>;
  118135. /**
  118136. * An event triggered when a transform node is created
  118137. */
  118138. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  118139. /**
  118140. * An event triggered when a transform node is removed
  118141. */
  118142. onTransformNodeRemovedObservable: Observable<TransformNode>;
  118143. /**
  118144. * An event triggered when a mesh is created
  118145. */
  118146. onNewMeshAddedObservable: Observable<AbstractMesh>;
  118147. /**
  118148. * An event triggered when a mesh is removed
  118149. */
  118150. onMeshRemovedObservable: Observable<AbstractMesh>;
  118151. /**
  118152. * An event triggered when a skeleton is created
  118153. */
  118154. onNewSkeletonAddedObservable: Observable<Skeleton>;
  118155. /**
  118156. * An event triggered when a skeleton is removed
  118157. */
  118158. onSkeletonRemovedObservable: Observable<Skeleton>;
  118159. /**
  118160. * An event triggered when a material is created
  118161. */
  118162. onNewMaterialAddedObservable: Observable<Material>;
  118163. /**
  118164. * An event triggered when a material is removed
  118165. */
  118166. onMaterialRemovedObservable: Observable<Material>;
  118167. /**
  118168. * An event triggered when a texture is created
  118169. */
  118170. onNewTextureAddedObservable: Observable<BaseTexture>;
  118171. /**
  118172. * An event triggered when a texture is removed
  118173. */
  118174. onTextureRemovedObservable: Observable<BaseTexture>;
  118175. /**
  118176. * An event triggered when render targets are about to be rendered
  118177. * Can happen multiple times per frame.
  118178. */
  118179. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  118180. /**
  118181. * An event triggered when render targets were rendered.
  118182. * Can happen multiple times per frame.
  118183. */
  118184. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  118185. /**
  118186. * An event triggered before calculating deterministic simulation step
  118187. */
  118188. onBeforeStepObservable: Observable<Scene>;
  118189. /**
  118190. * An event triggered after calculating deterministic simulation step
  118191. */
  118192. onAfterStepObservable: Observable<Scene>;
  118193. /**
  118194. * An event triggered when the activeCamera property is updated
  118195. */
  118196. onActiveCameraChanged: Observable<Scene>;
  118197. /**
  118198. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  118199. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118200. * 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)
  118201. */
  118202. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118203. /**
  118204. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  118205. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118206. * 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)
  118207. */
  118208. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118209. /**
  118210. * This Observable will when a mesh has been imported into the scene.
  118211. */
  118212. onMeshImportedObservable: Observable<AbstractMesh>;
  118213. /**
  118214. * This Observable will when an animation file has been imported into the scene.
  118215. */
  118216. onAnimationFileImportedObservable: Observable<Scene>;
  118217. /**
  118218. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  118219. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  118220. */
  118221. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  118222. /** @hidden */
  118223. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  118224. /**
  118225. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  118226. */
  118227. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  118228. /**
  118229. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  118230. */
  118231. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  118232. /**
  118233. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  118234. */
  118235. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  118236. /** Callback called when a pointer move is detected */
  118237. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118238. /** Callback called when a pointer down is detected */
  118239. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118240. /** Callback called when a pointer up is detected */
  118241. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  118242. /** Callback called when a pointer pick is detected */
  118243. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  118244. /**
  118245. * 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).
  118246. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  118247. */
  118248. onPrePointerObservable: Observable<PointerInfoPre>;
  118249. /**
  118250. * Observable event triggered each time an input event is received from the rendering canvas
  118251. */
  118252. onPointerObservable: Observable<PointerInfo>;
  118253. /**
  118254. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  118255. */
  118256. get unTranslatedPointer(): Vector2;
  118257. /**
  118258. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  118259. */
  118260. static get DragMovementThreshold(): number;
  118261. static set DragMovementThreshold(value: number);
  118262. /**
  118263. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  118264. */
  118265. static get LongPressDelay(): number;
  118266. static set LongPressDelay(value: number);
  118267. /**
  118268. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  118269. */
  118270. static get DoubleClickDelay(): number;
  118271. static set DoubleClickDelay(value: number);
  118272. /** If you need to check double click without raising a single click at first click, enable this flag */
  118273. static get ExclusiveDoubleClickMode(): boolean;
  118274. static set ExclusiveDoubleClickMode(value: boolean);
  118275. /** @hidden */
  118276. _mirroredCameraPosition: Nullable<Vector3>;
  118277. /**
  118278. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  118279. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  118280. */
  118281. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  118282. /**
  118283. * Observable event triggered each time an keyboard event is received from the hosting window
  118284. */
  118285. onKeyboardObservable: Observable<KeyboardInfo>;
  118286. private _useRightHandedSystem;
  118287. /**
  118288. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  118289. */
  118290. set useRightHandedSystem(value: boolean);
  118291. get useRightHandedSystem(): boolean;
  118292. private _timeAccumulator;
  118293. private _currentStepId;
  118294. private _currentInternalStep;
  118295. /**
  118296. * Sets the step Id used by deterministic lock step
  118297. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118298. * @param newStepId defines the step Id
  118299. */
  118300. setStepId(newStepId: number): void;
  118301. /**
  118302. * Gets the step Id used by deterministic lock step
  118303. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118304. * @returns the step Id
  118305. */
  118306. getStepId(): number;
  118307. /**
  118308. * Gets the internal step used by deterministic lock step
  118309. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118310. * @returns the internal step
  118311. */
  118312. getInternalStep(): number;
  118313. private _fogEnabled;
  118314. /**
  118315. * Gets or sets a boolean indicating if fog is enabled on this scene
  118316. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118317. * (Default is true)
  118318. */
  118319. set fogEnabled(value: boolean);
  118320. get fogEnabled(): boolean;
  118321. private _fogMode;
  118322. /**
  118323. * Gets or sets the fog mode to use
  118324. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118325. * | mode | value |
  118326. * | --- | --- |
  118327. * | FOGMODE_NONE | 0 |
  118328. * | FOGMODE_EXP | 1 |
  118329. * | FOGMODE_EXP2 | 2 |
  118330. * | FOGMODE_LINEAR | 3 |
  118331. */
  118332. set fogMode(value: number);
  118333. get fogMode(): number;
  118334. /**
  118335. * Gets or sets the fog color to use
  118336. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118337. * (Default is Color3(0.2, 0.2, 0.3))
  118338. */
  118339. fogColor: Color3;
  118340. /**
  118341. * Gets or sets the fog density to use
  118342. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118343. * (Default is 0.1)
  118344. */
  118345. fogDensity: number;
  118346. /**
  118347. * Gets or sets the fog start distance to use
  118348. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118349. * (Default is 0)
  118350. */
  118351. fogStart: number;
  118352. /**
  118353. * Gets or sets the fog end distance to use
  118354. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118355. * (Default is 1000)
  118356. */
  118357. fogEnd: number;
  118358. /**
  118359. * Flag indicating that the frame buffer binding is handled by another component
  118360. */
  118361. prePass: boolean;
  118362. private _shadowsEnabled;
  118363. /**
  118364. * Gets or sets a boolean indicating if shadows are enabled on this scene
  118365. */
  118366. set shadowsEnabled(value: boolean);
  118367. get shadowsEnabled(): boolean;
  118368. private _lightsEnabled;
  118369. /**
  118370. * Gets or sets a boolean indicating if lights are enabled on this scene
  118371. */
  118372. set lightsEnabled(value: boolean);
  118373. get lightsEnabled(): boolean;
  118374. /** All of the active cameras added to this scene. */
  118375. activeCameras: Camera[];
  118376. /** @hidden */
  118377. _activeCamera: Nullable<Camera>;
  118378. /** Gets or sets the current active camera */
  118379. get activeCamera(): Nullable<Camera>;
  118380. set activeCamera(value: Nullable<Camera>);
  118381. private _defaultMaterial;
  118382. /** The default material used on meshes when no material is affected */
  118383. get defaultMaterial(): Material;
  118384. /** The default material used on meshes when no material is affected */
  118385. set defaultMaterial(value: Material);
  118386. private _texturesEnabled;
  118387. /**
  118388. * Gets or sets a boolean indicating if textures are enabled on this scene
  118389. */
  118390. set texturesEnabled(value: boolean);
  118391. get texturesEnabled(): boolean;
  118392. /**
  118393. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  118394. */
  118395. physicsEnabled: boolean;
  118396. /**
  118397. * Gets or sets a boolean indicating if particles are enabled on this scene
  118398. */
  118399. particlesEnabled: boolean;
  118400. /**
  118401. * Gets or sets a boolean indicating if sprites are enabled on this scene
  118402. */
  118403. spritesEnabled: boolean;
  118404. private _skeletonsEnabled;
  118405. /**
  118406. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  118407. */
  118408. set skeletonsEnabled(value: boolean);
  118409. get skeletonsEnabled(): boolean;
  118410. /**
  118411. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  118412. */
  118413. lensFlaresEnabled: boolean;
  118414. /**
  118415. * Gets or sets a boolean indicating if collisions are enabled on this scene
  118416. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  118417. */
  118418. collisionsEnabled: boolean;
  118419. private _collisionCoordinator;
  118420. /** @hidden */
  118421. get collisionCoordinator(): ICollisionCoordinator;
  118422. /**
  118423. * Defines the gravity applied to this scene (used only for collisions)
  118424. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  118425. */
  118426. gravity: Vector3;
  118427. /**
  118428. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  118429. */
  118430. postProcessesEnabled: boolean;
  118431. /**
  118432. * The list of postprocesses added to the scene
  118433. */
  118434. postProcesses: PostProcess[];
  118435. /**
  118436. * Gets the current postprocess manager
  118437. */
  118438. postProcessManager: PostProcessManager;
  118439. /**
  118440. * Gets or sets a boolean indicating if render targets are enabled on this scene
  118441. */
  118442. renderTargetsEnabled: boolean;
  118443. /**
  118444. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  118445. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  118446. */
  118447. dumpNextRenderTargets: boolean;
  118448. /**
  118449. * The list of user defined render targets added to the scene
  118450. */
  118451. customRenderTargets: RenderTargetTexture[];
  118452. /**
  118453. * Defines if texture loading must be delayed
  118454. * If true, textures will only be loaded when they need to be rendered
  118455. */
  118456. useDelayedTextureLoading: boolean;
  118457. /**
  118458. * Gets the list of meshes imported to the scene through SceneLoader
  118459. */
  118460. importedMeshesFiles: String[];
  118461. /**
  118462. * Gets or sets a boolean indicating if probes are enabled on this scene
  118463. */
  118464. probesEnabled: boolean;
  118465. /**
  118466. * Gets or sets the current offline provider to use to store scene data
  118467. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  118468. */
  118469. offlineProvider: IOfflineProvider;
  118470. /**
  118471. * Gets or sets the action manager associated with the scene
  118472. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  118473. */
  118474. actionManager: AbstractActionManager;
  118475. private _meshesForIntersections;
  118476. /**
  118477. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  118478. */
  118479. proceduralTexturesEnabled: boolean;
  118480. private _engine;
  118481. private _totalVertices;
  118482. /** @hidden */
  118483. _activeIndices: PerfCounter;
  118484. /** @hidden */
  118485. _activeParticles: PerfCounter;
  118486. /** @hidden */
  118487. _activeBones: PerfCounter;
  118488. private _animationRatio;
  118489. /** @hidden */
  118490. _animationTimeLast: number;
  118491. /** @hidden */
  118492. _animationTime: number;
  118493. /**
  118494. * Gets or sets a general scale for animation speed
  118495. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  118496. */
  118497. animationTimeScale: number;
  118498. /** @hidden */
  118499. _cachedMaterial: Nullable<Material>;
  118500. /** @hidden */
  118501. _cachedEffect: Nullable<Effect>;
  118502. /** @hidden */
  118503. _cachedVisibility: Nullable<number>;
  118504. private _renderId;
  118505. private _frameId;
  118506. private _executeWhenReadyTimeoutId;
  118507. private _intermediateRendering;
  118508. private _viewUpdateFlag;
  118509. private _projectionUpdateFlag;
  118510. /** @hidden */
  118511. _toBeDisposed: Nullable<IDisposable>[];
  118512. private _activeRequests;
  118513. /** @hidden */
  118514. _pendingData: any[];
  118515. private _isDisposed;
  118516. /**
  118517. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  118518. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  118519. */
  118520. dispatchAllSubMeshesOfActiveMeshes: boolean;
  118521. private _activeMeshes;
  118522. private _processedMaterials;
  118523. private _renderTargets;
  118524. /** @hidden */
  118525. _activeParticleSystems: SmartArray<IParticleSystem>;
  118526. private _activeSkeletons;
  118527. private _softwareSkinnedMeshes;
  118528. private _renderingManager;
  118529. /** @hidden */
  118530. _activeAnimatables: Animatable[];
  118531. private _transformMatrix;
  118532. private _sceneUbo;
  118533. /** @hidden */
  118534. _viewMatrix: Matrix;
  118535. private _projectionMatrix;
  118536. /** @hidden */
  118537. _forcedViewPosition: Nullable<Vector3>;
  118538. /** @hidden */
  118539. _frustumPlanes: Plane[];
  118540. /**
  118541. * Gets the list of frustum planes (built from the active camera)
  118542. */
  118543. get frustumPlanes(): Plane[];
  118544. /**
  118545. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  118546. * This is useful if there are more lights that the maximum simulteanous authorized
  118547. */
  118548. requireLightSorting: boolean;
  118549. /** @hidden */
  118550. readonly useMaterialMeshMap: boolean;
  118551. /** @hidden */
  118552. readonly useClonedMeshMap: boolean;
  118553. private _externalData;
  118554. private _uid;
  118555. /**
  118556. * @hidden
  118557. * Backing store of defined scene components.
  118558. */
  118559. _components: ISceneComponent[];
  118560. /**
  118561. * @hidden
  118562. * Backing store of defined scene components.
  118563. */
  118564. _serializableComponents: ISceneSerializableComponent[];
  118565. /**
  118566. * List of components to register on the next registration step.
  118567. */
  118568. private _transientComponents;
  118569. /**
  118570. * Registers the transient components if needed.
  118571. */
  118572. private _registerTransientComponents;
  118573. /**
  118574. * @hidden
  118575. * Add a component to the scene.
  118576. * Note that the ccomponent could be registered on th next frame if this is called after
  118577. * the register component stage.
  118578. * @param component Defines the component to add to the scene
  118579. */
  118580. _addComponent(component: ISceneComponent): void;
  118581. /**
  118582. * @hidden
  118583. * Gets a component from the scene.
  118584. * @param name defines the name of the component to retrieve
  118585. * @returns the component or null if not present
  118586. */
  118587. _getComponent(name: string): Nullable<ISceneComponent>;
  118588. /**
  118589. * @hidden
  118590. * Defines the actions happening before camera updates.
  118591. */
  118592. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  118593. /**
  118594. * @hidden
  118595. * Defines the actions happening before clear the canvas.
  118596. */
  118597. _beforeClearStage: Stage<SimpleStageAction>;
  118598. /**
  118599. * @hidden
  118600. * Defines the actions when collecting render targets for the frame.
  118601. */
  118602. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  118603. /**
  118604. * @hidden
  118605. * Defines the actions happening for one camera in the frame.
  118606. */
  118607. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  118608. /**
  118609. * @hidden
  118610. * Defines the actions happening during the per mesh ready checks.
  118611. */
  118612. _isReadyForMeshStage: Stage<MeshStageAction>;
  118613. /**
  118614. * @hidden
  118615. * Defines the actions happening before evaluate active mesh checks.
  118616. */
  118617. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  118618. /**
  118619. * @hidden
  118620. * Defines the actions happening during the evaluate sub mesh checks.
  118621. */
  118622. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  118623. /**
  118624. * @hidden
  118625. * Defines the actions happening during the active mesh stage.
  118626. */
  118627. _activeMeshStage: Stage<ActiveMeshStageAction>;
  118628. /**
  118629. * @hidden
  118630. * Defines the actions happening during the per camera render target step.
  118631. */
  118632. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  118633. /**
  118634. * @hidden
  118635. * Defines the actions happening just before the active camera is drawing.
  118636. */
  118637. _beforeCameraDrawStage: Stage<CameraStageAction>;
  118638. /**
  118639. * @hidden
  118640. * Defines the actions happening just before a render target is drawing.
  118641. */
  118642. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  118643. /**
  118644. * @hidden
  118645. * Defines the actions happening just before a rendering group is drawing.
  118646. */
  118647. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  118648. /**
  118649. * @hidden
  118650. * Defines the actions happening just before a mesh is drawing.
  118651. */
  118652. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  118653. /**
  118654. * @hidden
  118655. * Defines the actions happening just after a mesh has been drawn.
  118656. */
  118657. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  118658. /**
  118659. * @hidden
  118660. * Defines the actions happening just after a rendering group has been drawn.
  118661. */
  118662. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  118663. /**
  118664. * @hidden
  118665. * Defines the actions happening just after the active camera has been drawn.
  118666. */
  118667. _afterCameraDrawStage: Stage<CameraStageAction>;
  118668. /**
  118669. * @hidden
  118670. * Defines the actions happening just after a render target has been drawn.
  118671. */
  118672. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  118673. /**
  118674. * @hidden
  118675. * Defines the actions happening just after rendering all cameras and computing intersections.
  118676. */
  118677. _afterRenderStage: Stage<SimpleStageAction>;
  118678. /**
  118679. * @hidden
  118680. * Defines the actions happening when a pointer move event happens.
  118681. */
  118682. _pointerMoveStage: Stage<PointerMoveStageAction>;
  118683. /**
  118684. * @hidden
  118685. * Defines the actions happening when a pointer down event happens.
  118686. */
  118687. _pointerDownStage: Stage<PointerUpDownStageAction>;
  118688. /**
  118689. * @hidden
  118690. * Defines the actions happening when a pointer up event happens.
  118691. */
  118692. _pointerUpStage: Stage<PointerUpDownStageAction>;
  118693. /**
  118694. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  118695. */
  118696. private geometriesByUniqueId;
  118697. /**
  118698. * Creates a new Scene
  118699. * @param engine defines the engine to use to render this scene
  118700. * @param options defines the scene options
  118701. */
  118702. constructor(engine: Engine, options?: SceneOptions);
  118703. /**
  118704. * Gets a string idenfifying the name of the class
  118705. * @returns "Scene" string
  118706. */
  118707. getClassName(): string;
  118708. private _defaultMeshCandidates;
  118709. /**
  118710. * @hidden
  118711. */
  118712. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118713. private _defaultSubMeshCandidates;
  118714. /**
  118715. * @hidden
  118716. */
  118717. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118718. /**
  118719. * Sets the default candidate providers for the scene.
  118720. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  118721. * and getCollidingSubMeshCandidates to their default function
  118722. */
  118723. setDefaultCandidateProviders(): void;
  118724. /**
  118725. * Gets the mesh that is currently under the pointer
  118726. */
  118727. get meshUnderPointer(): Nullable<AbstractMesh>;
  118728. /**
  118729. * Gets or sets the current on-screen X position of the pointer
  118730. */
  118731. get pointerX(): number;
  118732. set pointerX(value: number);
  118733. /**
  118734. * Gets or sets the current on-screen Y position of the pointer
  118735. */
  118736. get pointerY(): number;
  118737. set pointerY(value: number);
  118738. /**
  118739. * Gets the cached material (ie. the latest rendered one)
  118740. * @returns the cached material
  118741. */
  118742. getCachedMaterial(): Nullable<Material>;
  118743. /**
  118744. * Gets the cached effect (ie. the latest rendered one)
  118745. * @returns the cached effect
  118746. */
  118747. getCachedEffect(): Nullable<Effect>;
  118748. /**
  118749. * Gets the cached visibility state (ie. the latest rendered one)
  118750. * @returns the cached visibility state
  118751. */
  118752. getCachedVisibility(): Nullable<number>;
  118753. /**
  118754. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  118755. * @param material defines the current material
  118756. * @param effect defines the current effect
  118757. * @param visibility defines the current visibility state
  118758. * @returns true if one parameter is not cached
  118759. */
  118760. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  118761. /**
  118762. * Gets the engine associated with the scene
  118763. * @returns an Engine
  118764. */
  118765. getEngine(): Engine;
  118766. /**
  118767. * Gets the total number of vertices rendered per frame
  118768. * @returns the total number of vertices rendered per frame
  118769. */
  118770. getTotalVertices(): number;
  118771. /**
  118772. * Gets the performance counter for total vertices
  118773. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  118774. */
  118775. get totalVerticesPerfCounter(): PerfCounter;
  118776. /**
  118777. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  118778. * @returns the total number of active indices rendered per frame
  118779. */
  118780. getActiveIndices(): number;
  118781. /**
  118782. * Gets the performance counter for active indices
  118783. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  118784. */
  118785. get totalActiveIndicesPerfCounter(): PerfCounter;
  118786. /**
  118787. * Gets the total number of active particles rendered per frame
  118788. * @returns the total number of active particles rendered per frame
  118789. */
  118790. getActiveParticles(): number;
  118791. /**
  118792. * Gets the performance counter for active particles
  118793. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  118794. */
  118795. get activeParticlesPerfCounter(): PerfCounter;
  118796. /**
  118797. * Gets the total number of active bones rendered per frame
  118798. * @returns the total number of active bones rendered per frame
  118799. */
  118800. getActiveBones(): number;
  118801. /**
  118802. * Gets the performance counter for active bones
  118803. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  118804. */
  118805. get activeBonesPerfCounter(): PerfCounter;
  118806. /**
  118807. * Gets the array of active meshes
  118808. * @returns an array of AbstractMesh
  118809. */
  118810. getActiveMeshes(): SmartArray<AbstractMesh>;
  118811. /**
  118812. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  118813. * @returns a number
  118814. */
  118815. getAnimationRatio(): number;
  118816. /**
  118817. * Gets an unique Id for the current render phase
  118818. * @returns a number
  118819. */
  118820. getRenderId(): number;
  118821. /**
  118822. * Gets an unique Id for the current frame
  118823. * @returns a number
  118824. */
  118825. getFrameId(): number;
  118826. /** Call this function if you want to manually increment the render Id*/
  118827. incrementRenderId(): void;
  118828. private _createUbo;
  118829. /**
  118830. * Use this method to simulate a pointer move on a mesh
  118831. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118832. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118833. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118834. * @returns the current scene
  118835. */
  118836. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  118837. /**
  118838. * Use this method to simulate a pointer down on a mesh
  118839. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118840. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118841. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118842. * @returns the current scene
  118843. */
  118844. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  118845. /**
  118846. * Use this method to simulate a pointer up on a mesh
  118847. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118848. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118849. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118850. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  118851. * @returns the current scene
  118852. */
  118853. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  118854. /**
  118855. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  118856. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  118857. * @returns true if the pointer was captured
  118858. */
  118859. isPointerCaptured(pointerId?: number): boolean;
  118860. /**
  118861. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  118862. * @param attachUp defines if you want to attach events to pointerup
  118863. * @param attachDown defines if you want to attach events to pointerdown
  118864. * @param attachMove defines if you want to attach events to pointermove
  118865. */
  118866. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  118867. /** Detaches all event handlers*/
  118868. detachControl(): void;
  118869. /**
  118870. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  118871. * Delay loaded resources are not taking in account
  118872. * @return true if all required resources are ready
  118873. */
  118874. isReady(): boolean;
  118875. /** Resets all cached information relative to material (including effect and visibility) */
  118876. resetCachedMaterial(): void;
  118877. /**
  118878. * Registers a function to be called before every frame render
  118879. * @param func defines the function to register
  118880. */
  118881. registerBeforeRender(func: () => void): void;
  118882. /**
  118883. * Unregisters a function called before every frame render
  118884. * @param func defines the function to unregister
  118885. */
  118886. unregisterBeforeRender(func: () => void): void;
  118887. /**
  118888. * Registers a function to be called after every frame render
  118889. * @param func defines the function to register
  118890. */
  118891. registerAfterRender(func: () => void): void;
  118892. /**
  118893. * Unregisters a function called after every frame render
  118894. * @param func defines the function to unregister
  118895. */
  118896. unregisterAfterRender(func: () => void): void;
  118897. private _executeOnceBeforeRender;
  118898. /**
  118899. * The provided function will run before render once and will be disposed afterwards.
  118900. * A timeout delay can be provided so that the function will be executed in N ms.
  118901. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  118902. * @param func The function to be executed.
  118903. * @param timeout optional delay in ms
  118904. */
  118905. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  118906. /** @hidden */
  118907. _addPendingData(data: any): void;
  118908. /** @hidden */
  118909. _removePendingData(data: any): void;
  118910. /**
  118911. * Returns the number of items waiting to be loaded
  118912. * @returns the number of items waiting to be loaded
  118913. */
  118914. getWaitingItemsCount(): number;
  118915. /**
  118916. * Returns a boolean indicating if the scene is still loading data
  118917. */
  118918. get isLoading(): boolean;
  118919. /**
  118920. * Registers a function to be executed when the scene is ready
  118921. * @param {Function} func - the function to be executed
  118922. */
  118923. executeWhenReady(func: () => void): void;
  118924. /**
  118925. * Returns a promise that resolves when the scene is ready
  118926. * @returns A promise that resolves when the scene is ready
  118927. */
  118928. whenReadyAsync(): Promise<void>;
  118929. /** @hidden */
  118930. _checkIsReady(): void;
  118931. /**
  118932. * Gets all animatable attached to the scene
  118933. */
  118934. get animatables(): Animatable[];
  118935. /**
  118936. * Resets the last animation time frame.
  118937. * Useful to override when animations start running when loading a scene for the first time.
  118938. */
  118939. resetLastAnimationTimeFrame(): void;
  118940. /**
  118941. * Gets the current view matrix
  118942. * @returns a Matrix
  118943. */
  118944. getViewMatrix(): Matrix;
  118945. /**
  118946. * Gets the current projection matrix
  118947. * @returns a Matrix
  118948. */
  118949. getProjectionMatrix(): Matrix;
  118950. /**
  118951. * Gets the current transform matrix
  118952. * @returns a Matrix made of View * Projection
  118953. */
  118954. getTransformMatrix(): Matrix;
  118955. /**
  118956. * Sets the current transform matrix
  118957. * @param viewL defines the View matrix to use
  118958. * @param projectionL defines the Projection matrix to use
  118959. * @param viewR defines the right View matrix to use (if provided)
  118960. * @param projectionR defines the right Projection matrix to use (if provided)
  118961. */
  118962. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  118963. /**
  118964. * Gets the uniform buffer used to store scene data
  118965. * @returns a UniformBuffer
  118966. */
  118967. getSceneUniformBuffer(): UniformBuffer;
  118968. /**
  118969. * Gets an unique (relatively to the current scene) Id
  118970. * @returns an unique number for the scene
  118971. */
  118972. getUniqueId(): number;
  118973. /**
  118974. * Add a mesh to the list of scene's meshes
  118975. * @param newMesh defines the mesh to add
  118976. * @param recursive if all child meshes should also be added to the scene
  118977. */
  118978. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  118979. /**
  118980. * Remove a mesh for the list of scene's meshes
  118981. * @param toRemove defines the mesh to remove
  118982. * @param recursive if all child meshes should also be removed from the scene
  118983. * @returns the index where the mesh was in the mesh list
  118984. */
  118985. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  118986. /**
  118987. * Add a transform node to the list of scene's transform nodes
  118988. * @param newTransformNode defines the transform node to add
  118989. */
  118990. addTransformNode(newTransformNode: TransformNode): void;
  118991. /**
  118992. * Remove a transform node for the list of scene's transform nodes
  118993. * @param toRemove defines the transform node to remove
  118994. * @returns the index where the transform node was in the transform node list
  118995. */
  118996. removeTransformNode(toRemove: TransformNode): number;
  118997. /**
  118998. * Remove a skeleton for the list of scene's skeletons
  118999. * @param toRemove defines the skeleton to remove
  119000. * @returns the index where the skeleton was in the skeleton list
  119001. */
  119002. removeSkeleton(toRemove: Skeleton): number;
  119003. /**
  119004. * Remove a morph target for the list of scene's morph targets
  119005. * @param toRemove defines the morph target to remove
  119006. * @returns the index where the morph target was in the morph target list
  119007. */
  119008. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  119009. /**
  119010. * Remove a light for the list of scene's lights
  119011. * @param toRemove defines the light to remove
  119012. * @returns the index where the light was in the light list
  119013. */
  119014. removeLight(toRemove: Light): number;
  119015. /**
  119016. * Remove a camera for the list of scene's cameras
  119017. * @param toRemove defines the camera to remove
  119018. * @returns the index where the camera was in the camera list
  119019. */
  119020. removeCamera(toRemove: Camera): number;
  119021. /**
  119022. * Remove a particle system for the list of scene's particle systems
  119023. * @param toRemove defines the particle system to remove
  119024. * @returns the index where the particle system was in the particle system list
  119025. */
  119026. removeParticleSystem(toRemove: IParticleSystem): number;
  119027. /**
  119028. * Remove a animation for the list of scene's animations
  119029. * @param toRemove defines the animation to remove
  119030. * @returns the index where the animation was in the animation list
  119031. */
  119032. removeAnimation(toRemove: Animation): number;
  119033. /**
  119034. * Will stop the animation of the given target
  119035. * @param target - the target
  119036. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  119037. * @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)
  119038. */
  119039. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  119040. /**
  119041. * Removes the given animation group from this scene.
  119042. * @param toRemove The animation group to remove
  119043. * @returns The index of the removed animation group
  119044. */
  119045. removeAnimationGroup(toRemove: AnimationGroup): number;
  119046. /**
  119047. * Removes the given multi-material from this scene.
  119048. * @param toRemove The multi-material to remove
  119049. * @returns The index of the removed multi-material
  119050. */
  119051. removeMultiMaterial(toRemove: MultiMaterial): number;
  119052. /**
  119053. * Removes the given material from this scene.
  119054. * @param toRemove The material to remove
  119055. * @returns The index of the removed material
  119056. */
  119057. removeMaterial(toRemove: Material): number;
  119058. /**
  119059. * Removes the given action manager from this scene.
  119060. * @param toRemove The action manager to remove
  119061. * @returns The index of the removed action manager
  119062. */
  119063. removeActionManager(toRemove: AbstractActionManager): number;
  119064. /**
  119065. * Removes the given texture from this scene.
  119066. * @param toRemove The texture to remove
  119067. * @returns The index of the removed texture
  119068. */
  119069. removeTexture(toRemove: BaseTexture): number;
  119070. /**
  119071. * Adds the given light to this scene
  119072. * @param newLight The light to add
  119073. */
  119074. addLight(newLight: Light): void;
  119075. /**
  119076. * Sorts the list list based on light priorities
  119077. */
  119078. sortLightsByPriority(): void;
  119079. /**
  119080. * Adds the given camera to this scene
  119081. * @param newCamera The camera to add
  119082. */
  119083. addCamera(newCamera: Camera): void;
  119084. /**
  119085. * Adds the given skeleton to this scene
  119086. * @param newSkeleton The skeleton to add
  119087. */
  119088. addSkeleton(newSkeleton: Skeleton): void;
  119089. /**
  119090. * Adds the given particle system to this scene
  119091. * @param newParticleSystem The particle system to add
  119092. */
  119093. addParticleSystem(newParticleSystem: IParticleSystem): void;
  119094. /**
  119095. * Adds the given animation to this scene
  119096. * @param newAnimation The animation to add
  119097. */
  119098. addAnimation(newAnimation: Animation): void;
  119099. /**
  119100. * Adds the given animation group to this scene.
  119101. * @param newAnimationGroup The animation group to add
  119102. */
  119103. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  119104. /**
  119105. * Adds the given multi-material to this scene
  119106. * @param newMultiMaterial The multi-material to add
  119107. */
  119108. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  119109. /**
  119110. * Adds the given material to this scene
  119111. * @param newMaterial The material to add
  119112. */
  119113. addMaterial(newMaterial: Material): void;
  119114. /**
  119115. * Adds the given morph target to this scene
  119116. * @param newMorphTargetManager The morph target to add
  119117. */
  119118. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  119119. /**
  119120. * Adds the given geometry to this scene
  119121. * @param newGeometry The geometry to add
  119122. */
  119123. addGeometry(newGeometry: Geometry): void;
  119124. /**
  119125. * Adds the given action manager to this scene
  119126. * @param newActionManager The action manager to add
  119127. */
  119128. addActionManager(newActionManager: AbstractActionManager): void;
  119129. /**
  119130. * Adds the given texture to this scene.
  119131. * @param newTexture The texture to add
  119132. */
  119133. addTexture(newTexture: BaseTexture): void;
  119134. /**
  119135. * Switch active camera
  119136. * @param newCamera defines the new active camera
  119137. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  119138. */
  119139. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  119140. /**
  119141. * sets the active camera of the scene using its ID
  119142. * @param id defines the camera's ID
  119143. * @return the new active camera or null if none found.
  119144. */
  119145. setActiveCameraByID(id: string): Nullable<Camera>;
  119146. /**
  119147. * sets the active camera of the scene using its name
  119148. * @param name defines the camera's name
  119149. * @returns the new active camera or null if none found.
  119150. */
  119151. setActiveCameraByName(name: string): Nullable<Camera>;
  119152. /**
  119153. * get an animation group using its name
  119154. * @param name defines the material's name
  119155. * @return the animation group or null if none found.
  119156. */
  119157. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  119158. /**
  119159. * Get a material using its unique id
  119160. * @param uniqueId defines the material's unique id
  119161. * @return the material or null if none found.
  119162. */
  119163. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  119164. /**
  119165. * get a material using its id
  119166. * @param id defines the material's ID
  119167. * @return the material or null if none found.
  119168. */
  119169. getMaterialByID(id: string): Nullable<Material>;
  119170. /**
  119171. * Gets a the last added material using a given id
  119172. * @param id defines the material's ID
  119173. * @return the last material with the given id or null if none found.
  119174. */
  119175. getLastMaterialByID(id: string): Nullable<Material>;
  119176. /**
  119177. * Gets a material using its name
  119178. * @param name defines the material's name
  119179. * @return the material or null if none found.
  119180. */
  119181. getMaterialByName(name: string): Nullable<Material>;
  119182. /**
  119183. * Get a texture using its unique id
  119184. * @param uniqueId defines the texture's unique id
  119185. * @return the texture or null if none found.
  119186. */
  119187. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  119188. /**
  119189. * Gets a camera using its id
  119190. * @param id defines the id to look for
  119191. * @returns the camera or null if not found
  119192. */
  119193. getCameraByID(id: string): Nullable<Camera>;
  119194. /**
  119195. * Gets a camera using its unique id
  119196. * @param uniqueId defines the unique id to look for
  119197. * @returns the camera or null if not found
  119198. */
  119199. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  119200. /**
  119201. * Gets a camera using its name
  119202. * @param name defines the camera's name
  119203. * @return the camera or null if none found.
  119204. */
  119205. getCameraByName(name: string): Nullable<Camera>;
  119206. /**
  119207. * Gets a bone using its id
  119208. * @param id defines the bone's id
  119209. * @return the bone or null if not found
  119210. */
  119211. getBoneByID(id: string): Nullable<Bone>;
  119212. /**
  119213. * Gets a bone using its id
  119214. * @param name defines the bone's name
  119215. * @return the bone or null if not found
  119216. */
  119217. getBoneByName(name: string): Nullable<Bone>;
  119218. /**
  119219. * Gets a light node using its name
  119220. * @param name defines the the light's name
  119221. * @return the light or null if none found.
  119222. */
  119223. getLightByName(name: string): Nullable<Light>;
  119224. /**
  119225. * Gets a light node using its id
  119226. * @param id defines the light's id
  119227. * @return the light or null if none found.
  119228. */
  119229. getLightByID(id: string): Nullable<Light>;
  119230. /**
  119231. * Gets a light node using its scene-generated unique ID
  119232. * @param uniqueId defines the light's unique id
  119233. * @return the light or null if none found.
  119234. */
  119235. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  119236. /**
  119237. * Gets a particle system by id
  119238. * @param id defines the particle system id
  119239. * @return the corresponding system or null if none found
  119240. */
  119241. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  119242. /**
  119243. * Gets a geometry using its ID
  119244. * @param id defines the geometry's id
  119245. * @return the geometry or null if none found.
  119246. */
  119247. getGeometryByID(id: string): Nullable<Geometry>;
  119248. private _getGeometryByUniqueID;
  119249. /**
  119250. * Add a new geometry to this scene
  119251. * @param geometry defines the geometry to be added to the scene.
  119252. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  119253. * @return a boolean defining if the geometry was added or not
  119254. */
  119255. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  119256. /**
  119257. * Removes an existing geometry
  119258. * @param geometry defines the geometry to be removed from the scene
  119259. * @return a boolean defining if the geometry was removed or not
  119260. */
  119261. removeGeometry(geometry: Geometry): boolean;
  119262. /**
  119263. * Gets the list of geometries attached to the scene
  119264. * @returns an array of Geometry
  119265. */
  119266. getGeometries(): Geometry[];
  119267. /**
  119268. * Gets the first added mesh found of a given ID
  119269. * @param id defines the id to search for
  119270. * @return the mesh found or null if not found at all
  119271. */
  119272. getMeshByID(id: string): Nullable<AbstractMesh>;
  119273. /**
  119274. * Gets a list of meshes using their id
  119275. * @param id defines the id to search for
  119276. * @returns a list of meshes
  119277. */
  119278. getMeshesByID(id: string): Array<AbstractMesh>;
  119279. /**
  119280. * Gets the first added transform node found of a given ID
  119281. * @param id defines the id to search for
  119282. * @return the found transform node or null if not found at all.
  119283. */
  119284. getTransformNodeByID(id: string): Nullable<TransformNode>;
  119285. /**
  119286. * Gets a transform node with its auto-generated unique id
  119287. * @param uniqueId efines the unique id to search for
  119288. * @return the found transform node or null if not found at all.
  119289. */
  119290. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  119291. /**
  119292. * Gets a list of transform nodes using their id
  119293. * @param id defines the id to search for
  119294. * @returns a list of transform nodes
  119295. */
  119296. getTransformNodesByID(id: string): Array<TransformNode>;
  119297. /**
  119298. * Gets a mesh with its auto-generated unique id
  119299. * @param uniqueId defines the unique id to search for
  119300. * @return the found mesh or null if not found at all.
  119301. */
  119302. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  119303. /**
  119304. * Gets a the last added mesh using a given id
  119305. * @param id defines the id to search for
  119306. * @return the found mesh or null if not found at all.
  119307. */
  119308. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  119309. /**
  119310. * Gets a the last added node (Mesh, Camera, Light) using a given id
  119311. * @param id defines the id to search for
  119312. * @return the found node or null if not found at all
  119313. */
  119314. getLastEntryByID(id: string): Nullable<Node>;
  119315. /**
  119316. * Gets a node (Mesh, Camera, Light) using a given id
  119317. * @param id defines the id to search for
  119318. * @return the found node or null if not found at all
  119319. */
  119320. getNodeByID(id: string): Nullable<Node>;
  119321. /**
  119322. * Gets a node (Mesh, Camera, Light) using a given name
  119323. * @param name defines the name to search for
  119324. * @return the found node or null if not found at all.
  119325. */
  119326. getNodeByName(name: string): Nullable<Node>;
  119327. /**
  119328. * Gets a mesh using a given name
  119329. * @param name defines the name to search for
  119330. * @return the found mesh or null if not found at all.
  119331. */
  119332. getMeshByName(name: string): Nullable<AbstractMesh>;
  119333. /**
  119334. * Gets a transform node using a given name
  119335. * @param name defines the name to search for
  119336. * @return the found transform node or null if not found at all.
  119337. */
  119338. getTransformNodeByName(name: string): Nullable<TransformNode>;
  119339. /**
  119340. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  119341. * @param id defines the id to search for
  119342. * @return the found skeleton or null if not found at all.
  119343. */
  119344. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  119345. /**
  119346. * Gets a skeleton using a given auto generated unique id
  119347. * @param uniqueId defines the unique id to search for
  119348. * @return the found skeleton or null if not found at all.
  119349. */
  119350. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  119351. /**
  119352. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  119353. * @param id defines the id to search for
  119354. * @return the found skeleton or null if not found at all.
  119355. */
  119356. getSkeletonById(id: string): Nullable<Skeleton>;
  119357. /**
  119358. * Gets a skeleton using a given name
  119359. * @param name defines the name to search for
  119360. * @return the found skeleton or null if not found at all.
  119361. */
  119362. getSkeletonByName(name: string): Nullable<Skeleton>;
  119363. /**
  119364. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  119365. * @param id defines the id to search for
  119366. * @return the found morph target manager or null if not found at all.
  119367. */
  119368. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  119369. /**
  119370. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  119371. * @param id defines the id to search for
  119372. * @return the found morph target or null if not found at all.
  119373. */
  119374. getMorphTargetById(id: string): Nullable<MorphTarget>;
  119375. /**
  119376. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  119377. * @param name defines the name to search for
  119378. * @return the found morph target or null if not found at all.
  119379. */
  119380. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  119381. /**
  119382. * Gets a boolean indicating if the given mesh is active
  119383. * @param mesh defines the mesh to look for
  119384. * @returns true if the mesh is in the active list
  119385. */
  119386. isActiveMesh(mesh: AbstractMesh): boolean;
  119387. /**
  119388. * Return a unique id as a string which can serve as an identifier for the scene
  119389. */
  119390. get uid(): string;
  119391. /**
  119392. * Add an externaly attached data from its key.
  119393. * This method call will fail and return false, if such key already exists.
  119394. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  119395. * @param key the unique key that identifies the data
  119396. * @param data the data object to associate to the key for this Engine instance
  119397. * @return true if no such key were already present and the data was added successfully, false otherwise
  119398. */
  119399. addExternalData<T>(key: string, data: T): boolean;
  119400. /**
  119401. * Get an externaly attached data from its key
  119402. * @param key the unique key that identifies the data
  119403. * @return the associated data, if present (can be null), or undefined if not present
  119404. */
  119405. getExternalData<T>(key: string): Nullable<T>;
  119406. /**
  119407. * Get an externaly attached data from its key, create it using a factory if it's not already present
  119408. * @param key the unique key that identifies the data
  119409. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  119410. * @return the associated data, can be null if the factory returned null.
  119411. */
  119412. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  119413. /**
  119414. * Remove an externaly attached data from the Engine instance
  119415. * @param key the unique key that identifies the data
  119416. * @return true if the data was successfully removed, false if it doesn't exist
  119417. */
  119418. removeExternalData(key: string): boolean;
  119419. private _evaluateSubMesh;
  119420. /**
  119421. * Clear the processed materials smart array preventing retention point in material dispose.
  119422. */
  119423. freeProcessedMaterials(): void;
  119424. private _preventFreeActiveMeshesAndRenderingGroups;
  119425. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  119426. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  119427. * when disposing several meshes in a row or a hierarchy of meshes.
  119428. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  119429. */
  119430. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  119431. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  119432. /**
  119433. * Clear the active meshes smart array preventing retention point in mesh dispose.
  119434. */
  119435. freeActiveMeshes(): void;
  119436. /**
  119437. * Clear the info related to rendering groups preventing retention points during dispose.
  119438. */
  119439. freeRenderingGroups(): void;
  119440. /** @hidden */
  119441. _isInIntermediateRendering(): boolean;
  119442. /**
  119443. * Lambda returning the list of potentially active meshes.
  119444. */
  119445. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  119446. /**
  119447. * Lambda returning the list of potentially active sub meshes.
  119448. */
  119449. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  119450. /**
  119451. * Lambda returning the list of potentially intersecting sub meshes.
  119452. */
  119453. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  119454. /**
  119455. * Lambda returning the list of potentially colliding sub meshes.
  119456. */
  119457. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  119458. private _activeMeshesFrozen;
  119459. private _skipEvaluateActiveMeshesCompletely;
  119460. /**
  119461. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  119462. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  119463. * @returns the current scene
  119464. */
  119465. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  119466. /**
  119467. * Use this function to restart evaluating active meshes on every frame
  119468. * @returns the current scene
  119469. */
  119470. unfreezeActiveMeshes(): Scene;
  119471. private _evaluateActiveMeshes;
  119472. private _activeMesh;
  119473. /**
  119474. * Update the transform matrix to update from the current active camera
  119475. * @param force defines a boolean used to force the update even if cache is up to date
  119476. */
  119477. updateTransformMatrix(force?: boolean): void;
  119478. private _bindFrameBuffer;
  119479. /** @hidden */
  119480. _allowPostProcessClearColor: boolean;
  119481. /** @hidden */
  119482. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  119483. private _processSubCameras;
  119484. private _checkIntersections;
  119485. /** @hidden */
  119486. _advancePhysicsEngineStep(step: number): void;
  119487. /**
  119488. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  119489. */
  119490. getDeterministicFrameTime: () => number;
  119491. /** @hidden */
  119492. _animate(): void;
  119493. /** Execute all animations (for a frame) */
  119494. animate(): void;
  119495. /**
  119496. * Render the scene
  119497. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  119498. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  119499. */
  119500. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  119501. /**
  119502. * Freeze all materials
  119503. * A frozen material will not be updatable but should be faster to render
  119504. */
  119505. freezeMaterials(): void;
  119506. /**
  119507. * Unfreeze all materials
  119508. * A frozen material will not be updatable but should be faster to render
  119509. */
  119510. unfreezeMaterials(): void;
  119511. /**
  119512. * Releases all held ressources
  119513. */
  119514. dispose(): void;
  119515. /**
  119516. * Gets if the scene is already disposed
  119517. */
  119518. get isDisposed(): boolean;
  119519. /**
  119520. * Call this function to reduce memory footprint of the scene.
  119521. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  119522. */
  119523. clearCachedVertexData(): void;
  119524. /**
  119525. * This function will remove the local cached buffer data from texture.
  119526. * It will save memory but will prevent the texture from being rebuilt
  119527. */
  119528. cleanCachedTextureBuffer(): void;
  119529. /**
  119530. * Get the world extend vectors with an optional filter
  119531. *
  119532. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  119533. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  119534. */
  119535. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  119536. min: Vector3;
  119537. max: Vector3;
  119538. };
  119539. /**
  119540. * Creates a ray that can be used to pick in the scene
  119541. * @param x defines the x coordinate of the origin (on-screen)
  119542. * @param y defines the y coordinate of the origin (on-screen)
  119543. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  119544. * @param camera defines the camera to use for the picking
  119545. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  119546. * @returns a Ray
  119547. */
  119548. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  119549. /**
  119550. * Creates a ray that can be used to pick in the scene
  119551. * @param x defines the x coordinate of the origin (on-screen)
  119552. * @param y defines the y coordinate of the origin (on-screen)
  119553. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  119554. * @param result defines the ray where to store the picking ray
  119555. * @param camera defines the camera to use for the picking
  119556. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  119557. * @returns the current scene
  119558. */
  119559. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  119560. /**
  119561. * Creates a ray that can be used to pick in the scene
  119562. * @param x defines the x coordinate of the origin (on-screen)
  119563. * @param y defines the y coordinate of the origin (on-screen)
  119564. * @param camera defines the camera to use for the picking
  119565. * @returns a Ray
  119566. */
  119567. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  119568. /**
  119569. * Creates a ray that can be used to pick in the scene
  119570. * @param x defines the x coordinate of the origin (on-screen)
  119571. * @param y defines the y coordinate of the origin (on-screen)
  119572. * @param result defines the ray where to store the picking ray
  119573. * @param camera defines the camera to use for the picking
  119574. * @returns the current scene
  119575. */
  119576. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  119577. /** Launch a ray to try to pick a mesh in the scene
  119578. * @param x position on screen
  119579. * @param y position on screen
  119580. * @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
  119581. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119582. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119583. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119584. * @returns a PickingInfo
  119585. */
  119586. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  119587. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  119588. * @param x position on screen
  119589. * @param y position on screen
  119590. * @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
  119591. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119592. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119593. * @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)
  119594. */
  119595. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  119596. /** Use the given ray to pick a mesh in the scene
  119597. * @param ray The ray to use to pick meshes
  119598. * @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
  119599. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119600. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119601. * @returns a PickingInfo
  119602. */
  119603. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  119604. /**
  119605. * Launch a ray to try to pick a mesh in the scene
  119606. * @param x X position on screen
  119607. * @param y Y position on screen
  119608. * @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
  119609. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119610. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119611. * @returns an array of PickingInfo
  119612. */
  119613. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  119614. /**
  119615. * Launch a ray to try to pick a mesh in the scene
  119616. * @param ray Ray to use
  119617. * @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
  119618. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119619. * @returns an array of PickingInfo
  119620. */
  119621. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  119622. /**
  119623. * Force the value of meshUnderPointer
  119624. * @param mesh defines the mesh to use
  119625. */
  119626. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  119627. /**
  119628. * Gets the mesh under the pointer
  119629. * @returns a Mesh or null if no mesh is under the pointer
  119630. */
  119631. getPointerOverMesh(): Nullable<AbstractMesh>;
  119632. /** @hidden */
  119633. _rebuildGeometries(): void;
  119634. /** @hidden */
  119635. _rebuildTextures(): void;
  119636. private _getByTags;
  119637. /**
  119638. * Get a list of meshes by tags
  119639. * @param tagsQuery defines the tags query to use
  119640. * @param forEach defines a predicate used to filter results
  119641. * @returns an array of Mesh
  119642. */
  119643. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  119644. /**
  119645. * Get a list of cameras by tags
  119646. * @param tagsQuery defines the tags query to use
  119647. * @param forEach defines a predicate used to filter results
  119648. * @returns an array of Camera
  119649. */
  119650. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  119651. /**
  119652. * Get a list of lights by tags
  119653. * @param tagsQuery defines the tags query to use
  119654. * @param forEach defines a predicate used to filter results
  119655. * @returns an array of Light
  119656. */
  119657. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  119658. /**
  119659. * Get a list of materials by tags
  119660. * @param tagsQuery defines the tags query to use
  119661. * @param forEach defines a predicate used to filter results
  119662. * @returns an array of Material
  119663. */
  119664. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  119665. /**
  119666. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  119667. * This allowed control for front to back rendering or reversly depending of the special needs.
  119668. *
  119669. * @param renderingGroupId The rendering group id corresponding to its index
  119670. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  119671. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  119672. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  119673. */
  119674. 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;
  119675. /**
  119676. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  119677. *
  119678. * @param renderingGroupId The rendering group id corresponding to its index
  119679. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119680. * @param depth Automatically clears depth between groups if true and autoClear is true.
  119681. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  119682. */
  119683. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  119684. /**
  119685. * Gets the current auto clear configuration for one rendering group of the rendering
  119686. * manager.
  119687. * @param index the rendering group index to get the information for
  119688. * @returns The auto clear setup for the requested rendering group
  119689. */
  119690. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  119691. private _blockMaterialDirtyMechanism;
  119692. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  119693. get blockMaterialDirtyMechanism(): boolean;
  119694. set blockMaterialDirtyMechanism(value: boolean);
  119695. /**
  119696. * Will flag all materials as dirty to trigger new shader compilation
  119697. * @param flag defines the flag used to specify which material part must be marked as dirty
  119698. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  119699. */
  119700. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  119701. /** @hidden */
  119702. _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;
  119703. /** @hidden */
  119704. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  119705. /** @hidden */
  119706. _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;
  119707. /** @hidden */
  119708. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  119709. /** @hidden */
  119710. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  119711. /** @hidden */
  119712. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  119713. }
  119714. }
  119715. declare module BABYLON {
  119716. /**
  119717. * Set of assets to keep when moving a scene into an asset container.
  119718. */
  119719. export class KeepAssets extends AbstractScene {
  119720. }
  119721. /**
  119722. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  119723. */
  119724. export class InstantiatedEntries {
  119725. /**
  119726. * List of new root nodes (eg. nodes with no parent)
  119727. */
  119728. rootNodes: TransformNode[];
  119729. /**
  119730. * List of new skeletons
  119731. */
  119732. skeletons: Skeleton[];
  119733. /**
  119734. * List of new animation groups
  119735. */
  119736. animationGroups: AnimationGroup[];
  119737. }
  119738. /**
  119739. * Container with a set of assets that can be added or removed from a scene.
  119740. */
  119741. export class AssetContainer extends AbstractScene {
  119742. private _wasAddedToScene;
  119743. /**
  119744. * The scene the AssetContainer belongs to.
  119745. */
  119746. scene: Scene;
  119747. /**
  119748. * Instantiates an AssetContainer.
  119749. * @param scene The scene the AssetContainer belongs to.
  119750. */
  119751. constructor(scene: Scene);
  119752. /**
  119753. * Instantiate or clone all meshes and add the new ones to the scene.
  119754. * Skeletons and animation groups will all be cloned
  119755. * @param nameFunction defines an optional function used to get new names for clones
  119756. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  119757. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  119758. */
  119759. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  119760. /**
  119761. * Adds all the assets from the container to the scene.
  119762. */
  119763. addAllToScene(): void;
  119764. /**
  119765. * Removes all the assets in the container from the scene
  119766. */
  119767. removeAllFromScene(): void;
  119768. /**
  119769. * Disposes all the assets in the container
  119770. */
  119771. dispose(): void;
  119772. private _moveAssets;
  119773. /**
  119774. * Removes all the assets contained in the scene and adds them to the container.
  119775. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  119776. */
  119777. moveAllFromScene(keepAssets?: KeepAssets): void;
  119778. /**
  119779. * 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.
  119780. * @returns the root mesh
  119781. */
  119782. createRootMesh(): Mesh;
  119783. /**
  119784. * Merge animations (direct and animation groups) from this asset container into a scene
  119785. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  119786. * @param animatables set of animatables to retarget to a node from the scene
  119787. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  119788. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  119789. */
  119790. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  119791. }
  119792. }
  119793. declare module BABYLON {
  119794. /**
  119795. * Defines how the parser contract is defined.
  119796. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  119797. */
  119798. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  119799. /**
  119800. * Defines how the individual parser contract is defined.
  119801. * These parser can parse an individual asset
  119802. */
  119803. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  119804. /**
  119805. * Base class of the scene acting as a container for the different elements composing a scene.
  119806. * This class is dynamically extended by the different components of the scene increasing
  119807. * flexibility and reducing coupling
  119808. */
  119809. export abstract class AbstractScene {
  119810. /**
  119811. * Stores the list of available parsers in the application.
  119812. */
  119813. private static _BabylonFileParsers;
  119814. /**
  119815. * Stores the list of available individual parsers in the application.
  119816. */
  119817. private static _IndividualBabylonFileParsers;
  119818. /**
  119819. * Adds a parser in the list of available ones
  119820. * @param name Defines the name of the parser
  119821. * @param parser Defines the parser to add
  119822. */
  119823. static AddParser(name: string, parser: BabylonFileParser): void;
  119824. /**
  119825. * Gets a general parser from the list of avaialble ones
  119826. * @param name Defines the name of the parser
  119827. * @returns the requested parser or null
  119828. */
  119829. static GetParser(name: string): Nullable<BabylonFileParser>;
  119830. /**
  119831. * Adds n individual parser in the list of available ones
  119832. * @param name Defines the name of the parser
  119833. * @param parser Defines the parser to add
  119834. */
  119835. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  119836. /**
  119837. * Gets an individual parser from the list of avaialble ones
  119838. * @param name Defines the name of the parser
  119839. * @returns the requested parser or null
  119840. */
  119841. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  119842. /**
  119843. * Parser json data and populate both a scene and its associated container object
  119844. * @param jsonData Defines the data to parse
  119845. * @param scene Defines the scene to parse the data for
  119846. * @param container Defines the container attached to the parsing sequence
  119847. * @param rootUrl Defines the root url of the data
  119848. */
  119849. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  119850. /**
  119851. * Gets the list of root nodes (ie. nodes with no parent)
  119852. */
  119853. rootNodes: Node[];
  119854. /** All of the cameras added to this scene
  119855. * @see https://doc.babylonjs.com/babylon101/cameras
  119856. */
  119857. cameras: Camera[];
  119858. /**
  119859. * All of the lights added to this scene
  119860. * @see https://doc.babylonjs.com/babylon101/lights
  119861. */
  119862. lights: Light[];
  119863. /**
  119864. * All of the (abstract) meshes added to this scene
  119865. */
  119866. meshes: AbstractMesh[];
  119867. /**
  119868. * The list of skeletons added to the scene
  119869. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  119870. */
  119871. skeletons: Skeleton[];
  119872. /**
  119873. * All of the particle systems added to this scene
  119874. * @see https://doc.babylonjs.com/babylon101/particles
  119875. */
  119876. particleSystems: IParticleSystem[];
  119877. /**
  119878. * Gets a list of Animations associated with the scene
  119879. */
  119880. animations: Animation[];
  119881. /**
  119882. * All of the animation groups added to this scene
  119883. * @see https://doc.babylonjs.com/how_to/group
  119884. */
  119885. animationGroups: AnimationGroup[];
  119886. /**
  119887. * All of the multi-materials added to this scene
  119888. * @see https://doc.babylonjs.com/how_to/multi_materials
  119889. */
  119890. multiMaterials: MultiMaterial[];
  119891. /**
  119892. * All of the materials added to this scene
  119893. * In the context of a Scene, it is not supposed to be modified manually.
  119894. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  119895. * Note also that the order of the Material within the array is not significant and might change.
  119896. * @see https://doc.babylonjs.com/babylon101/materials
  119897. */
  119898. materials: Material[];
  119899. /**
  119900. * The list of morph target managers added to the scene
  119901. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  119902. */
  119903. morphTargetManagers: MorphTargetManager[];
  119904. /**
  119905. * The list of geometries used in the scene.
  119906. */
  119907. geometries: Geometry[];
  119908. /**
  119909. * All of the tranform nodes added to this scene
  119910. * In the context of a Scene, it is not supposed to be modified manually.
  119911. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  119912. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  119913. * @see https://doc.babylonjs.com/how_to/transformnode
  119914. */
  119915. transformNodes: TransformNode[];
  119916. /**
  119917. * ActionManagers available on the scene.
  119918. */
  119919. actionManagers: AbstractActionManager[];
  119920. /**
  119921. * Textures to keep.
  119922. */
  119923. textures: BaseTexture[];
  119924. /**
  119925. * Environment texture for the scene
  119926. */
  119927. environmentTexture: Nullable<BaseTexture>;
  119928. /**
  119929. * @returns all meshes, lights, cameras, transformNodes and bones
  119930. */
  119931. getNodes(): Array<Node>;
  119932. }
  119933. }
  119934. declare module BABYLON {
  119935. /**
  119936. * Interface used to define options for Sound class
  119937. */
  119938. export interface ISoundOptions {
  119939. /**
  119940. * Does the sound autoplay once loaded.
  119941. */
  119942. autoplay?: boolean;
  119943. /**
  119944. * Does the sound loop after it finishes playing once.
  119945. */
  119946. loop?: boolean;
  119947. /**
  119948. * Sound's volume
  119949. */
  119950. volume?: number;
  119951. /**
  119952. * Is it a spatial sound?
  119953. */
  119954. spatialSound?: boolean;
  119955. /**
  119956. * Maximum distance to hear that sound
  119957. */
  119958. maxDistance?: number;
  119959. /**
  119960. * Uses user defined attenuation function
  119961. */
  119962. useCustomAttenuation?: boolean;
  119963. /**
  119964. * Define the roll off factor of spatial sounds.
  119965. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119966. */
  119967. rolloffFactor?: number;
  119968. /**
  119969. * Define the reference distance the sound should be heard perfectly.
  119970. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119971. */
  119972. refDistance?: number;
  119973. /**
  119974. * Define the distance attenuation model the sound will follow.
  119975. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119976. */
  119977. distanceModel?: string;
  119978. /**
  119979. * Defines the playback speed (1 by default)
  119980. */
  119981. playbackRate?: number;
  119982. /**
  119983. * Defines if the sound is from a streaming source
  119984. */
  119985. streaming?: boolean;
  119986. /**
  119987. * Defines an optional length (in seconds) inside the sound file
  119988. */
  119989. length?: number;
  119990. /**
  119991. * Defines an optional offset (in seconds) inside the sound file
  119992. */
  119993. offset?: number;
  119994. /**
  119995. * If true, URLs will not be required to state the audio file codec to use.
  119996. */
  119997. skipCodecCheck?: boolean;
  119998. }
  119999. /**
  120000. * Defines a sound that can be played in the application.
  120001. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  120002. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120003. */
  120004. export class Sound {
  120005. /**
  120006. * The name of the sound in the scene.
  120007. */
  120008. name: string;
  120009. /**
  120010. * Does the sound autoplay once loaded.
  120011. */
  120012. autoplay: boolean;
  120013. /**
  120014. * Does the sound loop after it finishes playing once.
  120015. */
  120016. loop: boolean;
  120017. /**
  120018. * Does the sound use a custom attenuation curve to simulate the falloff
  120019. * happening when the source gets further away from the camera.
  120020. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  120021. */
  120022. useCustomAttenuation: boolean;
  120023. /**
  120024. * The sound track id this sound belongs to.
  120025. */
  120026. soundTrackId: number;
  120027. /**
  120028. * Is this sound currently played.
  120029. */
  120030. isPlaying: boolean;
  120031. /**
  120032. * Is this sound currently paused.
  120033. */
  120034. isPaused: boolean;
  120035. /**
  120036. * Does this sound enables spatial sound.
  120037. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120038. */
  120039. spatialSound: boolean;
  120040. /**
  120041. * Define the reference distance the sound should be heard perfectly.
  120042. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120043. */
  120044. refDistance: number;
  120045. /**
  120046. * Define the roll off factor of spatial sounds.
  120047. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120048. */
  120049. rolloffFactor: number;
  120050. /**
  120051. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  120052. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120053. */
  120054. maxDistance: number;
  120055. /**
  120056. * Define the distance attenuation model the sound will follow.
  120057. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120058. */
  120059. distanceModel: string;
  120060. /**
  120061. * @hidden
  120062. * Back Compat
  120063. **/
  120064. onended: () => any;
  120065. /**
  120066. * Gets or sets an object used to store user defined information for the sound.
  120067. */
  120068. metadata: any;
  120069. /**
  120070. * Observable event when the current playing sound finishes.
  120071. */
  120072. onEndedObservable: Observable<Sound>;
  120073. private _panningModel;
  120074. private _playbackRate;
  120075. private _streaming;
  120076. private _startTime;
  120077. private _startOffset;
  120078. private _position;
  120079. /** @hidden */
  120080. _positionInEmitterSpace: boolean;
  120081. private _localDirection;
  120082. private _volume;
  120083. private _isReadyToPlay;
  120084. private _isDirectional;
  120085. private _readyToPlayCallback;
  120086. private _audioBuffer;
  120087. private _soundSource;
  120088. private _streamingSource;
  120089. private _soundPanner;
  120090. private _soundGain;
  120091. private _inputAudioNode;
  120092. private _outputAudioNode;
  120093. private _coneInnerAngle;
  120094. private _coneOuterAngle;
  120095. private _coneOuterGain;
  120096. private _scene;
  120097. private _connectedTransformNode;
  120098. private _customAttenuationFunction;
  120099. private _registerFunc;
  120100. private _isOutputConnected;
  120101. private _htmlAudioElement;
  120102. private _urlType;
  120103. private _length?;
  120104. private _offset?;
  120105. /** @hidden */
  120106. static _SceneComponentInitialization: (scene: Scene) => void;
  120107. /**
  120108. * Create a sound and attach it to a scene
  120109. * @param name Name of your sound
  120110. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  120111. * @param scene defines the scene the sound belongs to
  120112. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  120113. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  120114. */
  120115. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  120116. /**
  120117. * Release the sound and its associated resources
  120118. */
  120119. dispose(): void;
  120120. /**
  120121. * Gets if the sounds is ready to be played or not.
  120122. * @returns true if ready, otherwise false
  120123. */
  120124. isReady(): boolean;
  120125. private _soundLoaded;
  120126. /**
  120127. * Sets the data of the sound from an audiobuffer
  120128. * @param audioBuffer The audioBuffer containing the data
  120129. */
  120130. setAudioBuffer(audioBuffer: AudioBuffer): void;
  120131. /**
  120132. * Updates the current sounds options such as maxdistance, loop...
  120133. * @param options A JSON object containing values named as the object properties
  120134. */
  120135. updateOptions(options: ISoundOptions): void;
  120136. private _createSpatialParameters;
  120137. private _updateSpatialParameters;
  120138. /**
  120139. * Switch the panning model to HRTF:
  120140. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  120141. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120142. */
  120143. switchPanningModelToHRTF(): void;
  120144. /**
  120145. * Switch the panning model to Equal Power:
  120146. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  120147. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120148. */
  120149. switchPanningModelToEqualPower(): void;
  120150. private _switchPanningModel;
  120151. /**
  120152. * Connect this sound to a sound track audio node like gain...
  120153. * @param soundTrackAudioNode the sound track audio node to connect to
  120154. */
  120155. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  120156. /**
  120157. * Transform this sound into a directional source
  120158. * @param coneInnerAngle Size of the inner cone in degree
  120159. * @param coneOuterAngle Size of the outer cone in degree
  120160. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  120161. */
  120162. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  120163. /**
  120164. * Gets or sets the inner angle for the directional cone.
  120165. */
  120166. get directionalConeInnerAngle(): number;
  120167. /**
  120168. * Gets or sets the inner angle for the directional cone.
  120169. */
  120170. set directionalConeInnerAngle(value: number);
  120171. /**
  120172. * Gets or sets the outer angle for the directional cone.
  120173. */
  120174. get directionalConeOuterAngle(): number;
  120175. /**
  120176. * Gets or sets the outer angle for the directional cone.
  120177. */
  120178. set directionalConeOuterAngle(value: number);
  120179. /**
  120180. * Sets the position of the emitter if spatial sound is enabled
  120181. * @param newPosition Defines the new posisiton
  120182. */
  120183. setPosition(newPosition: Vector3): void;
  120184. /**
  120185. * Sets the local direction of the emitter if spatial sound is enabled
  120186. * @param newLocalDirection Defines the new local direction
  120187. */
  120188. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  120189. private _updateDirection;
  120190. /** @hidden */
  120191. updateDistanceFromListener(): void;
  120192. /**
  120193. * Sets a new custom attenuation function for the sound.
  120194. * @param callback Defines the function used for the attenuation
  120195. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  120196. */
  120197. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  120198. /**
  120199. * Play the sound
  120200. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  120201. * @param offset (optional) Start the sound at a specific time in seconds
  120202. * @param length (optional) Sound duration (in seconds)
  120203. */
  120204. play(time?: number, offset?: number, length?: number): void;
  120205. private _onended;
  120206. /**
  120207. * Stop the sound
  120208. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  120209. */
  120210. stop(time?: number): void;
  120211. /**
  120212. * Put the sound in pause
  120213. */
  120214. pause(): void;
  120215. /**
  120216. * Sets a dedicated volume for this sounds
  120217. * @param newVolume Define the new volume of the sound
  120218. * @param time Define time for gradual change to new volume
  120219. */
  120220. setVolume(newVolume: number, time?: number): void;
  120221. /**
  120222. * Set the sound play back rate
  120223. * @param newPlaybackRate Define the playback rate the sound should be played at
  120224. */
  120225. setPlaybackRate(newPlaybackRate: number): void;
  120226. /**
  120227. * Gets the volume of the sound.
  120228. * @returns the volume of the sound
  120229. */
  120230. getVolume(): number;
  120231. /**
  120232. * Attach the sound to a dedicated mesh
  120233. * @param transformNode The transform node to connect the sound with
  120234. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120235. */
  120236. attachToMesh(transformNode: TransformNode): void;
  120237. /**
  120238. * Detach the sound from the previously attached mesh
  120239. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120240. */
  120241. detachFromMesh(): void;
  120242. private _onRegisterAfterWorldMatrixUpdate;
  120243. /**
  120244. * Clone the current sound in the scene.
  120245. * @returns the new sound clone
  120246. */
  120247. clone(): Nullable<Sound>;
  120248. /**
  120249. * Gets the current underlying audio buffer containing the data
  120250. * @returns the audio buffer
  120251. */
  120252. getAudioBuffer(): Nullable<AudioBuffer>;
  120253. /**
  120254. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  120255. * @returns the source node
  120256. */
  120257. getSoundSource(): Nullable<AudioBufferSourceNode>;
  120258. /**
  120259. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  120260. * @returns the gain node
  120261. */
  120262. getSoundGain(): Nullable<GainNode>;
  120263. /**
  120264. * Serializes the Sound in a JSON representation
  120265. * @returns the JSON representation of the sound
  120266. */
  120267. serialize(): any;
  120268. /**
  120269. * Parse a JSON representation of a sound to innstantiate in a given scene
  120270. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  120271. * @param scene Define the scene the new parsed sound should be created in
  120272. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  120273. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  120274. * @returns the newly parsed sound
  120275. */
  120276. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  120277. }
  120278. }
  120279. declare module BABYLON {
  120280. /**
  120281. * This defines an action helpful to play a defined sound on a triggered action.
  120282. */
  120283. export class PlaySoundAction extends Action {
  120284. private _sound;
  120285. /**
  120286. * Instantiate the action
  120287. * @param triggerOptions defines the trigger options
  120288. * @param sound defines the sound to play
  120289. * @param condition defines the trigger related conditions
  120290. */
  120291. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  120292. /** @hidden */
  120293. _prepare(): void;
  120294. /**
  120295. * Execute the action and play the sound.
  120296. */
  120297. execute(): void;
  120298. /**
  120299. * Serializes the actions and its related information.
  120300. * @param parent defines the object to serialize in
  120301. * @returns the serialized object
  120302. */
  120303. serialize(parent: any): any;
  120304. }
  120305. /**
  120306. * This defines an action helpful to stop a defined sound on a triggered action.
  120307. */
  120308. export class StopSoundAction extends Action {
  120309. private _sound;
  120310. /**
  120311. * Instantiate the action
  120312. * @param triggerOptions defines the trigger options
  120313. * @param sound defines the sound to stop
  120314. * @param condition defines the trigger related conditions
  120315. */
  120316. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  120317. /** @hidden */
  120318. _prepare(): void;
  120319. /**
  120320. * Execute the action and stop the sound.
  120321. */
  120322. execute(): void;
  120323. /**
  120324. * Serializes the actions and its related information.
  120325. * @param parent defines the object to serialize in
  120326. * @returns the serialized object
  120327. */
  120328. serialize(parent: any): any;
  120329. }
  120330. }
  120331. declare module BABYLON {
  120332. /**
  120333. * This defines an action responsible to change the value of a property
  120334. * by interpolating between its current value and the newly set one once triggered.
  120335. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120336. */
  120337. export class InterpolateValueAction extends Action {
  120338. /**
  120339. * Defines the path of the property where the value should be interpolated
  120340. */
  120341. propertyPath: string;
  120342. /**
  120343. * Defines the target value at the end of the interpolation.
  120344. */
  120345. value: any;
  120346. /**
  120347. * Defines the time it will take for the property to interpolate to the value.
  120348. */
  120349. duration: number;
  120350. /**
  120351. * Defines if the other scene animations should be stopped when the action has been triggered
  120352. */
  120353. stopOtherAnimations?: boolean;
  120354. /**
  120355. * Defines a callback raised once the interpolation animation has been done.
  120356. */
  120357. onInterpolationDone?: () => void;
  120358. /**
  120359. * Observable triggered once the interpolation animation has been done.
  120360. */
  120361. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  120362. private _target;
  120363. private _effectiveTarget;
  120364. private _property;
  120365. /**
  120366. * Instantiate the action
  120367. * @param triggerOptions defines the trigger options
  120368. * @param target defines the object containing the value to interpolate
  120369. * @param propertyPath defines the path to the property in the target object
  120370. * @param value defines the target value at the end of the interpolation
  120371. * @param duration deines the time it will take for the property to interpolate to the value.
  120372. * @param condition defines the trigger related conditions
  120373. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  120374. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  120375. */
  120376. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  120377. /** @hidden */
  120378. _prepare(): void;
  120379. /**
  120380. * Execute the action starts the value interpolation.
  120381. */
  120382. execute(): void;
  120383. /**
  120384. * Serializes the actions and its related information.
  120385. * @param parent defines the object to serialize in
  120386. * @returns the serialized object
  120387. */
  120388. serialize(parent: any): any;
  120389. }
  120390. }
  120391. declare module BABYLON {
  120392. /**
  120393. * Options allowed during the creation of a sound track.
  120394. */
  120395. export interface ISoundTrackOptions {
  120396. /**
  120397. * The volume the sound track should take during creation
  120398. */
  120399. volume?: number;
  120400. /**
  120401. * Define if the sound track is the main sound track of the scene
  120402. */
  120403. mainTrack?: boolean;
  120404. }
  120405. /**
  120406. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  120407. * It will be also used in a future release to apply effects on a specific track.
  120408. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  120409. */
  120410. export class SoundTrack {
  120411. /**
  120412. * The unique identifier of the sound track in the scene.
  120413. */
  120414. id: number;
  120415. /**
  120416. * The list of sounds included in the sound track.
  120417. */
  120418. soundCollection: Array<Sound>;
  120419. private _outputAudioNode;
  120420. private _scene;
  120421. private _connectedAnalyser;
  120422. private _options;
  120423. private _isInitialized;
  120424. /**
  120425. * Creates a new sound track.
  120426. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  120427. * @param scene Define the scene the sound track belongs to
  120428. * @param options
  120429. */
  120430. constructor(scene: Scene, options?: ISoundTrackOptions);
  120431. private _initializeSoundTrackAudioGraph;
  120432. /**
  120433. * Release the sound track and its associated resources
  120434. */
  120435. dispose(): void;
  120436. /**
  120437. * Adds a sound to this sound track
  120438. * @param sound define the cound to add
  120439. * @ignoreNaming
  120440. */
  120441. AddSound(sound: Sound): void;
  120442. /**
  120443. * Removes a sound to this sound track
  120444. * @param sound define the cound to remove
  120445. * @ignoreNaming
  120446. */
  120447. RemoveSound(sound: Sound): void;
  120448. /**
  120449. * Set a global volume for the full sound track.
  120450. * @param newVolume Define the new volume of the sound track
  120451. */
  120452. setVolume(newVolume: number): void;
  120453. /**
  120454. * Switch the panning model to HRTF:
  120455. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  120456. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120457. */
  120458. switchPanningModelToHRTF(): void;
  120459. /**
  120460. * Switch the panning model to Equal Power:
  120461. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  120462. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120463. */
  120464. switchPanningModelToEqualPower(): void;
  120465. /**
  120466. * Connect the sound track to an audio analyser allowing some amazing
  120467. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120468. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120469. * @param analyser The analyser to connect to the engine
  120470. */
  120471. connectToAnalyser(analyser: Analyser): void;
  120472. }
  120473. }
  120474. declare module BABYLON {
  120475. interface AbstractScene {
  120476. /**
  120477. * The list of sounds used in the scene.
  120478. */
  120479. sounds: Nullable<Array<Sound>>;
  120480. }
  120481. interface Scene {
  120482. /**
  120483. * @hidden
  120484. * Backing field
  120485. */
  120486. _mainSoundTrack: SoundTrack;
  120487. /**
  120488. * The main sound track played by the scene.
  120489. * It cotains your primary collection of sounds.
  120490. */
  120491. mainSoundTrack: SoundTrack;
  120492. /**
  120493. * The list of sound tracks added to the scene
  120494. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120495. */
  120496. soundTracks: Nullable<Array<SoundTrack>>;
  120497. /**
  120498. * Gets a sound using a given name
  120499. * @param name defines the name to search for
  120500. * @return the found sound or null if not found at all.
  120501. */
  120502. getSoundByName(name: string): Nullable<Sound>;
  120503. /**
  120504. * Gets or sets if audio support is enabled
  120505. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120506. */
  120507. audioEnabled: boolean;
  120508. /**
  120509. * Gets or sets if audio will be output to headphones
  120510. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120511. */
  120512. headphone: boolean;
  120513. /**
  120514. * Gets or sets custom audio listener position provider
  120515. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120516. */
  120517. audioListenerPositionProvider: Nullable<() => Vector3>;
  120518. /**
  120519. * Gets or sets a refresh rate when using 3D audio positioning
  120520. */
  120521. audioPositioningRefreshRate: number;
  120522. }
  120523. /**
  120524. * Defines the sound scene component responsible to manage any sounds
  120525. * in a given scene.
  120526. */
  120527. export class AudioSceneComponent implements ISceneSerializableComponent {
  120528. /**
  120529. * The component name helpfull to identify the component in the list of scene components.
  120530. */
  120531. readonly name: string;
  120532. /**
  120533. * The scene the component belongs to.
  120534. */
  120535. scene: Scene;
  120536. private _audioEnabled;
  120537. /**
  120538. * Gets whether audio is enabled or not.
  120539. * Please use related enable/disable method to switch state.
  120540. */
  120541. get audioEnabled(): boolean;
  120542. private _headphone;
  120543. /**
  120544. * Gets whether audio is outputing to headphone or not.
  120545. * Please use the according Switch methods to change output.
  120546. */
  120547. get headphone(): boolean;
  120548. /**
  120549. * Gets or sets a refresh rate when using 3D audio positioning
  120550. */
  120551. audioPositioningRefreshRate: number;
  120552. private _audioListenerPositionProvider;
  120553. /**
  120554. * Gets the current audio listener position provider
  120555. */
  120556. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  120557. /**
  120558. * Sets a custom listener position for all sounds in the scene
  120559. * By default, this is the position of the first active camera
  120560. */
  120561. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  120562. /**
  120563. * Creates a new instance of the component for the given scene
  120564. * @param scene Defines the scene to register the component in
  120565. */
  120566. constructor(scene: Scene);
  120567. /**
  120568. * Registers the component in a given scene
  120569. */
  120570. register(): void;
  120571. /**
  120572. * Rebuilds the elements related to this component in case of
  120573. * context lost for instance.
  120574. */
  120575. rebuild(): void;
  120576. /**
  120577. * Serializes the component data to the specified json object
  120578. * @param serializationObject The object to serialize to
  120579. */
  120580. serialize(serializationObject: any): void;
  120581. /**
  120582. * Adds all the elements from the container to the scene
  120583. * @param container the container holding the elements
  120584. */
  120585. addFromContainer(container: AbstractScene): void;
  120586. /**
  120587. * Removes all the elements in the container from the scene
  120588. * @param container contains the elements to remove
  120589. * @param dispose if the removed element should be disposed (default: false)
  120590. */
  120591. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120592. /**
  120593. * Disposes the component and the associated ressources.
  120594. */
  120595. dispose(): void;
  120596. /**
  120597. * Disables audio in the associated scene.
  120598. */
  120599. disableAudio(): void;
  120600. /**
  120601. * Enables audio in the associated scene.
  120602. */
  120603. enableAudio(): void;
  120604. /**
  120605. * Switch audio to headphone output.
  120606. */
  120607. switchAudioModeForHeadphones(): void;
  120608. /**
  120609. * Switch audio to normal speakers.
  120610. */
  120611. switchAudioModeForNormalSpeakers(): void;
  120612. private _cachedCameraDirection;
  120613. private _cachedCameraPosition;
  120614. private _lastCheck;
  120615. private _afterRender;
  120616. }
  120617. }
  120618. declare module BABYLON {
  120619. /**
  120620. * Wraps one or more Sound objects and selects one with random weight for playback.
  120621. */
  120622. export class WeightedSound {
  120623. /** When true a Sound will be selected and played when the current playing Sound completes. */
  120624. loop: boolean;
  120625. private _coneInnerAngle;
  120626. private _coneOuterAngle;
  120627. private _volume;
  120628. /** A Sound is currently playing. */
  120629. isPlaying: boolean;
  120630. /** A Sound is currently paused. */
  120631. isPaused: boolean;
  120632. private _sounds;
  120633. private _weights;
  120634. private _currentIndex?;
  120635. /**
  120636. * Creates a new WeightedSound from the list of sounds given.
  120637. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  120638. * @param sounds Array of Sounds that will be selected from.
  120639. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  120640. */
  120641. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  120642. /**
  120643. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  120644. */
  120645. get directionalConeInnerAngle(): number;
  120646. /**
  120647. * The size of cone in degress for a directional sound in which there will be no attenuation.
  120648. */
  120649. set directionalConeInnerAngle(value: number);
  120650. /**
  120651. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  120652. * Listener angles between innerAngle and outerAngle will falloff linearly.
  120653. */
  120654. get directionalConeOuterAngle(): number;
  120655. /**
  120656. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  120657. * Listener angles between innerAngle and outerAngle will falloff linearly.
  120658. */
  120659. set directionalConeOuterAngle(value: number);
  120660. /**
  120661. * Playback volume.
  120662. */
  120663. get volume(): number;
  120664. /**
  120665. * Playback volume.
  120666. */
  120667. set volume(value: number);
  120668. private _onended;
  120669. /**
  120670. * Suspend playback
  120671. */
  120672. pause(): void;
  120673. /**
  120674. * Stop playback
  120675. */
  120676. stop(): void;
  120677. /**
  120678. * Start playback.
  120679. * @param startOffset Position the clip head at a specific time in seconds.
  120680. */
  120681. play(startOffset?: number): void;
  120682. }
  120683. }
  120684. declare module BABYLON {
  120685. /**
  120686. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  120687. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120688. */
  120689. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  120690. /**
  120691. * Gets the name of the behavior.
  120692. */
  120693. get name(): string;
  120694. /**
  120695. * The easing function used by animations
  120696. */
  120697. static EasingFunction: BackEase;
  120698. /**
  120699. * The easing mode used by animations
  120700. */
  120701. static EasingMode: number;
  120702. /**
  120703. * The duration of the animation, in milliseconds
  120704. */
  120705. transitionDuration: number;
  120706. /**
  120707. * Length of the distance animated by the transition when lower radius is reached
  120708. */
  120709. lowerRadiusTransitionRange: number;
  120710. /**
  120711. * Length of the distance animated by the transition when upper radius is reached
  120712. */
  120713. upperRadiusTransitionRange: number;
  120714. private _autoTransitionRange;
  120715. /**
  120716. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  120717. */
  120718. get autoTransitionRange(): boolean;
  120719. /**
  120720. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  120721. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  120722. */
  120723. set autoTransitionRange(value: boolean);
  120724. private _attachedCamera;
  120725. private _onAfterCheckInputsObserver;
  120726. private _onMeshTargetChangedObserver;
  120727. /**
  120728. * Initializes the behavior.
  120729. */
  120730. init(): void;
  120731. /**
  120732. * Attaches the behavior to its arc rotate camera.
  120733. * @param camera Defines the camera to attach the behavior to
  120734. */
  120735. attach(camera: ArcRotateCamera): void;
  120736. /**
  120737. * Detaches the behavior from its current arc rotate camera.
  120738. */
  120739. detach(): void;
  120740. private _radiusIsAnimating;
  120741. private _radiusBounceTransition;
  120742. private _animatables;
  120743. private _cachedWheelPrecision;
  120744. /**
  120745. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  120746. * @param radiusLimit The limit to check against.
  120747. * @return Bool to indicate if at limit.
  120748. */
  120749. private _isRadiusAtLimit;
  120750. /**
  120751. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  120752. * @param radiusDelta The delta by which to animate to. Can be negative.
  120753. */
  120754. private _applyBoundRadiusAnimation;
  120755. /**
  120756. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  120757. */
  120758. protected _clearAnimationLocks(): void;
  120759. /**
  120760. * Stops and removes all animations that have been applied to the camera
  120761. */
  120762. stopAllAnimations(): void;
  120763. }
  120764. }
  120765. declare module BABYLON {
  120766. /**
  120767. * 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.
  120768. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  120769. */
  120770. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  120771. /**
  120772. * Gets the name of the behavior.
  120773. */
  120774. get name(): string;
  120775. private _mode;
  120776. private _radiusScale;
  120777. private _positionScale;
  120778. private _defaultElevation;
  120779. private _elevationReturnTime;
  120780. private _elevationReturnWaitTime;
  120781. private _zoomStopsAnimation;
  120782. private _framingTime;
  120783. /**
  120784. * The easing function used by animations
  120785. */
  120786. static EasingFunction: ExponentialEase;
  120787. /**
  120788. * The easing mode used by animations
  120789. */
  120790. static EasingMode: number;
  120791. /**
  120792. * Sets the current mode used by the behavior
  120793. */
  120794. set mode(mode: number);
  120795. /**
  120796. * Gets current mode used by the behavior.
  120797. */
  120798. get mode(): number;
  120799. /**
  120800. * Sets the scale applied to the radius (1 by default)
  120801. */
  120802. set radiusScale(radius: number);
  120803. /**
  120804. * Gets the scale applied to the radius
  120805. */
  120806. get radiusScale(): number;
  120807. /**
  120808. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  120809. */
  120810. set positionScale(scale: number);
  120811. /**
  120812. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  120813. */
  120814. get positionScale(): number;
  120815. /**
  120816. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  120817. * behaviour is triggered, in radians.
  120818. */
  120819. set defaultElevation(elevation: number);
  120820. /**
  120821. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  120822. * behaviour is triggered, in radians.
  120823. */
  120824. get defaultElevation(): number;
  120825. /**
  120826. * Sets the time (in milliseconds) taken to return to the default beta position.
  120827. * Negative value indicates camera should not return to default.
  120828. */
  120829. set elevationReturnTime(speed: number);
  120830. /**
  120831. * Gets the time (in milliseconds) taken to return to the default beta position.
  120832. * Negative value indicates camera should not return to default.
  120833. */
  120834. get elevationReturnTime(): number;
  120835. /**
  120836. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  120837. */
  120838. set elevationReturnWaitTime(time: number);
  120839. /**
  120840. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  120841. */
  120842. get elevationReturnWaitTime(): number;
  120843. /**
  120844. * Sets the flag that indicates if user zooming should stop animation.
  120845. */
  120846. set zoomStopsAnimation(flag: boolean);
  120847. /**
  120848. * Gets the flag that indicates if user zooming should stop animation.
  120849. */
  120850. get zoomStopsAnimation(): boolean;
  120851. /**
  120852. * Sets the transition time when framing the mesh, in milliseconds
  120853. */
  120854. set framingTime(time: number);
  120855. /**
  120856. * Gets the transition time when framing the mesh, in milliseconds
  120857. */
  120858. get framingTime(): number;
  120859. /**
  120860. * Define if the behavior should automatically change the configured
  120861. * camera limits and sensibilities.
  120862. */
  120863. autoCorrectCameraLimitsAndSensibility: boolean;
  120864. private _onPrePointerObservableObserver;
  120865. private _onAfterCheckInputsObserver;
  120866. private _onMeshTargetChangedObserver;
  120867. private _attachedCamera;
  120868. private _isPointerDown;
  120869. private _lastInteractionTime;
  120870. /**
  120871. * Initializes the behavior.
  120872. */
  120873. init(): void;
  120874. /**
  120875. * Attaches the behavior to its arc rotate camera.
  120876. * @param camera Defines the camera to attach the behavior to
  120877. */
  120878. attach(camera: ArcRotateCamera): void;
  120879. /**
  120880. * Detaches the behavior from its current arc rotate camera.
  120881. */
  120882. detach(): void;
  120883. private _animatables;
  120884. private _betaIsAnimating;
  120885. private _betaTransition;
  120886. private _radiusTransition;
  120887. private _vectorTransition;
  120888. /**
  120889. * Targets the given mesh and updates zoom level accordingly.
  120890. * @param mesh The mesh to target.
  120891. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  120892. * @param onAnimationEnd Callback triggered at the end of the framing animation
  120893. */
  120894. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  120895. /**
  120896. * Targets the given mesh with its children and updates zoom level accordingly.
  120897. * @param mesh The mesh to target.
  120898. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  120899. * @param onAnimationEnd Callback triggered at the end of the framing animation
  120900. */
  120901. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  120902. /**
  120903. * Targets the given meshes with their children and updates zoom level accordingly.
  120904. * @param meshes The mesh to target.
  120905. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  120906. * @param onAnimationEnd Callback triggered at the end of the framing animation
  120907. */
  120908. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  120909. /**
  120910. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  120911. * @param minimumWorld Determines the smaller position of the bounding box extend
  120912. * @param maximumWorld Determines the bigger position of the bounding box extend
  120913. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  120914. * @param onAnimationEnd Callback triggered at the end of the framing animation
  120915. */
  120916. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  120917. /**
  120918. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  120919. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  120920. * frustum width.
  120921. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  120922. * to fully enclose the mesh in the viewing frustum.
  120923. */
  120924. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  120925. /**
  120926. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  120927. * is automatically returned to its default position (expected to be above ground plane).
  120928. */
  120929. private _maintainCameraAboveGround;
  120930. /**
  120931. * Returns the frustum slope based on the canvas ratio and camera FOV
  120932. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  120933. */
  120934. private _getFrustumSlope;
  120935. /**
  120936. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  120937. */
  120938. private _clearAnimationLocks;
  120939. /**
  120940. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  120941. */
  120942. private _applyUserInteraction;
  120943. /**
  120944. * Stops and removes all animations that have been applied to the camera
  120945. */
  120946. stopAllAnimations(): void;
  120947. /**
  120948. * Gets a value indicating if the user is moving the camera
  120949. */
  120950. get isUserIsMoving(): boolean;
  120951. /**
  120952. * The camera can move all the way towards the mesh.
  120953. */
  120954. static IgnoreBoundsSizeMode: number;
  120955. /**
  120956. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  120957. */
  120958. static FitFrustumSidesMode: number;
  120959. }
  120960. }
  120961. declare module BABYLON {
  120962. /**
  120963. * Base class for Camera Pointer Inputs.
  120964. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  120965. * for example usage.
  120966. */
  120967. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  120968. /**
  120969. * Defines the camera the input is attached to.
  120970. */
  120971. abstract camera: Camera;
  120972. /**
  120973. * Whether keyboard modifier keys are pressed at time of last mouse event.
  120974. */
  120975. protected _altKey: boolean;
  120976. protected _ctrlKey: boolean;
  120977. protected _metaKey: boolean;
  120978. protected _shiftKey: boolean;
  120979. /**
  120980. * Which mouse buttons were pressed at time of last mouse event.
  120981. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  120982. */
  120983. protected _buttonsPressed: number;
  120984. /**
  120985. * Defines the buttons associated with the input to handle camera move.
  120986. */
  120987. buttons: number[];
  120988. /**
  120989. * Attach the input controls to a specific dom element to get the input from.
  120990. * @param element Defines the element the controls should be listened from
  120991. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120992. */
  120993. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120994. /**
  120995. * Detach the current controls from the specified dom element.
  120996. * @param element Defines the element to stop listening the inputs from
  120997. */
  120998. detachControl(element: Nullable<HTMLElement>): void;
  120999. /**
  121000. * Gets the class name of the current input.
  121001. * @returns the class name
  121002. */
  121003. getClassName(): string;
  121004. /**
  121005. * Get the friendly name associated with the input class.
  121006. * @returns the input friendly name
  121007. */
  121008. getSimpleName(): string;
  121009. /**
  121010. * Called on pointer POINTERDOUBLETAP event.
  121011. * Override this method to provide functionality on POINTERDOUBLETAP event.
  121012. */
  121013. protected onDoubleTap(type: string): void;
  121014. /**
  121015. * Called on pointer POINTERMOVE event if only a single touch is active.
  121016. * Override this method to provide functionality.
  121017. */
  121018. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121019. /**
  121020. * Called on pointer POINTERMOVE event if multiple touches are active.
  121021. * Override this method to provide functionality.
  121022. */
  121023. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121024. /**
  121025. * Called on JS contextmenu event.
  121026. * Override this method to provide functionality.
  121027. */
  121028. protected onContextMenu(evt: PointerEvent): void;
  121029. /**
  121030. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  121031. * press.
  121032. * Override this method to provide functionality.
  121033. */
  121034. protected onButtonDown(evt: PointerEvent): void;
  121035. /**
  121036. * Called each time a new POINTERUP event occurs. Ie, for each button
  121037. * release.
  121038. * Override this method to provide functionality.
  121039. */
  121040. protected onButtonUp(evt: PointerEvent): void;
  121041. /**
  121042. * Called when window becomes inactive.
  121043. * Override this method to provide functionality.
  121044. */
  121045. protected onLostFocus(): void;
  121046. private _pointerInput;
  121047. private _observer;
  121048. private _onLostFocus;
  121049. private pointA;
  121050. private pointB;
  121051. }
  121052. }
  121053. declare module BABYLON {
  121054. /**
  121055. * Manage the pointers inputs to control an arc rotate camera.
  121056. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121057. */
  121058. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  121059. /**
  121060. * Defines the camera the input is attached to.
  121061. */
  121062. camera: ArcRotateCamera;
  121063. /**
  121064. * Gets the class name of the current input.
  121065. * @returns the class name
  121066. */
  121067. getClassName(): string;
  121068. /**
  121069. * Defines the buttons associated with the input to handle camera move.
  121070. */
  121071. buttons: number[];
  121072. /**
  121073. * Defines the pointer angular sensibility along the X axis or how fast is
  121074. * the camera rotating.
  121075. */
  121076. angularSensibilityX: number;
  121077. /**
  121078. * Defines the pointer angular sensibility along the Y axis or how fast is
  121079. * the camera rotating.
  121080. */
  121081. angularSensibilityY: number;
  121082. /**
  121083. * Defines the pointer pinch precision or how fast is the camera zooming.
  121084. */
  121085. pinchPrecision: number;
  121086. /**
  121087. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121088. * from 0.
  121089. * It defines the percentage of current camera.radius to use as delta when
  121090. * pinch zoom is used.
  121091. */
  121092. pinchDeltaPercentage: number;
  121093. /**
  121094. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  121095. * that any object in the plane at the camera's target point will scale
  121096. * perfectly with finger motion.
  121097. * Overrides pinchDeltaPercentage and pinchPrecision.
  121098. */
  121099. useNaturalPinchZoom: boolean;
  121100. /**
  121101. * Defines the pointer panning sensibility or how fast is the camera moving.
  121102. */
  121103. panningSensibility: number;
  121104. /**
  121105. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  121106. */
  121107. multiTouchPanning: boolean;
  121108. /**
  121109. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  121110. * zoom (pinch) through multitouch.
  121111. */
  121112. multiTouchPanAndZoom: boolean;
  121113. /**
  121114. * Revers pinch action direction.
  121115. */
  121116. pinchInwards: boolean;
  121117. private _isPanClick;
  121118. private _twoFingerActivityCount;
  121119. private _isPinching;
  121120. /**
  121121. * Called on pointer POINTERMOVE event if only a single touch is active.
  121122. */
  121123. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121124. /**
  121125. * Called on pointer POINTERDOUBLETAP event.
  121126. */
  121127. protected onDoubleTap(type: string): void;
  121128. /**
  121129. * Called on pointer POINTERMOVE event if multiple touches are active.
  121130. */
  121131. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121132. /**
  121133. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  121134. * press.
  121135. */
  121136. protected onButtonDown(evt: PointerEvent): void;
  121137. /**
  121138. * Called each time a new POINTERUP event occurs. Ie, for each button
  121139. * release.
  121140. */
  121141. protected onButtonUp(evt: PointerEvent): void;
  121142. /**
  121143. * Called when window becomes inactive.
  121144. */
  121145. protected onLostFocus(): void;
  121146. }
  121147. }
  121148. declare module BABYLON {
  121149. /**
  121150. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  121151. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121152. */
  121153. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  121154. /**
  121155. * Defines the camera the input is attached to.
  121156. */
  121157. camera: ArcRotateCamera;
  121158. /**
  121159. * Defines the list of key codes associated with the up action (increase alpha)
  121160. */
  121161. keysUp: number[];
  121162. /**
  121163. * Defines the list of key codes associated with the down action (decrease alpha)
  121164. */
  121165. keysDown: number[];
  121166. /**
  121167. * Defines the list of key codes associated with the left action (increase beta)
  121168. */
  121169. keysLeft: number[];
  121170. /**
  121171. * Defines the list of key codes associated with the right action (decrease beta)
  121172. */
  121173. keysRight: number[];
  121174. /**
  121175. * Defines the list of key codes associated with the reset action.
  121176. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  121177. */
  121178. keysReset: number[];
  121179. /**
  121180. * Defines the panning sensibility of the inputs.
  121181. * (How fast is the camera panning)
  121182. */
  121183. panningSensibility: number;
  121184. /**
  121185. * Defines the zooming sensibility of the inputs.
  121186. * (How fast is the camera zooming)
  121187. */
  121188. zoomingSensibility: number;
  121189. /**
  121190. * Defines whether maintaining the alt key down switch the movement mode from
  121191. * orientation to zoom.
  121192. */
  121193. useAltToZoom: boolean;
  121194. /**
  121195. * Rotation speed of the camera
  121196. */
  121197. angularSpeed: number;
  121198. private _keys;
  121199. private _ctrlPressed;
  121200. private _altPressed;
  121201. private _onCanvasBlurObserver;
  121202. private _onKeyboardObserver;
  121203. private _engine;
  121204. private _scene;
  121205. /**
  121206. * Attach the input controls to a specific dom element to get the input from.
  121207. * @param element Defines the element the controls should be listened from
  121208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121209. */
  121210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121211. /**
  121212. * Detach the current controls from the specified dom element.
  121213. * @param element Defines the element to stop listening the inputs from
  121214. */
  121215. detachControl(element: Nullable<HTMLElement>): void;
  121216. /**
  121217. * Update the current camera state depending on the inputs that have been used this frame.
  121218. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121219. */
  121220. checkInputs(): void;
  121221. /**
  121222. * Gets the class name of the current intput.
  121223. * @returns the class name
  121224. */
  121225. getClassName(): string;
  121226. /**
  121227. * Get the friendly name associated with the input class.
  121228. * @returns the input friendly name
  121229. */
  121230. getSimpleName(): string;
  121231. }
  121232. }
  121233. declare module BABYLON {
  121234. /**
  121235. * Manage the mouse wheel inputs to control an arc rotate camera.
  121236. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121237. */
  121238. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  121239. /**
  121240. * Defines the camera the input is attached to.
  121241. */
  121242. camera: ArcRotateCamera;
  121243. /**
  121244. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  121245. */
  121246. wheelPrecision: number;
  121247. /**
  121248. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121249. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121250. */
  121251. wheelDeltaPercentage: number;
  121252. private _wheel;
  121253. private _observer;
  121254. private computeDeltaFromMouseWheelLegacyEvent;
  121255. /**
  121256. * Attach the input controls to a specific dom element to get the input from.
  121257. * @param element Defines the element the controls should be listened from
  121258. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121259. */
  121260. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121261. /**
  121262. * Detach the current controls from the specified dom element.
  121263. * @param element Defines the element to stop listening the inputs from
  121264. */
  121265. detachControl(element: Nullable<HTMLElement>): void;
  121266. /**
  121267. * Gets the class name of the current intput.
  121268. * @returns the class name
  121269. */
  121270. getClassName(): string;
  121271. /**
  121272. * Get the friendly name associated with the input class.
  121273. * @returns the input friendly name
  121274. */
  121275. getSimpleName(): string;
  121276. }
  121277. }
  121278. declare module BABYLON {
  121279. /**
  121280. * Default Inputs manager for the ArcRotateCamera.
  121281. * It groups all the default supported inputs for ease of use.
  121282. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121283. */
  121284. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  121285. /**
  121286. * Instantiates a new ArcRotateCameraInputsManager.
  121287. * @param camera Defines the camera the inputs belong to
  121288. */
  121289. constructor(camera: ArcRotateCamera);
  121290. /**
  121291. * Add mouse wheel input support to the input manager.
  121292. * @returns the current input manager
  121293. */
  121294. addMouseWheel(): ArcRotateCameraInputsManager;
  121295. /**
  121296. * Add pointers input support to the input manager.
  121297. * @returns the current input manager
  121298. */
  121299. addPointers(): ArcRotateCameraInputsManager;
  121300. /**
  121301. * Add keyboard input support to the input manager.
  121302. * @returns the current input manager
  121303. */
  121304. addKeyboard(): ArcRotateCameraInputsManager;
  121305. }
  121306. }
  121307. declare module BABYLON {
  121308. /**
  121309. * This represents an orbital type of camera.
  121310. *
  121311. * 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.
  121312. * 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.
  121313. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  121314. */
  121315. export class ArcRotateCamera extends TargetCamera {
  121316. /**
  121317. * Defines the rotation angle of the camera along the longitudinal axis.
  121318. */
  121319. alpha: number;
  121320. /**
  121321. * Defines the rotation angle of the camera along the latitudinal axis.
  121322. */
  121323. beta: number;
  121324. /**
  121325. * Defines the radius of the camera from it s target point.
  121326. */
  121327. radius: number;
  121328. protected _target: Vector3;
  121329. protected _targetHost: Nullable<AbstractMesh>;
  121330. /**
  121331. * Defines the target point of the camera.
  121332. * The camera looks towards it form the radius distance.
  121333. */
  121334. get target(): Vector3;
  121335. set target(value: Vector3);
  121336. /**
  121337. * Define the current local position of the camera in the scene
  121338. */
  121339. get position(): Vector3;
  121340. set position(newPosition: Vector3);
  121341. protected _upVector: Vector3;
  121342. protected _upToYMatrix: Matrix;
  121343. protected _YToUpMatrix: Matrix;
  121344. /**
  121345. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  121346. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  121347. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  121348. */
  121349. set upVector(vec: Vector3);
  121350. get upVector(): Vector3;
  121351. /**
  121352. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  121353. */
  121354. setMatUp(): void;
  121355. /**
  121356. * Current inertia value on the longitudinal axis.
  121357. * The bigger this number the longer it will take for the camera to stop.
  121358. */
  121359. inertialAlphaOffset: number;
  121360. /**
  121361. * Current inertia value on the latitudinal axis.
  121362. * The bigger this number the longer it will take for the camera to stop.
  121363. */
  121364. inertialBetaOffset: number;
  121365. /**
  121366. * Current inertia value on the radius axis.
  121367. * The bigger this number the longer it will take for the camera to stop.
  121368. */
  121369. inertialRadiusOffset: number;
  121370. /**
  121371. * Minimum allowed angle on the longitudinal axis.
  121372. * This can help limiting how the Camera is able to move in the scene.
  121373. */
  121374. lowerAlphaLimit: Nullable<number>;
  121375. /**
  121376. * Maximum allowed angle on the longitudinal axis.
  121377. * This can help limiting how the Camera is able to move in the scene.
  121378. */
  121379. upperAlphaLimit: Nullable<number>;
  121380. /**
  121381. * Minimum allowed angle on the latitudinal axis.
  121382. * This can help limiting how the Camera is able to move in the scene.
  121383. */
  121384. lowerBetaLimit: number;
  121385. /**
  121386. * Maximum allowed angle on the latitudinal axis.
  121387. * This can help limiting how the Camera is able to move in the scene.
  121388. */
  121389. upperBetaLimit: number;
  121390. /**
  121391. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  121392. * This can help limiting how the Camera is able to move in the scene.
  121393. */
  121394. lowerRadiusLimit: Nullable<number>;
  121395. /**
  121396. * Maximum allowed distance of the camera to the target (The camera can not get further).
  121397. * This can help limiting how the Camera is able to move in the scene.
  121398. */
  121399. upperRadiusLimit: Nullable<number>;
  121400. /**
  121401. * Defines the current inertia value used during panning of the camera along the X axis.
  121402. */
  121403. inertialPanningX: number;
  121404. /**
  121405. * Defines the current inertia value used during panning of the camera along the Y axis.
  121406. */
  121407. inertialPanningY: number;
  121408. /**
  121409. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  121410. * Basically if your fingers moves away from more than this distance you will be considered
  121411. * in pinch mode.
  121412. */
  121413. pinchToPanMaxDistance: number;
  121414. /**
  121415. * Defines the maximum distance the camera can pan.
  121416. * This could help keeping the cammera always in your scene.
  121417. */
  121418. panningDistanceLimit: Nullable<number>;
  121419. /**
  121420. * Defines the target of the camera before paning.
  121421. */
  121422. panningOriginTarget: Vector3;
  121423. /**
  121424. * Defines the value of the inertia used during panning.
  121425. * 0 would mean stop inertia and one would mean no decelleration at all.
  121426. */
  121427. panningInertia: number;
  121428. /**
  121429. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  121430. */
  121431. get angularSensibilityX(): number;
  121432. set angularSensibilityX(value: number);
  121433. /**
  121434. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  121435. */
  121436. get angularSensibilityY(): number;
  121437. set angularSensibilityY(value: number);
  121438. /**
  121439. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  121440. */
  121441. get pinchPrecision(): number;
  121442. set pinchPrecision(value: number);
  121443. /**
  121444. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  121445. * It will be used instead of pinchDeltaPrecision if different from 0.
  121446. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  121447. */
  121448. get pinchDeltaPercentage(): number;
  121449. set pinchDeltaPercentage(value: number);
  121450. /**
  121451. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  121452. * and pinch delta percentage.
  121453. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  121454. * that any object in the plane at the camera's target point will scale
  121455. * perfectly with finger motion.
  121456. */
  121457. get useNaturalPinchZoom(): boolean;
  121458. set useNaturalPinchZoom(value: boolean);
  121459. /**
  121460. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  121461. */
  121462. get panningSensibility(): number;
  121463. set panningSensibility(value: number);
  121464. /**
  121465. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  121466. */
  121467. get keysUp(): number[];
  121468. set keysUp(value: number[]);
  121469. /**
  121470. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  121471. */
  121472. get keysDown(): number[];
  121473. set keysDown(value: number[]);
  121474. /**
  121475. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  121476. */
  121477. get keysLeft(): number[];
  121478. set keysLeft(value: number[]);
  121479. /**
  121480. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  121481. */
  121482. get keysRight(): number[];
  121483. set keysRight(value: number[]);
  121484. /**
  121485. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  121486. */
  121487. get wheelPrecision(): number;
  121488. set wheelPrecision(value: number);
  121489. /**
  121490. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  121491. * It will be used instead of pinchDeltaPrecision if different from 0.
  121492. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  121493. */
  121494. get wheelDeltaPercentage(): number;
  121495. set wheelDeltaPercentage(value: number);
  121496. /**
  121497. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  121498. */
  121499. zoomOnFactor: number;
  121500. /**
  121501. * Defines a screen offset for the camera position.
  121502. */
  121503. targetScreenOffset: Vector2;
  121504. /**
  121505. * Allows the camera to be completely reversed.
  121506. * If false the camera can not arrive upside down.
  121507. */
  121508. allowUpsideDown: boolean;
  121509. /**
  121510. * Define if double tap/click is used to restore the previously saved state of the camera.
  121511. */
  121512. useInputToRestoreState: boolean;
  121513. /** @hidden */
  121514. _viewMatrix: Matrix;
  121515. /** @hidden */
  121516. _useCtrlForPanning: boolean;
  121517. /** @hidden */
  121518. _panningMouseButton: number;
  121519. /**
  121520. * Defines the input associated to the camera.
  121521. */
  121522. inputs: ArcRotateCameraInputsManager;
  121523. /** @hidden */
  121524. _reset: () => void;
  121525. /**
  121526. * Defines the allowed panning axis.
  121527. */
  121528. panningAxis: Vector3;
  121529. protected _localDirection: Vector3;
  121530. protected _transformedDirection: Vector3;
  121531. private _bouncingBehavior;
  121532. /**
  121533. * Gets the bouncing behavior of the camera if it has been enabled.
  121534. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121535. */
  121536. get bouncingBehavior(): Nullable<BouncingBehavior>;
  121537. /**
  121538. * Defines if the bouncing behavior of the camera is enabled on the camera.
  121539. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121540. */
  121541. get useBouncingBehavior(): boolean;
  121542. set useBouncingBehavior(value: boolean);
  121543. private _framingBehavior;
  121544. /**
  121545. * Gets the framing behavior of the camera if it has been enabled.
  121546. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121547. */
  121548. get framingBehavior(): Nullable<FramingBehavior>;
  121549. /**
  121550. * Defines if the framing behavior of the camera is enabled on the camera.
  121551. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121552. */
  121553. get useFramingBehavior(): boolean;
  121554. set useFramingBehavior(value: boolean);
  121555. private _autoRotationBehavior;
  121556. /**
  121557. * Gets the auto rotation behavior of the camera if it has been enabled.
  121558. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121559. */
  121560. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  121561. /**
  121562. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  121563. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121564. */
  121565. get useAutoRotationBehavior(): boolean;
  121566. set useAutoRotationBehavior(value: boolean);
  121567. /**
  121568. * Observable triggered when the mesh target has been changed on the camera.
  121569. */
  121570. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  121571. /**
  121572. * Event raised when the camera is colliding with a mesh.
  121573. */
  121574. onCollide: (collidedMesh: AbstractMesh) => void;
  121575. /**
  121576. * Defines whether the camera should check collision with the objects oh the scene.
  121577. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  121578. */
  121579. checkCollisions: boolean;
  121580. /**
  121581. * Defines the collision radius of the camera.
  121582. * This simulates a sphere around the camera.
  121583. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  121584. */
  121585. collisionRadius: Vector3;
  121586. protected _collider: Collider;
  121587. protected _previousPosition: Vector3;
  121588. protected _collisionVelocity: Vector3;
  121589. protected _newPosition: Vector3;
  121590. protected _previousAlpha: number;
  121591. protected _previousBeta: number;
  121592. protected _previousRadius: number;
  121593. protected _collisionTriggered: boolean;
  121594. protected _targetBoundingCenter: Nullable<Vector3>;
  121595. private _computationVector;
  121596. /**
  121597. * Instantiates a new ArcRotateCamera in a given scene
  121598. * @param name Defines the name of the camera
  121599. * @param alpha Defines the camera rotation along the logitudinal axis
  121600. * @param beta Defines the camera rotation along the latitudinal axis
  121601. * @param radius Defines the camera distance from its target
  121602. * @param target Defines the camera target
  121603. * @param scene Defines the scene the camera belongs to
  121604. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  121605. */
  121606. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  121607. /** @hidden */
  121608. _initCache(): void;
  121609. /** @hidden */
  121610. _updateCache(ignoreParentClass?: boolean): void;
  121611. protected _getTargetPosition(): Vector3;
  121612. private _storedAlpha;
  121613. private _storedBeta;
  121614. private _storedRadius;
  121615. private _storedTarget;
  121616. private _storedTargetScreenOffset;
  121617. /**
  121618. * Stores the current state of the camera (alpha, beta, radius and target)
  121619. * @returns the camera itself
  121620. */
  121621. storeState(): Camera;
  121622. /**
  121623. * @hidden
  121624. * Restored camera state. You must call storeState() first
  121625. */
  121626. _restoreStateValues(): boolean;
  121627. /** @hidden */
  121628. _isSynchronizedViewMatrix(): boolean;
  121629. /**
  121630. * Attached controls to the current camera.
  121631. * @param element Defines the element the controls should be listened from
  121632. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121633. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  121634. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  121635. */
  121636. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  121637. /**
  121638. * Detach the current controls from the camera.
  121639. * The camera will stop reacting to inputs.
  121640. * @param element Defines the element to stop listening the inputs from
  121641. */
  121642. detachControl(element: HTMLElement): void;
  121643. /** @hidden */
  121644. _checkInputs(): void;
  121645. protected _checkLimits(): void;
  121646. /**
  121647. * Rebuilds angles (alpha, beta) and radius from the give position and target
  121648. */
  121649. rebuildAnglesAndRadius(): void;
  121650. /**
  121651. * Use a position to define the current camera related information like alpha, beta and radius
  121652. * @param position Defines the position to set the camera at
  121653. */
  121654. setPosition(position: Vector3): void;
  121655. /**
  121656. * Defines the target the camera should look at.
  121657. * This will automatically adapt alpha beta and radius to fit within the new target.
  121658. * @param target Defines the new target as a Vector or a mesh
  121659. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  121660. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  121661. */
  121662. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  121663. /** @hidden */
  121664. _getViewMatrix(): Matrix;
  121665. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  121666. /**
  121667. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  121668. * @param meshes Defines the mesh to zoom on
  121669. * @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)
  121670. */
  121671. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  121672. /**
  121673. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  121674. * The target will be changed but the radius
  121675. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  121676. * @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)
  121677. */
  121678. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  121679. min: Vector3;
  121680. max: Vector3;
  121681. distance: number;
  121682. }, doNotUpdateMaxZ?: boolean): void;
  121683. /**
  121684. * @override
  121685. * Override Camera.createRigCamera
  121686. */
  121687. createRigCamera(name: string, cameraIndex: number): Camera;
  121688. /**
  121689. * @hidden
  121690. * @override
  121691. * Override Camera._updateRigCameras
  121692. */
  121693. _updateRigCameras(): void;
  121694. /**
  121695. * Destroy the camera and release the current resources hold by it.
  121696. */
  121697. dispose(): void;
  121698. /**
  121699. * Gets the current object class name.
  121700. * @return the class name
  121701. */
  121702. getClassName(): string;
  121703. }
  121704. }
  121705. declare module BABYLON {
  121706. /**
  121707. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  121708. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121709. */
  121710. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  121711. /**
  121712. * Gets the name of the behavior.
  121713. */
  121714. get name(): string;
  121715. private _zoomStopsAnimation;
  121716. private _idleRotationSpeed;
  121717. private _idleRotationWaitTime;
  121718. private _idleRotationSpinupTime;
  121719. /**
  121720. * Sets the flag that indicates if user zooming should stop animation.
  121721. */
  121722. set zoomStopsAnimation(flag: boolean);
  121723. /**
  121724. * Gets the flag that indicates if user zooming should stop animation.
  121725. */
  121726. get zoomStopsAnimation(): boolean;
  121727. /**
  121728. * Sets the default speed at which the camera rotates around the model.
  121729. */
  121730. set idleRotationSpeed(speed: number);
  121731. /**
  121732. * Gets the default speed at which the camera rotates around the model.
  121733. */
  121734. get idleRotationSpeed(): number;
  121735. /**
  121736. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  121737. */
  121738. set idleRotationWaitTime(time: number);
  121739. /**
  121740. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  121741. */
  121742. get idleRotationWaitTime(): number;
  121743. /**
  121744. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  121745. */
  121746. set idleRotationSpinupTime(time: number);
  121747. /**
  121748. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  121749. */
  121750. get idleRotationSpinupTime(): number;
  121751. /**
  121752. * Gets a value indicating if the camera is currently rotating because of this behavior
  121753. */
  121754. get rotationInProgress(): boolean;
  121755. private _onPrePointerObservableObserver;
  121756. private _onAfterCheckInputsObserver;
  121757. private _attachedCamera;
  121758. private _isPointerDown;
  121759. private _lastFrameTime;
  121760. private _lastInteractionTime;
  121761. private _cameraRotationSpeed;
  121762. /**
  121763. * Initializes the behavior.
  121764. */
  121765. init(): void;
  121766. /**
  121767. * Attaches the behavior to its arc rotate camera.
  121768. * @param camera Defines the camera to attach the behavior to
  121769. */
  121770. attach(camera: ArcRotateCamera): void;
  121771. /**
  121772. * Detaches the behavior from its current arc rotate camera.
  121773. */
  121774. detach(): void;
  121775. /**
  121776. * Returns true if user is scrolling.
  121777. * @return true if user is scrolling.
  121778. */
  121779. private _userIsZooming;
  121780. private _lastFrameRadius;
  121781. private _shouldAnimationStopForInteraction;
  121782. /**
  121783. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  121784. */
  121785. private _applyUserInteraction;
  121786. private _userIsMoving;
  121787. }
  121788. }
  121789. declare module BABYLON {
  121790. /**
  121791. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  121792. */
  121793. export class AttachToBoxBehavior implements Behavior<Mesh> {
  121794. private ui;
  121795. /**
  121796. * The name of the behavior
  121797. */
  121798. name: string;
  121799. /**
  121800. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  121801. */
  121802. distanceAwayFromFace: number;
  121803. /**
  121804. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  121805. */
  121806. distanceAwayFromBottomOfFace: number;
  121807. private _faceVectors;
  121808. private _target;
  121809. private _scene;
  121810. private _onRenderObserver;
  121811. private _tmpMatrix;
  121812. private _tmpVector;
  121813. /**
  121814. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  121815. * @param ui The transform node that should be attched to the mesh
  121816. */
  121817. constructor(ui: TransformNode);
  121818. /**
  121819. * Initializes the behavior
  121820. */
  121821. init(): void;
  121822. private _closestFace;
  121823. private _zeroVector;
  121824. private _lookAtTmpMatrix;
  121825. private _lookAtToRef;
  121826. /**
  121827. * Attaches the AttachToBoxBehavior to the passed in mesh
  121828. * @param target The mesh that the specified node will be attached to
  121829. */
  121830. attach(target: Mesh): void;
  121831. /**
  121832. * Detaches the behavior from the mesh
  121833. */
  121834. detach(): void;
  121835. }
  121836. }
  121837. declare module BABYLON {
  121838. /**
  121839. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  121840. */
  121841. export class FadeInOutBehavior implements Behavior<Mesh> {
  121842. /**
  121843. * Time in milliseconds to delay before fading in (Default: 0)
  121844. */
  121845. delay: number;
  121846. /**
  121847. * Time in milliseconds for the mesh to fade in (Default: 300)
  121848. */
  121849. fadeInTime: number;
  121850. private _millisecondsPerFrame;
  121851. private _hovered;
  121852. private _hoverValue;
  121853. private _ownerNode;
  121854. /**
  121855. * Instatiates the FadeInOutBehavior
  121856. */
  121857. constructor();
  121858. /**
  121859. * The name of the behavior
  121860. */
  121861. get name(): string;
  121862. /**
  121863. * Initializes the behavior
  121864. */
  121865. init(): void;
  121866. /**
  121867. * Attaches the fade behavior on the passed in mesh
  121868. * @param ownerNode The mesh that will be faded in/out once attached
  121869. */
  121870. attach(ownerNode: Mesh): void;
  121871. /**
  121872. * Detaches the behavior from the mesh
  121873. */
  121874. detach(): void;
  121875. /**
  121876. * Triggers the mesh to begin fading in or out
  121877. * @param value if the object should fade in or out (true to fade in)
  121878. */
  121879. fadeIn(value: boolean): void;
  121880. private _update;
  121881. private _setAllVisibility;
  121882. }
  121883. }
  121884. declare module BABYLON {
  121885. /**
  121886. * Class containing a set of static utilities functions for managing Pivots
  121887. * @hidden
  121888. */
  121889. export class PivotTools {
  121890. private static _PivotCached;
  121891. private static _OldPivotPoint;
  121892. private static _PivotTranslation;
  121893. private static _PivotTmpVector;
  121894. /** @hidden */
  121895. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  121896. /** @hidden */
  121897. static _RestorePivotPoint(mesh: AbstractMesh): void;
  121898. }
  121899. }
  121900. declare module BABYLON {
  121901. /**
  121902. * Class containing static functions to help procedurally build meshes
  121903. */
  121904. export class PlaneBuilder {
  121905. /**
  121906. * Creates a plane mesh
  121907. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  121908. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  121909. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  121910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121911. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121913. * @param name defines the name of the mesh
  121914. * @param options defines the options used to create the mesh
  121915. * @param scene defines the hosting scene
  121916. * @returns the plane mesh
  121917. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121918. */
  121919. static CreatePlane(name: string, options: {
  121920. size?: number;
  121921. width?: number;
  121922. height?: number;
  121923. sideOrientation?: number;
  121924. frontUVs?: Vector4;
  121925. backUVs?: Vector4;
  121926. updatable?: boolean;
  121927. sourcePlane?: Plane;
  121928. }, scene?: Nullable<Scene>): Mesh;
  121929. }
  121930. }
  121931. declare module BABYLON {
  121932. /**
  121933. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  121934. */
  121935. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  121936. private static _AnyMouseID;
  121937. /**
  121938. * Abstract mesh the behavior is set on
  121939. */
  121940. attachedNode: AbstractMesh;
  121941. private _dragPlane;
  121942. private _scene;
  121943. private _pointerObserver;
  121944. private _beforeRenderObserver;
  121945. private static _planeScene;
  121946. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  121947. /**
  121948. * 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)
  121949. */
  121950. maxDragAngle: number;
  121951. /**
  121952. * @hidden
  121953. */
  121954. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  121955. /**
  121956. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  121957. */
  121958. currentDraggingPointerID: number;
  121959. /**
  121960. * The last position where the pointer hit the drag plane in world space
  121961. */
  121962. lastDragPosition: Vector3;
  121963. /**
  121964. * If the behavior is currently in a dragging state
  121965. */
  121966. dragging: boolean;
  121967. /**
  121968. * 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)
  121969. */
  121970. dragDeltaRatio: number;
  121971. /**
  121972. * If the drag plane orientation should be updated during the dragging (Default: true)
  121973. */
  121974. updateDragPlane: boolean;
  121975. private _debugMode;
  121976. private _moving;
  121977. /**
  121978. * Fires each time the attached mesh is dragged with the pointer
  121979. * * delta between last drag position and current drag position in world space
  121980. * * dragDistance along the drag axis
  121981. * * dragPlaneNormal normal of the current drag plane used during the drag
  121982. * * dragPlanePoint in world space where the drag intersects the drag plane
  121983. */
  121984. onDragObservable: Observable<{
  121985. delta: Vector3;
  121986. dragPlanePoint: Vector3;
  121987. dragPlaneNormal: Vector3;
  121988. dragDistance: number;
  121989. pointerId: number;
  121990. }>;
  121991. /**
  121992. * Fires each time a drag begins (eg. mouse down on mesh)
  121993. */
  121994. onDragStartObservable: Observable<{
  121995. dragPlanePoint: Vector3;
  121996. pointerId: number;
  121997. }>;
  121998. /**
  121999. * Fires each time a drag ends (eg. mouse release after drag)
  122000. */
  122001. onDragEndObservable: Observable<{
  122002. dragPlanePoint: Vector3;
  122003. pointerId: number;
  122004. }>;
  122005. /**
  122006. * If the attached mesh should be moved when dragged
  122007. */
  122008. moveAttached: boolean;
  122009. /**
  122010. * If the drag behavior will react to drag events (Default: true)
  122011. */
  122012. enabled: boolean;
  122013. /**
  122014. * If pointer events should start and release the drag (Default: true)
  122015. */
  122016. startAndReleaseDragOnPointerEvents: boolean;
  122017. /**
  122018. * If camera controls should be detached during the drag
  122019. */
  122020. detachCameraControls: boolean;
  122021. /**
  122022. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  122023. */
  122024. useObjectOrientationForDragging: boolean;
  122025. private _options;
  122026. /**
  122027. * Gets the options used by the behavior
  122028. */
  122029. get options(): {
  122030. dragAxis?: Vector3;
  122031. dragPlaneNormal?: Vector3;
  122032. };
  122033. /**
  122034. * Sets the options used by the behavior
  122035. */
  122036. set options(options: {
  122037. dragAxis?: Vector3;
  122038. dragPlaneNormal?: Vector3;
  122039. });
  122040. /**
  122041. * Creates a pointer drag behavior that can be attached to a mesh
  122042. * @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)
  122043. */
  122044. constructor(options?: {
  122045. dragAxis?: Vector3;
  122046. dragPlaneNormal?: Vector3;
  122047. });
  122048. /**
  122049. * Predicate to determine if it is valid to move the object to a new position when it is moved
  122050. */
  122051. validateDrag: (targetPosition: Vector3) => boolean;
  122052. /**
  122053. * The name of the behavior
  122054. */
  122055. get name(): string;
  122056. /**
  122057. * Initializes the behavior
  122058. */
  122059. init(): void;
  122060. private _tmpVector;
  122061. private _alternatePickedPoint;
  122062. private _worldDragAxis;
  122063. private _targetPosition;
  122064. private _attachedElement;
  122065. /**
  122066. * Attaches the drag behavior the passed in mesh
  122067. * @param ownerNode The mesh that will be dragged around once attached
  122068. * @param predicate Predicate to use for pick filtering
  122069. */
  122070. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  122071. /**
  122072. * Force relase the drag action by code.
  122073. */
  122074. releaseDrag(): void;
  122075. private _startDragRay;
  122076. private _lastPointerRay;
  122077. /**
  122078. * Simulates the start of a pointer drag event on the behavior
  122079. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  122080. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  122081. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  122082. */
  122083. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  122084. private _startDrag;
  122085. private _dragDelta;
  122086. private _moveDrag;
  122087. private _pickWithRayOnDragPlane;
  122088. private _pointA;
  122089. private _pointC;
  122090. private _localAxis;
  122091. private _lookAt;
  122092. private _updateDragPlanePosition;
  122093. /**
  122094. * Detaches the behavior from the mesh
  122095. */
  122096. detach(): void;
  122097. }
  122098. }
  122099. declare module BABYLON {
  122100. /**
  122101. * A behavior that when attached to a mesh will allow the mesh to be scaled
  122102. */
  122103. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  122104. private _dragBehaviorA;
  122105. private _dragBehaviorB;
  122106. private _startDistance;
  122107. private _initialScale;
  122108. private _targetScale;
  122109. private _ownerNode;
  122110. private _sceneRenderObserver;
  122111. /**
  122112. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  122113. */
  122114. constructor();
  122115. /**
  122116. * The name of the behavior
  122117. */
  122118. get name(): string;
  122119. /**
  122120. * Initializes the behavior
  122121. */
  122122. init(): void;
  122123. private _getCurrentDistance;
  122124. /**
  122125. * Attaches the scale behavior the passed in mesh
  122126. * @param ownerNode The mesh that will be scaled around once attached
  122127. */
  122128. attach(ownerNode: Mesh): void;
  122129. /**
  122130. * Detaches the behavior from the mesh
  122131. */
  122132. detach(): void;
  122133. }
  122134. }
  122135. declare module BABYLON {
  122136. /**
  122137. * 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
  122138. */
  122139. export class SixDofDragBehavior implements Behavior<Mesh> {
  122140. private static _virtualScene;
  122141. private _ownerNode;
  122142. private _sceneRenderObserver;
  122143. private _scene;
  122144. private _targetPosition;
  122145. private _virtualOriginMesh;
  122146. private _virtualDragMesh;
  122147. private _pointerObserver;
  122148. private _moving;
  122149. private _startingOrientation;
  122150. private _attachedElement;
  122151. /**
  122152. * 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)
  122153. */
  122154. private zDragFactor;
  122155. /**
  122156. * If the object should rotate to face the drag origin
  122157. */
  122158. rotateDraggedObject: boolean;
  122159. /**
  122160. * If the behavior is currently in a dragging state
  122161. */
  122162. dragging: boolean;
  122163. /**
  122164. * 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)
  122165. */
  122166. dragDeltaRatio: number;
  122167. /**
  122168. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  122169. */
  122170. currentDraggingPointerID: number;
  122171. /**
  122172. * If camera controls should be detached during the drag
  122173. */
  122174. detachCameraControls: boolean;
  122175. /**
  122176. * Fires each time a drag starts
  122177. */
  122178. onDragStartObservable: Observable<{}>;
  122179. /**
  122180. * Fires each time a drag ends (eg. mouse release after drag)
  122181. */
  122182. onDragEndObservable: Observable<{}>;
  122183. /**
  122184. * 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
  122185. */
  122186. constructor();
  122187. /**
  122188. * The name of the behavior
  122189. */
  122190. get name(): string;
  122191. /**
  122192. * Initializes the behavior
  122193. */
  122194. init(): void;
  122195. /**
  122196. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  122197. */
  122198. private get _pointerCamera();
  122199. /**
  122200. * Attaches the scale behavior the passed in mesh
  122201. * @param ownerNode The mesh that will be scaled around once attached
  122202. */
  122203. attach(ownerNode: Mesh): void;
  122204. /**
  122205. * Detaches the behavior from the mesh
  122206. */
  122207. detach(): void;
  122208. }
  122209. }
  122210. declare module BABYLON {
  122211. /**
  122212. * Class used to apply inverse kinematics to bones
  122213. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  122214. */
  122215. export class BoneIKController {
  122216. private static _tmpVecs;
  122217. private static _tmpQuat;
  122218. private static _tmpMats;
  122219. /**
  122220. * Gets or sets the target mesh
  122221. */
  122222. targetMesh: AbstractMesh;
  122223. /** Gets or sets the mesh used as pole */
  122224. poleTargetMesh: AbstractMesh;
  122225. /**
  122226. * Gets or sets the bone used as pole
  122227. */
  122228. poleTargetBone: Nullable<Bone>;
  122229. /**
  122230. * Gets or sets the target position
  122231. */
  122232. targetPosition: Vector3;
  122233. /**
  122234. * Gets or sets the pole target position
  122235. */
  122236. poleTargetPosition: Vector3;
  122237. /**
  122238. * Gets or sets the pole target local offset
  122239. */
  122240. poleTargetLocalOffset: Vector3;
  122241. /**
  122242. * Gets or sets the pole angle
  122243. */
  122244. poleAngle: number;
  122245. /**
  122246. * Gets or sets the mesh associated with the controller
  122247. */
  122248. mesh: AbstractMesh;
  122249. /**
  122250. * 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)
  122251. */
  122252. slerpAmount: number;
  122253. private _bone1Quat;
  122254. private _bone1Mat;
  122255. private _bone2Ang;
  122256. private _bone1;
  122257. private _bone2;
  122258. private _bone1Length;
  122259. private _bone2Length;
  122260. private _maxAngle;
  122261. private _maxReach;
  122262. private _rightHandedSystem;
  122263. private _bendAxis;
  122264. private _slerping;
  122265. private _adjustRoll;
  122266. /**
  122267. * Gets or sets maximum allowed angle
  122268. */
  122269. get maxAngle(): number;
  122270. set maxAngle(value: number);
  122271. /**
  122272. * Creates a new BoneIKController
  122273. * @param mesh defines the mesh to control
  122274. * @param bone defines the bone to control
  122275. * @param options defines options to set up the controller
  122276. */
  122277. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  122278. targetMesh?: AbstractMesh;
  122279. poleTargetMesh?: AbstractMesh;
  122280. poleTargetBone?: Bone;
  122281. poleTargetLocalOffset?: Vector3;
  122282. poleAngle?: number;
  122283. bendAxis?: Vector3;
  122284. maxAngle?: number;
  122285. slerpAmount?: number;
  122286. });
  122287. private _setMaxAngle;
  122288. /**
  122289. * Force the controller to update the bones
  122290. */
  122291. update(): void;
  122292. }
  122293. }
  122294. declare module BABYLON {
  122295. /**
  122296. * Class used to make a bone look toward a point in space
  122297. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  122298. */
  122299. export class BoneLookController {
  122300. private static _tmpVecs;
  122301. private static _tmpQuat;
  122302. private static _tmpMats;
  122303. /**
  122304. * The target Vector3 that the bone will look at
  122305. */
  122306. target: Vector3;
  122307. /**
  122308. * The mesh that the bone is attached to
  122309. */
  122310. mesh: AbstractMesh;
  122311. /**
  122312. * The bone that will be looking to the target
  122313. */
  122314. bone: Bone;
  122315. /**
  122316. * The up axis of the coordinate system that is used when the bone is rotated
  122317. */
  122318. upAxis: Vector3;
  122319. /**
  122320. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  122321. */
  122322. upAxisSpace: Space;
  122323. /**
  122324. * Used to make an adjustment to the yaw of the bone
  122325. */
  122326. adjustYaw: number;
  122327. /**
  122328. * Used to make an adjustment to the pitch of the bone
  122329. */
  122330. adjustPitch: number;
  122331. /**
  122332. * Used to make an adjustment to the roll of the bone
  122333. */
  122334. adjustRoll: number;
  122335. /**
  122336. * 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)
  122337. */
  122338. slerpAmount: number;
  122339. private _minYaw;
  122340. private _maxYaw;
  122341. private _minPitch;
  122342. private _maxPitch;
  122343. private _minYawSin;
  122344. private _minYawCos;
  122345. private _maxYawSin;
  122346. private _maxYawCos;
  122347. private _midYawConstraint;
  122348. private _minPitchTan;
  122349. private _maxPitchTan;
  122350. private _boneQuat;
  122351. private _slerping;
  122352. private _transformYawPitch;
  122353. private _transformYawPitchInv;
  122354. private _firstFrameSkipped;
  122355. private _yawRange;
  122356. private _fowardAxis;
  122357. /**
  122358. * Gets or sets the minimum yaw angle that the bone can look to
  122359. */
  122360. get minYaw(): number;
  122361. set minYaw(value: number);
  122362. /**
  122363. * Gets or sets the maximum yaw angle that the bone can look to
  122364. */
  122365. get maxYaw(): number;
  122366. set maxYaw(value: number);
  122367. /**
  122368. * Gets or sets the minimum pitch angle that the bone can look to
  122369. */
  122370. get minPitch(): number;
  122371. set minPitch(value: number);
  122372. /**
  122373. * Gets or sets the maximum pitch angle that the bone can look to
  122374. */
  122375. get maxPitch(): number;
  122376. set maxPitch(value: number);
  122377. /**
  122378. * Create a BoneLookController
  122379. * @param mesh the mesh that the bone belongs to
  122380. * @param bone the bone that will be looking to the target
  122381. * @param target the target Vector3 to look at
  122382. * @param options optional settings:
  122383. * * maxYaw: the maximum angle the bone will yaw to
  122384. * * minYaw: the minimum angle the bone will yaw to
  122385. * * maxPitch: the maximum angle the bone will pitch to
  122386. * * minPitch: the minimum angle the bone will yaw to
  122387. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  122388. * * upAxis: the up axis of the coordinate system
  122389. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  122390. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  122391. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  122392. * * adjustYaw: used to make an adjustment to the yaw of the bone
  122393. * * adjustPitch: used to make an adjustment to the pitch of the bone
  122394. * * adjustRoll: used to make an adjustment to the roll of the bone
  122395. **/
  122396. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  122397. maxYaw?: number;
  122398. minYaw?: number;
  122399. maxPitch?: number;
  122400. minPitch?: number;
  122401. slerpAmount?: number;
  122402. upAxis?: Vector3;
  122403. upAxisSpace?: Space;
  122404. yawAxis?: Vector3;
  122405. pitchAxis?: Vector3;
  122406. adjustYaw?: number;
  122407. adjustPitch?: number;
  122408. adjustRoll?: number;
  122409. });
  122410. /**
  122411. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  122412. */
  122413. update(): void;
  122414. private _getAngleDiff;
  122415. private _getAngleBetween;
  122416. private _isAngleBetween;
  122417. }
  122418. }
  122419. declare module BABYLON {
  122420. /**
  122421. * Manage the gamepad inputs to control an arc rotate camera.
  122422. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122423. */
  122424. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  122425. /**
  122426. * Defines the camera the input is attached to.
  122427. */
  122428. camera: ArcRotateCamera;
  122429. /**
  122430. * Defines the gamepad the input is gathering event from.
  122431. */
  122432. gamepad: Nullable<Gamepad>;
  122433. /**
  122434. * Defines the gamepad rotation sensiblity.
  122435. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122436. */
  122437. gamepadRotationSensibility: number;
  122438. /**
  122439. * Defines the gamepad move sensiblity.
  122440. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122441. */
  122442. gamepadMoveSensibility: number;
  122443. private _yAxisScale;
  122444. /**
  122445. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  122446. */
  122447. get invertYAxis(): boolean;
  122448. set invertYAxis(value: boolean);
  122449. private _onGamepadConnectedObserver;
  122450. private _onGamepadDisconnectedObserver;
  122451. /**
  122452. * Attach the input controls to a specific dom element to get the input from.
  122453. * @param element Defines the element the controls should be listened from
  122454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122455. */
  122456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122457. /**
  122458. * Detach the current controls from the specified dom element.
  122459. * @param element Defines the element to stop listening the inputs from
  122460. */
  122461. detachControl(element: Nullable<HTMLElement>): void;
  122462. /**
  122463. * Update the current camera state depending on the inputs that have been used this frame.
  122464. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122465. */
  122466. checkInputs(): void;
  122467. /**
  122468. * Gets the class name of the current intput.
  122469. * @returns the class name
  122470. */
  122471. getClassName(): string;
  122472. /**
  122473. * Get the friendly name associated with the input class.
  122474. * @returns the input friendly name
  122475. */
  122476. getSimpleName(): string;
  122477. }
  122478. }
  122479. declare module BABYLON {
  122480. interface ArcRotateCameraInputsManager {
  122481. /**
  122482. * Add orientation input support to the input manager.
  122483. * @returns the current input manager
  122484. */
  122485. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  122486. }
  122487. /**
  122488. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  122489. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122490. */
  122491. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  122492. /**
  122493. * Defines the camera the input is attached to.
  122494. */
  122495. camera: ArcRotateCamera;
  122496. /**
  122497. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  122498. */
  122499. alphaCorrection: number;
  122500. /**
  122501. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  122502. */
  122503. gammaCorrection: number;
  122504. private _alpha;
  122505. private _gamma;
  122506. private _dirty;
  122507. private _deviceOrientationHandler;
  122508. /**
  122509. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  122510. */
  122511. constructor();
  122512. /**
  122513. * Attach the input controls to a specific dom element to get the input from.
  122514. * @param element Defines the element the controls should be listened from
  122515. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122516. */
  122517. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122518. /** @hidden */
  122519. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  122520. /**
  122521. * Update the current camera state depending on the inputs that have been used this frame.
  122522. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122523. */
  122524. checkInputs(): void;
  122525. /**
  122526. * Detach the current controls from the specified dom element.
  122527. * @param element Defines the element to stop listening the inputs from
  122528. */
  122529. detachControl(element: Nullable<HTMLElement>): void;
  122530. /**
  122531. * Gets the class name of the current intput.
  122532. * @returns the class name
  122533. */
  122534. getClassName(): string;
  122535. /**
  122536. * Get the friendly name associated with the input class.
  122537. * @returns the input friendly name
  122538. */
  122539. getSimpleName(): string;
  122540. }
  122541. }
  122542. declare module BABYLON {
  122543. /**
  122544. * Listen to mouse events to control the camera.
  122545. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122546. */
  122547. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  122548. /**
  122549. * Defines the camera the input is attached to.
  122550. */
  122551. camera: FlyCamera;
  122552. /**
  122553. * Defines if touch is enabled. (Default is true.)
  122554. */
  122555. touchEnabled: boolean;
  122556. /**
  122557. * Defines the buttons associated with the input to handle camera rotation.
  122558. */
  122559. buttons: number[];
  122560. /**
  122561. * Assign buttons for Yaw control.
  122562. */
  122563. buttonsYaw: number[];
  122564. /**
  122565. * Assign buttons for Pitch control.
  122566. */
  122567. buttonsPitch: number[];
  122568. /**
  122569. * Assign buttons for Roll control.
  122570. */
  122571. buttonsRoll: number[];
  122572. /**
  122573. * Detect if any button is being pressed while mouse is moved.
  122574. * -1 = Mouse locked.
  122575. * 0 = Left button.
  122576. * 1 = Middle Button.
  122577. * 2 = Right Button.
  122578. */
  122579. activeButton: number;
  122580. /**
  122581. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  122582. * Higher values reduce its sensitivity.
  122583. */
  122584. angularSensibility: number;
  122585. private _mousemoveCallback;
  122586. private _observer;
  122587. private _rollObserver;
  122588. private previousPosition;
  122589. private noPreventDefault;
  122590. private element;
  122591. /**
  122592. * Listen to mouse events to control the camera.
  122593. * @param touchEnabled Define if touch is enabled. (Default is true.)
  122594. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122595. */
  122596. constructor(touchEnabled?: boolean);
  122597. /**
  122598. * Attach the mouse control to the HTML DOM element.
  122599. * @param element Defines the element that listens to the input events.
  122600. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  122601. */
  122602. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122603. /**
  122604. * Detach the current controls from the specified dom element.
  122605. * @param element Defines the element to stop listening the inputs from
  122606. */
  122607. detachControl(element: Nullable<HTMLElement>): void;
  122608. /**
  122609. * Gets the class name of the current input.
  122610. * @returns the class name.
  122611. */
  122612. getClassName(): string;
  122613. /**
  122614. * Get the friendly name associated with the input class.
  122615. * @returns the input's friendly name.
  122616. */
  122617. getSimpleName(): string;
  122618. private _pointerInput;
  122619. private _onMouseMove;
  122620. /**
  122621. * Rotate camera by mouse offset.
  122622. */
  122623. private rotateCamera;
  122624. }
  122625. }
  122626. declare module BABYLON {
  122627. /**
  122628. * Default Inputs manager for the FlyCamera.
  122629. * It groups all the default supported inputs for ease of use.
  122630. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122631. */
  122632. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  122633. /**
  122634. * Instantiates a new FlyCameraInputsManager.
  122635. * @param camera Defines the camera the inputs belong to.
  122636. */
  122637. constructor(camera: FlyCamera);
  122638. /**
  122639. * Add keyboard input support to the input manager.
  122640. * @returns the new FlyCameraKeyboardMoveInput().
  122641. */
  122642. addKeyboard(): FlyCameraInputsManager;
  122643. /**
  122644. * Add mouse input support to the input manager.
  122645. * @param touchEnabled Enable touch screen support.
  122646. * @returns the new FlyCameraMouseInput().
  122647. */
  122648. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  122649. }
  122650. }
  122651. declare module BABYLON {
  122652. /**
  122653. * This is a flying camera, designed for 3D movement and rotation in all directions,
  122654. * such as in a 3D Space Shooter or a Flight Simulator.
  122655. */
  122656. export class FlyCamera extends TargetCamera {
  122657. /**
  122658. * Define the collision ellipsoid of the camera.
  122659. * This is helpful for simulating a camera body, like a player's body.
  122660. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  122661. */
  122662. ellipsoid: Vector3;
  122663. /**
  122664. * Define an offset for the position of the ellipsoid around the camera.
  122665. * This can be helpful if the camera is attached away from the player's body center,
  122666. * such as at its head.
  122667. */
  122668. ellipsoidOffset: Vector3;
  122669. /**
  122670. * Enable or disable collisions of the camera with the rest of the scene objects.
  122671. */
  122672. checkCollisions: boolean;
  122673. /**
  122674. * Enable or disable gravity on the camera.
  122675. */
  122676. applyGravity: boolean;
  122677. /**
  122678. * Define the current direction the camera is moving to.
  122679. */
  122680. cameraDirection: Vector3;
  122681. /**
  122682. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  122683. * This overrides and empties cameraRotation.
  122684. */
  122685. rotationQuaternion: Quaternion;
  122686. /**
  122687. * Track Roll to maintain the wanted Rolling when looking around.
  122688. */
  122689. _trackRoll: number;
  122690. /**
  122691. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  122692. */
  122693. rollCorrect: number;
  122694. /**
  122695. * Mimic a banked turn, Rolling the camera when Yawing.
  122696. * It's recommended to use rollCorrect = 10 for faster banking correction.
  122697. */
  122698. bankedTurn: boolean;
  122699. /**
  122700. * Limit in radians for how much Roll banking will add. (Default: 90°)
  122701. */
  122702. bankedTurnLimit: number;
  122703. /**
  122704. * Value of 0 disables the banked Roll.
  122705. * Value of 1 is equal to the Yaw angle in radians.
  122706. */
  122707. bankedTurnMultiplier: number;
  122708. /**
  122709. * The inputs manager loads all the input sources, such as keyboard and mouse.
  122710. */
  122711. inputs: FlyCameraInputsManager;
  122712. /**
  122713. * Gets the input sensibility for mouse input.
  122714. * Higher values reduce sensitivity.
  122715. */
  122716. get angularSensibility(): number;
  122717. /**
  122718. * Sets the input sensibility for a mouse input.
  122719. * Higher values reduce sensitivity.
  122720. */
  122721. set angularSensibility(value: number);
  122722. /**
  122723. * Get the keys for camera movement forward.
  122724. */
  122725. get keysForward(): number[];
  122726. /**
  122727. * Set the keys for camera movement forward.
  122728. */
  122729. set keysForward(value: number[]);
  122730. /**
  122731. * Get the keys for camera movement backward.
  122732. */
  122733. get keysBackward(): number[];
  122734. set keysBackward(value: number[]);
  122735. /**
  122736. * Get the keys for camera movement up.
  122737. */
  122738. get keysUp(): number[];
  122739. /**
  122740. * Set the keys for camera movement up.
  122741. */
  122742. set keysUp(value: number[]);
  122743. /**
  122744. * Get the keys for camera movement down.
  122745. */
  122746. get keysDown(): number[];
  122747. /**
  122748. * Set the keys for camera movement down.
  122749. */
  122750. set keysDown(value: number[]);
  122751. /**
  122752. * Get the keys for camera movement left.
  122753. */
  122754. get keysLeft(): number[];
  122755. /**
  122756. * Set the keys for camera movement left.
  122757. */
  122758. set keysLeft(value: number[]);
  122759. /**
  122760. * Set the keys for camera movement right.
  122761. */
  122762. get keysRight(): number[];
  122763. /**
  122764. * Set the keys for camera movement right.
  122765. */
  122766. set keysRight(value: number[]);
  122767. /**
  122768. * Event raised when the camera collides with a mesh in the scene.
  122769. */
  122770. onCollide: (collidedMesh: AbstractMesh) => void;
  122771. private _collider;
  122772. private _needMoveForGravity;
  122773. private _oldPosition;
  122774. private _diffPosition;
  122775. private _newPosition;
  122776. /** @hidden */
  122777. _localDirection: Vector3;
  122778. /** @hidden */
  122779. _transformedDirection: Vector3;
  122780. /**
  122781. * Instantiates a FlyCamera.
  122782. * This is a flying camera, designed for 3D movement and rotation in all directions,
  122783. * such as in a 3D Space Shooter or a Flight Simulator.
  122784. * @param name Define the name of the camera in the scene.
  122785. * @param position Define the starting position of the camera in the scene.
  122786. * @param scene Define the scene the camera belongs to.
  122787. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  122788. */
  122789. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  122790. /**
  122791. * Attach a control to the HTML DOM element.
  122792. * @param element Defines the element that listens to the input events.
  122793. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  122794. */
  122795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122796. /**
  122797. * Detach a control from the HTML DOM element.
  122798. * The camera will stop reacting to that input.
  122799. * @param element Defines the element that listens to the input events.
  122800. */
  122801. detachControl(element: HTMLElement): void;
  122802. private _collisionMask;
  122803. /**
  122804. * Get the mask that the camera ignores in collision events.
  122805. */
  122806. get collisionMask(): number;
  122807. /**
  122808. * Set the mask that the camera ignores in collision events.
  122809. */
  122810. set collisionMask(mask: number);
  122811. /** @hidden */
  122812. _collideWithWorld(displacement: Vector3): void;
  122813. /** @hidden */
  122814. private _onCollisionPositionChange;
  122815. /** @hidden */
  122816. _checkInputs(): void;
  122817. /** @hidden */
  122818. _decideIfNeedsToMove(): boolean;
  122819. /** @hidden */
  122820. _updatePosition(): void;
  122821. /**
  122822. * Restore the Roll to its target value at the rate specified.
  122823. * @param rate - Higher means slower restoring.
  122824. * @hidden
  122825. */
  122826. restoreRoll(rate: number): void;
  122827. /**
  122828. * Destroy the camera and release the current resources held by it.
  122829. */
  122830. dispose(): void;
  122831. /**
  122832. * Get the current object class name.
  122833. * @returns the class name.
  122834. */
  122835. getClassName(): string;
  122836. }
  122837. }
  122838. declare module BABYLON {
  122839. /**
  122840. * Listen to keyboard events to control the camera.
  122841. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122842. */
  122843. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  122844. /**
  122845. * Defines the camera the input is attached to.
  122846. */
  122847. camera: FlyCamera;
  122848. /**
  122849. * The list of keyboard keys used to control the forward move of the camera.
  122850. */
  122851. keysForward: number[];
  122852. /**
  122853. * The list of keyboard keys used to control the backward move of the camera.
  122854. */
  122855. keysBackward: number[];
  122856. /**
  122857. * The list of keyboard keys used to control the forward move of the camera.
  122858. */
  122859. keysUp: number[];
  122860. /**
  122861. * The list of keyboard keys used to control the backward move of the camera.
  122862. */
  122863. keysDown: number[];
  122864. /**
  122865. * The list of keyboard keys used to control the right strafe move of the camera.
  122866. */
  122867. keysRight: number[];
  122868. /**
  122869. * The list of keyboard keys used to control the left strafe move of the camera.
  122870. */
  122871. keysLeft: number[];
  122872. private _keys;
  122873. private _onCanvasBlurObserver;
  122874. private _onKeyboardObserver;
  122875. private _engine;
  122876. private _scene;
  122877. /**
  122878. * Attach the input controls to a specific dom element to get the input from.
  122879. * @param element Defines the element the controls should be listened from
  122880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122881. */
  122882. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122883. /**
  122884. * Detach the current controls from the specified dom element.
  122885. * @param element Defines the element to stop listening the inputs from
  122886. */
  122887. detachControl(element: Nullable<HTMLElement>): void;
  122888. /**
  122889. * Gets the class name of the current intput.
  122890. * @returns the class name
  122891. */
  122892. getClassName(): string;
  122893. /** @hidden */
  122894. _onLostFocus(e: FocusEvent): void;
  122895. /**
  122896. * Get the friendly name associated with the input class.
  122897. * @returns the input friendly name
  122898. */
  122899. getSimpleName(): string;
  122900. /**
  122901. * Update the current camera state depending on the inputs that have been used this frame.
  122902. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122903. */
  122904. checkInputs(): void;
  122905. }
  122906. }
  122907. declare module BABYLON {
  122908. /**
  122909. * Manage the mouse wheel inputs to control a follow camera.
  122910. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122911. */
  122912. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  122913. /**
  122914. * Defines the camera the input is attached to.
  122915. */
  122916. camera: FollowCamera;
  122917. /**
  122918. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  122919. */
  122920. axisControlRadius: boolean;
  122921. /**
  122922. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  122923. */
  122924. axisControlHeight: boolean;
  122925. /**
  122926. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  122927. */
  122928. axisControlRotation: boolean;
  122929. /**
  122930. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  122931. * relation to mouseWheel events.
  122932. */
  122933. wheelPrecision: number;
  122934. /**
  122935. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  122936. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  122937. */
  122938. wheelDeltaPercentage: number;
  122939. private _wheel;
  122940. private _observer;
  122941. /**
  122942. * Attach the input controls to a specific dom element to get the input from.
  122943. * @param element Defines the element the controls should be listened from
  122944. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122945. */
  122946. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122947. /**
  122948. * Detach the current controls from the specified dom element.
  122949. * @param element Defines the element to stop listening the inputs from
  122950. */
  122951. detachControl(element: Nullable<HTMLElement>): void;
  122952. /**
  122953. * Gets the class name of the current intput.
  122954. * @returns the class name
  122955. */
  122956. getClassName(): string;
  122957. /**
  122958. * Get the friendly name associated with the input class.
  122959. * @returns the input friendly name
  122960. */
  122961. getSimpleName(): string;
  122962. }
  122963. }
  122964. declare module BABYLON {
  122965. /**
  122966. * Manage the pointers inputs to control an follow camera.
  122967. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122968. */
  122969. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  122970. /**
  122971. * Defines the camera the input is attached to.
  122972. */
  122973. camera: FollowCamera;
  122974. /**
  122975. * Gets the class name of the current input.
  122976. * @returns the class name
  122977. */
  122978. getClassName(): string;
  122979. /**
  122980. * Defines the pointer angular sensibility along the X axis or how fast is
  122981. * the camera rotating.
  122982. * A negative number will reverse the axis direction.
  122983. */
  122984. angularSensibilityX: number;
  122985. /**
  122986. * Defines the pointer angular sensibility along the Y axis or how fast is
  122987. * the camera rotating.
  122988. * A negative number will reverse the axis direction.
  122989. */
  122990. angularSensibilityY: number;
  122991. /**
  122992. * Defines the pointer pinch precision or how fast is the camera zooming.
  122993. * A negative number will reverse the axis direction.
  122994. */
  122995. pinchPrecision: number;
  122996. /**
  122997. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  122998. * from 0.
  122999. * It defines the percentage of current camera.radius to use as delta when
  123000. * pinch zoom is used.
  123001. */
  123002. pinchDeltaPercentage: number;
  123003. /**
  123004. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  123005. */
  123006. axisXControlRadius: boolean;
  123007. /**
  123008. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  123009. */
  123010. axisXControlHeight: boolean;
  123011. /**
  123012. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  123013. */
  123014. axisXControlRotation: boolean;
  123015. /**
  123016. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  123017. */
  123018. axisYControlRadius: boolean;
  123019. /**
  123020. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  123021. */
  123022. axisYControlHeight: boolean;
  123023. /**
  123024. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  123025. */
  123026. axisYControlRotation: boolean;
  123027. /**
  123028. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  123029. */
  123030. axisPinchControlRadius: boolean;
  123031. /**
  123032. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  123033. */
  123034. axisPinchControlHeight: boolean;
  123035. /**
  123036. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  123037. */
  123038. axisPinchControlRotation: boolean;
  123039. /**
  123040. * Log error messages if basic misconfiguration has occurred.
  123041. */
  123042. warningEnable: boolean;
  123043. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123044. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123045. private _warningCounter;
  123046. private _warning;
  123047. }
  123048. }
  123049. declare module BABYLON {
  123050. /**
  123051. * Default Inputs manager for the FollowCamera.
  123052. * It groups all the default supported inputs for ease of use.
  123053. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123054. */
  123055. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  123056. /**
  123057. * Instantiates a new FollowCameraInputsManager.
  123058. * @param camera Defines the camera the inputs belong to
  123059. */
  123060. constructor(camera: FollowCamera);
  123061. /**
  123062. * Add keyboard input support to the input manager.
  123063. * @returns the current input manager
  123064. */
  123065. addKeyboard(): FollowCameraInputsManager;
  123066. /**
  123067. * Add mouse wheel input support to the input manager.
  123068. * @returns the current input manager
  123069. */
  123070. addMouseWheel(): FollowCameraInputsManager;
  123071. /**
  123072. * Add pointers input support to the input manager.
  123073. * @returns the current input manager
  123074. */
  123075. addPointers(): FollowCameraInputsManager;
  123076. /**
  123077. * Add orientation input support to the input manager.
  123078. * @returns the current input manager
  123079. */
  123080. addVRDeviceOrientation(): FollowCameraInputsManager;
  123081. }
  123082. }
  123083. declare module BABYLON {
  123084. /**
  123085. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  123086. * an arc rotate version arcFollowCamera are available.
  123087. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123088. */
  123089. export class FollowCamera extends TargetCamera {
  123090. /**
  123091. * Distance the follow camera should follow an object at
  123092. */
  123093. radius: number;
  123094. /**
  123095. * Minimum allowed distance of the camera to the axis of rotation
  123096. * (The camera can not get closer).
  123097. * This can help limiting how the Camera is able to move in the scene.
  123098. */
  123099. lowerRadiusLimit: Nullable<number>;
  123100. /**
  123101. * Maximum allowed distance of the camera to the axis of rotation
  123102. * (The camera can not get further).
  123103. * This can help limiting how the Camera is able to move in the scene.
  123104. */
  123105. upperRadiusLimit: Nullable<number>;
  123106. /**
  123107. * Define a rotation offset between the camera and the object it follows
  123108. */
  123109. rotationOffset: number;
  123110. /**
  123111. * Minimum allowed angle to camera position relative to target object.
  123112. * This can help limiting how the Camera is able to move in the scene.
  123113. */
  123114. lowerRotationOffsetLimit: Nullable<number>;
  123115. /**
  123116. * Maximum allowed angle to camera position relative to target object.
  123117. * This can help limiting how the Camera is able to move in the scene.
  123118. */
  123119. upperRotationOffsetLimit: Nullable<number>;
  123120. /**
  123121. * Define a height offset between the camera and the object it follows.
  123122. * It can help following an object from the top (like a car chaing a plane)
  123123. */
  123124. heightOffset: number;
  123125. /**
  123126. * Minimum allowed height of camera position relative to target object.
  123127. * This can help limiting how the Camera is able to move in the scene.
  123128. */
  123129. lowerHeightOffsetLimit: Nullable<number>;
  123130. /**
  123131. * Maximum allowed height of camera position relative to target object.
  123132. * This can help limiting how the Camera is able to move in the scene.
  123133. */
  123134. upperHeightOffsetLimit: Nullable<number>;
  123135. /**
  123136. * Define how fast the camera can accelerate to follow it s target.
  123137. */
  123138. cameraAcceleration: number;
  123139. /**
  123140. * Define the speed limit of the camera following an object.
  123141. */
  123142. maxCameraSpeed: number;
  123143. /**
  123144. * Define the target of the camera.
  123145. */
  123146. lockedTarget: Nullable<AbstractMesh>;
  123147. /**
  123148. * Defines the input associated with the camera.
  123149. */
  123150. inputs: FollowCameraInputsManager;
  123151. /**
  123152. * Instantiates the follow camera.
  123153. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123154. * @param name Define the name of the camera in the scene
  123155. * @param position Define the position of the camera
  123156. * @param scene Define the scene the camera belong to
  123157. * @param lockedTarget Define the target of the camera
  123158. */
  123159. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  123160. private _follow;
  123161. /**
  123162. * Attached controls to the current camera.
  123163. * @param element Defines the element the controls should be listened from
  123164. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123165. */
  123166. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123167. /**
  123168. * Detach the current controls from the camera.
  123169. * The camera will stop reacting to inputs.
  123170. * @param element Defines the element to stop listening the inputs from
  123171. */
  123172. detachControl(element: HTMLElement): void;
  123173. /** @hidden */
  123174. _checkInputs(): void;
  123175. private _checkLimits;
  123176. /**
  123177. * Gets the camera class name.
  123178. * @returns the class name
  123179. */
  123180. getClassName(): string;
  123181. }
  123182. /**
  123183. * Arc Rotate version of the follow camera.
  123184. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  123185. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123186. */
  123187. export class ArcFollowCamera extends TargetCamera {
  123188. /** The longitudinal angle of the camera */
  123189. alpha: number;
  123190. /** The latitudinal angle of the camera */
  123191. beta: number;
  123192. /** The radius of the camera from its target */
  123193. radius: number;
  123194. /** Define the camera target (the mesh it should follow) */
  123195. target: Nullable<AbstractMesh>;
  123196. private _cartesianCoordinates;
  123197. /**
  123198. * Instantiates a new ArcFollowCamera
  123199. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123200. * @param name Define the name of the camera
  123201. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  123202. * @param beta Define the rotation angle of the camera around the elevation axis
  123203. * @param radius Define the radius of the camera from its target point
  123204. * @param target Define the target of the camera
  123205. * @param scene Define the scene the camera belongs to
  123206. */
  123207. constructor(name: string,
  123208. /** The longitudinal angle of the camera */
  123209. alpha: number,
  123210. /** The latitudinal angle of the camera */
  123211. beta: number,
  123212. /** The radius of the camera from its target */
  123213. radius: number,
  123214. /** Define the camera target (the mesh it should follow) */
  123215. target: Nullable<AbstractMesh>, scene: Scene);
  123216. private _follow;
  123217. /** @hidden */
  123218. _checkInputs(): void;
  123219. /**
  123220. * Returns the class name of the object.
  123221. * It is mostly used internally for serialization purposes.
  123222. */
  123223. getClassName(): string;
  123224. }
  123225. }
  123226. declare module BABYLON {
  123227. /**
  123228. * Manage the keyboard inputs to control the movement of a follow camera.
  123229. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123230. */
  123231. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  123232. /**
  123233. * Defines the camera the input is attached to.
  123234. */
  123235. camera: FollowCamera;
  123236. /**
  123237. * Defines the list of key codes associated with the up action (increase heightOffset)
  123238. */
  123239. keysHeightOffsetIncr: number[];
  123240. /**
  123241. * Defines the list of key codes associated with the down action (decrease heightOffset)
  123242. */
  123243. keysHeightOffsetDecr: number[];
  123244. /**
  123245. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  123246. */
  123247. keysHeightOffsetModifierAlt: boolean;
  123248. /**
  123249. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  123250. */
  123251. keysHeightOffsetModifierCtrl: boolean;
  123252. /**
  123253. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  123254. */
  123255. keysHeightOffsetModifierShift: boolean;
  123256. /**
  123257. * Defines the list of key codes associated with the left action (increase rotationOffset)
  123258. */
  123259. keysRotationOffsetIncr: number[];
  123260. /**
  123261. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  123262. */
  123263. keysRotationOffsetDecr: number[];
  123264. /**
  123265. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  123266. */
  123267. keysRotationOffsetModifierAlt: boolean;
  123268. /**
  123269. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  123270. */
  123271. keysRotationOffsetModifierCtrl: boolean;
  123272. /**
  123273. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  123274. */
  123275. keysRotationOffsetModifierShift: boolean;
  123276. /**
  123277. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  123278. */
  123279. keysRadiusIncr: number[];
  123280. /**
  123281. * Defines the list of key codes associated with the zoom-out action (increase radius)
  123282. */
  123283. keysRadiusDecr: number[];
  123284. /**
  123285. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  123286. */
  123287. keysRadiusModifierAlt: boolean;
  123288. /**
  123289. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  123290. */
  123291. keysRadiusModifierCtrl: boolean;
  123292. /**
  123293. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  123294. */
  123295. keysRadiusModifierShift: boolean;
  123296. /**
  123297. * Defines the rate of change of heightOffset.
  123298. */
  123299. heightSensibility: number;
  123300. /**
  123301. * Defines the rate of change of rotationOffset.
  123302. */
  123303. rotationSensibility: number;
  123304. /**
  123305. * Defines the rate of change of radius.
  123306. */
  123307. radiusSensibility: number;
  123308. private _keys;
  123309. private _ctrlPressed;
  123310. private _altPressed;
  123311. private _shiftPressed;
  123312. private _onCanvasBlurObserver;
  123313. private _onKeyboardObserver;
  123314. private _engine;
  123315. private _scene;
  123316. /**
  123317. * Attach the input controls to a specific dom element to get the input from.
  123318. * @param element Defines the element the controls should be listened from
  123319. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123320. */
  123321. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123322. /**
  123323. * Detach the current controls from the specified dom element.
  123324. * @param element Defines the element to stop listening the inputs from
  123325. */
  123326. detachControl(element: Nullable<HTMLElement>): void;
  123327. /**
  123328. * Update the current camera state depending on the inputs that have been used this frame.
  123329. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123330. */
  123331. checkInputs(): void;
  123332. /**
  123333. * Gets the class name of the current input.
  123334. * @returns the class name
  123335. */
  123336. getClassName(): string;
  123337. /**
  123338. * Get the friendly name associated with the input class.
  123339. * @returns the input friendly name
  123340. */
  123341. getSimpleName(): string;
  123342. /**
  123343. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123344. * allow modification of the heightOffset value.
  123345. */
  123346. private _modifierHeightOffset;
  123347. /**
  123348. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123349. * allow modification of the rotationOffset value.
  123350. */
  123351. private _modifierRotationOffset;
  123352. /**
  123353. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123354. * allow modification of the radius value.
  123355. */
  123356. private _modifierRadius;
  123357. }
  123358. }
  123359. declare module BABYLON {
  123360. interface FreeCameraInputsManager {
  123361. /**
  123362. * @hidden
  123363. */
  123364. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  123365. /**
  123366. * Add orientation input support to the input manager.
  123367. * @returns the current input manager
  123368. */
  123369. addDeviceOrientation(): FreeCameraInputsManager;
  123370. }
  123371. /**
  123372. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  123373. * Screen rotation is taken into account.
  123374. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123375. */
  123376. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  123377. private _camera;
  123378. private _screenOrientationAngle;
  123379. private _constantTranform;
  123380. private _screenQuaternion;
  123381. private _alpha;
  123382. private _beta;
  123383. private _gamma;
  123384. /**
  123385. * Can be used to detect if a device orientation sensor is available on a device
  123386. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  123387. * @returns a promise that will resolve on orientation change
  123388. */
  123389. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  123390. /**
  123391. * @hidden
  123392. */
  123393. _onDeviceOrientationChangedObservable: Observable<void>;
  123394. /**
  123395. * Instantiates a new input
  123396. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123397. */
  123398. constructor();
  123399. /**
  123400. * Define the camera controlled by the input.
  123401. */
  123402. get camera(): FreeCamera;
  123403. set camera(camera: FreeCamera);
  123404. /**
  123405. * Attach the input controls to a specific dom element to get the input from.
  123406. * @param element Defines the element the controls should be listened from
  123407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123408. */
  123409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123410. private _orientationChanged;
  123411. private _deviceOrientation;
  123412. /**
  123413. * Detach the current controls from the specified dom element.
  123414. * @param element Defines the element to stop listening the inputs from
  123415. */
  123416. detachControl(element: Nullable<HTMLElement>): void;
  123417. /**
  123418. * Update the current camera state depending on the inputs that have been used this frame.
  123419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123420. */
  123421. checkInputs(): void;
  123422. /**
  123423. * Gets the class name of the current intput.
  123424. * @returns the class name
  123425. */
  123426. getClassName(): string;
  123427. /**
  123428. * Get the friendly name associated with the input class.
  123429. * @returns the input friendly name
  123430. */
  123431. getSimpleName(): string;
  123432. }
  123433. }
  123434. declare module BABYLON {
  123435. /**
  123436. * Manage the gamepad inputs to control a free camera.
  123437. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123438. */
  123439. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  123440. /**
  123441. * Define the camera the input is attached to.
  123442. */
  123443. camera: FreeCamera;
  123444. /**
  123445. * Define the Gamepad controlling the input
  123446. */
  123447. gamepad: Nullable<Gamepad>;
  123448. /**
  123449. * Defines the gamepad rotation sensiblity.
  123450. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123451. */
  123452. gamepadAngularSensibility: number;
  123453. /**
  123454. * Defines the gamepad move sensiblity.
  123455. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123456. */
  123457. gamepadMoveSensibility: number;
  123458. private _yAxisScale;
  123459. /**
  123460. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  123461. */
  123462. get invertYAxis(): boolean;
  123463. set invertYAxis(value: boolean);
  123464. private _onGamepadConnectedObserver;
  123465. private _onGamepadDisconnectedObserver;
  123466. private _cameraTransform;
  123467. private _deltaTransform;
  123468. private _vector3;
  123469. private _vector2;
  123470. /**
  123471. * Attach the input controls to a specific dom element to get the input from.
  123472. * @param element Defines the element the controls should be listened from
  123473. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123474. */
  123475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123476. /**
  123477. * Detach the current controls from the specified dom element.
  123478. * @param element Defines the element to stop listening the inputs from
  123479. */
  123480. detachControl(element: Nullable<HTMLElement>): void;
  123481. /**
  123482. * Update the current camera state depending on the inputs that have been used this frame.
  123483. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123484. */
  123485. checkInputs(): void;
  123486. /**
  123487. * Gets the class name of the current intput.
  123488. * @returns the class name
  123489. */
  123490. getClassName(): string;
  123491. /**
  123492. * Get the friendly name associated with the input class.
  123493. * @returns the input friendly name
  123494. */
  123495. getSimpleName(): string;
  123496. }
  123497. }
  123498. declare module BABYLON {
  123499. /**
  123500. * Defines the potential axis of a Joystick
  123501. */
  123502. export enum JoystickAxis {
  123503. /** X axis */
  123504. X = 0,
  123505. /** Y axis */
  123506. Y = 1,
  123507. /** Z axis */
  123508. Z = 2
  123509. }
  123510. /**
  123511. * Represents the different customization options available
  123512. * for VirtualJoystick
  123513. */
  123514. interface VirtualJoystickCustomizations {
  123515. /**
  123516. * Size of the joystick's puck
  123517. */
  123518. puckSize: number;
  123519. /**
  123520. * Size of the joystick's container
  123521. */
  123522. containerSize: number;
  123523. /**
  123524. * Color of the joystick && puck
  123525. */
  123526. color: string;
  123527. /**
  123528. * Image URL for the joystick's puck
  123529. */
  123530. puckImage?: string;
  123531. /**
  123532. * Image URL for the joystick's container
  123533. */
  123534. containerImage?: string;
  123535. /**
  123536. * Defines the unmoving position of the joystick container
  123537. */
  123538. position?: {
  123539. x: number;
  123540. y: number;
  123541. };
  123542. /**
  123543. * Defines whether or not the joystick container is always visible
  123544. */
  123545. alwaysVisible: boolean;
  123546. /**
  123547. * Defines whether or not to limit the movement of the puck to the joystick's container
  123548. */
  123549. limitToContainer: boolean;
  123550. }
  123551. /**
  123552. * Class used to define virtual joystick (used in touch mode)
  123553. */
  123554. export class VirtualJoystick {
  123555. /**
  123556. * Gets or sets a boolean indicating that left and right values must be inverted
  123557. */
  123558. reverseLeftRight: boolean;
  123559. /**
  123560. * Gets or sets a boolean indicating that up and down values must be inverted
  123561. */
  123562. reverseUpDown: boolean;
  123563. /**
  123564. * Gets the offset value for the position (ie. the change of the position value)
  123565. */
  123566. deltaPosition: Vector3;
  123567. /**
  123568. * Gets a boolean indicating if the virtual joystick was pressed
  123569. */
  123570. pressed: boolean;
  123571. /**
  123572. * Canvas the virtual joystick will render onto, default z-index of this is 5
  123573. */
  123574. static Canvas: Nullable<HTMLCanvasElement>;
  123575. /**
  123576. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  123577. */
  123578. limitToContainer: boolean;
  123579. private static _globalJoystickIndex;
  123580. private static _alwaysVisibleSticks;
  123581. private static vjCanvasContext;
  123582. private static vjCanvasWidth;
  123583. private static vjCanvasHeight;
  123584. private static halfWidth;
  123585. private static _GetDefaultOptions;
  123586. private _action;
  123587. private _axisTargetedByLeftAndRight;
  123588. private _axisTargetedByUpAndDown;
  123589. private _joystickSensibility;
  123590. private _inversedSensibility;
  123591. private _joystickPointerID;
  123592. private _joystickColor;
  123593. private _joystickPointerPos;
  123594. private _joystickPreviousPointerPos;
  123595. private _joystickPointerStartPos;
  123596. private _deltaJoystickVector;
  123597. private _leftJoystick;
  123598. private _touches;
  123599. private _joystickPosition;
  123600. private _alwaysVisible;
  123601. private _puckImage;
  123602. private _containerImage;
  123603. private _joystickPuckSize;
  123604. private _joystickContainerSize;
  123605. private _clearPuckSize;
  123606. private _clearContainerSize;
  123607. private _clearPuckSizeOffset;
  123608. private _clearContainerSizeOffset;
  123609. private _onPointerDownHandlerRef;
  123610. private _onPointerMoveHandlerRef;
  123611. private _onPointerUpHandlerRef;
  123612. private _onResize;
  123613. /**
  123614. * Creates a new virtual joystick
  123615. * @param leftJoystick defines that the joystick is for left hand (false by default)
  123616. * @param customizations Defines the options we want to customize the VirtualJoystick
  123617. */
  123618. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  123619. /**
  123620. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  123621. * @param newJoystickSensibility defines the new sensibility
  123622. */
  123623. setJoystickSensibility(newJoystickSensibility: number): void;
  123624. private _onPointerDown;
  123625. private _onPointerMove;
  123626. private _onPointerUp;
  123627. /**
  123628. * Change the color of the virtual joystick
  123629. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  123630. */
  123631. setJoystickColor(newColor: string): void;
  123632. /**
  123633. * Size of the joystick's container
  123634. */
  123635. set containerSize(newSize: number);
  123636. get containerSize(): number;
  123637. /**
  123638. * Size of the joystick's puck
  123639. */
  123640. set puckSize(newSize: number);
  123641. get puckSize(): number;
  123642. /**
  123643. * Clears the set position of the joystick
  123644. */
  123645. clearPosition(): void;
  123646. /**
  123647. * Defines whether or not the joystick container is always visible
  123648. */
  123649. set alwaysVisible(value: boolean);
  123650. get alwaysVisible(): boolean;
  123651. /**
  123652. * Sets the constant position of the Joystick container
  123653. * @param x X axis coordinate
  123654. * @param y Y axis coordinate
  123655. */
  123656. setPosition(x: number, y: number): void;
  123657. /**
  123658. * Defines a callback to call when the joystick is touched
  123659. * @param action defines the callback
  123660. */
  123661. setActionOnTouch(action: () => any): void;
  123662. /**
  123663. * Defines which axis you'd like to control for left & right
  123664. * @param axis defines the axis to use
  123665. */
  123666. setAxisForLeftRight(axis: JoystickAxis): void;
  123667. /**
  123668. * Defines which axis you'd like to control for up & down
  123669. * @param axis defines the axis to use
  123670. */
  123671. setAxisForUpDown(axis: JoystickAxis): void;
  123672. /**
  123673. * Clears the canvas from the previous puck / container draw
  123674. */
  123675. private _clearPreviousDraw;
  123676. /**
  123677. * Loads `urlPath` to be used for the container's image
  123678. * @param urlPath defines the urlPath of an image to use
  123679. */
  123680. setContainerImage(urlPath: string): void;
  123681. /**
  123682. * Loads `urlPath` to be used for the puck's image
  123683. * @param urlPath defines the urlPath of an image to use
  123684. */
  123685. setPuckImage(urlPath: string): void;
  123686. /**
  123687. * Draws the Virtual Joystick's container
  123688. */
  123689. private _drawContainer;
  123690. /**
  123691. * Draws the Virtual Joystick's puck
  123692. */
  123693. private _drawPuck;
  123694. private _drawVirtualJoystick;
  123695. /**
  123696. * Release internal HTML canvas
  123697. */
  123698. releaseCanvas(): void;
  123699. }
  123700. }
  123701. declare module BABYLON {
  123702. interface FreeCameraInputsManager {
  123703. /**
  123704. * Add virtual joystick input support to the input manager.
  123705. * @returns the current input manager
  123706. */
  123707. addVirtualJoystick(): FreeCameraInputsManager;
  123708. }
  123709. /**
  123710. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  123711. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123712. */
  123713. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  123714. /**
  123715. * Defines the camera the input is attached to.
  123716. */
  123717. camera: FreeCamera;
  123718. private _leftjoystick;
  123719. private _rightjoystick;
  123720. /**
  123721. * Gets the left stick of the virtual joystick.
  123722. * @returns The virtual Joystick
  123723. */
  123724. getLeftJoystick(): VirtualJoystick;
  123725. /**
  123726. * Gets the right stick of the virtual joystick.
  123727. * @returns The virtual Joystick
  123728. */
  123729. getRightJoystick(): VirtualJoystick;
  123730. /**
  123731. * Update the current camera state depending on the inputs that have been used this frame.
  123732. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123733. */
  123734. checkInputs(): void;
  123735. /**
  123736. * Attach the input controls to a specific dom element to get the input from.
  123737. * @param element Defines the element the controls should be listened from
  123738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123739. */
  123740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123741. /**
  123742. * Detach the current controls from the specified dom element.
  123743. * @param element Defines the element to stop listening the inputs from
  123744. */
  123745. detachControl(element: Nullable<HTMLElement>): void;
  123746. /**
  123747. * Gets the class name of the current intput.
  123748. * @returns the class name
  123749. */
  123750. getClassName(): string;
  123751. /**
  123752. * Get the friendly name associated with the input class.
  123753. * @returns the input friendly name
  123754. */
  123755. getSimpleName(): string;
  123756. }
  123757. }
  123758. declare module BABYLON {
  123759. /**
  123760. * This represents a FPS type of camera controlled by touch.
  123761. * This is like a universal camera minus the Gamepad controls.
  123762. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123763. */
  123764. export class TouchCamera extends FreeCamera {
  123765. /**
  123766. * Defines the touch sensibility for rotation.
  123767. * The higher the faster.
  123768. */
  123769. get touchAngularSensibility(): number;
  123770. set touchAngularSensibility(value: number);
  123771. /**
  123772. * Defines the touch sensibility for move.
  123773. * The higher the faster.
  123774. */
  123775. get touchMoveSensibility(): number;
  123776. set touchMoveSensibility(value: number);
  123777. /**
  123778. * Instantiates a new touch camera.
  123779. * This represents a FPS type of camera controlled by touch.
  123780. * This is like a universal camera minus the Gamepad controls.
  123781. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123782. * @param name Define the name of the camera in the scene
  123783. * @param position Define the start position of the camera in the scene
  123784. * @param scene Define the scene the camera belongs to
  123785. */
  123786. constructor(name: string, position: Vector3, scene: Scene);
  123787. /**
  123788. * Gets the current object class name.
  123789. * @return the class name
  123790. */
  123791. getClassName(): string;
  123792. /** @hidden */
  123793. _setupInputs(): void;
  123794. }
  123795. }
  123796. declare module BABYLON {
  123797. /**
  123798. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  123799. * being tilted forward or back and left or right.
  123800. */
  123801. export class DeviceOrientationCamera extends FreeCamera {
  123802. private _initialQuaternion;
  123803. private _quaternionCache;
  123804. private _tmpDragQuaternion;
  123805. private _disablePointerInputWhenUsingDeviceOrientation;
  123806. /**
  123807. * Creates a new device orientation camera
  123808. * @param name The name of the camera
  123809. * @param position The start position camera
  123810. * @param scene The scene the camera belongs to
  123811. */
  123812. constructor(name: string, position: Vector3, scene: Scene);
  123813. /**
  123814. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  123815. */
  123816. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  123817. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  123818. private _dragFactor;
  123819. /**
  123820. * Enabled turning on the y axis when the orientation sensor is active
  123821. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  123822. */
  123823. enableHorizontalDragging(dragFactor?: number): void;
  123824. /**
  123825. * Gets the current instance class name ("DeviceOrientationCamera").
  123826. * This helps avoiding instanceof at run time.
  123827. * @returns the class name
  123828. */
  123829. getClassName(): string;
  123830. /**
  123831. * @hidden
  123832. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  123833. */
  123834. _checkInputs(): void;
  123835. /**
  123836. * Reset the camera to its default orientation on the specified axis only.
  123837. * @param axis The axis to reset
  123838. */
  123839. resetToCurrentRotation(axis?: Axis): void;
  123840. }
  123841. }
  123842. declare module BABYLON {
  123843. /**
  123844. * Defines supported buttons for XBox360 compatible gamepads
  123845. */
  123846. export enum Xbox360Button {
  123847. /** A */
  123848. A = 0,
  123849. /** B */
  123850. B = 1,
  123851. /** X */
  123852. X = 2,
  123853. /** Y */
  123854. Y = 3,
  123855. /** Left button */
  123856. LB = 4,
  123857. /** Right button */
  123858. RB = 5,
  123859. /** Back */
  123860. Back = 8,
  123861. /** Start */
  123862. Start = 9,
  123863. /** Left stick */
  123864. LeftStick = 10,
  123865. /** Right stick */
  123866. RightStick = 11
  123867. }
  123868. /** Defines values for XBox360 DPad */
  123869. export enum Xbox360Dpad {
  123870. /** Up */
  123871. Up = 12,
  123872. /** Down */
  123873. Down = 13,
  123874. /** Left */
  123875. Left = 14,
  123876. /** Right */
  123877. Right = 15
  123878. }
  123879. /**
  123880. * Defines a XBox360 gamepad
  123881. */
  123882. export class Xbox360Pad extends Gamepad {
  123883. private _leftTrigger;
  123884. private _rightTrigger;
  123885. private _onlefttriggerchanged;
  123886. private _onrighttriggerchanged;
  123887. private _onbuttondown;
  123888. private _onbuttonup;
  123889. private _ondpaddown;
  123890. private _ondpadup;
  123891. /** Observable raised when a button is pressed */
  123892. onButtonDownObservable: Observable<Xbox360Button>;
  123893. /** Observable raised when a button is released */
  123894. onButtonUpObservable: Observable<Xbox360Button>;
  123895. /** Observable raised when a pad is pressed */
  123896. onPadDownObservable: Observable<Xbox360Dpad>;
  123897. /** Observable raised when a pad is released */
  123898. onPadUpObservable: Observable<Xbox360Dpad>;
  123899. private _buttonA;
  123900. private _buttonB;
  123901. private _buttonX;
  123902. private _buttonY;
  123903. private _buttonBack;
  123904. private _buttonStart;
  123905. private _buttonLB;
  123906. private _buttonRB;
  123907. private _buttonLeftStick;
  123908. private _buttonRightStick;
  123909. private _dPadUp;
  123910. private _dPadDown;
  123911. private _dPadLeft;
  123912. private _dPadRight;
  123913. private _isXboxOnePad;
  123914. /**
  123915. * Creates a new XBox360 gamepad object
  123916. * @param id defines the id of this gamepad
  123917. * @param index defines its index
  123918. * @param gamepad defines the internal HTML gamepad object
  123919. * @param xboxOne defines if it is a XBox One gamepad
  123920. */
  123921. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  123922. /**
  123923. * Defines the callback to call when left trigger is pressed
  123924. * @param callback defines the callback to use
  123925. */
  123926. onlefttriggerchanged(callback: (value: number) => void): void;
  123927. /**
  123928. * Defines the callback to call when right trigger is pressed
  123929. * @param callback defines the callback to use
  123930. */
  123931. onrighttriggerchanged(callback: (value: number) => void): void;
  123932. /**
  123933. * Gets the left trigger value
  123934. */
  123935. get leftTrigger(): number;
  123936. /**
  123937. * Sets the left trigger value
  123938. */
  123939. set leftTrigger(newValue: number);
  123940. /**
  123941. * Gets the right trigger value
  123942. */
  123943. get rightTrigger(): number;
  123944. /**
  123945. * Sets the right trigger value
  123946. */
  123947. set rightTrigger(newValue: number);
  123948. /**
  123949. * Defines the callback to call when a button is pressed
  123950. * @param callback defines the callback to use
  123951. */
  123952. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  123953. /**
  123954. * Defines the callback to call when a button is released
  123955. * @param callback defines the callback to use
  123956. */
  123957. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  123958. /**
  123959. * Defines the callback to call when a pad is pressed
  123960. * @param callback defines the callback to use
  123961. */
  123962. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  123963. /**
  123964. * Defines the callback to call when a pad is released
  123965. * @param callback defines the callback to use
  123966. */
  123967. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  123968. private _setButtonValue;
  123969. private _setDPadValue;
  123970. /**
  123971. * Gets the value of the `A` button
  123972. */
  123973. get buttonA(): number;
  123974. /**
  123975. * Sets the value of the `A` button
  123976. */
  123977. set buttonA(value: number);
  123978. /**
  123979. * Gets the value of the `B` button
  123980. */
  123981. get buttonB(): number;
  123982. /**
  123983. * Sets the value of the `B` button
  123984. */
  123985. set buttonB(value: number);
  123986. /**
  123987. * Gets the value of the `X` button
  123988. */
  123989. get buttonX(): number;
  123990. /**
  123991. * Sets the value of the `X` button
  123992. */
  123993. set buttonX(value: number);
  123994. /**
  123995. * Gets the value of the `Y` button
  123996. */
  123997. get buttonY(): number;
  123998. /**
  123999. * Sets the value of the `Y` button
  124000. */
  124001. set buttonY(value: number);
  124002. /**
  124003. * Gets the value of the `Start` button
  124004. */
  124005. get buttonStart(): number;
  124006. /**
  124007. * Sets the value of the `Start` button
  124008. */
  124009. set buttonStart(value: number);
  124010. /**
  124011. * Gets the value of the `Back` button
  124012. */
  124013. get buttonBack(): number;
  124014. /**
  124015. * Sets the value of the `Back` button
  124016. */
  124017. set buttonBack(value: number);
  124018. /**
  124019. * Gets the value of the `Left` button
  124020. */
  124021. get buttonLB(): number;
  124022. /**
  124023. * Sets the value of the `Left` button
  124024. */
  124025. set buttonLB(value: number);
  124026. /**
  124027. * Gets the value of the `Right` button
  124028. */
  124029. get buttonRB(): number;
  124030. /**
  124031. * Sets the value of the `Right` button
  124032. */
  124033. set buttonRB(value: number);
  124034. /**
  124035. * Gets the value of the Left joystick
  124036. */
  124037. get buttonLeftStick(): number;
  124038. /**
  124039. * Sets the value of the Left joystick
  124040. */
  124041. set buttonLeftStick(value: number);
  124042. /**
  124043. * Gets the value of the Right joystick
  124044. */
  124045. get buttonRightStick(): number;
  124046. /**
  124047. * Sets the value of the Right joystick
  124048. */
  124049. set buttonRightStick(value: number);
  124050. /**
  124051. * Gets the value of D-pad up
  124052. */
  124053. get dPadUp(): number;
  124054. /**
  124055. * Sets the value of D-pad up
  124056. */
  124057. set dPadUp(value: number);
  124058. /**
  124059. * Gets the value of D-pad down
  124060. */
  124061. get dPadDown(): number;
  124062. /**
  124063. * Sets the value of D-pad down
  124064. */
  124065. set dPadDown(value: number);
  124066. /**
  124067. * Gets the value of D-pad left
  124068. */
  124069. get dPadLeft(): number;
  124070. /**
  124071. * Sets the value of D-pad left
  124072. */
  124073. set dPadLeft(value: number);
  124074. /**
  124075. * Gets the value of D-pad right
  124076. */
  124077. get dPadRight(): number;
  124078. /**
  124079. * Sets the value of D-pad right
  124080. */
  124081. set dPadRight(value: number);
  124082. /**
  124083. * Force the gamepad to synchronize with device values
  124084. */
  124085. update(): void;
  124086. /**
  124087. * Disposes the gamepad
  124088. */
  124089. dispose(): void;
  124090. }
  124091. }
  124092. declare module BABYLON {
  124093. /**
  124094. * Defines supported buttons for DualShock compatible gamepads
  124095. */
  124096. export enum DualShockButton {
  124097. /** Cross */
  124098. Cross = 0,
  124099. /** Circle */
  124100. Circle = 1,
  124101. /** Square */
  124102. Square = 2,
  124103. /** Triangle */
  124104. Triangle = 3,
  124105. /** L1 */
  124106. L1 = 4,
  124107. /** R1 */
  124108. R1 = 5,
  124109. /** Share */
  124110. Share = 8,
  124111. /** Options */
  124112. Options = 9,
  124113. /** Left stick */
  124114. LeftStick = 10,
  124115. /** Right stick */
  124116. RightStick = 11
  124117. }
  124118. /** Defines values for DualShock DPad */
  124119. export enum DualShockDpad {
  124120. /** Up */
  124121. Up = 12,
  124122. /** Down */
  124123. Down = 13,
  124124. /** Left */
  124125. Left = 14,
  124126. /** Right */
  124127. Right = 15
  124128. }
  124129. /**
  124130. * Defines a DualShock gamepad
  124131. */
  124132. export class DualShockPad extends Gamepad {
  124133. private _leftTrigger;
  124134. private _rightTrigger;
  124135. private _onlefttriggerchanged;
  124136. private _onrighttriggerchanged;
  124137. private _onbuttondown;
  124138. private _onbuttonup;
  124139. private _ondpaddown;
  124140. private _ondpadup;
  124141. /** Observable raised when a button is pressed */
  124142. onButtonDownObservable: Observable<DualShockButton>;
  124143. /** Observable raised when a button is released */
  124144. onButtonUpObservable: Observable<DualShockButton>;
  124145. /** Observable raised when a pad is pressed */
  124146. onPadDownObservable: Observable<DualShockDpad>;
  124147. /** Observable raised when a pad is released */
  124148. onPadUpObservable: Observable<DualShockDpad>;
  124149. private _buttonCross;
  124150. private _buttonCircle;
  124151. private _buttonSquare;
  124152. private _buttonTriangle;
  124153. private _buttonShare;
  124154. private _buttonOptions;
  124155. private _buttonL1;
  124156. private _buttonR1;
  124157. private _buttonLeftStick;
  124158. private _buttonRightStick;
  124159. private _dPadUp;
  124160. private _dPadDown;
  124161. private _dPadLeft;
  124162. private _dPadRight;
  124163. /**
  124164. * Creates a new DualShock gamepad object
  124165. * @param id defines the id of this gamepad
  124166. * @param index defines its index
  124167. * @param gamepad defines the internal HTML gamepad object
  124168. */
  124169. constructor(id: string, index: number, gamepad: any);
  124170. /**
  124171. * Defines the callback to call when left trigger is pressed
  124172. * @param callback defines the callback to use
  124173. */
  124174. onlefttriggerchanged(callback: (value: number) => void): void;
  124175. /**
  124176. * Defines the callback to call when right trigger is pressed
  124177. * @param callback defines the callback to use
  124178. */
  124179. onrighttriggerchanged(callback: (value: number) => void): void;
  124180. /**
  124181. * Gets the left trigger value
  124182. */
  124183. get leftTrigger(): number;
  124184. /**
  124185. * Sets the left trigger value
  124186. */
  124187. set leftTrigger(newValue: number);
  124188. /**
  124189. * Gets the right trigger value
  124190. */
  124191. get rightTrigger(): number;
  124192. /**
  124193. * Sets the right trigger value
  124194. */
  124195. set rightTrigger(newValue: number);
  124196. /**
  124197. * Defines the callback to call when a button is pressed
  124198. * @param callback defines the callback to use
  124199. */
  124200. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  124201. /**
  124202. * Defines the callback to call when a button is released
  124203. * @param callback defines the callback to use
  124204. */
  124205. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  124206. /**
  124207. * Defines the callback to call when a pad is pressed
  124208. * @param callback defines the callback to use
  124209. */
  124210. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  124211. /**
  124212. * Defines the callback to call when a pad is released
  124213. * @param callback defines the callback to use
  124214. */
  124215. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  124216. private _setButtonValue;
  124217. private _setDPadValue;
  124218. /**
  124219. * Gets the value of the `Cross` button
  124220. */
  124221. get buttonCross(): number;
  124222. /**
  124223. * Sets the value of the `Cross` button
  124224. */
  124225. set buttonCross(value: number);
  124226. /**
  124227. * Gets the value of the `Circle` button
  124228. */
  124229. get buttonCircle(): number;
  124230. /**
  124231. * Sets the value of the `Circle` button
  124232. */
  124233. set buttonCircle(value: number);
  124234. /**
  124235. * Gets the value of the `Square` button
  124236. */
  124237. get buttonSquare(): number;
  124238. /**
  124239. * Sets the value of the `Square` button
  124240. */
  124241. set buttonSquare(value: number);
  124242. /**
  124243. * Gets the value of the `Triangle` button
  124244. */
  124245. get buttonTriangle(): number;
  124246. /**
  124247. * Sets the value of the `Triangle` button
  124248. */
  124249. set buttonTriangle(value: number);
  124250. /**
  124251. * Gets the value of the `Options` button
  124252. */
  124253. get buttonOptions(): number;
  124254. /**
  124255. * Sets the value of the `Options` button
  124256. */
  124257. set buttonOptions(value: number);
  124258. /**
  124259. * Gets the value of the `Share` button
  124260. */
  124261. get buttonShare(): number;
  124262. /**
  124263. * Sets the value of the `Share` button
  124264. */
  124265. set buttonShare(value: number);
  124266. /**
  124267. * Gets the value of the `L1` button
  124268. */
  124269. get buttonL1(): number;
  124270. /**
  124271. * Sets the value of the `L1` button
  124272. */
  124273. set buttonL1(value: number);
  124274. /**
  124275. * Gets the value of the `R1` button
  124276. */
  124277. get buttonR1(): number;
  124278. /**
  124279. * Sets the value of the `R1` button
  124280. */
  124281. set buttonR1(value: number);
  124282. /**
  124283. * Gets the value of the Left joystick
  124284. */
  124285. get buttonLeftStick(): number;
  124286. /**
  124287. * Sets the value of the Left joystick
  124288. */
  124289. set buttonLeftStick(value: number);
  124290. /**
  124291. * Gets the value of the Right joystick
  124292. */
  124293. get buttonRightStick(): number;
  124294. /**
  124295. * Sets the value of the Right joystick
  124296. */
  124297. set buttonRightStick(value: number);
  124298. /**
  124299. * Gets the value of D-pad up
  124300. */
  124301. get dPadUp(): number;
  124302. /**
  124303. * Sets the value of D-pad up
  124304. */
  124305. set dPadUp(value: number);
  124306. /**
  124307. * Gets the value of D-pad down
  124308. */
  124309. get dPadDown(): number;
  124310. /**
  124311. * Sets the value of D-pad down
  124312. */
  124313. set dPadDown(value: number);
  124314. /**
  124315. * Gets the value of D-pad left
  124316. */
  124317. get dPadLeft(): number;
  124318. /**
  124319. * Sets the value of D-pad left
  124320. */
  124321. set dPadLeft(value: number);
  124322. /**
  124323. * Gets the value of D-pad right
  124324. */
  124325. get dPadRight(): number;
  124326. /**
  124327. * Sets the value of D-pad right
  124328. */
  124329. set dPadRight(value: number);
  124330. /**
  124331. * Force the gamepad to synchronize with device values
  124332. */
  124333. update(): void;
  124334. /**
  124335. * Disposes the gamepad
  124336. */
  124337. dispose(): void;
  124338. }
  124339. }
  124340. declare module BABYLON {
  124341. /**
  124342. * Manager for handling gamepads
  124343. */
  124344. export class GamepadManager {
  124345. private _scene?;
  124346. private _babylonGamepads;
  124347. private _oneGamepadConnected;
  124348. /** @hidden */
  124349. _isMonitoring: boolean;
  124350. private _gamepadEventSupported;
  124351. private _gamepadSupport?;
  124352. /**
  124353. * observable to be triggered when the gamepad controller has been connected
  124354. */
  124355. onGamepadConnectedObservable: Observable<Gamepad>;
  124356. /**
  124357. * observable to be triggered when the gamepad controller has been disconnected
  124358. */
  124359. onGamepadDisconnectedObservable: Observable<Gamepad>;
  124360. private _onGamepadConnectedEvent;
  124361. private _onGamepadDisconnectedEvent;
  124362. /**
  124363. * Initializes the gamepad manager
  124364. * @param _scene BabylonJS scene
  124365. */
  124366. constructor(_scene?: Scene | undefined);
  124367. /**
  124368. * The gamepads in the game pad manager
  124369. */
  124370. get gamepads(): Gamepad[];
  124371. /**
  124372. * Get the gamepad controllers based on type
  124373. * @param type The type of gamepad controller
  124374. * @returns Nullable gamepad
  124375. */
  124376. getGamepadByType(type?: number): Nullable<Gamepad>;
  124377. /**
  124378. * Disposes the gamepad manager
  124379. */
  124380. dispose(): void;
  124381. private _addNewGamepad;
  124382. private _startMonitoringGamepads;
  124383. private _stopMonitoringGamepads;
  124384. /** @hidden */
  124385. _checkGamepadsStatus(): void;
  124386. private _updateGamepadObjects;
  124387. }
  124388. }
  124389. declare module BABYLON {
  124390. interface Scene {
  124391. /** @hidden */
  124392. _gamepadManager: Nullable<GamepadManager>;
  124393. /**
  124394. * Gets the gamepad manager associated with the scene
  124395. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  124396. */
  124397. gamepadManager: GamepadManager;
  124398. }
  124399. /**
  124400. * Interface representing a free camera inputs manager
  124401. */
  124402. interface FreeCameraInputsManager {
  124403. /**
  124404. * Adds gamepad input support to the FreeCameraInputsManager.
  124405. * @returns the FreeCameraInputsManager
  124406. */
  124407. addGamepad(): FreeCameraInputsManager;
  124408. }
  124409. /**
  124410. * Interface representing an arc rotate camera inputs manager
  124411. */
  124412. interface ArcRotateCameraInputsManager {
  124413. /**
  124414. * Adds gamepad input support to the ArcRotateCamera InputManager.
  124415. * @returns the camera inputs manager
  124416. */
  124417. addGamepad(): ArcRotateCameraInputsManager;
  124418. }
  124419. /**
  124420. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  124421. */
  124422. export class GamepadSystemSceneComponent implements ISceneComponent {
  124423. /**
  124424. * The component name helpfull to identify the component in the list of scene components.
  124425. */
  124426. readonly name: string;
  124427. /**
  124428. * The scene the component belongs to.
  124429. */
  124430. scene: Scene;
  124431. /**
  124432. * Creates a new instance of the component for the given scene
  124433. * @param scene Defines the scene to register the component in
  124434. */
  124435. constructor(scene: Scene);
  124436. /**
  124437. * Registers the component in a given scene
  124438. */
  124439. register(): void;
  124440. /**
  124441. * Rebuilds the elements related to this component in case of
  124442. * context lost for instance.
  124443. */
  124444. rebuild(): void;
  124445. /**
  124446. * Disposes the component and the associated ressources
  124447. */
  124448. dispose(): void;
  124449. private _beforeCameraUpdate;
  124450. }
  124451. }
  124452. declare module BABYLON {
  124453. /**
  124454. * 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,
  124455. * which still works and will still be found in many Playgrounds.
  124456. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124457. */
  124458. export class UniversalCamera extends TouchCamera {
  124459. /**
  124460. * Defines the gamepad rotation sensiblity.
  124461. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124462. */
  124463. get gamepadAngularSensibility(): number;
  124464. set gamepadAngularSensibility(value: number);
  124465. /**
  124466. * Defines the gamepad move sensiblity.
  124467. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124468. */
  124469. get gamepadMoveSensibility(): number;
  124470. set gamepadMoveSensibility(value: number);
  124471. /**
  124472. * 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,
  124473. * which still works and will still be found in many Playgrounds.
  124474. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124475. * @param name Define the name of the camera in the scene
  124476. * @param position Define the start position of the camera in the scene
  124477. * @param scene Define the scene the camera belongs to
  124478. */
  124479. constructor(name: string, position: Vector3, scene: Scene);
  124480. /**
  124481. * Gets the current object class name.
  124482. * @return the class name
  124483. */
  124484. getClassName(): string;
  124485. }
  124486. }
  124487. declare module BABYLON {
  124488. /**
  124489. * This represents a FPS type of camera. This is only here for back compat purpose.
  124490. * Please use the UniversalCamera instead as both are identical.
  124491. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124492. */
  124493. export class GamepadCamera extends UniversalCamera {
  124494. /**
  124495. * Instantiates a new Gamepad Camera
  124496. * This represents a FPS type of camera. This is only here for back compat purpose.
  124497. * Please use the UniversalCamera instead as both are identical.
  124498. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124499. * @param name Define the name of the camera in the scene
  124500. * @param position Define the start position of the camera in the scene
  124501. * @param scene Define the scene the camera belongs to
  124502. */
  124503. constructor(name: string, position: Vector3, scene: Scene);
  124504. /**
  124505. * Gets the current object class name.
  124506. * @return the class name
  124507. */
  124508. getClassName(): string;
  124509. }
  124510. }
  124511. declare module BABYLON {
  124512. /** @hidden */
  124513. export var passPixelShader: {
  124514. name: string;
  124515. shader: string;
  124516. };
  124517. }
  124518. declare module BABYLON {
  124519. /** @hidden */
  124520. export var passCubePixelShader: {
  124521. name: string;
  124522. shader: string;
  124523. };
  124524. }
  124525. declare module BABYLON {
  124526. /**
  124527. * PassPostProcess which produces an output the same as it's input
  124528. */
  124529. export class PassPostProcess extends PostProcess {
  124530. /**
  124531. * Creates the PassPostProcess
  124532. * @param name The name of the effect.
  124533. * @param options The required width/height ratio to downsize to before computing the render pass.
  124534. * @param camera The camera to apply the render pass to.
  124535. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124536. * @param engine The engine which the post process will be applied. (default: current engine)
  124537. * @param reusable If the post process can be reused on the same frame. (default: false)
  124538. * @param textureType The type of texture to be used when performing the post processing.
  124539. * @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)
  124540. */
  124541. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124542. }
  124543. /**
  124544. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  124545. */
  124546. export class PassCubePostProcess extends PostProcess {
  124547. private _face;
  124548. /**
  124549. * Gets or sets the cube face to display.
  124550. * * 0 is +X
  124551. * * 1 is -X
  124552. * * 2 is +Y
  124553. * * 3 is -Y
  124554. * * 4 is +Z
  124555. * * 5 is -Z
  124556. */
  124557. get face(): number;
  124558. set face(value: number);
  124559. /**
  124560. * Creates the PassCubePostProcess
  124561. * @param name The name of the effect.
  124562. * @param options The required width/height ratio to downsize to before computing the render pass.
  124563. * @param camera The camera to apply the render pass to.
  124564. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124565. * @param engine The engine which the post process will be applied. (default: current engine)
  124566. * @param reusable If the post process can be reused on the same frame. (default: false)
  124567. * @param textureType The type of texture to be used when performing the post processing.
  124568. * @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)
  124569. */
  124570. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124571. }
  124572. }
  124573. declare module BABYLON {
  124574. /** @hidden */
  124575. export var anaglyphPixelShader: {
  124576. name: string;
  124577. shader: string;
  124578. };
  124579. }
  124580. declare module BABYLON {
  124581. /**
  124582. * Postprocess used to generate anaglyphic rendering
  124583. */
  124584. export class AnaglyphPostProcess extends PostProcess {
  124585. private _passedProcess;
  124586. /**
  124587. * Creates a new AnaglyphPostProcess
  124588. * @param name defines postprocess name
  124589. * @param options defines creation options or target ratio scale
  124590. * @param rigCameras defines cameras using this postprocess
  124591. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  124592. * @param engine defines hosting engine
  124593. * @param reusable defines if the postprocess will be reused multiple times per frame
  124594. */
  124595. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  124596. }
  124597. }
  124598. declare module BABYLON {
  124599. /**
  124600. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  124601. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124602. */
  124603. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  124604. /**
  124605. * Creates a new AnaglyphArcRotateCamera
  124606. * @param name defines camera name
  124607. * @param alpha defines alpha angle (in radians)
  124608. * @param beta defines beta angle (in radians)
  124609. * @param radius defines radius
  124610. * @param target defines camera target
  124611. * @param interaxialDistance defines distance between each color axis
  124612. * @param scene defines the hosting scene
  124613. */
  124614. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  124615. /**
  124616. * Gets camera class name
  124617. * @returns AnaglyphArcRotateCamera
  124618. */
  124619. getClassName(): string;
  124620. }
  124621. }
  124622. declare module BABYLON {
  124623. /**
  124624. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  124625. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124626. */
  124627. export class AnaglyphFreeCamera extends FreeCamera {
  124628. /**
  124629. * Creates a new AnaglyphFreeCamera
  124630. * @param name defines camera name
  124631. * @param position defines initial position
  124632. * @param interaxialDistance defines distance between each color axis
  124633. * @param scene defines the hosting scene
  124634. */
  124635. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  124636. /**
  124637. * Gets camera class name
  124638. * @returns AnaglyphFreeCamera
  124639. */
  124640. getClassName(): string;
  124641. }
  124642. }
  124643. declare module BABYLON {
  124644. /**
  124645. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  124646. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124647. */
  124648. export class AnaglyphGamepadCamera extends GamepadCamera {
  124649. /**
  124650. * Creates a new AnaglyphGamepadCamera
  124651. * @param name defines camera name
  124652. * @param position defines initial position
  124653. * @param interaxialDistance defines distance between each color axis
  124654. * @param scene defines the hosting scene
  124655. */
  124656. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  124657. /**
  124658. * Gets camera class name
  124659. * @returns AnaglyphGamepadCamera
  124660. */
  124661. getClassName(): string;
  124662. }
  124663. }
  124664. declare module BABYLON {
  124665. /**
  124666. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  124667. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124668. */
  124669. export class AnaglyphUniversalCamera extends UniversalCamera {
  124670. /**
  124671. * Creates a new AnaglyphUniversalCamera
  124672. * @param name defines camera name
  124673. * @param position defines initial position
  124674. * @param interaxialDistance defines distance between each color axis
  124675. * @param scene defines the hosting scene
  124676. */
  124677. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  124678. /**
  124679. * Gets camera class name
  124680. * @returns AnaglyphUniversalCamera
  124681. */
  124682. getClassName(): string;
  124683. }
  124684. }
  124685. declare module BABYLON {
  124686. /**
  124687. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  124688. * @see https://doc.babylonjs.com/features/cameras
  124689. */
  124690. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  124691. /**
  124692. * Creates a new StereoscopicArcRotateCamera
  124693. * @param name defines camera name
  124694. * @param alpha defines alpha angle (in radians)
  124695. * @param beta defines beta angle (in radians)
  124696. * @param radius defines radius
  124697. * @param target defines camera target
  124698. * @param interaxialDistance defines distance between each color axis
  124699. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124700. * @param scene defines the hosting scene
  124701. */
  124702. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124703. /**
  124704. * Gets camera class name
  124705. * @returns StereoscopicArcRotateCamera
  124706. */
  124707. getClassName(): string;
  124708. }
  124709. }
  124710. declare module BABYLON {
  124711. /**
  124712. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  124713. * @see https://doc.babylonjs.com/features/cameras
  124714. */
  124715. export class StereoscopicFreeCamera extends FreeCamera {
  124716. /**
  124717. * Creates a new StereoscopicFreeCamera
  124718. * @param name defines camera name
  124719. * @param position defines initial position
  124720. * @param interaxialDistance defines distance between each color axis
  124721. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124722. * @param scene defines the hosting scene
  124723. */
  124724. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124725. /**
  124726. * Gets camera class name
  124727. * @returns StereoscopicFreeCamera
  124728. */
  124729. getClassName(): string;
  124730. }
  124731. }
  124732. declare module BABYLON {
  124733. /**
  124734. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  124735. * @see https://doc.babylonjs.com/features/cameras
  124736. */
  124737. export class StereoscopicGamepadCamera extends GamepadCamera {
  124738. /**
  124739. * Creates a new StereoscopicGamepadCamera
  124740. * @param name defines camera name
  124741. * @param position defines initial position
  124742. * @param interaxialDistance defines distance between each color axis
  124743. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124744. * @param scene defines the hosting scene
  124745. */
  124746. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124747. /**
  124748. * Gets camera class name
  124749. * @returns StereoscopicGamepadCamera
  124750. */
  124751. getClassName(): string;
  124752. }
  124753. }
  124754. declare module BABYLON {
  124755. /**
  124756. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  124757. * @see https://doc.babylonjs.com/features/cameras
  124758. */
  124759. export class StereoscopicUniversalCamera extends UniversalCamera {
  124760. /**
  124761. * Creates a new StereoscopicUniversalCamera
  124762. * @param name defines camera name
  124763. * @param position defines initial position
  124764. * @param interaxialDistance defines distance between each color axis
  124765. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124766. * @param scene defines the hosting scene
  124767. */
  124768. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124769. /**
  124770. * Gets camera class name
  124771. * @returns StereoscopicUniversalCamera
  124772. */
  124773. getClassName(): string;
  124774. }
  124775. }
  124776. declare module BABYLON {
  124777. /**
  124778. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  124779. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  124780. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  124781. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  124782. */
  124783. export class VirtualJoysticksCamera extends FreeCamera {
  124784. /**
  124785. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  124786. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  124787. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  124788. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  124789. * @param name Define the name of the camera in the scene
  124790. * @param position Define the start position of the camera in the scene
  124791. * @param scene Define the scene the camera belongs to
  124792. */
  124793. constructor(name: string, position: Vector3, scene: Scene);
  124794. /**
  124795. * Gets the current object class name.
  124796. * @return the class name
  124797. */
  124798. getClassName(): string;
  124799. }
  124800. }
  124801. declare module BABYLON {
  124802. /**
  124803. * This represents all the required metrics to create a VR camera.
  124804. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  124805. */
  124806. export class VRCameraMetrics {
  124807. /**
  124808. * Define the horizontal resolution off the screen.
  124809. */
  124810. hResolution: number;
  124811. /**
  124812. * Define the vertical resolution off the screen.
  124813. */
  124814. vResolution: number;
  124815. /**
  124816. * Define the horizontal screen size.
  124817. */
  124818. hScreenSize: number;
  124819. /**
  124820. * Define the vertical screen size.
  124821. */
  124822. vScreenSize: number;
  124823. /**
  124824. * Define the vertical screen center position.
  124825. */
  124826. vScreenCenter: number;
  124827. /**
  124828. * Define the distance of the eyes to the screen.
  124829. */
  124830. eyeToScreenDistance: number;
  124831. /**
  124832. * Define the distance between both lenses
  124833. */
  124834. lensSeparationDistance: number;
  124835. /**
  124836. * Define the distance between both viewer's eyes.
  124837. */
  124838. interpupillaryDistance: number;
  124839. /**
  124840. * Define the distortion factor of the VR postprocess.
  124841. * Please, touch with care.
  124842. */
  124843. distortionK: number[];
  124844. /**
  124845. * Define the chromatic aberration correction factors for the VR post process.
  124846. */
  124847. chromaAbCorrection: number[];
  124848. /**
  124849. * Define the scale factor of the post process.
  124850. * The smaller the better but the slower.
  124851. */
  124852. postProcessScaleFactor: number;
  124853. /**
  124854. * Define an offset for the lens center.
  124855. */
  124856. lensCenterOffset: number;
  124857. /**
  124858. * Define if the current vr camera should compensate the distortion of the lense or not.
  124859. */
  124860. compensateDistortion: boolean;
  124861. /**
  124862. * Defines if multiview should be enabled when rendering (Default: false)
  124863. */
  124864. multiviewEnabled: boolean;
  124865. /**
  124866. * Gets the rendering aspect ratio based on the provided resolutions.
  124867. */
  124868. get aspectRatio(): number;
  124869. /**
  124870. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  124871. */
  124872. get aspectRatioFov(): number;
  124873. /**
  124874. * @hidden
  124875. */
  124876. get leftHMatrix(): Matrix;
  124877. /**
  124878. * @hidden
  124879. */
  124880. get rightHMatrix(): Matrix;
  124881. /**
  124882. * @hidden
  124883. */
  124884. get leftPreViewMatrix(): Matrix;
  124885. /**
  124886. * @hidden
  124887. */
  124888. get rightPreViewMatrix(): Matrix;
  124889. /**
  124890. * Get the default VRMetrics based on the most generic setup.
  124891. * @returns the default vr metrics
  124892. */
  124893. static GetDefault(): VRCameraMetrics;
  124894. }
  124895. }
  124896. declare module BABYLON {
  124897. /** @hidden */
  124898. export var vrDistortionCorrectionPixelShader: {
  124899. name: string;
  124900. shader: string;
  124901. };
  124902. }
  124903. declare module BABYLON {
  124904. /**
  124905. * VRDistortionCorrectionPostProcess used for mobile VR
  124906. */
  124907. export class VRDistortionCorrectionPostProcess extends PostProcess {
  124908. private _isRightEye;
  124909. private _distortionFactors;
  124910. private _postProcessScaleFactor;
  124911. private _lensCenterOffset;
  124912. private _scaleIn;
  124913. private _scaleFactor;
  124914. private _lensCenter;
  124915. /**
  124916. * Initializes the VRDistortionCorrectionPostProcess
  124917. * @param name The name of the effect.
  124918. * @param camera The camera to apply the render pass to.
  124919. * @param isRightEye If this is for the right eye distortion
  124920. * @param vrMetrics All the required metrics for the VR camera
  124921. */
  124922. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  124923. }
  124924. }
  124925. declare module BABYLON {
  124926. /**
  124927. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  124928. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  124929. */
  124930. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  124931. /**
  124932. * Creates a new VRDeviceOrientationArcRotateCamera
  124933. * @param name defines camera name
  124934. * @param alpha defines the camera rotation along the logitudinal axis
  124935. * @param beta defines the camera rotation along the latitudinal axis
  124936. * @param radius defines the camera distance from its target
  124937. * @param target defines the camera target
  124938. * @param scene defines the scene the camera belongs to
  124939. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  124940. * @param vrCameraMetrics defines the vr metrics associated to the camera
  124941. */
  124942. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  124943. /**
  124944. * Gets camera class name
  124945. * @returns VRDeviceOrientationArcRotateCamera
  124946. */
  124947. getClassName(): string;
  124948. }
  124949. }
  124950. declare module BABYLON {
  124951. /**
  124952. * Camera used to simulate VR rendering (based on FreeCamera)
  124953. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  124954. */
  124955. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  124956. /**
  124957. * Creates a new VRDeviceOrientationFreeCamera
  124958. * @param name defines camera name
  124959. * @param position defines the start position of the camera
  124960. * @param scene defines the scene the camera belongs to
  124961. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  124962. * @param vrCameraMetrics defines the vr metrics associated to the camera
  124963. */
  124964. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  124965. /**
  124966. * Gets camera class name
  124967. * @returns VRDeviceOrientationFreeCamera
  124968. */
  124969. getClassName(): string;
  124970. }
  124971. }
  124972. declare module BABYLON {
  124973. /**
  124974. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  124975. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  124976. */
  124977. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  124978. /**
  124979. * Creates a new VRDeviceOrientationGamepadCamera
  124980. * @param name defines camera name
  124981. * @param position defines the start position of the camera
  124982. * @param scene defines the scene the camera belongs to
  124983. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  124984. * @param vrCameraMetrics defines the vr metrics associated to the camera
  124985. */
  124986. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  124987. /**
  124988. * Gets camera class name
  124989. * @returns VRDeviceOrientationGamepadCamera
  124990. */
  124991. getClassName(): string;
  124992. }
  124993. }
  124994. declare module BABYLON {
  124995. /**
  124996. * A class extending Texture allowing drawing on a texture
  124997. * @see https://doc.babylonjs.com/how_to/dynamictexture
  124998. */
  124999. export class DynamicTexture extends Texture {
  125000. private _generateMipMaps;
  125001. private _canvas;
  125002. private _context;
  125003. /**
  125004. * Creates a DynamicTexture
  125005. * @param name defines the name of the texture
  125006. * @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
  125007. * @param scene defines the scene where you want the texture
  125008. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  125009. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125010. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  125011. */
  125012. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  125013. /**
  125014. * Get the current class name of the texture useful for serialization or dynamic coding.
  125015. * @returns "DynamicTexture"
  125016. */
  125017. getClassName(): string;
  125018. /**
  125019. * Gets the current state of canRescale
  125020. */
  125021. get canRescale(): boolean;
  125022. private _recreate;
  125023. /**
  125024. * Scales the texture
  125025. * @param ratio the scale factor to apply to both width and height
  125026. */
  125027. scale(ratio: number): void;
  125028. /**
  125029. * Resizes the texture
  125030. * @param width the new width
  125031. * @param height the new height
  125032. */
  125033. scaleTo(width: number, height: number): void;
  125034. /**
  125035. * Gets the context of the canvas used by the texture
  125036. * @returns the canvas context of the dynamic texture
  125037. */
  125038. getContext(): CanvasRenderingContext2D;
  125039. /**
  125040. * Clears the texture
  125041. */
  125042. clear(): void;
  125043. /**
  125044. * Updates the texture
  125045. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  125046. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  125047. */
  125048. update(invertY?: boolean, premulAlpha?: boolean): void;
  125049. /**
  125050. * Draws text onto the texture
  125051. * @param text defines the text to be drawn
  125052. * @param x defines the placement of the text from the left
  125053. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  125054. * @param font defines the font to be used with font-style, font-size, font-name
  125055. * @param color defines the color used for the text
  125056. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  125057. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  125058. * @param update defines whether texture is immediately update (default is true)
  125059. */
  125060. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  125061. /**
  125062. * Clones the texture
  125063. * @returns the clone of the texture.
  125064. */
  125065. clone(): DynamicTexture;
  125066. /**
  125067. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  125068. * @returns a serialized dynamic texture object
  125069. */
  125070. serialize(): any;
  125071. private _IsCanvasElement;
  125072. /** @hidden */
  125073. _rebuild(): void;
  125074. }
  125075. }
  125076. declare module BABYLON {
  125077. /**
  125078. * Class containing static functions to help procedurally build meshes
  125079. */
  125080. export class GroundBuilder {
  125081. /**
  125082. * Creates a ground mesh
  125083. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  125084. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  125085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125086. * @param name defines the name of the mesh
  125087. * @param options defines the options used to create the mesh
  125088. * @param scene defines the hosting scene
  125089. * @returns the ground mesh
  125090. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  125091. */
  125092. static CreateGround(name: string, options: {
  125093. width?: number;
  125094. height?: number;
  125095. subdivisions?: number;
  125096. subdivisionsX?: number;
  125097. subdivisionsY?: number;
  125098. updatable?: boolean;
  125099. }, scene: any): Mesh;
  125100. /**
  125101. * Creates a tiled ground mesh
  125102. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  125103. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  125104. * * 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
  125105. * * 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
  125106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125107. * @param name defines the name of the mesh
  125108. * @param options defines the options used to create the mesh
  125109. * @param scene defines the hosting scene
  125110. * @returns the tiled ground mesh
  125111. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  125112. */
  125113. static CreateTiledGround(name: string, options: {
  125114. xmin: number;
  125115. zmin: number;
  125116. xmax: number;
  125117. zmax: number;
  125118. subdivisions?: {
  125119. w: number;
  125120. h: number;
  125121. };
  125122. precision?: {
  125123. w: number;
  125124. h: number;
  125125. };
  125126. updatable?: boolean;
  125127. }, scene?: Nullable<Scene>): Mesh;
  125128. /**
  125129. * Creates a ground mesh from a height map
  125130. * * The parameter `url` sets the URL of the height map image resource.
  125131. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  125132. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  125133. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  125134. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  125135. * * 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.
  125136. * * 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).
  125137. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  125138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125139. * @param name defines the name of the mesh
  125140. * @param url defines the url to the height map
  125141. * @param options defines the options used to create the mesh
  125142. * @param scene defines the hosting scene
  125143. * @returns the ground mesh
  125144. * @see https://doc.babylonjs.com/babylon101/height_map
  125145. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  125146. */
  125147. static CreateGroundFromHeightMap(name: string, url: string, options: {
  125148. width?: number;
  125149. height?: number;
  125150. subdivisions?: number;
  125151. minHeight?: number;
  125152. maxHeight?: number;
  125153. colorFilter?: Color3;
  125154. alphaFilter?: number;
  125155. updatable?: boolean;
  125156. onReady?: (mesh: GroundMesh) => void;
  125157. }, scene?: Nullable<Scene>): GroundMesh;
  125158. }
  125159. }
  125160. declare module BABYLON {
  125161. /**
  125162. * Class containing static functions to help procedurally build meshes
  125163. */
  125164. export class TorusBuilder {
  125165. /**
  125166. * Creates a torus mesh
  125167. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125168. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125169. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125173. * @param name defines the name of the mesh
  125174. * @param options defines the options used to create the mesh
  125175. * @param scene defines the hosting scene
  125176. * @returns the torus mesh
  125177. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125178. */
  125179. static CreateTorus(name: string, options: {
  125180. diameter?: number;
  125181. thickness?: number;
  125182. tessellation?: number;
  125183. updatable?: boolean;
  125184. sideOrientation?: number;
  125185. frontUVs?: Vector4;
  125186. backUVs?: Vector4;
  125187. }, scene: any): Mesh;
  125188. }
  125189. }
  125190. declare module BABYLON {
  125191. /**
  125192. * Class containing static functions to help procedurally build meshes
  125193. */
  125194. export class CylinderBuilder {
  125195. /**
  125196. * Creates a cylinder or a cone mesh
  125197. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125198. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125199. * * 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.
  125200. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125201. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125202. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125203. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125204. * * 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).
  125205. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125206. * * 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).
  125207. * * 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
  125208. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125209. * * 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
  125210. * * 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.
  125211. * * If `enclose` is false, a ring surface is one element.
  125212. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125213. * * 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
  125214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125217. * @param name defines the name of the mesh
  125218. * @param options defines the options used to create the mesh
  125219. * @param scene defines the hosting scene
  125220. * @returns the cylinder mesh
  125221. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125222. */
  125223. static CreateCylinder(name: string, options: {
  125224. height?: number;
  125225. diameterTop?: number;
  125226. diameterBottom?: number;
  125227. diameter?: number;
  125228. tessellation?: number;
  125229. subdivisions?: number;
  125230. arc?: number;
  125231. faceColors?: Color4[];
  125232. faceUV?: Vector4[];
  125233. updatable?: boolean;
  125234. hasRings?: boolean;
  125235. enclose?: boolean;
  125236. cap?: number;
  125237. sideOrientation?: number;
  125238. frontUVs?: Vector4;
  125239. backUVs?: Vector4;
  125240. }, scene: any): Mesh;
  125241. }
  125242. }
  125243. declare module BABYLON {
  125244. /**
  125245. * States of the webXR experience
  125246. */
  125247. export enum WebXRState {
  125248. /**
  125249. * Transitioning to being in XR mode
  125250. */
  125251. ENTERING_XR = 0,
  125252. /**
  125253. * Transitioning to non XR mode
  125254. */
  125255. EXITING_XR = 1,
  125256. /**
  125257. * In XR mode and presenting
  125258. */
  125259. IN_XR = 2,
  125260. /**
  125261. * Not entered XR mode
  125262. */
  125263. NOT_IN_XR = 3
  125264. }
  125265. /**
  125266. * Abstraction of the XR render target
  125267. */
  125268. export interface WebXRRenderTarget extends IDisposable {
  125269. /**
  125270. * xrpresent context of the canvas which can be used to display/mirror xr content
  125271. */
  125272. canvasContext: WebGLRenderingContext;
  125273. /**
  125274. * xr layer for the canvas
  125275. */
  125276. xrLayer: Nullable<XRWebGLLayer>;
  125277. /**
  125278. * Initializes the xr layer for the session
  125279. * @param xrSession xr session
  125280. * @returns a promise that will resolve once the XR Layer has been created
  125281. */
  125282. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  125283. }
  125284. }
  125285. declare module BABYLON {
  125286. /**
  125287. * COnfiguration object for WebXR output canvas
  125288. */
  125289. export class WebXRManagedOutputCanvasOptions {
  125290. /**
  125291. * An optional canvas in case you wish to create it yourself and provide it here.
  125292. * If not provided, a new canvas will be created
  125293. */
  125294. canvasElement?: HTMLCanvasElement;
  125295. /**
  125296. * Options for this XR Layer output
  125297. */
  125298. canvasOptions?: XRWebGLLayerOptions;
  125299. /**
  125300. * CSS styling for a newly created canvas (if not provided)
  125301. */
  125302. newCanvasCssStyle?: string;
  125303. /**
  125304. * Get the default values of the configuration object
  125305. * @returns default values of this configuration object
  125306. */
  125307. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  125308. }
  125309. /**
  125310. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  125311. */
  125312. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  125313. private _options;
  125314. private _canvas;
  125315. private _engine;
  125316. private _originalCanvasSize;
  125317. /**
  125318. * Rendering context of the canvas which can be used to display/mirror xr content
  125319. */
  125320. canvasContext: WebGLRenderingContext;
  125321. /**
  125322. * xr layer for the canvas
  125323. */
  125324. xrLayer: Nullable<XRWebGLLayer>;
  125325. /**
  125326. * Obseervers registered here will be triggered when the xr layer was initialized
  125327. */
  125328. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  125329. /**
  125330. * Initializes the canvas to be added/removed upon entering/exiting xr
  125331. * @param _xrSessionManager The XR Session manager
  125332. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  125333. */
  125334. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  125335. /**
  125336. * Disposes of the object
  125337. */
  125338. dispose(): void;
  125339. /**
  125340. * Initializes the xr layer for the session
  125341. * @param xrSession xr session
  125342. * @returns a promise that will resolve once the XR Layer has been created
  125343. */
  125344. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  125345. private _addCanvas;
  125346. private _removeCanvas;
  125347. private _setCanvasSize;
  125348. private _setManagedOutputCanvas;
  125349. }
  125350. }
  125351. declare module BABYLON {
  125352. /**
  125353. * Manages an XRSession to work with Babylon's engine
  125354. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  125355. */
  125356. export class WebXRSessionManager implements IDisposable {
  125357. /** The scene which the session should be created for */
  125358. scene: Scene;
  125359. private _referenceSpace;
  125360. private _rttProvider;
  125361. private _sessionEnded;
  125362. private _xrNavigator;
  125363. private baseLayer;
  125364. /**
  125365. * The base reference space from which the session started. good if you want to reset your
  125366. * reference space
  125367. */
  125368. baseReferenceSpace: XRReferenceSpace;
  125369. /**
  125370. * Current XR frame
  125371. */
  125372. currentFrame: Nullable<XRFrame>;
  125373. /** WebXR timestamp updated every frame */
  125374. currentTimestamp: number;
  125375. /**
  125376. * Used just in case of a failure to initialize an immersive session.
  125377. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  125378. */
  125379. defaultHeightCompensation: number;
  125380. /**
  125381. * Fires every time a new xrFrame arrives which can be used to update the camera
  125382. */
  125383. onXRFrameObservable: Observable<XRFrame>;
  125384. /**
  125385. * Fires when the reference space changed
  125386. */
  125387. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  125388. /**
  125389. * Fires when the xr session is ended either by the device or manually done
  125390. */
  125391. onXRSessionEnded: Observable<any>;
  125392. /**
  125393. * Fires when the xr session is ended either by the device or manually done
  125394. */
  125395. onXRSessionInit: Observable<XRSession>;
  125396. /**
  125397. * Underlying xr session
  125398. */
  125399. session: XRSession;
  125400. /**
  125401. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  125402. * or get the offset the player is currently at.
  125403. */
  125404. viewerReferenceSpace: XRReferenceSpace;
  125405. /**
  125406. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  125407. * @param scene The scene which the session should be created for
  125408. */
  125409. constructor(
  125410. /** The scene which the session should be created for */
  125411. scene: Scene);
  125412. /**
  125413. * The current reference space used in this session. This reference space can constantly change!
  125414. * It is mainly used to offset the camera's position.
  125415. */
  125416. get referenceSpace(): XRReferenceSpace;
  125417. /**
  125418. * Set a new reference space and triggers the observable
  125419. */
  125420. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  125421. /**
  125422. * Disposes of the session manager
  125423. */
  125424. dispose(): void;
  125425. /**
  125426. * Stops the xrSession and restores the render loop
  125427. * @returns Promise which resolves after it exits XR
  125428. */
  125429. exitXRAsync(): Promise<void>;
  125430. /**
  125431. * Gets the correct render target texture to be rendered this frame for this eye
  125432. * @param eye the eye for which to get the render target
  125433. * @returns the render target for the specified eye
  125434. */
  125435. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  125436. /**
  125437. * Creates a WebXRRenderTarget object for the XR session
  125438. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  125439. * @param options optional options to provide when creating a new render target
  125440. * @returns a WebXR render target to which the session can render
  125441. */
  125442. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  125443. /**
  125444. * Initializes the manager
  125445. * After initialization enterXR can be called to start an XR session
  125446. * @returns Promise which resolves after it is initialized
  125447. */
  125448. initializeAsync(): Promise<void>;
  125449. /**
  125450. * Initializes an xr session
  125451. * @param xrSessionMode mode to initialize
  125452. * @param xrSessionInit defines optional and required values to pass to the session builder
  125453. * @returns a promise which will resolve once the session has been initialized
  125454. */
  125455. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  125456. /**
  125457. * Checks if a session would be supported for the creation options specified
  125458. * @param sessionMode session mode to check if supported eg. immersive-vr
  125459. * @returns A Promise that resolves to true if supported and false if not
  125460. */
  125461. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  125462. /**
  125463. * Resets the reference space to the one started the session
  125464. */
  125465. resetReferenceSpace(): void;
  125466. /**
  125467. * Starts rendering to the xr layer
  125468. */
  125469. runXRRenderLoop(): void;
  125470. /**
  125471. * Sets the reference space on the xr session
  125472. * @param referenceSpaceType space to set
  125473. * @returns a promise that will resolve once the reference space has been set
  125474. */
  125475. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  125476. /**
  125477. * Updates the render state of the session
  125478. * @param state state to set
  125479. * @returns a promise that resolves once the render state has been updated
  125480. */
  125481. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  125482. /**
  125483. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  125484. * @param sessionMode defines the session to test
  125485. * @returns a promise with boolean as final value
  125486. */
  125487. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  125488. private _createRenderTargetTexture;
  125489. }
  125490. }
  125491. declare module BABYLON {
  125492. /**
  125493. * WebXR Camera which holds the views for the xrSession
  125494. * @see https://doc.babylonjs.com/how_to/webxr_camera
  125495. */
  125496. export class WebXRCamera extends FreeCamera {
  125497. private _xrSessionManager;
  125498. private _firstFrame;
  125499. private _referenceQuaternion;
  125500. private _referencedPosition;
  125501. private _xrInvPositionCache;
  125502. private _xrInvQuaternionCache;
  125503. /**
  125504. * Should position compensation execute on first frame.
  125505. * This is used when copying the position from a native (non XR) camera
  125506. */
  125507. compensateOnFirstFrame: boolean;
  125508. /**
  125509. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  125510. * @param name the name of the camera
  125511. * @param scene the scene to add the camera to
  125512. * @param _xrSessionManager a constructed xr session manager
  125513. */
  125514. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  125515. /**
  125516. * Return the user's height, unrelated to the current ground.
  125517. * This will be the y position of this camera, when ground level is 0.
  125518. */
  125519. get realWorldHeight(): number;
  125520. /** @hidden */
  125521. _updateForDualEyeDebugging(): void;
  125522. /**
  125523. * Sets this camera's transformation based on a non-vr camera
  125524. * @param otherCamera the non-vr camera to copy the transformation from
  125525. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  125526. */
  125527. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  125528. /**
  125529. * Gets the current instance class name ("WebXRCamera").
  125530. * @returns the class name
  125531. */
  125532. getClassName(): string;
  125533. private _rotate180;
  125534. private _updateFromXRSession;
  125535. private _updateNumberOfRigCameras;
  125536. private _updateReferenceSpace;
  125537. private _updateReferenceSpaceOffset;
  125538. }
  125539. }
  125540. declare module BABYLON {
  125541. /**
  125542. * Defining the interface required for a (webxr) feature
  125543. */
  125544. export interface IWebXRFeature extends IDisposable {
  125545. /**
  125546. * Is this feature attached
  125547. */
  125548. attached: boolean;
  125549. /**
  125550. * Should auto-attach be disabled?
  125551. */
  125552. disableAutoAttach: boolean;
  125553. /**
  125554. * Attach the feature to the session
  125555. * Will usually be called by the features manager
  125556. *
  125557. * @param force should attachment be forced (even when already attached)
  125558. * @returns true if successful.
  125559. */
  125560. attach(force?: boolean): boolean;
  125561. /**
  125562. * Detach the feature from the session
  125563. * Will usually be called by the features manager
  125564. *
  125565. * @returns true if successful.
  125566. */
  125567. detach(): boolean;
  125568. /**
  125569. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  125570. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  125571. *
  125572. * @returns whether or not the feature is compatible in this environment
  125573. */
  125574. isCompatible(): boolean;
  125575. /**
  125576. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  125577. */
  125578. xrNativeFeatureName?: string;
  125579. }
  125580. /**
  125581. * A list of the currently available features without referencing them
  125582. */
  125583. export class WebXRFeatureName {
  125584. /**
  125585. * The name of the anchor system feature
  125586. */
  125587. static ANCHOR_SYSTEM: string;
  125588. /**
  125589. * The name of the background remover feature
  125590. */
  125591. static BACKGROUND_REMOVER: string;
  125592. /**
  125593. * The name of the hit test feature
  125594. */
  125595. static HIT_TEST: string;
  125596. /**
  125597. * physics impostors for xr controllers feature
  125598. */
  125599. static PHYSICS_CONTROLLERS: string;
  125600. /**
  125601. * The name of the plane detection feature
  125602. */
  125603. static PLANE_DETECTION: string;
  125604. /**
  125605. * The name of the pointer selection feature
  125606. */
  125607. static POINTER_SELECTION: string;
  125608. /**
  125609. * The name of the teleportation feature
  125610. */
  125611. static TELEPORTATION: string;
  125612. }
  125613. /**
  125614. * Defining the constructor of a feature. Used to register the modules.
  125615. */
  125616. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  125617. /**
  125618. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  125619. * It is mainly used in AR sessions.
  125620. *
  125621. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  125622. */
  125623. export class WebXRFeaturesManager implements IDisposable {
  125624. private _xrSessionManager;
  125625. private static readonly _AvailableFeatures;
  125626. private _features;
  125627. /**
  125628. * constructs a new features manages.
  125629. *
  125630. * @param _xrSessionManager an instance of WebXRSessionManager
  125631. */
  125632. constructor(_xrSessionManager: WebXRSessionManager);
  125633. /**
  125634. * Used to register a module. After calling this function a developer can use this feature in the scene.
  125635. * Mainly used internally.
  125636. *
  125637. * @param featureName the name of the feature to register
  125638. * @param constructorFunction the function used to construct the module
  125639. * @param version the (babylon) version of the module
  125640. * @param stable is that a stable version of this module
  125641. */
  125642. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  125643. /**
  125644. * Returns a constructor of a specific feature.
  125645. *
  125646. * @param featureName the name of the feature to construct
  125647. * @param version the version of the feature to load
  125648. * @param xrSessionManager the xrSessionManager. Used to construct the module
  125649. * @param options optional options provided to the module.
  125650. * @returns a function that, when called, will return a new instance of this feature
  125651. */
  125652. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  125653. /**
  125654. * Can be used to return the list of features currently registered
  125655. *
  125656. * @returns an Array of available features
  125657. */
  125658. static GetAvailableFeatures(): string[];
  125659. /**
  125660. * Gets the versions available for a specific feature
  125661. * @param featureName the name of the feature
  125662. * @returns an array with the available versions
  125663. */
  125664. static GetAvailableVersions(featureName: string): string[];
  125665. /**
  125666. * Return the latest unstable version of this feature
  125667. * @param featureName the name of the feature to search
  125668. * @returns the version number. if not found will return -1
  125669. */
  125670. static GetLatestVersionOfFeature(featureName: string): number;
  125671. /**
  125672. * Return the latest stable version of this feature
  125673. * @param featureName the name of the feature to search
  125674. * @returns the version number. if not found will return -1
  125675. */
  125676. static GetStableVersionOfFeature(featureName: string): number;
  125677. /**
  125678. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  125679. * Can be used during a session to start a feature
  125680. * @param featureName the name of feature to attach
  125681. */
  125682. attachFeature(featureName: string): void;
  125683. /**
  125684. * Can be used inside a session or when the session ends to detach a specific feature
  125685. * @param featureName the name of the feature to detach
  125686. */
  125687. detachFeature(featureName: string): void;
  125688. /**
  125689. * Used to disable an already-enabled feature
  125690. * The feature will be disposed and will be recreated once enabled.
  125691. * @param featureName the feature to disable
  125692. * @returns true if disable was successful
  125693. */
  125694. disableFeature(featureName: string | {
  125695. Name: string;
  125696. }): boolean;
  125697. /**
  125698. * dispose this features manager
  125699. */
  125700. dispose(): void;
  125701. /**
  125702. * 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.
  125703. * 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.
  125704. *
  125705. * @param featureName the name of the feature to load or the class of the feature
  125706. * @param version optional version to load. if not provided the latest version will be enabled
  125707. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  125708. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  125709. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  125710. * @returns a new constructed feature or throws an error if feature not found.
  125711. */
  125712. enableFeature(featureName: string | {
  125713. Name: string;
  125714. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  125715. /**
  125716. * get the implementation of an enabled feature.
  125717. * @param featureName the name of the feature to load
  125718. * @returns the feature class, if found
  125719. */
  125720. getEnabledFeature(featureName: string): IWebXRFeature;
  125721. /**
  125722. * Get the list of enabled features
  125723. * @returns an array of enabled features
  125724. */
  125725. getEnabledFeatures(): string[];
  125726. /**
  125727. * This function will exten the session creation configuration object with enabled features.
  125728. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  125729. * according to the defined "required" variable, provided during enableFeature call
  125730. * @param xrSessionInit the xr Session init object to extend
  125731. *
  125732. * @returns an extended XRSessionInit object
  125733. */
  125734. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  125735. }
  125736. }
  125737. declare module BABYLON {
  125738. /**
  125739. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  125740. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  125741. */
  125742. export class WebXRExperienceHelper implements IDisposable {
  125743. private scene;
  125744. private _nonVRCamera;
  125745. private _originalSceneAutoClear;
  125746. private _supported;
  125747. /**
  125748. * Camera used to render xr content
  125749. */
  125750. camera: WebXRCamera;
  125751. /** A features manager for this xr session */
  125752. featuresManager: WebXRFeaturesManager;
  125753. /**
  125754. * Observers registered here will be triggered after the camera's initial transformation is set
  125755. * This can be used to set a different ground level or an extra rotation.
  125756. *
  125757. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  125758. * to the position set after this observable is done executing.
  125759. */
  125760. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  125761. /**
  125762. * Fires when the state of the experience helper has changed
  125763. */
  125764. onStateChangedObservable: Observable<WebXRState>;
  125765. /** Session manager used to keep track of xr session */
  125766. sessionManager: WebXRSessionManager;
  125767. /**
  125768. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  125769. */
  125770. state: WebXRState;
  125771. /**
  125772. * Creates a WebXRExperienceHelper
  125773. * @param scene The scene the helper should be created in
  125774. */
  125775. private constructor();
  125776. /**
  125777. * Creates the experience helper
  125778. * @param scene the scene to attach the experience helper to
  125779. * @returns a promise for the experience helper
  125780. */
  125781. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  125782. /**
  125783. * Disposes of the experience helper
  125784. */
  125785. dispose(): void;
  125786. /**
  125787. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  125788. * @param sessionMode options for the XR session
  125789. * @param referenceSpaceType frame of reference of the XR session
  125790. * @param renderTarget the output canvas that will be used to enter XR mode
  125791. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  125792. * @returns promise that resolves after xr mode has entered
  125793. */
  125794. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  125795. /**
  125796. * Exits XR mode and returns the scene to its original state
  125797. * @returns promise that resolves after xr mode has exited
  125798. */
  125799. exitXRAsync(): Promise<void>;
  125800. private _nonXRToXRCamera;
  125801. private _setState;
  125802. }
  125803. }
  125804. declare module BABYLON {
  125805. /**
  125806. * X-Y values for axes in WebXR
  125807. */
  125808. export interface IWebXRMotionControllerAxesValue {
  125809. /**
  125810. * The value of the x axis
  125811. */
  125812. x: number;
  125813. /**
  125814. * The value of the y-axis
  125815. */
  125816. y: number;
  125817. }
  125818. /**
  125819. * changed / previous values for the values of this component
  125820. */
  125821. export interface IWebXRMotionControllerComponentChangesValues<T> {
  125822. /**
  125823. * current (this frame) value
  125824. */
  125825. current: T;
  125826. /**
  125827. * previous (last change) value
  125828. */
  125829. previous: T;
  125830. }
  125831. /**
  125832. * Represents changes in the component between current frame and last values recorded
  125833. */
  125834. export interface IWebXRMotionControllerComponentChanges {
  125835. /**
  125836. * will be populated with previous and current values if axes changed
  125837. */
  125838. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  125839. /**
  125840. * will be populated with previous and current values if pressed changed
  125841. */
  125842. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  125843. /**
  125844. * will be populated with previous and current values if touched changed
  125845. */
  125846. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  125847. /**
  125848. * will be populated with previous and current values if value changed
  125849. */
  125850. value?: IWebXRMotionControllerComponentChangesValues<number>;
  125851. }
  125852. /**
  125853. * This class represents a single component (for example button or thumbstick) of a motion controller
  125854. */
  125855. export class WebXRControllerComponent implements IDisposable {
  125856. /**
  125857. * the id of this component
  125858. */
  125859. id: string;
  125860. /**
  125861. * the type of the component
  125862. */
  125863. type: MotionControllerComponentType;
  125864. private _buttonIndex;
  125865. private _axesIndices;
  125866. private _axes;
  125867. private _changes;
  125868. private _currentValue;
  125869. private _hasChanges;
  125870. private _pressed;
  125871. private _touched;
  125872. /**
  125873. * button component type
  125874. */
  125875. static BUTTON_TYPE: MotionControllerComponentType;
  125876. /**
  125877. * squeeze component type
  125878. */
  125879. static SQUEEZE_TYPE: MotionControllerComponentType;
  125880. /**
  125881. * Thumbstick component type
  125882. */
  125883. static THUMBSTICK_TYPE: MotionControllerComponentType;
  125884. /**
  125885. * Touchpad component type
  125886. */
  125887. static TOUCHPAD_TYPE: MotionControllerComponentType;
  125888. /**
  125889. * trigger component type
  125890. */
  125891. static TRIGGER_TYPE: MotionControllerComponentType;
  125892. /**
  125893. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  125894. * the axes data changes
  125895. */
  125896. onAxisValueChangedObservable: Observable<{
  125897. x: number;
  125898. y: number;
  125899. }>;
  125900. /**
  125901. * Observers registered here will be triggered when the state of a button changes
  125902. * State change is either pressed / touched / value
  125903. */
  125904. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  125905. /**
  125906. * Creates a new component for a motion controller.
  125907. * It is created by the motion controller itself
  125908. *
  125909. * @param id the id of this component
  125910. * @param type the type of the component
  125911. * @param _buttonIndex index in the buttons array of the gamepad
  125912. * @param _axesIndices indices of the values in the axes array of the gamepad
  125913. */
  125914. constructor(
  125915. /**
  125916. * the id of this component
  125917. */
  125918. id: string,
  125919. /**
  125920. * the type of the component
  125921. */
  125922. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  125923. /**
  125924. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  125925. */
  125926. get axes(): IWebXRMotionControllerAxesValue;
  125927. /**
  125928. * Get the changes. Elements will be populated only if they changed with their previous and current value
  125929. */
  125930. get changes(): IWebXRMotionControllerComponentChanges;
  125931. /**
  125932. * Return whether or not the component changed the last frame
  125933. */
  125934. get hasChanges(): boolean;
  125935. /**
  125936. * is the button currently pressed
  125937. */
  125938. get pressed(): boolean;
  125939. /**
  125940. * is the button currently touched
  125941. */
  125942. get touched(): boolean;
  125943. /**
  125944. * Get the current value of this component
  125945. */
  125946. get value(): number;
  125947. /**
  125948. * Dispose this component
  125949. */
  125950. dispose(): void;
  125951. /**
  125952. * Are there axes correlating to this component
  125953. * @return true is axes data is available
  125954. */
  125955. isAxes(): boolean;
  125956. /**
  125957. * Is this component a button (hence - pressable)
  125958. * @returns true if can be pressed
  125959. */
  125960. isButton(): boolean;
  125961. /**
  125962. * update this component using the gamepad object it is in. Called on every frame
  125963. * @param nativeController the native gamepad controller object
  125964. */
  125965. update(nativeController: IMinimalMotionControllerObject): void;
  125966. }
  125967. }
  125968. declare module BABYLON {
  125969. /**
  125970. * Interface used to represent data loading progression
  125971. */
  125972. export interface ISceneLoaderProgressEvent {
  125973. /**
  125974. * Defines if data length to load can be evaluated
  125975. */
  125976. readonly lengthComputable: boolean;
  125977. /**
  125978. * Defines the loaded data length
  125979. */
  125980. readonly loaded: number;
  125981. /**
  125982. * Defines the data length to load
  125983. */
  125984. readonly total: number;
  125985. }
  125986. /**
  125987. * Interface used by SceneLoader plugins to define supported file extensions
  125988. */
  125989. export interface ISceneLoaderPluginExtensions {
  125990. /**
  125991. * Defines the list of supported extensions
  125992. */
  125993. [extension: string]: {
  125994. isBinary: boolean;
  125995. };
  125996. }
  125997. /**
  125998. * Interface used by SceneLoader plugin factory
  125999. */
  126000. export interface ISceneLoaderPluginFactory {
  126001. /**
  126002. * Defines the name of the factory
  126003. */
  126004. name: string;
  126005. /**
  126006. * Function called to create a new plugin
  126007. * @return the new plugin
  126008. */
  126009. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  126010. /**
  126011. * The callback that returns true if the data can be directly loaded.
  126012. * @param data string containing the file data
  126013. * @returns if the data can be loaded directly
  126014. */
  126015. canDirectLoad?(data: string): boolean;
  126016. }
  126017. /**
  126018. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  126019. */
  126020. export interface ISceneLoaderPluginBase {
  126021. /**
  126022. * The friendly name of this plugin.
  126023. */
  126024. name: string;
  126025. /**
  126026. * The file extensions supported by this plugin.
  126027. */
  126028. extensions: string | ISceneLoaderPluginExtensions;
  126029. /**
  126030. * The callback called when loading from a url.
  126031. * @param scene scene loading this url
  126032. * @param url url to load
  126033. * @param onSuccess callback called when the file successfully loads
  126034. * @param onProgress callback called while file is loading (if the server supports this mode)
  126035. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  126036. * @param onError callback called when the file fails to load
  126037. * @returns a file request object
  126038. */
  126039. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  126040. /**
  126041. * The callback called when loading from a file object.
  126042. * @param scene scene loading this file
  126043. * @param file defines the file to load
  126044. * @param onSuccess defines the callback to call when data is loaded
  126045. * @param onProgress defines the callback to call during loading process
  126046. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  126047. * @param onError defines the callback to call when an error occurs
  126048. * @returns a file request object
  126049. */
  126050. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  126051. /**
  126052. * The callback that returns true if the data can be directly loaded.
  126053. * @param data string containing the file data
  126054. * @returns if the data can be loaded directly
  126055. */
  126056. canDirectLoad?(data: string): boolean;
  126057. /**
  126058. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  126059. * @param scene scene loading this data
  126060. * @param data string containing the data
  126061. * @returns data to pass to the plugin
  126062. */
  126063. directLoad?(scene: Scene, data: string): any;
  126064. /**
  126065. * The callback that allows custom handling of the root url based on the response url.
  126066. * @param rootUrl the original root url
  126067. * @param responseURL the response url if available
  126068. * @returns the new root url
  126069. */
  126070. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  126071. }
  126072. /**
  126073. * Interface used to define a SceneLoader plugin
  126074. */
  126075. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  126076. /**
  126077. * Import meshes into a scene.
  126078. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126079. * @param scene The scene to import into
  126080. * @param data The data to import
  126081. * @param rootUrl The root url for scene and resources
  126082. * @param meshes The meshes array to import into
  126083. * @param particleSystems The particle systems array to import into
  126084. * @param skeletons The skeletons array to import into
  126085. * @param onError The callback when import fails
  126086. * @returns True if successful or false otherwise
  126087. */
  126088. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  126089. /**
  126090. * Load into a scene.
  126091. * @param scene The scene to load into
  126092. * @param data The data to import
  126093. * @param rootUrl The root url for scene and resources
  126094. * @param onError The callback when import fails
  126095. * @returns True if successful or false otherwise
  126096. */
  126097. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  126098. /**
  126099. * Load into an asset container.
  126100. * @param scene The scene to load into
  126101. * @param data The data to import
  126102. * @param rootUrl The root url for scene and resources
  126103. * @param onError The callback when import fails
  126104. * @returns The loaded asset container
  126105. */
  126106. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  126107. }
  126108. /**
  126109. * Interface used to define an async SceneLoader plugin
  126110. */
  126111. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  126112. /**
  126113. * Import meshes into a scene.
  126114. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126115. * @param scene The scene to import into
  126116. * @param data The data to import
  126117. * @param rootUrl The root url for scene and resources
  126118. * @param onProgress The callback when the load progresses
  126119. * @param fileName Defines the name of the file to load
  126120. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  126121. */
  126122. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  126123. meshes: AbstractMesh[];
  126124. particleSystems: IParticleSystem[];
  126125. skeletons: Skeleton[];
  126126. animationGroups: AnimationGroup[];
  126127. }>;
  126128. /**
  126129. * Load into a scene.
  126130. * @param scene The scene to load into
  126131. * @param data The data to import
  126132. * @param rootUrl The root url for scene and resources
  126133. * @param onProgress The callback when the load progresses
  126134. * @param fileName Defines the name of the file to load
  126135. * @returns Nothing
  126136. */
  126137. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  126138. /**
  126139. * Load into an asset container.
  126140. * @param scene The scene to load into
  126141. * @param data The data to import
  126142. * @param rootUrl The root url for scene and resources
  126143. * @param onProgress The callback when the load progresses
  126144. * @param fileName Defines the name of the file to load
  126145. * @returns The loaded asset container
  126146. */
  126147. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  126148. }
  126149. /**
  126150. * Mode that determines how to handle old animation groups before loading new ones.
  126151. */
  126152. export enum SceneLoaderAnimationGroupLoadingMode {
  126153. /**
  126154. * Reset all old animations to initial state then dispose them.
  126155. */
  126156. Clean = 0,
  126157. /**
  126158. * Stop all old animations.
  126159. */
  126160. Stop = 1,
  126161. /**
  126162. * Restart old animations from first frame.
  126163. */
  126164. Sync = 2,
  126165. /**
  126166. * Old animations remains untouched.
  126167. */
  126168. NoSync = 3
  126169. }
  126170. /**
  126171. * Defines a plugin registered by the SceneLoader
  126172. */
  126173. interface IRegisteredPlugin {
  126174. /**
  126175. * Defines the plugin to use
  126176. */
  126177. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  126178. /**
  126179. * Defines if the plugin supports binary data
  126180. */
  126181. isBinary: boolean;
  126182. }
  126183. /**
  126184. * Class used to load scene from various file formats using registered plugins
  126185. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  126186. */
  126187. export class SceneLoader {
  126188. /**
  126189. * No logging while loading
  126190. */
  126191. static readonly NO_LOGGING: number;
  126192. /**
  126193. * Minimal logging while loading
  126194. */
  126195. static readonly MINIMAL_LOGGING: number;
  126196. /**
  126197. * Summary logging while loading
  126198. */
  126199. static readonly SUMMARY_LOGGING: number;
  126200. /**
  126201. * Detailled logging while loading
  126202. */
  126203. static readonly DETAILED_LOGGING: number;
  126204. /**
  126205. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  126206. */
  126207. static get ForceFullSceneLoadingForIncremental(): boolean;
  126208. static set ForceFullSceneLoadingForIncremental(value: boolean);
  126209. /**
  126210. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  126211. */
  126212. static get ShowLoadingScreen(): boolean;
  126213. static set ShowLoadingScreen(value: boolean);
  126214. /**
  126215. * Defines the current logging level (while loading the scene)
  126216. * @ignorenaming
  126217. */
  126218. static get loggingLevel(): number;
  126219. static set loggingLevel(value: number);
  126220. /**
  126221. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  126222. */
  126223. static get CleanBoneMatrixWeights(): boolean;
  126224. static set CleanBoneMatrixWeights(value: boolean);
  126225. /**
  126226. * Event raised when a plugin is used to load a scene
  126227. */
  126228. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  126229. private static _registeredPlugins;
  126230. private static _showingLoadingScreen;
  126231. /**
  126232. * Gets the default plugin (used to load Babylon files)
  126233. * @returns the .babylon plugin
  126234. */
  126235. static GetDefaultPlugin(): IRegisteredPlugin;
  126236. private static _GetPluginForExtension;
  126237. private static _GetPluginForDirectLoad;
  126238. private static _GetPluginForFilename;
  126239. private static _GetDirectLoad;
  126240. private static _LoadData;
  126241. private static _GetFileInfo;
  126242. /**
  126243. * Gets a plugin that can load the given extension
  126244. * @param extension defines the extension to load
  126245. * @returns a plugin or null if none works
  126246. */
  126247. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  126248. /**
  126249. * Gets a boolean indicating that the given extension can be loaded
  126250. * @param extension defines the extension to load
  126251. * @returns true if the extension is supported
  126252. */
  126253. static IsPluginForExtensionAvailable(extension: string): boolean;
  126254. /**
  126255. * Adds a new plugin to the list of registered plugins
  126256. * @param plugin defines the plugin to add
  126257. */
  126258. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  126259. /**
  126260. * Import meshes into a scene
  126261. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126262. * @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)
  126263. * @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)
  126264. * @param scene the instance of BABYLON.Scene to append to
  126265. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  126266. * @param onProgress a callback with a progress event for each file being loaded
  126267. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126268. * @param pluginExtension the extension used to determine the plugin
  126269. * @returns The loaded plugin
  126270. */
  126271. 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>;
  126272. /**
  126273. * Import meshes into a scene
  126274. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126275. * @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)
  126276. * @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)
  126277. * @param scene the instance of BABYLON.Scene to append to
  126278. * @param onProgress a callback with a progress event for each file being loaded
  126279. * @param pluginExtension the extension used to determine the plugin
  126280. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  126281. */
  126282. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  126283. meshes: AbstractMesh[];
  126284. particleSystems: IParticleSystem[];
  126285. skeletons: Skeleton[];
  126286. animationGroups: AnimationGroup[];
  126287. }>;
  126288. /**
  126289. * Load a scene
  126290. * @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)
  126291. * @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)
  126292. * @param engine is the instance of BABYLON.Engine to use to create the scene
  126293. * @param onSuccess a callback with the scene when import succeeds
  126294. * @param onProgress a callback with a progress event for each file being loaded
  126295. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126296. * @param pluginExtension the extension used to determine the plugin
  126297. * @returns The loaded plugin
  126298. */
  126299. 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>;
  126300. /**
  126301. * Load a scene
  126302. * @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)
  126303. * @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)
  126304. * @param engine is the instance of BABYLON.Engine to use to create the scene
  126305. * @param onProgress a callback with a progress event for each file being loaded
  126306. * @param pluginExtension the extension used to determine the plugin
  126307. * @returns The loaded scene
  126308. */
  126309. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  126310. /**
  126311. * Append a scene
  126312. * @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)
  126313. * @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)
  126314. * @param scene is the instance of BABYLON.Scene to append to
  126315. * @param onSuccess a callback with the scene when import succeeds
  126316. * @param onProgress a callback with a progress event for each file being loaded
  126317. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126318. * @param pluginExtension the extension used to determine the plugin
  126319. * @returns The loaded plugin
  126320. */
  126321. 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>;
  126322. /**
  126323. * Append a scene
  126324. * @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)
  126325. * @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)
  126326. * @param scene is the instance of BABYLON.Scene to append to
  126327. * @param onProgress a callback with a progress event for each file being loaded
  126328. * @param pluginExtension the extension used to determine the plugin
  126329. * @returns The given scene
  126330. */
  126331. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  126332. /**
  126333. * Load a scene into an asset container
  126334. * @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)
  126335. * @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)
  126336. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126337. * @param onSuccess a callback with the scene when import succeeds
  126338. * @param onProgress a callback with a progress event for each file being loaded
  126339. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126340. * @param pluginExtension the extension used to determine the plugin
  126341. * @returns The loaded plugin
  126342. */
  126343. 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>;
  126344. /**
  126345. * Load a scene into an asset container
  126346. * @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)
  126347. * @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)
  126348. * @param scene is the instance of Scene to append to
  126349. * @param onProgress a callback with a progress event for each file being loaded
  126350. * @param pluginExtension the extension used to determine the plugin
  126351. * @returns The loaded asset container
  126352. */
  126353. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  126354. /**
  126355. * Import animations from a file into a scene
  126356. * @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)
  126357. * @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)
  126358. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126359. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  126360. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  126361. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  126362. * @param onSuccess a callback with the scene when import succeeds
  126363. * @param onProgress a callback with a progress event for each file being loaded
  126364. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126365. * @param pluginExtension the extension used to determine the plugin
  126366. */
  126367. 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;
  126368. /**
  126369. * Import animations from a file into a scene
  126370. * @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)
  126371. * @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)
  126372. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126373. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  126374. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  126375. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  126376. * @param onSuccess a callback with the scene when import succeeds
  126377. * @param onProgress a callback with a progress event for each file being loaded
  126378. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126379. * @param pluginExtension the extension used to determine the plugin
  126380. * @returns the updated scene with imported animations
  126381. */
  126382. 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>;
  126383. }
  126384. }
  126385. declare module BABYLON {
  126386. /**
  126387. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  126388. */
  126389. export type MotionControllerHandedness = "none" | "left" | "right";
  126390. /**
  126391. * The type of components available in motion controllers.
  126392. * This is not the name of the component.
  126393. */
  126394. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  126395. /**
  126396. * The state of a controller component
  126397. */
  126398. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  126399. /**
  126400. * The schema of motion controller layout.
  126401. * No object will be initialized using this interface
  126402. * This is used just to define the profile.
  126403. */
  126404. export interface IMotionControllerLayout {
  126405. /**
  126406. * Path to load the assets. Usually relative to the base path
  126407. */
  126408. assetPath: string;
  126409. /**
  126410. * Available components (unsorted)
  126411. */
  126412. components: {
  126413. /**
  126414. * A map of component Ids
  126415. */
  126416. [componentId: string]: {
  126417. /**
  126418. * The type of input the component outputs
  126419. */
  126420. type: MotionControllerComponentType;
  126421. /**
  126422. * The indices of this component in the gamepad object
  126423. */
  126424. gamepadIndices: {
  126425. /**
  126426. * Index of button
  126427. */
  126428. button?: number;
  126429. /**
  126430. * If available, index of x-axis
  126431. */
  126432. xAxis?: number;
  126433. /**
  126434. * If available, index of y-axis
  126435. */
  126436. yAxis?: number;
  126437. };
  126438. /**
  126439. * The mesh's root node name
  126440. */
  126441. rootNodeName: string;
  126442. /**
  126443. * Animation definitions for this model
  126444. */
  126445. visualResponses: {
  126446. [stateKey: string]: {
  126447. /**
  126448. * What property will be animated
  126449. */
  126450. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  126451. /**
  126452. * What states influence this visual response
  126453. */
  126454. states: MotionControllerComponentStateType[];
  126455. /**
  126456. * Type of animation - movement or visibility
  126457. */
  126458. valueNodeProperty: "transform" | "visibility";
  126459. /**
  126460. * Base node name to move. Its position will be calculated according to the min and max nodes
  126461. */
  126462. valueNodeName?: string;
  126463. /**
  126464. * Minimum movement node
  126465. */
  126466. minNodeName?: string;
  126467. /**
  126468. * Max movement node
  126469. */
  126470. maxNodeName?: string;
  126471. };
  126472. };
  126473. /**
  126474. * If touch enabled, what is the name of node to display user feedback
  126475. */
  126476. touchPointNodeName?: string;
  126477. };
  126478. };
  126479. /**
  126480. * Is it xr standard mapping or not
  126481. */
  126482. gamepadMapping: "" | "xr-standard";
  126483. /**
  126484. * Base root node of this entire model
  126485. */
  126486. rootNodeName: string;
  126487. /**
  126488. * Defines the main button component id
  126489. */
  126490. selectComponentId: string;
  126491. }
  126492. /**
  126493. * A definition for the layout map in the input profile
  126494. */
  126495. export interface IMotionControllerLayoutMap {
  126496. /**
  126497. * Layouts with handedness type as a key
  126498. */
  126499. [handedness: string]: IMotionControllerLayout;
  126500. }
  126501. /**
  126502. * The XR Input profile schema
  126503. * Profiles can be found here:
  126504. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  126505. */
  126506. export interface IMotionControllerProfile {
  126507. /**
  126508. * fallback profiles for this profileId
  126509. */
  126510. fallbackProfileIds: string[];
  126511. /**
  126512. * The layout map, with handedness as key
  126513. */
  126514. layouts: IMotionControllerLayoutMap;
  126515. /**
  126516. * The id of this profile
  126517. * correlates to the profile(s) in the xrInput.profiles array
  126518. */
  126519. profileId: string;
  126520. }
  126521. /**
  126522. * A helper-interface for the 3 meshes needed for controller button animation
  126523. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  126524. */
  126525. export interface IMotionControllerButtonMeshMap {
  126526. /**
  126527. * the mesh that defines the pressed value mesh position.
  126528. * This is used to find the max-position of this button
  126529. */
  126530. pressedMesh: AbstractMesh;
  126531. /**
  126532. * the mesh that defines the unpressed value mesh position.
  126533. * This is used to find the min (or initial) position of this button
  126534. */
  126535. unpressedMesh: AbstractMesh;
  126536. /**
  126537. * The mesh that will be changed when value changes
  126538. */
  126539. valueMesh: AbstractMesh;
  126540. }
  126541. /**
  126542. * A helper-interface for the 3 meshes needed for controller axis animation.
  126543. * This will be expanded when touchpad animations are fully supported
  126544. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  126545. */
  126546. export interface IMotionControllerMeshMap {
  126547. /**
  126548. * the mesh that defines the maximum value mesh position.
  126549. */
  126550. maxMesh?: AbstractMesh;
  126551. /**
  126552. * the mesh that defines the minimum value mesh position.
  126553. */
  126554. minMesh?: AbstractMesh;
  126555. /**
  126556. * The mesh that will be changed when axis value changes
  126557. */
  126558. valueMesh: AbstractMesh;
  126559. }
  126560. /**
  126561. * The elements needed for change-detection of the gamepad objects in motion controllers
  126562. */
  126563. export interface IMinimalMotionControllerObject {
  126564. /**
  126565. * Available axes of this controller
  126566. */
  126567. axes: number[];
  126568. /**
  126569. * An array of available buttons
  126570. */
  126571. buttons: Array<{
  126572. /**
  126573. * Value of the button/trigger
  126574. */
  126575. value: number;
  126576. /**
  126577. * If the button/trigger is currently touched
  126578. */
  126579. touched: boolean;
  126580. /**
  126581. * If the button/trigger is currently pressed
  126582. */
  126583. pressed: boolean;
  126584. }>;
  126585. /**
  126586. * EXPERIMENTAL haptic support.
  126587. */
  126588. hapticActuators?: Array<{
  126589. pulse: (value: number, duration: number) => Promise<boolean>;
  126590. }>;
  126591. }
  126592. /**
  126593. * An Abstract Motion controller
  126594. * This class receives an xrInput and a profile layout and uses those to initialize the components
  126595. * Each component has an observable to check for changes in value and state
  126596. */
  126597. export abstract class WebXRAbstractMotionController implements IDisposable {
  126598. protected scene: Scene;
  126599. protected layout: IMotionControllerLayout;
  126600. /**
  126601. * The gamepad object correlating to this controller
  126602. */
  126603. gamepadObject: IMinimalMotionControllerObject;
  126604. /**
  126605. * handedness (left/right/none) of this controller
  126606. */
  126607. handedness: MotionControllerHandedness;
  126608. private _initComponent;
  126609. private _modelReady;
  126610. /**
  126611. * A map of components (WebXRControllerComponent) in this motion controller
  126612. * Components have a ComponentType and can also have both button and axis definitions
  126613. */
  126614. readonly components: {
  126615. [id: string]: WebXRControllerComponent;
  126616. };
  126617. /**
  126618. * Disable the model's animation. Can be set at any time.
  126619. */
  126620. disableAnimation: boolean;
  126621. /**
  126622. * Observers registered here will be triggered when the model of this controller is done loading
  126623. */
  126624. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  126625. /**
  126626. * The profile id of this motion controller
  126627. */
  126628. abstract profileId: string;
  126629. /**
  126630. * The root mesh of the model. It is null if the model was not yet initialized
  126631. */
  126632. rootMesh: Nullable<AbstractMesh>;
  126633. /**
  126634. * constructs a new abstract motion controller
  126635. * @param scene the scene to which the model of the controller will be added
  126636. * @param layout The profile layout to load
  126637. * @param gamepadObject The gamepad object correlating to this controller
  126638. * @param handedness handedness (left/right/none) of this controller
  126639. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  126640. */
  126641. constructor(scene: Scene, layout: IMotionControllerLayout,
  126642. /**
  126643. * The gamepad object correlating to this controller
  126644. */
  126645. gamepadObject: IMinimalMotionControllerObject,
  126646. /**
  126647. * handedness (left/right/none) of this controller
  126648. */
  126649. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  126650. /**
  126651. * Dispose this controller, the model mesh and all its components
  126652. */
  126653. dispose(): void;
  126654. /**
  126655. * Returns all components of specific type
  126656. * @param type the type to search for
  126657. * @return an array of components with this type
  126658. */
  126659. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  126660. /**
  126661. * get a component based an its component id as defined in layout.components
  126662. * @param id the id of the component
  126663. * @returns the component correlates to the id or undefined if not found
  126664. */
  126665. getComponent(id: string): WebXRControllerComponent;
  126666. /**
  126667. * Get the list of components available in this motion controller
  126668. * @returns an array of strings correlating to available components
  126669. */
  126670. getComponentIds(): string[];
  126671. /**
  126672. * Get the first component of specific type
  126673. * @param type type of component to find
  126674. * @return a controller component or null if not found
  126675. */
  126676. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  126677. /**
  126678. * Get the main (Select) component of this controller as defined in the layout
  126679. * @returns the main component of this controller
  126680. */
  126681. getMainComponent(): WebXRControllerComponent;
  126682. /**
  126683. * Loads the model correlating to this controller
  126684. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  126685. * @returns A promise fulfilled with the result of the model loading
  126686. */
  126687. loadModel(): Promise<boolean>;
  126688. /**
  126689. * Update this model using the current XRFrame
  126690. * @param xrFrame the current xr frame to use and update the model
  126691. */
  126692. updateFromXRFrame(xrFrame: XRFrame): void;
  126693. /**
  126694. * Backwards compatibility due to a deeply-integrated typo
  126695. */
  126696. get handness(): XREye;
  126697. /**
  126698. * Pulse (vibrate) this controller
  126699. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  126700. * Consecutive calls to this function will cancel the last pulse call
  126701. *
  126702. * @param value the strength of the pulse in 0.0...1.0 range
  126703. * @param duration Duration of the pulse in milliseconds
  126704. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  126705. * @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
  126706. */
  126707. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  126708. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  126709. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  126710. /**
  126711. * Moves the axis on the controller mesh based on its current state
  126712. * @param axis the index of the axis
  126713. * @param axisValue the value of the axis which determines the meshes new position
  126714. * @hidden
  126715. */
  126716. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  126717. /**
  126718. * Update the model itself with the current frame data
  126719. * @param xrFrame the frame to use for updating the model mesh
  126720. */
  126721. protected updateModel(xrFrame: XRFrame): void;
  126722. /**
  126723. * Get the filename and path for this controller's model
  126724. * @returns a map of filename and path
  126725. */
  126726. protected abstract _getFilenameAndPath(): {
  126727. filename: string;
  126728. path: string;
  126729. };
  126730. /**
  126731. * This function is called before the mesh is loaded. It checks for loading constraints.
  126732. * For example, this function can check if the GLB loader is available
  126733. * If this function returns false, the generic controller will be loaded instead
  126734. * @returns Is the client ready to load the mesh
  126735. */
  126736. protected abstract _getModelLoadingConstraints(): boolean;
  126737. /**
  126738. * This function will be called after the model was successfully loaded and can be used
  126739. * for mesh transformations before it is available for the user
  126740. * @param meshes the loaded meshes
  126741. */
  126742. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  126743. /**
  126744. * Set the root mesh for this controller. Important for the WebXR controller class
  126745. * @param meshes the loaded meshes
  126746. */
  126747. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  126748. /**
  126749. * A function executed each frame that updates the mesh (if needed)
  126750. * @param xrFrame the current xrFrame
  126751. */
  126752. protected abstract _updateModel(xrFrame: XRFrame): void;
  126753. private _getGenericFilenameAndPath;
  126754. private _getGenericParentMesh;
  126755. }
  126756. }
  126757. declare module BABYLON {
  126758. /**
  126759. * A generic trigger-only motion controller for WebXR
  126760. */
  126761. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  126762. /**
  126763. * Static version of the profile id of this controller
  126764. */
  126765. static ProfileId: string;
  126766. profileId: string;
  126767. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  126768. protected _getFilenameAndPath(): {
  126769. filename: string;
  126770. path: string;
  126771. };
  126772. protected _getModelLoadingConstraints(): boolean;
  126773. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  126774. protected _setRootMesh(meshes: AbstractMesh[]): void;
  126775. protected _updateModel(): void;
  126776. }
  126777. }
  126778. declare module BABYLON {
  126779. /**
  126780. * Class containing static functions to help procedurally build meshes
  126781. */
  126782. export class SphereBuilder {
  126783. /**
  126784. * Creates a sphere mesh
  126785. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  126786. * * 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`)
  126787. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  126788. * * 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
  126789. * * 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)
  126790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126791. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126793. * @param name defines the name of the mesh
  126794. * @param options defines the options used to create the mesh
  126795. * @param scene defines the hosting scene
  126796. * @returns the sphere mesh
  126797. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  126798. */
  126799. static CreateSphere(name: string, options: {
  126800. segments?: number;
  126801. diameter?: number;
  126802. diameterX?: number;
  126803. diameterY?: number;
  126804. diameterZ?: number;
  126805. arc?: number;
  126806. slice?: number;
  126807. sideOrientation?: number;
  126808. frontUVs?: Vector4;
  126809. backUVs?: Vector4;
  126810. updatable?: boolean;
  126811. }, scene?: Nullable<Scene>): Mesh;
  126812. }
  126813. }
  126814. declare module BABYLON {
  126815. /**
  126816. * A profiled motion controller has its profile loaded from an online repository.
  126817. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  126818. */
  126819. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  126820. private _repositoryUrl;
  126821. private _buttonMeshMapping;
  126822. private _touchDots;
  126823. /**
  126824. * The profile ID of this controller. Will be populated when the controller initializes.
  126825. */
  126826. profileId: string;
  126827. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  126828. dispose(): void;
  126829. protected _getFilenameAndPath(): {
  126830. filename: string;
  126831. path: string;
  126832. };
  126833. protected _getModelLoadingConstraints(): boolean;
  126834. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  126835. protected _setRootMesh(meshes: AbstractMesh[]): void;
  126836. protected _updateModel(_xrFrame: XRFrame): void;
  126837. }
  126838. }
  126839. declare module BABYLON {
  126840. /**
  126841. * A construction function type to create a new controller based on an xrInput object
  126842. */
  126843. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  126844. /**
  126845. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  126846. *
  126847. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  126848. * it should be replaced with auto-loaded controllers.
  126849. *
  126850. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  126851. */
  126852. export class WebXRMotionControllerManager {
  126853. private static _AvailableControllers;
  126854. private static _Fallbacks;
  126855. private static _ProfileLoadingPromises;
  126856. private static _ProfilesList;
  126857. /**
  126858. * The base URL of the online controller repository. Can be changed at any time.
  126859. */
  126860. static BaseRepositoryUrl: string;
  126861. /**
  126862. * Which repository gets priority - local or online
  126863. */
  126864. static PrioritizeOnlineRepository: boolean;
  126865. /**
  126866. * Use the online repository, or use only locally-defined controllers
  126867. */
  126868. static UseOnlineRepository: boolean;
  126869. /**
  126870. * Clear the cache used for profile loading and reload when requested again
  126871. */
  126872. static ClearProfilesCache(): void;
  126873. /**
  126874. * Register the default fallbacks.
  126875. * This function is called automatically when this file is imported.
  126876. */
  126877. static DefaultFallbacks(): void;
  126878. /**
  126879. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  126880. * @param profileId the profile to which a fallback needs to be found
  126881. * @return an array with corresponding fallback profiles
  126882. */
  126883. static FindFallbackWithProfileId(profileId: string): string[];
  126884. /**
  126885. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  126886. * The order of search:
  126887. *
  126888. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  126889. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  126890. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  126891. * 4) return the generic trigger controller if none were found
  126892. *
  126893. * @param xrInput the xrInput to which a new controller is initialized
  126894. * @param scene the scene to which the model will be added
  126895. * @param forceProfile force a certain profile for this controller
  126896. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  126897. */
  126898. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  126899. /**
  126900. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  126901. *
  126902. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  126903. *
  126904. * @param type the profile type to register
  126905. * @param constructFunction the function to be called when loading this profile
  126906. */
  126907. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  126908. /**
  126909. * Register a fallback to a specific profile.
  126910. * @param profileId the profileId that will receive the fallbacks
  126911. * @param fallbacks A list of fallback profiles
  126912. */
  126913. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  126914. /**
  126915. * Will update the list of profiles available in the repository
  126916. * @return a promise that resolves to a map of profiles available online
  126917. */
  126918. static UpdateProfilesList(): Promise<{
  126919. [profile: string]: string;
  126920. }>;
  126921. private static _LoadProfileFromRepository;
  126922. private static _LoadProfilesFromAvailableControllers;
  126923. }
  126924. }
  126925. declare module BABYLON {
  126926. /**
  126927. * Configuration options for the WebXR controller creation
  126928. */
  126929. export interface IWebXRControllerOptions {
  126930. /**
  126931. * Should the controller mesh be animated when a user interacts with it
  126932. * The pressed buttons / thumbstick and touchpad animations will be disabled
  126933. */
  126934. disableMotionControllerAnimation?: boolean;
  126935. /**
  126936. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  126937. */
  126938. doNotLoadControllerMesh?: boolean;
  126939. /**
  126940. * Force a specific controller type for this controller.
  126941. * This can be used when creating your own profile or when testing different controllers
  126942. */
  126943. forceControllerProfile?: string;
  126944. /**
  126945. * Defines a rendering group ID for meshes that will be loaded.
  126946. * This is for the default controllers only.
  126947. */
  126948. renderingGroupId?: number;
  126949. }
  126950. /**
  126951. * Represents an XR controller
  126952. */
  126953. export class WebXRInputSource {
  126954. private _scene;
  126955. /** The underlying input source for the controller */
  126956. inputSource: XRInputSource;
  126957. private _options;
  126958. private _tmpVector;
  126959. private _uniqueId;
  126960. /**
  126961. * 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
  126962. */
  126963. grip?: AbstractMesh;
  126964. /**
  126965. * If available, this is the gamepad object related to this controller.
  126966. * Using this object it is possible to get click events and trackpad changes of the
  126967. * webxr controller that is currently being used.
  126968. */
  126969. motionController?: WebXRAbstractMotionController;
  126970. /**
  126971. * Event that fires when the controller is removed/disposed.
  126972. * The object provided as event data is this controller, after associated assets were disposed.
  126973. * uniqueId is still available.
  126974. */
  126975. onDisposeObservable: Observable<WebXRInputSource>;
  126976. /**
  126977. * Will be triggered when the mesh associated with the motion controller is done loading.
  126978. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  126979. * A shortened version of controller -> motion controller -> on mesh loaded.
  126980. */
  126981. onMeshLoadedObservable: Observable<AbstractMesh>;
  126982. /**
  126983. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  126984. */
  126985. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  126986. /**
  126987. * Pointer which can be used to select objects or attach a visible laser to
  126988. */
  126989. pointer: AbstractMesh;
  126990. /**
  126991. * Creates the input source object
  126992. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  126993. * @param _scene the scene which the controller should be associated to
  126994. * @param inputSource the underlying input source for the controller
  126995. * @param _options options for this controller creation
  126996. */
  126997. constructor(_scene: Scene,
  126998. /** The underlying input source for the controller */
  126999. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  127000. /**
  127001. * Get this controllers unique id
  127002. */
  127003. get uniqueId(): string;
  127004. /**
  127005. * Disposes of the object
  127006. */
  127007. dispose(): void;
  127008. /**
  127009. * Gets a world space ray coming from the pointer or grip
  127010. * @param result the resulting ray
  127011. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  127012. */
  127013. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  127014. /**
  127015. * Updates the controller pose based on the given XRFrame
  127016. * @param xrFrame xr frame to update the pose with
  127017. * @param referenceSpace reference space to use
  127018. */
  127019. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  127020. }
  127021. }
  127022. declare module BABYLON {
  127023. /**
  127024. * The schema for initialization options of the XR Input class
  127025. */
  127026. export interface IWebXRInputOptions {
  127027. /**
  127028. * If set to true no model will be automatically loaded
  127029. */
  127030. doNotLoadControllerMeshes?: boolean;
  127031. /**
  127032. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  127033. * If not found, the xr input profile data will be used.
  127034. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  127035. */
  127036. forceInputProfile?: string;
  127037. /**
  127038. * Do not send a request to the controller repository to load the profile.
  127039. *
  127040. * Instead, use the controllers available in babylon itself.
  127041. */
  127042. disableOnlineControllerRepository?: boolean;
  127043. /**
  127044. * A custom URL for the controllers repository
  127045. */
  127046. customControllersRepositoryURL?: string;
  127047. /**
  127048. * Should the controller model's components not move according to the user input
  127049. */
  127050. disableControllerAnimation?: boolean;
  127051. /**
  127052. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  127053. */
  127054. controllerOptions?: IWebXRControllerOptions;
  127055. }
  127056. /**
  127057. * XR input used to track XR inputs such as controllers/rays
  127058. */
  127059. export class WebXRInput implements IDisposable {
  127060. /**
  127061. * the xr session manager for this session
  127062. */
  127063. xrSessionManager: WebXRSessionManager;
  127064. /**
  127065. * the WebXR camera for this session. Mainly used for teleportation
  127066. */
  127067. xrCamera: WebXRCamera;
  127068. private readonly options;
  127069. /**
  127070. * XR controllers being tracked
  127071. */
  127072. controllers: Array<WebXRInputSource>;
  127073. private _frameObserver;
  127074. private _sessionEndedObserver;
  127075. private _sessionInitObserver;
  127076. /**
  127077. * Event when a controller has been connected/added
  127078. */
  127079. onControllerAddedObservable: Observable<WebXRInputSource>;
  127080. /**
  127081. * Event when a controller has been removed/disconnected
  127082. */
  127083. onControllerRemovedObservable: Observable<WebXRInputSource>;
  127084. /**
  127085. * Initializes the WebXRInput
  127086. * @param xrSessionManager the xr session manager for this session
  127087. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  127088. * @param options = initialization options for this xr input
  127089. */
  127090. constructor(
  127091. /**
  127092. * the xr session manager for this session
  127093. */
  127094. xrSessionManager: WebXRSessionManager,
  127095. /**
  127096. * the WebXR camera for this session. Mainly used for teleportation
  127097. */
  127098. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  127099. private _onInputSourcesChange;
  127100. private _addAndRemoveControllers;
  127101. /**
  127102. * Disposes of the object
  127103. */
  127104. dispose(): void;
  127105. }
  127106. }
  127107. declare module BABYLON {
  127108. /**
  127109. * This is the base class for all WebXR features.
  127110. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  127111. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  127112. */
  127113. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  127114. protected _xrSessionManager: WebXRSessionManager;
  127115. private _attached;
  127116. private _removeOnDetach;
  127117. /**
  127118. * Should auto-attach be disabled?
  127119. */
  127120. disableAutoAttach: boolean;
  127121. /**
  127122. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  127123. */
  127124. xrNativeFeatureName: string;
  127125. /**
  127126. * Construct a new (abstract) WebXR feature
  127127. * @param _xrSessionManager the xr session manager for this feature
  127128. */
  127129. constructor(_xrSessionManager: WebXRSessionManager);
  127130. /**
  127131. * Is this feature attached
  127132. */
  127133. get attached(): boolean;
  127134. /**
  127135. * attach this feature
  127136. *
  127137. * @param force should attachment be forced (even when already attached)
  127138. * @returns true if successful, false is failed or already attached
  127139. */
  127140. attach(force?: boolean): boolean;
  127141. /**
  127142. * detach this feature.
  127143. *
  127144. * @returns true if successful, false if failed or already detached
  127145. */
  127146. detach(): boolean;
  127147. /**
  127148. * Dispose this feature and all of the resources attached
  127149. */
  127150. dispose(): void;
  127151. /**
  127152. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127153. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127154. *
  127155. * @returns whether or not the feature is compatible in this environment
  127156. */
  127157. isCompatible(): boolean;
  127158. /**
  127159. * This is used to register callbacks that will automatically be removed when detach is called.
  127160. * @param observable the observable to which the observer will be attached
  127161. * @param callback the callback to register
  127162. */
  127163. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  127164. /**
  127165. * Code in this function will be executed on each xrFrame received from the browser.
  127166. * This function will not execute after the feature is detached.
  127167. * @param _xrFrame the current frame
  127168. */
  127169. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  127170. }
  127171. }
  127172. declare module BABYLON {
  127173. /**
  127174. * Renders a layer on top of an existing scene
  127175. */
  127176. export class UtilityLayerRenderer implements IDisposable {
  127177. /** the original scene that will be rendered on top of */
  127178. originalScene: Scene;
  127179. private _pointerCaptures;
  127180. private _lastPointerEvents;
  127181. private static _DefaultUtilityLayer;
  127182. private static _DefaultKeepDepthUtilityLayer;
  127183. private _sharedGizmoLight;
  127184. private _renderCamera;
  127185. /**
  127186. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  127187. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  127188. * @returns the camera that is used when rendering the utility layer
  127189. */
  127190. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  127191. /**
  127192. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  127193. * @param cam the camera that should be used when rendering the utility layer
  127194. */
  127195. setRenderCamera(cam: Nullable<Camera>): void;
  127196. /**
  127197. * @hidden
  127198. * Light which used by gizmos to get light shading
  127199. */
  127200. _getSharedGizmoLight(): HemisphericLight;
  127201. /**
  127202. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  127203. */
  127204. pickUtilitySceneFirst: boolean;
  127205. /**
  127206. * 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)
  127207. */
  127208. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  127209. /**
  127210. * 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)
  127211. */
  127212. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  127213. /**
  127214. * The scene that is rendered on top of the original scene
  127215. */
  127216. utilityLayerScene: Scene;
  127217. /**
  127218. * If the utility layer should automatically be rendered on top of existing scene
  127219. */
  127220. shouldRender: boolean;
  127221. /**
  127222. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  127223. */
  127224. onlyCheckPointerDownEvents: boolean;
  127225. /**
  127226. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  127227. */
  127228. processAllEvents: boolean;
  127229. /**
  127230. * Observable raised when the pointer move from the utility layer scene to the main scene
  127231. */
  127232. onPointerOutObservable: Observable<number>;
  127233. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  127234. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  127235. private _afterRenderObserver;
  127236. private _sceneDisposeObserver;
  127237. private _originalPointerObserver;
  127238. /**
  127239. * Instantiates a UtilityLayerRenderer
  127240. * @param originalScene the original scene that will be rendered on top of
  127241. * @param handleEvents boolean indicating if the utility layer should handle events
  127242. */
  127243. constructor(
  127244. /** the original scene that will be rendered on top of */
  127245. originalScene: Scene, handleEvents?: boolean);
  127246. private _notifyObservers;
  127247. /**
  127248. * Renders the utility layers scene on top of the original scene
  127249. */
  127250. render(): void;
  127251. /**
  127252. * Disposes of the renderer
  127253. */
  127254. dispose(): void;
  127255. private _updateCamera;
  127256. }
  127257. }
  127258. declare module BABYLON {
  127259. /**
  127260. * Options interface for the pointer selection module
  127261. */
  127262. export interface IWebXRControllerPointerSelectionOptions {
  127263. /**
  127264. * if provided, this scene will be used to render meshes.
  127265. */
  127266. customUtilityLayerScene?: Scene;
  127267. /**
  127268. * 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)
  127269. * If not disabled, the last picked point will be used to execute a pointer up event
  127270. * If disabled, pointer up event will be triggered right after the pointer down event.
  127271. * Used in screen and gaze target ray mode only
  127272. */
  127273. disablePointerUpOnTouchOut: boolean;
  127274. /**
  127275. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  127276. */
  127277. forceGazeMode: boolean;
  127278. /**
  127279. * 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
  127280. * to start a new countdown to the pointer down event.
  127281. * Defaults to 1.
  127282. */
  127283. gazeModePointerMovedFactor?: number;
  127284. /**
  127285. * Different button type to use instead of the main component
  127286. */
  127287. overrideButtonId?: string;
  127288. /**
  127289. * use this rendering group id for the meshes (optional)
  127290. */
  127291. renderingGroupId?: number;
  127292. /**
  127293. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  127294. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  127295. * 3000 means 3 seconds between pointing at something and selecting it
  127296. */
  127297. timeToSelect?: number;
  127298. /**
  127299. * Should meshes created here be added to a utility layer or the main scene
  127300. */
  127301. useUtilityLayer?: boolean;
  127302. /**
  127303. * Optional WebXR camera to be used for gaze selection
  127304. */
  127305. gazeCamera?: WebXRCamera;
  127306. /**
  127307. * the xr input to use with this pointer selection
  127308. */
  127309. xrInput: WebXRInput;
  127310. }
  127311. /**
  127312. * A module that will enable pointer selection for motion controllers of XR Input Sources
  127313. */
  127314. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  127315. private readonly _options;
  127316. private static _idCounter;
  127317. private _attachController;
  127318. private _controllers;
  127319. private _scene;
  127320. private _tmpVectorForPickCompare;
  127321. /**
  127322. * The module's name
  127323. */
  127324. static readonly Name: string;
  127325. /**
  127326. * The (Babylon) version of this module.
  127327. * This is an integer representing the implementation version.
  127328. * This number does not correspond to the WebXR specs version
  127329. */
  127330. static readonly Version: number;
  127331. /**
  127332. * Disable lighting on the laser pointer (so it will always be visible)
  127333. */
  127334. disablePointerLighting: boolean;
  127335. /**
  127336. * Disable lighting on the selection mesh (so it will always be visible)
  127337. */
  127338. disableSelectionMeshLighting: boolean;
  127339. /**
  127340. * Should the laser pointer be displayed
  127341. */
  127342. displayLaserPointer: boolean;
  127343. /**
  127344. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  127345. */
  127346. displaySelectionMesh: boolean;
  127347. /**
  127348. * This color will be set to the laser pointer when selection is triggered
  127349. */
  127350. laserPointerPickedColor: Color3;
  127351. /**
  127352. * Default color of the laser pointer
  127353. */
  127354. laserPointerDefaultColor: Color3;
  127355. /**
  127356. * default color of the selection ring
  127357. */
  127358. selectionMeshDefaultColor: Color3;
  127359. /**
  127360. * This color will be applied to the selection ring when selection is triggered
  127361. */
  127362. selectionMeshPickedColor: Color3;
  127363. /**
  127364. * Optional filter to be used for ray selection. This predicate shares behavior with
  127365. * scene.pointerMovePredicate which takes priority if it is also assigned.
  127366. */
  127367. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  127368. /**
  127369. * constructs a new background remover module
  127370. * @param _xrSessionManager the session manager for this module
  127371. * @param _options read-only options to be used in this module
  127372. */
  127373. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  127374. /**
  127375. * attach this feature
  127376. * Will usually be called by the features manager
  127377. *
  127378. * @returns true if successful.
  127379. */
  127380. attach(): boolean;
  127381. /**
  127382. * detach this feature.
  127383. * Will usually be called by the features manager
  127384. *
  127385. * @returns true if successful.
  127386. */
  127387. detach(): boolean;
  127388. /**
  127389. * Will get the mesh under a specific pointer.
  127390. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  127391. * @param controllerId the controllerId to check
  127392. * @returns The mesh under pointer or null if no mesh is under the pointer
  127393. */
  127394. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  127395. /**
  127396. * Get the xr controller that correlates to the pointer id in the pointer event
  127397. *
  127398. * @param id the pointer id to search for
  127399. * @returns the controller that correlates to this id or null if not found
  127400. */
  127401. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  127402. protected _onXRFrame(_xrFrame: XRFrame): void;
  127403. private _attachGazeMode;
  127404. private _attachScreenRayMode;
  127405. private _attachTrackedPointerRayMode;
  127406. private _convertNormalToDirectionOfRay;
  127407. private _detachController;
  127408. private _generateNewMeshPair;
  127409. private _pickingMoved;
  127410. private _updatePointerDistance;
  127411. /** @hidden */
  127412. get lasterPointerDefaultColor(): Color3;
  127413. }
  127414. }
  127415. declare module BABYLON {
  127416. /**
  127417. * Button which can be used to enter a different mode of XR
  127418. */
  127419. export class WebXREnterExitUIButton {
  127420. /** button element */
  127421. element: HTMLElement;
  127422. /** XR initialization options for the button */
  127423. sessionMode: XRSessionMode;
  127424. /** Reference space type */
  127425. referenceSpaceType: XRReferenceSpaceType;
  127426. /**
  127427. * Creates a WebXREnterExitUIButton
  127428. * @param element button element
  127429. * @param sessionMode XR initialization session mode
  127430. * @param referenceSpaceType the type of reference space to be used
  127431. */
  127432. constructor(
  127433. /** button element */
  127434. element: HTMLElement,
  127435. /** XR initialization options for the button */
  127436. sessionMode: XRSessionMode,
  127437. /** Reference space type */
  127438. referenceSpaceType: XRReferenceSpaceType);
  127439. /**
  127440. * Extendable function which can be used to update the button's visuals when the state changes
  127441. * @param activeButton the current active button in the UI
  127442. */
  127443. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  127444. }
  127445. /**
  127446. * Options to create the webXR UI
  127447. */
  127448. export class WebXREnterExitUIOptions {
  127449. /**
  127450. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  127451. */
  127452. customButtons?: Array<WebXREnterExitUIButton>;
  127453. /**
  127454. * A reference space type to use when creating the default button.
  127455. * Default is local-floor
  127456. */
  127457. referenceSpaceType?: XRReferenceSpaceType;
  127458. /**
  127459. * Context to enter xr with
  127460. */
  127461. renderTarget?: Nullable<WebXRRenderTarget>;
  127462. /**
  127463. * A session mode to use when creating the default button.
  127464. * Default is immersive-vr
  127465. */
  127466. sessionMode?: XRSessionMode;
  127467. /**
  127468. * A list of optional features to init the session with
  127469. */
  127470. optionalFeatures?: string[];
  127471. /**
  127472. * A list of optional features to init the session with
  127473. */
  127474. requiredFeatures?: string[];
  127475. }
  127476. /**
  127477. * UI to allow the user to enter/exit XR mode
  127478. */
  127479. export class WebXREnterExitUI implements IDisposable {
  127480. private scene;
  127481. /** version of the options passed to this UI */
  127482. options: WebXREnterExitUIOptions;
  127483. private _activeButton;
  127484. private _buttons;
  127485. private _overlay;
  127486. /**
  127487. * Fired every time the active button is changed.
  127488. *
  127489. * When xr is entered via a button that launches xr that button will be the callback parameter
  127490. *
  127491. * When exiting xr the callback parameter will be null)
  127492. */
  127493. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  127494. /**
  127495. *
  127496. * @param scene babylon scene object to use
  127497. * @param options (read-only) version of the options passed to this UI
  127498. */
  127499. private constructor();
  127500. /**
  127501. * Creates UI to allow the user to enter/exit XR mode
  127502. * @param scene the scene to add the ui to
  127503. * @param helper the xr experience helper to enter/exit xr with
  127504. * @param options options to configure the UI
  127505. * @returns the created ui
  127506. */
  127507. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  127508. /**
  127509. * Disposes of the XR UI component
  127510. */
  127511. dispose(): void;
  127512. private _updateButtons;
  127513. }
  127514. }
  127515. declare module BABYLON {
  127516. /**
  127517. * Class containing static functions to help procedurally build meshes
  127518. */
  127519. export class LinesBuilder {
  127520. /**
  127521. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  127522. * * 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
  127523. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  127524. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  127525. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  127526. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  127527. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127528. * * 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
  127529. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  127530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127531. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  127532. * @param name defines the name of the new line system
  127533. * @param options defines the options used to create the line system
  127534. * @param scene defines the hosting scene
  127535. * @returns a new line system mesh
  127536. */
  127537. static CreateLineSystem(name: string, options: {
  127538. lines: Vector3[][];
  127539. updatable?: boolean;
  127540. instance?: Nullable<LinesMesh>;
  127541. colors?: Nullable<Color4[][]>;
  127542. useVertexAlpha?: boolean;
  127543. }, scene: Nullable<Scene>): LinesMesh;
  127544. /**
  127545. * Creates a line mesh
  127546. * 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
  127547. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127548. * * The parameter `points` is an array successive Vector3
  127549. * * 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
  127550. * * The optional parameter `colors` is an array of successive Color4, one per line point
  127551. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  127552. * * When updating an instance, remember that only point positions can change, not the number of points
  127553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127554. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  127555. * @param name defines the name of the new line system
  127556. * @param options defines the options used to create the line system
  127557. * @param scene defines the hosting scene
  127558. * @returns a new line mesh
  127559. */
  127560. static CreateLines(name: string, options: {
  127561. points: Vector3[];
  127562. updatable?: boolean;
  127563. instance?: Nullable<LinesMesh>;
  127564. colors?: Color4[];
  127565. useVertexAlpha?: boolean;
  127566. }, scene?: Nullable<Scene>): LinesMesh;
  127567. /**
  127568. * Creates a dashed line mesh
  127569. * * 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
  127570. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127571. * * The parameter `points` is an array successive Vector3
  127572. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  127573. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  127574. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  127575. * * 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
  127576. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127577. * * When updating an instance, remember that only point positions can change, not the number of points
  127578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127579. * @param name defines the name of the mesh
  127580. * @param options defines the options used to create the mesh
  127581. * @param scene defines the hosting scene
  127582. * @returns the dashed line mesh
  127583. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  127584. */
  127585. static CreateDashedLines(name: string, options: {
  127586. points: Vector3[];
  127587. dashSize?: number;
  127588. gapSize?: number;
  127589. dashNb?: number;
  127590. updatable?: boolean;
  127591. instance?: LinesMesh;
  127592. useVertexAlpha?: boolean;
  127593. }, scene?: Nullable<Scene>): LinesMesh;
  127594. }
  127595. }
  127596. declare module BABYLON {
  127597. /**
  127598. * Construction options for a timer
  127599. */
  127600. export interface ITimerOptions<T> {
  127601. /**
  127602. * Time-to-end
  127603. */
  127604. timeout: number;
  127605. /**
  127606. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  127607. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  127608. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  127609. */
  127610. contextObservable: Observable<T>;
  127611. /**
  127612. * Optional parameters when adding an observer to the observable
  127613. */
  127614. observableParameters?: {
  127615. mask?: number;
  127616. insertFirst?: boolean;
  127617. scope?: any;
  127618. };
  127619. /**
  127620. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  127621. */
  127622. breakCondition?: (data?: ITimerData<T>) => boolean;
  127623. /**
  127624. * Will be triggered when the time condition has met
  127625. */
  127626. onEnded?: (data: ITimerData<any>) => void;
  127627. /**
  127628. * Will be triggered when the break condition has met (prematurely ended)
  127629. */
  127630. onAborted?: (data: ITimerData<any>) => void;
  127631. /**
  127632. * Optional function to execute on each tick (or count)
  127633. */
  127634. onTick?: (data: ITimerData<any>) => void;
  127635. }
  127636. /**
  127637. * An interface defining the data sent by the timer
  127638. */
  127639. export interface ITimerData<T> {
  127640. /**
  127641. * When did it start
  127642. */
  127643. startTime: number;
  127644. /**
  127645. * Time now
  127646. */
  127647. currentTime: number;
  127648. /**
  127649. * Time passed since started
  127650. */
  127651. deltaTime: number;
  127652. /**
  127653. * How much is completed, in [0.0...1.0].
  127654. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  127655. */
  127656. completeRate: number;
  127657. /**
  127658. * What the registered observable sent in the last count
  127659. */
  127660. payload: T;
  127661. }
  127662. /**
  127663. * The current state of the timer
  127664. */
  127665. export enum TimerState {
  127666. /**
  127667. * Timer initialized, not yet started
  127668. */
  127669. INIT = 0,
  127670. /**
  127671. * Timer started and counting
  127672. */
  127673. STARTED = 1,
  127674. /**
  127675. * Timer ended (whether aborted or time reached)
  127676. */
  127677. ENDED = 2
  127678. }
  127679. /**
  127680. * A simple version of the timer. Will take options and start the timer immediately after calling it
  127681. *
  127682. * @param options options with which to initialize this timer
  127683. */
  127684. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  127685. /**
  127686. * An advanced implementation of a timer class
  127687. */
  127688. export class AdvancedTimer<T = any> implements IDisposable {
  127689. /**
  127690. * Will notify each time the timer calculates the remaining time
  127691. */
  127692. onEachCountObservable: Observable<ITimerData<T>>;
  127693. /**
  127694. * Will trigger when the timer was aborted due to the break condition
  127695. */
  127696. onTimerAbortedObservable: Observable<ITimerData<T>>;
  127697. /**
  127698. * Will trigger when the timer ended successfully
  127699. */
  127700. onTimerEndedObservable: Observable<ITimerData<T>>;
  127701. /**
  127702. * Will trigger when the timer state has changed
  127703. */
  127704. onStateChangedObservable: Observable<TimerState>;
  127705. private _observer;
  127706. private _contextObservable;
  127707. private _observableParameters;
  127708. private _startTime;
  127709. private _timer;
  127710. private _state;
  127711. private _breakCondition;
  127712. private _timeToEnd;
  127713. private _breakOnNextTick;
  127714. /**
  127715. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  127716. * @param options construction options for this advanced timer
  127717. */
  127718. constructor(options: ITimerOptions<T>);
  127719. /**
  127720. * set a breaking condition for this timer. Default is to never break during count
  127721. * @param predicate the new break condition. Returns true to break, false otherwise
  127722. */
  127723. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  127724. /**
  127725. * Reset ALL associated observables in this advanced timer
  127726. */
  127727. clearObservables(): void;
  127728. /**
  127729. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  127730. *
  127731. * @param timeToEnd how much time to measure until timer ended
  127732. */
  127733. start(timeToEnd?: number): void;
  127734. /**
  127735. * Will force a stop on the next tick.
  127736. */
  127737. stop(): void;
  127738. /**
  127739. * Dispose this timer, clearing all resources
  127740. */
  127741. dispose(): void;
  127742. private _setState;
  127743. private _tick;
  127744. private _stop;
  127745. }
  127746. }
  127747. declare module BABYLON {
  127748. /**
  127749. * The options container for the teleportation module
  127750. */
  127751. export interface IWebXRTeleportationOptions {
  127752. /**
  127753. * if provided, this scene will be used to render meshes.
  127754. */
  127755. customUtilityLayerScene?: Scene;
  127756. /**
  127757. * Values to configure the default target mesh
  127758. */
  127759. defaultTargetMeshOptions?: {
  127760. /**
  127761. * Fill color of the teleportation area
  127762. */
  127763. teleportationFillColor?: string;
  127764. /**
  127765. * Border color for the teleportation area
  127766. */
  127767. teleportationBorderColor?: string;
  127768. /**
  127769. * Disable the mesh's animation sequence
  127770. */
  127771. disableAnimation?: boolean;
  127772. /**
  127773. * Disable lighting on the material or the ring and arrow
  127774. */
  127775. disableLighting?: boolean;
  127776. /**
  127777. * Override the default material of the torus and arrow
  127778. */
  127779. torusArrowMaterial?: Material;
  127780. };
  127781. /**
  127782. * A list of meshes to use as floor meshes.
  127783. * Meshes can be added and removed after initializing the feature using the
  127784. * addFloorMesh and removeFloorMesh functions
  127785. * If empty, rotation will still work
  127786. */
  127787. floorMeshes?: AbstractMesh[];
  127788. /**
  127789. * use this rendering group id for the meshes (optional)
  127790. */
  127791. renderingGroupId?: number;
  127792. /**
  127793. * Should teleportation move only to snap points
  127794. */
  127795. snapPointsOnly?: boolean;
  127796. /**
  127797. * An array of points to which the teleportation will snap to.
  127798. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  127799. */
  127800. snapPositions?: Vector3[];
  127801. /**
  127802. * How close should the teleportation ray be in order to snap to position.
  127803. * Default to 0.8 units (meters)
  127804. */
  127805. snapToPositionRadius?: number;
  127806. /**
  127807. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  127808. * If you want to support rotation, make sure your mesh has a direction indicator.
  127809. *
  127810. * When left untouched, the default mesh will be initialized.
  127811. */
  127812. teleportationTargetMesh?: AbstractMesh;
  127813. /**
  127814. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  127815. */
  127816. timeToTeleport?: number;
  127817. /**
  127818. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  127819. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  127820. */
  127821. useMainComponentOnly?: boolean;
  127822. /**
  127823. * Should meshes created here be added to a utility layer or the main scene
  127824. */
  127825. useUtilityLayer?: boolean;
  127826. /**
  127827. * Babylon XR Input class for controller
  127828. */
  127829. xrInput: WebXRInput;
  127830. }
  127831. /**
  127832. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  127833. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  127834. * the input of the attached controllers.
  127835. */
  127836. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  127837. private _options;
  127838. private _controllers;
  127839. private _currentTeleportationControllerId;
  127840. private _floorMeshes;
  127841. private _quadraticBezierCurve;
  127842. private _selectionFeature;
  127843. private _snapToPositions;
  127844. private _snappedToPoint;
  127845. private _teleportationRingMaterial?;
  127846. private _tmpRay;
  127847. private _tmpVector;
  127848. /**
  127849. * The module's name
  127850. */
  127851. static readonly Name: string;
  127852. /**
  127853. * The (Babylon) version of this module.
  127854. * This is an integer representing the implementation version.
  127855. * This number does not correspond to the webxr specs version
  127856. */
  127857. static readonly Version: number;
  127858. /**
  127859. * Is movement backwards enabled
  127860. */
  127861. backwardsMovementEnabled: boolean;
  127862. /**
  127863. * Distance to travel when moving backwards
  127864. */
  127865. backwardsTeleportationDistance: number;
  127866. /**
  127867. * The distance from the user to the inspection point in the direction of the controller
  127868. * A higher number will allow the user to move further
  127869. * defaults to 5 (meters, in xr units)
  127870. */
  127871. parabolicCheckRadius: number;
  127872. /**
  127873. * Should the module support parabolic ray on top of direct ray
  127874. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  127875. * Very helpful when moving between floors / different heights
  127876. */
  127877. parabolicRayEnabled: boolean;
  127878. /**
  127879. * How much rotation should be applied when rotating right and left
  127880. */
  127881. rotationAngle: number;
  127882. /**
  127883. * Is rotation enabled when moving forward?
  127884. * Disabling this feature will prevent the user from deciding the direction when teleporting
  127885. */
  127886. rotationEnabled: boolean;
  127887. /**
  127888. * constructs a new anchor system
  127889. * @param _xrSessionManager an instance of WebXRSessionManager
  127890. * @param _options configuration object for this feature
  127891. */
  127892. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  127893. /**
  127894. * Get the snapPointsOnly flag
  127895. */
  127896. get snapPointsOnly(): boolean;
  127897. /**
  127898. * Sets the snapPointsOnly flag
  127899. * @param snapToPoints should teleportation be exclusively to snap points
  127900. */
  127901. set snapPointsOnly(snapToPoints: boolean);
  127902. /**
  127903. * Add a new mesh to the floor meshes array
  127904. * @param mesh the mesh to use as floor mesh
  127905. */
  127906. addFloorMesh(mesh: AbstractMesh): void;
  127907. /**
  127908. * Add a new snap-to point to fix teleportation to this position
  127909. * @param newSnapPoint The new Snap-To point
  127910. */
  127911. addSnapPoint(newSnapPoint: Vector3): void;
  127912. attach(): boolean;
  127913. detach(): boolean;
  127914. dispose(): void;
  127915. /**
  127916. * Remove a mesh from the floor meshes array
  127917. * @param mesh the mesh to remove
  127918. */
  127919. removeFloorMesh(mesh: AbstractMesh): void;
  127920. /**
  127921. * Remove a mesh from the floor meshes array using its name
  127922. * @param name the mesh name to remove
  127923. */
  127924. removeFloorMeshByName(name: string): void;
  127925. /**
  127926. * 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
  127927. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  127928. * @returns was the point found and removed or not
  127929. */
  127930. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  127931. /**
  127932. * This function sets a selection feature that will be disabled when
  127933. * the forward ray is shown and will be reattached when hidden.
  127934. * This is used to remove the selection rays when moving.
  127935. * @param selectionFeature the feature to disable when forward movement is enabled
  127936. */
  127937. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  127938. protected _onXRFrame(_xrFrame: XRFrame): void;
  127939. private _attachController;
  127940. private _createDefaultTargetMesh;
  127941. private _detachController;
  127942. private _findClosestSnapPointWithRadius;
  127943. private _setTargetMeshPosition;
  127944. private _setTargetMeshVisibility;
  127945. private _showParabolicPath;
  127946. private _teleportForward;
  127947. }
  127948. }
  127949. declare module BABYLON {
  127950. /**
  127951. * Options for the default xr helper
  127952. */
  127953. export class WebXRDefaultExperienceOptions {
  127954. /**
  127955. * Enable or disable default UI to enter XR
  127956. */
  127957. disableDefaultUI?: boolean;
  127958. /**
  127959. * Should teleportation not initialize. defaults to false.
  127960. */
  127961. disableTeleportation?: boolean;
  127962. /**
  127963. * Floor meshes that will be used for teleport
  127964. */
  127965. floorMeshes?: Array<AbstractMesh>;
  127966. /**
  127967. * If set to true, the first frame will not be used to reset position
  127968. * The first frame is mainly used when copying transformation from the old camera
  127969. * Mainly used in AR
  127970. */
  127971. ignoreNativeCameraTransformation?: boolean;
  127972. /**
  127973. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  127974. */
  127975. inputOptions?: IWebXRInputOptions;
  127976. /**
  127977. * optional configuration for the output canvas
  127978. */
  127979. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  127980. /**
  127981. * optional UI options. This can be used among other to change session mode and reference space type
  127982. */
  127983. uiOptions?: WebXREnterExitUIOptions;
  127984. /**
  127985. * When loading teleportation and pointer select, use stable versions instead of latest.
  127986. */
  127987. useStablePlugins?: boolean;
  127988. /**
  127989. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  127990. */
  127991. renderingGroupId?: number;
  127992. /**
  127993. * A list of optional features to init the session with
  127994. * If set to true, all features we support will be added
  127995. */
  127996. optionalFeatures?: boolean | string[];
  127997. }
  127998. /**
  127999. * Default experience which provides a similar setup to the previous webVRExperience
  128000. */
  128001. export class WebXRDefaultExperience {
  128002. /**
  128003. * Base experience
  128004. */
  128005. baseExperience: WebXRExperienceHelper;
  128006. /**
  128007. * Enables ui for entering/exiting xr
  128008. */
  128009. enterExitUI: WebXREnterExitUI;
  128010. /**
  128011. * Input experience extension
  128012. */
  128013. input: WebXRInput;
  128014. /**
  128015. * Enables laser pointer and selection
  128016. */
  128017. pointerSelection: WebXRControllerPointerSelection;
  128018. /**
  128019. * Default target xr should render to
  128020. */
  128021. renderTarget: WebXRRenderTarget;
  128022. /**
  128023. * Enables teleportation
  128024. */
  128025. teleportation: WebXRMotionControllerTeleportation;
  128026. private constructor();
  128027. /**
  128028. * Creates the default xr experience
  128029. * @param scene scene
  128030. * @param options options for basic configuration
  128031. * @returns resulting WebXRDefaultExperience
  128032. */
  128033. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  128034. /**
  128035. * DIsposes of the experience helper
  128036. */
  128037. dispose(): void;
  128038. }
  128039. }
  128040. declare module BABYLON {
  128041. /**
  128042. * Options to modify the vr teleportation behavior.
  128043. */
  128044. export interface VRTeleportationOptions {
  128045. /**
  128046. * The name of the mesh which should be used as the teleportation floor. (default: null)
  128047. */
  128048. floorMeshName?: string;
  128049. /**
  128050. * A list of meshes to be used as the teleportation floor. (default: empty)
  128051. */
  128052. floorMeshes?: Mesh[];
  128053. /**
  128054. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  128055. */
  128056. teleportationMode?: number;
  128057. /**
  128058. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  128059. */
  128060. teleportationTime?: number;
  128061. /**
  128062. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  128063. */
  128064. teleportationSpeed?: number;
  128065. /**
  128066. * The easing function used in the animation or null for Linear. (default CircleEase)
  128067. */
  128068. easingFunction?: EasingFunction;
  128069. }
  128070. /**
  128071. * Options to modify the vr experience helper's behavior.
  128072. */
  128073. export interface VRExperienceHelperOptions extends WebVROptions {
  128074. /**
  128075. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  128076. */
  128077. createDeviceOrientationCamera?: boolean;
  128078. /**
  128079. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  128080. */
  128081. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  128082. /**
  128083. * Uses the main button on the controller to toggle the laser casted. (default: true)
  128084. */
  128085. laserToggle?: boolean;
  128086. /**
  128087. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  128088. */
  128089. floorMeshes?: Mesh[];
  128090. /**
  128091. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  128092. */
  128093. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  128094. /**
  128095. * Defines if WebXR should be used instead of WebVR (if available)
  128096. */
  128097. useXR?: boolean;
  128098. }
  128099. /**
  128100. * Event containing information after VR has been entered
  128101. */
  128102. export class OnAfterEnteringVRObservableEvent {
  128103. /**
  128104. * If entering vr was successful
  128105. */
  128106. success: boolean;
  128107. }
  128108. /**
  128109. * Helps to quickly add VR support to an existing scene.
  128110. * See https://doc.babylonjs.com/how_to/webvr_helper
  128111. */
  128112. export class VRExperienceHelper {
  128113. /** Options to modify the vr experience helper's behavior. */
  128114. webVROptions: VRExperienceHelperOptions;
  128115. private _scene;
  128116. private _position;
  128117. private _btnVR;
  128118. private _btnVRDisplayed;
  128119. private _webVRsupported;
  128120. private _webVRready;
  128121. private _webVRrequesting;
  128122. private _webVRpresenting;
  128123. private _hasEnteredVR;
  128124. private _fullscreenVRpresenting;
  128125. private _inputElement;
  128126. private _webVRCamera;
  128127. private _vrDeviceOrientationCamera;
  128128. private _deviceOrientationCamera;
  128129. private _existingCamera;
  128130. private _onKeyDown;
  128131. private _onVrDisplayPresentChange;
  128132. private _onVRDisplayChanged;
  128133. private _onVRRequestPresentStart;
  128134. private _onVRRequestPresentComplete;
  128135. /**
  128136. * 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)
  128137. */
  128138. enableGazeEvenWhenNoPointerLock: boolean;
  128139. /**
  128140. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  128141. */
  128142. exitVROnDoubleTap: boolean;
  128143. /**
  128144. * Observable raised right before entering VR.
  128145. */
  128146. onEnteringVRObservable: Observable<VRExperienceHelper>;
  128147. /**
  128148. * Observable raised when entering VR has completed.
  128149. */
  128150. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  128151. /**
  128152. * Observable raised when exiting VR.
  128153. */
  128154. onExitingVRObservable: Observable<VRExperienceHelper>;
  128155. /**
  128156. * Observable raised when controller mesh is loaded.
  128157. */
  128158. onControllerMeshLoadedObservable: Observable<WebVRController>;
  128159. /** Return this.onEnteringVRObservable
  128160. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  128161. */
  128162. get onEnteringVR(): Observable<VRExperienceHelper>;
  128163. /** Return this.onExitingVRObservable
  128164. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  128165. */
  128166. get onExitingVR(): Observable<VRExperienceHelper>;
  128167. /** Return this.onControllerMeshLoadedObservable
  128168. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  128169. */
  128170. get onControllerMeshLoaded(): Observable<WebVRController>;
  128171. private _rayLength;
  128172. private _useCustomVRButton;
  128173. private _teleportationRequested;
  128174. private _teleportActive;
  128175. private _floorMeshName;
  128176. private _floorMeshesCollection;
  128177. private _teleportationMode;
  128178. private _teleportationTime;
  128179. private _teleportationSpeed;
  128180. private _teleportationEasing;
  128181. private _rotationAllowed;
  128182. private _teleportBackwardsVector;
  128183. private _teleportationTarget;
  128184. private _isDefaultTeleportationTarget;
  128185. private _postProcessMove;
  128186. private _teleportationFillColor;
  128187. private _teleportationBorderColor;
  128188. private _rotationAngle;
  128189. private _haloCenter;
  128190. private _cameraGazer;
  128191. private _padSensibilityUp;
  128192. private _padSensibilityDown;
  128193. private _leftController;
  128194. private _rightController;
  128195. private _gazeColor;
  128196. private _laserColor;
  128197. private _pickedLaserColor;
  128198. private _pickedGazeColor;
  128199. /**
  128200. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  128201. */
  128202. onNewMeshSelected: Observable<AbstractMesh>;
  128203. /**
  128204. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  128205. * This observable will provide the mesh and the controller used to select the mesh
  128206. */
  128207. onMeshSelectedWithController: Observable<{
  128208. mesh: AbstractMesh;
  128209. controller: WebVRController;
  128210. }>;
  128211. /**
  128212. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  128213. */
  128214. onNewMeshPicked: Observable<PickingInfo>;
  128215. private _circleEase;
  128216. /**
  128217. * Observable raised before camera teleportation
  128218. */
  128219. onBeforeCameraTeleport: Observable<Vector3>;
  128220. /**
  128221. * Observable raised after camera teleportation
  128222. */
  128223. onAfterCameraTeleport: Observable<Vector3>;
  128224. /**
  128225. * Observable raised when current selected mesh gets unselected
  128226. */
  128227. onSelectedMeshUnselected: Observable<AbstractMesh>;
  128228. private _raySelectionPredicate;
  128229. /**
  128230. * To be optionaly changed by user to define custom ray selection
  128231. */
  128232. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  128233. /**
  128234. * To be optionaly changed by user to define custom selection logic (after ray selection)
  128235. */
  128236. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  128237. /**
  128238. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  128239. */
  128240. teleportationEnabled: boolean;
  128241. private _defaultHeight;
  128242. private _teleportationInitialized;
  128243. private _interactionsEnabled;
  128244. private _interactionsRequested;
  128245. private _displayGaze;
  128246. private _displayLaserPointer;
  128247. /**
  128248. * The mesh used to display where the user is going to teleport.
  128249. */
  128250. get teleportationTarget(): Mesh;
  128251. /**
  128252. * Sets the mesh to be used to display where the user is going to teleport.
  128253. */
  128254. set teleportationTarget(value: Mesh);
  128255. /**
  128256. * 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
  128257. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  128258. * See https://doc.babylonjs.com/resources/baking_transformations
  128259. */
  128260. get gazeTrackerMesh(): Mesh;
  128261. set gazeTrackerMesh(value: Mesh);
  128262. /**
  128263. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  128264. */
  128265. updateGazeTrackerScale: boolean;
  128266. /**
  128267. * If the gaze trackers color should be updated when selecting meshes
  128268. */
  128269. updateGazeTrackerColor: boolean;
  128270. /**
  128271. * If the controller laser color should be updated when selecting meshes
  128272. */
  128273. updateControllerLaserColor: boolean;
  128274. /**
  128275. * The gaze tracking mesh corresponding to the left controller
  128276. */
  128277. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  128278. /**
  128279. * The gaze tracking mesh corresponding to the right controller
  128280. */
  128281. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  128282. /**
  128283. * If the ray of the gaze should be displayed.
  128284. */
  128285. get displayGaze(): boolean;
  128286. /**
  128287. * Sets if the ray of the gaze should be displayed.
  128288. */
  128289. set displayGaze(value: boolean);
  128290. /**
  128291. * If the ray of the LaserPointer should be displayed.
  128292. */
  128293. get displayLaserPointer(): boolean;
  128294. /**
  128295. * Sets if the ray of the LaserPointer should be displayed.
  128296. */
  128297. set displayLaserPointer(value: boolean);
  128298. /**
  128299. * The deviceOrientationCamera used as the camera when not in VR.
  128300. */
  128301. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  128302. /**
  128303. * Based on the current WebVR support, returns the current VR camera used.
  128304. */
  128305. get currentVRCamera(): Nullable<Camera>;
  128306. /**
  128307. * The webVRCamera which is used when in VR.
  128308. */
  128309. get webVRCamera(): WebVRFreeCamera;
  128310. /**
  128311. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  128312. */
  128313. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  128314. /**
  128315. * The html button that is used to trigger entering into VR.
  128316. */
  128317. get vrButton(): Nullable<HTMLButtonElement>;
  128318. private get _teleportationRequestInitiated();
  128319. /**
  128320. * Defines whether or not Pointer lock should be requested when switching to
  128321. * full screen.
  128322. */
  128323. requestPointerLockOnFullScreen: boolean;
  128324. /**
  128325. * If asking to force XR, this will be populated with the default xr experience
  128326. */
  128327. xr: WebXRDefaultExperience;
  128328. /**
  128329. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  128330. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  128331. */
  128332. xrTestDone: boolean;
  128333. /**
  128334. * Instantiates a VRExperienceHelper.
  128335. * Helps to quickly add VR support to an existing scene.
  128336. * @param scene The scene the VRExperienceHelper belongs to.
  128337. * @param webVROptions Options to modify the vr experience helper's behavior.
  128338. */
  128339. constructor(scene: Scene,
  128340. /** Options to modify the vr experience helper's behavior. */
  128341. webVROptions?: VRExperienceHelperOptions);
  128342. private completeVRInit;
  128343. private _onDefaultMeshLoaded;
  128344. private _onResize;
  128345. private _onFullscreenChange;
  128346. /**
  128347. * Gets a value indicating if we are currently in VR mode.
  128348. */
  128349. get isInVRMode(): boolean;
  128350. private onVrDisplayPresentChange;
  128351. private onVRDisplayChanged;
  128352. private moveButtonToBottomRight;
  128353. private displayVRButton;
  128354. private updateButtonVisibility;
  128355. private _cachedAngularSensibility;
  128356. /**
  128357. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  128358. * Otherwise, will use the fullscreen API.
  128359. */
  128360. enterVR(): void;
  128361. /**
  128362. * Attempt to exit VR, or fullscreen.
  128363. */
  128364. exitVR(): void;
  128365. /**
  128366. * The position of the vr experience helper.
  128367. */
  128368. get position(): Vector3;
  128369. /**
  128370. * Sets the position of the vr experience helper.
  128371. */
  128372. set position(value: Vector3);
  128373. /**
  128374. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  128375. */
  128376. enableInteractions(): void;
  128377. private get _noControllerIsActive();
  128378. private beforeRender;
  128379. private _isTeleportationFloor;
  128380. /**
  128381. * Adds a floor mesh to be used for teleportation.
  128382. * @param floorMesh the mesh to be used for teleportation.
  128383. */
  128384. addFloorMesh(floorMesh: Mesh): void;
  128385. /**
  128386. * Removes a floor mesh from being used for teleportation.
  128387. * @param floorMesh the mesh to be removed.
  128388. */
  128389. removeFloorMesh(floorMesh: Mesh): void;
  128390. /**
  128391. * Enables interactions and teleportation using the VR controllers and gaze.
  128392. * @param vrTeleportationOptions options to modify teleportation behavior.
  128393. */
  128394. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  128395. private _onNewGamepadConnected;
  128396. private _tryEnableInteractionOnController;
  128397. private _onNewGamepadDisconnected;
  128398. private _enableInteractionOnController;
  128399. private _checkTeleportWithRay;
  128400. private _checkRotate;
  128401. private _checkTeleportBackwards;
  128402. private _enableTeleportationOnController;
  128403. private _createTeleportationCircles;
  128404. private _displayTeleportationTarget;
  128405. private _hideTeleportationTarget;
  128406. private _rotateCamera;
  128407. private _moveTeleportationSelectorTo;
  128408. private _workingVector;
  128409. private _workingQuaternion;
  128410. private _workingMatrix;
  128411. /**
  128412. * Time Constant Teleportation Mode
  128413. */
  128414. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  128415. /**
  128416. * Speed Constant Teleportation Mode
  128417. */
  128418. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  128419. /**
  128420. * Teleports the users feet to the desired location
  128421. * @param location The location where the user's feet should be placed
  128422. */
  128423. teleportCamera(location: Vector3): void;
  128424. private _convertNormalToDirectionOfRay;
  128425. private _castRayAndSelectObject;
  128426. private _notifySelectedMeshUnselected;
  128427. /**
  128428. * Permanently set new colors for the laser pointer
  128429. * @param color the new laser color
  128430. * @param pickedColor the new laser color when picked mesh detected
  128431. */
  128432. setLaserColor(color: Color3, pickedColor?: Color3): void;
  128433. /**
  128434. * Set lighting enabled / disabled on the laser pointer of both controllers
  128435. * @param enabled should the lighting be enabled on the laser pointer
  128436. */
  128437. setLaserLightingState(enabled?: boolean): void;
  128438. /**
  128439. * Permanently set new colors for the gaze pointer
  128440. * @param color the new gaze color
  128441. * @param pickedColor the new gaze color when picked mesh detected
  128442. */
  128443. setGazeColor(color: Color3, pickedColor?: Color3): void;
  128444. /**
  128445. * Sets the color of the laser ray from the vr controllers.
  128446. * @param color new color for the ray.
  128447. */
  128448. changeLaserColor(color: Color3): void;
  128449. /**
  128450. * Sets the color of the ray from the vr headsets gaze.
  128451. * @param color new color for the ray.
  128452. */
  128453. changeGazeColor(color: Color3): void;
  128454. /**
  128455. * Exits VR and disposes of the vr experience helper
  128456. */
  128457. dispose(): void;
  128458. /**
  128459. * Gets the name of the VRExperienceHelper class
  128460. * @returns "VRExperienceHelper"
  128461. */
  128462. getClassName(): string;
  128463. }
  128464. }
  128465. declare module BABYLON {
  128466. /**
  128467. * Contains an array of blocks representing the octree
  128468. */
  128469. export interface IOctreeContainer<T> {
  128470. /**
  128471. * Blocks within the octree
  128472. */
  128473. blocks: Array<OctreeBlock<T>>;
  128474. }
  128475. /**
  128476. * Class used to store a cell in an octree
  128477. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128478. */
  128479. export class OctreeBlock<T> {
  128480. /**
  128481. * Gets the content of the current block
  128482. */
  128483. entries: T[];
  128484. /**
  128485. * Gets the list of block children
  128486. */
  128487. blocks: Array<OctreeBlock<T>>;
  128488. private _depth;
  128489. private _maxDepth;
  128490. private _capacity;
  128491. private _minPoint;
  128492. private _maxPoint;
  128493. private _boundingVectors;
  128494. private _creationFunc;
  128495. /**
  128496. * Creates a new block
  128497. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  128498. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  128499. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  128500. * @param depth defines the current depth of this block in the octree
  128501. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  128502. * @param creationFunc defines a callback to call when an element is added to the block
  128503. */
  128504. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  128505. /**
  128506. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  128507. */
  128508. get capacity(): number;
  128509. /**
  128510. * Gets the minimum vector (in world space) of the block's bounding box
  128511. */
  128512. get minPoint(): Vector3;
  128513. /**
  128514. * Gets the maximum vector (in world space) of the block's bounding box
  128515. */
  128516. get maxPoint(): Vector3;
  128517. /**
  128518. * Add a new element to this block
  128519. * @param entry defines the element to add
  128520. */
  128521. addEntry(entry: T): void;
  128522. /**
  128523. * Remove an element from this block
  128524. * @param entry defines the element to remove
  128525. */
  128526. removeEntry(entry: T): void;
  128527. /**
  128528. * Add an array of elements to this block
  128529. * @param entries defines the array of elements to add
  128530. */
  128531. addEntries(entries: T[]): void;
  128532. /**
  128533. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  128534. * @param frustumPlanes defines the frustum planes to test
  128535. * @param selection defines the array to store current content if selection is positive
  128536. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128537. */
  128538. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  128539. /**
  128540. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  128541. * @param sphereCenter defines the bounding sphere center
  128542. * @param sphereRadius defines the bounding sphere radius
  128543. * @param selection defines the array to store current content if selection is positive
  128544. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128545. */
  128546. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  128547. /**
  128548. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  128549. * @param ray defines the ray to test with
  128550. * @param selection defines the array to store current content if selection is positive
  128551. */
  128552. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  128553. /**
  128554. * Subdivide the content into child blocks (this block will then be empty)
  128555. */
  128556. createInnerBlocks(): void;
  128557. /**
  128558. * @hidden
  128559. */
  128560. 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;
  128561. }
  128562. }
  128563. declare module BABYLON {
  128564. /**
  128565. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  128566. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128567. */
  128568. export class Octree<T> {
  128569. /** 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.) */
  128570. maxDepth: number;
  128571. /**
  128572. * Blocks within the octree containing objects
  128573. */
  128574. blocks: Array<OctreeBlock<T>>;
  128575. /**
  128576. * Content stored in the octree
  128577. */
  128578. dynamicContent: T[];
  128579. private _maxBlockCapacity;
  128580. private _selectionContent;
  128581. private _creationFunc;
  128582. /**
  128583. * Creates a octree
  128584. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128585. * @param creationFunc function to be used to instatiate the octree
  128586. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  128587. * @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.)
  128588. */
  128589. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  128590. /** 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.) */
  128591. maxDepth?: number);
  128592. /**
  128593. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  128594. * @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);
  128595. * @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);
  128596. * @param entries meshes to be added to the octree blocks
  128597. */
  128598. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  128599. /**
  128600. * Adds a mesh to the octree
  128601. * @param entry Mesh to add to the octree
  128602. */
  128603. addMesh(entry: T): void;
  128604. /**
  128605. * Remove an element from the octree
  128606. * @param entry defines the element to remove
  128607. */
  128608. removeMesh(entry: T): void;
  128609. /**
  128610. * Selects an array of meshes within the frustum
  128611. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  128612. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  128613. * @returns array of meshes within the frustum
  128614. */
  128615. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  128616. /**
  128617. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  128618. * @param sphereCenter defines the bounding sphere center
  128619. * @param sphereRadius defines the bounding sphere radius
  128620. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128621. * @returns an array of objects that intersect the sphere
  128622. */
  128623. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  128624. /**
  128625. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  128626. * @param ray defines the ray to test with
  128627. * @returns array of intersected objects
  128628. */
  128629. intersectsRay(ray: Ray): SmartArray<T>;
  128630. /**
  128631. * Adds a mesh into the octree block if it intersects the block
  128632. */
  128633. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  128634. /**
  128635. * Adds a submesh into the octree block if it intersects the block
  128636. */
  128637. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  128638. }
  128639. }
  128640. declare module BABYLON {
  128641. interface Scene {
  128642. /**
  128643. * @hidden
  128644. * Backing Filed
  128645. */
  128646. _selectionOctree: Octree<AbstractMesh>;
  128647. /**
  128648. * Gets the octree used to boost mesh selection (picking)
  128649. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128650. */
  128651. selectionOctree: Octree<AbstractMesh>;
  128652. /**
  128653. * Creates or updates the octree used to boost selection (picking)
  128654. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128655. * @param maxCapacity defines the maximum capacity per leaf
  128656. * @param maxDepth defines the maximum depth of the octree
  128657. * @returns an octree of AbstractMesh
  128658. */
  128659. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  128660. }
  128661. interface AbstractMesh {
  128662. /**
  128663. * @hidden
  128664. * Backing Field
  128665. */
  128666. _submeshesOctree: Octree<SubMesh>;
  128667. /**
  128668. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  128669. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  128670. * @param maxCapacity defines the maximum size of each block (64 by default)
  128671. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  128672. * @returns the new octree
  128673. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  128674. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128675. */
  128676. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  128677. }
  128678. /**
  128679. * Defines the octree scene component responsible to manage any octrees
  128680. * in a given scene.
  128681. */
  128682. export class OctreeSceneComponent {
  128683. /**
  128684. * The component name help to identify the component in the list of scene components.
  128685. */
  128686. readonly name: string;
  128687. /**
  128688. * The scene the component belongs to.
  128689. */
  128690. scene: Scene;
  128691. /**
  128692. * Indicates if the meshes have been checked to make sure they are isEnabled()
  128693. */
  128694. readonly checksIsEnabled: boolean;
  128695. /**
  128696. * Creates a new instance of the component for the given scene
  128697. * @param scene Defines the scene to register the component in
  128698. */
  128699. constructor(scene: Scene);
  128700. /**
  128701. * Registers the component in a given scene
  128702. */
  128703. register(): void;
  128704. /**
  128705. * Return the list of active meshes
  128706. * @returns the list of active meshes
  128707. */
  128708. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  128709. /**
  128710. * Return the list of active sub meshes
  128711. * @param mesh The mesh to get the candidates sub meshes from
  128712. * @returns the list of active sub meshes
  128713. */
  128714. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  128715. private _tempRay;
  128716. /**
  128717. * Return the list of sub meshes intersecting with a given local ray
  128718. * @param mesh defines the mesh to find the submesh for
  128719. * @param localRay defines the ray in local space
  128720. * @returns the list of intersecting sub meshes
  128721. */
  128722. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  128723. /**
  128724. * Return the list of sub meshes colliding with a collider
  128725. * @param mesh defines the mesh to find the submesh for
  128726. * @param collider defines the collider to evaluate the collision against
  128727. * @returns the list of colliding sub meshes
  128728. */
  128729. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  128730. /**
  128731. * Rebuilds the elements related to this component in case of
  128732. * context lost for instance.
  128733. */
  128734. rebuild(): void;
  128735. /**
  128736. * Disposes the component and the associated ressources.
  128737. */
  128738. dispose(): void;
  128739. }
  128740. }
  128741. declare module BABYLON {
  128742. /**
  128743. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  128744. */
  128745. export class Gizmo implements IDisposable {
  128746. /** The utility layer the gizmo will be added to */
  128747. gizmoLayer: UtilityLayerRenderer;
  128748. /**
  128749. * The root mesh of the gizmo
  128750. */
  128751. _rootMesh: Mesh;
  128752. private _attachedMesh;
  128753. private _attachedNode;
  128754. /**
  128755. * Ratio for the scale of the gizmo (Default: 1)
  128756. */
  128757. scaleRatio: number;
  128758. /**
  128759. * If a custom mesh has been set (Default: false)
  128760. */
  128761. protected _customMeshSet: boolean;
  128762. /**
  128763. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  128764. * * When set, interactions will be enabled
  128765. */
  128766. get attachedMesh(): Nullable<AbstractMesh>;
  128767. set attachedMesh(value: Nullable<AbstractMesh>);
  128768. /**
  128769. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  128770. * * When set, interactions will be enabled
  128771. */
  128772. get attachedNode(): Nullable<Node>;
  128773. set attachedNode(value: Nullable<Node>);
  128774. /**
  128775. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  128776. * @param mesh The mesh to replace the default mesh of the gizmo
  128777. */
  128778. setCustomMesh(mesh: Mesh): void;
  128779. /**
  128780. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  128781. */
  128782. updateGizmoRotationToMatchAttachedMesh: boolean;
  128783. /**
  128784. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  128785. */
  128786. updateGizmoPositionToMatchAttachedMesh: boolean;
  128787. /**
  128788. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  128789. */
  128790. updateScale: boolean;
  128791. protected _interactionsEnabled: boolean;
  128792. protected _attachedNodeChanged(value: Nullable<Node>): void;
  128793. private _beforeRenderObserver;
  128794. private _tempVector;
  128795. /**
  128796. * Creates a gizmo
  128797. * @param gizmoLayer The utility layer the gizmo will be added to
  128798. */
  128799. constructor(
  128800. /** The utility layer the gizmo will be added to */
  128801. gizmoLayer?: UtilityLayerRenderer);
  128802. /**
  128803. * Updates the gizmo to match the attached mesh's position/rotation
  128804. */
  128805. protected _update(): void;
  128806. /**
  128807. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  128808. * @param value Node, TransformNode or mesh
  128809. */
  128810. protected _matrixChanged(): void;
  128811. /**
  128812. * Disposes of the gizmo
  128813. */
  128814. dispose(): void;
  128815. }
  128816. }
  128817. declare module BABYLON {
  128818. /**
  128819. * Single plane drag gizmo
  128820. */
  128821. export class PlaneDragGizmo extends Gizmo {
  128822. /**
  128823. * Drag behavior responsible for the gizmos dragging interactions
  128824. */
  128825. dragBehavior: PointerDragBehavior;
  128826. private _pointerObserver;
  128827. /**
  128828. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  128829. */
  128830. snapDistance: number;
  128831. /**
  128832. * Event that fires each time the gizmo snaps to a new location.
  128833. * * snapDistance is the the change in distance
  128834. */
  128835. onSnapObservable: Observable<{
  128836. snapDistance: number;
  128837. }>;
  128838. private _plane;
  128839. private _coloredMaterial;
  128840. private _hoverMaterial;
  128841. private _isEnabled;
  128842. private _parent;
  128843. /** @hidden */
  128844. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  128845. /** @hidden */
  128846. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  128847. /**
  128848. * Creates a PlaneDragGizmo
  128849. * @param gizmoLayer The utility layer the gizmo will be added to
  128850. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  128851. * @param color The color of the gizmo
  128852. */
  128853. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  128854. protected _attachedNodeChanged(value: Nullable<Node>): void;
  128855. /**
  128856. * If the gizmo is enabled
  128857. */
  128858. set isEnabled(value: boolean);
  128859. get isEnabled(): boolean;
  128860. /**
  128861. * Disposes of the gizmo
  128862. */
  128863. dispose(): void;
  128864. }
  128865. }
  128866. declare module BABYLON {
  128867. /**
  128868. * Gizmo that enables dragging a mesh along 3 axis
  128869. */
  128870. export class PositionGizmo extends Gizmo {
  128871. /**
  128872. * Internal gizmo used for interactions on the x axis
  128873. */
  128874. xGizmo: AxisDragGizmo;
  128875. /**
  128876. * Internal gizmo used for interactions on the y axis
  128877. */
  128878. yGizmo: AxisDragGizmo;
  128879. /**
  128880. * Internal gizmo used for interactions on the z axis
  128881. */
  128882. zGizmo: AxisDragGizmo;
  128883. /**
  128884. * Internal gizmo used for interactions on the yz plane
  128885. */
  128886. xPlaneGizmo: PlaneDragGizmo;
  128887. /**
  128888. * Internal gizmo used for interactions on the xz plane
  128889. */
  128890. yPlaneGizmo: PlaneDragGizmo;
  128891. /**
  128892. * Internal gizmo used for interactions on the xy plane
  128893. */
  128894. zPlaneGizmo: PlaneDragGizmo;
  128895. /**
  128896. * private variables
  128897. */
  128898. private _meshAttached;
  128899. private _nodeAttached;
  128900. private _updateGizmoRotationToMatchAttachedMesh;
  128901. private _snapDistance;
  128902. private _scaleRatio;
  128903. /** Fires an event when any of it's sub gizmos are dragged */
  128904. onDragStartObservable: Observable<unknown>;
  128905. /** Fires an event when any of it's sub gizmos are released from dragging */
  128906. onDragEndObservable: Observable<unknown>;
  128907. /**
  128908. * If set to true, planar drag is enabled
  128909. */
  128910. private _planarGizmoEnabled;
  128911. get attachedMesh(): Nullable<AbstractMesh>;
  128912. set attachedMesh(mesh: Nullable<AbstractMesh>);
  128913. get attachedNode(): Nullable<Node>;
  128914. set attachedNode(node: Nullable<Node>);
  128915. /**
  128916. * Creates a PositionGizmo
  128917. * @param gizmoLayer The utility layer the gizmo will be added to
  128918. @param thickness display gizmo axis thickness
  128919. */
  128920. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  128921. /**
  128922. * If the planar drag gizmo is enabled
  128923. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  128924. */
  128925. set planarGizmoEnabled(value: boolean);
  128926. get planarGizmoEnabled(): boolean;
  128927. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  128928. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  128929. /**
  128930. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  128931. */
  128932. set snapDistance(value: number);
  128933. get snapDistance(): number;
  128934. /**
  128935. * Ratio for the scale of the gizmo (Default: 1)
  128936. */
  128937. set scaleRatio(value: number);
  128938. get scaleRatio(): number;
  128939. /**
  128940. * Disposes of the gizmo
  128941. */
  128942. dispose(): void;
  128943. /**
  128944. * CustomMeshes are not supported by this gizmo
  128945. * @param mesh The mesh to replace the default mesh of the gizmo
  128946. */
  128947. setCustomMesh(mesh: Mesh): void;
  128948. }
  128949. }
  128950. declare module BABYLON {
  128951. /**
  128952. * Single axis drag gizmo
  128953. */
  128954. export class AxisDragGizmo extends Gizmo {
  128955. /**
  128956. * Drag behavior responsible for the gizmos dragging interactions
  128957. */
  128958. dragBehavior: PointerDragBehavior;
  128959. private _pointerObserver;
  128960. /**
  128961. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  128962. */
  128963. snapDistance: number;
  128964. /**
  128965. * Event that fires each time the gizmo snaps to a new location.
  128966. * * snapDistance is the the change in distance
  128967. */
  128968. onSnapObservable: Observable<{
  128969. snapDistance: number;
  128970. }>;
  128971. private _isEnabled;
  128972. private _parent;
  128973. private _arrow;
  128974. private _coloredMaterial;
  128975. private _hoverMaterial;
  128976. /** @hidden */
  128977. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  128978. /** @hidden */
  128979. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  128980. /**
  128981. * Creates an AxisDragGizmo
  128982. * @param gizmoLayer The utility layer the gizmo will be added to
  128983. * @param dragAxis The axis which the gizmo will be able to drag on
  128984. * @param color The color of the gizmo
  128985. * @param thickness display gizmo axis thickness
  128986. */
  128987. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  128988. protected _attachedNodeChanged(value: Nullable<Node>): void;
  128989. /**
  128990. * If the gizmo is enabled
  128991. */
  128992. set isEnabled(value: boolean);
  128993. get isEnabled(): boolean;
  128994. /**
  128995. * Disposes of the gizmo
  128996. */
  128997. dispose(): void;
  128998. }
  128999. }
  129000. declare module BABYLON.Debug {
  129001. /**
  129002. * The Axes viewer will show 3 axes in a specific point in space
  129003. */
  129004. export class AxesViewer {
  129005. private _xAxis;
  129006. private _yAxis;
  129007. private _zAxis;
  129008. private _scaleLinesFactor;
  129009. private _instanced;
  129010. /**
  129011. * Gets the hosting scene
  129012. */
  129013. scene: Scene;
  129014. /**
  129015. * Gets or sets a number used to scale line length
  129016. */
  129017. scaleLines: number;
  129018. /** Gets the node hierarchy used to render x-axis */
  129019. get xAxis(): TransformNode;
  129020. /** Gets the node hierarchy used to render y-axis */
  129021. get yAxis(): TransformNode;
  129022. /** Gets the node hierarchy used to render z-axis */
  129023. get zAxis(): TransformNode;
  129024. /**
  129025. * Creates a new AxesViewer
  129026. * @param scene defines the hosting scene
  129027. * @param scaleLines defines a number used to scale line length (1 by default)
  129028. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  129029. * @param xAxis defines the node hierarchy used to render the x-axis
  129030. * @param yAxis defines the node hierarchy used to render the y-axis
  129031. * @param zAxis defines the node hierarchy used to render the z-axis
  129032. */
  129033. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  129034. /**
  129035. * Force the viewer to update
  129036. * @param position defines the position of the viewer
  129037. * @param xaxis defines the x axis of the viewer
  129038. * @param yaxis defines the y axis of the viewer
  129039. * @param zaxis defines the z axis of the viewer
  129040. */
  129041. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  129042. /**
  129043. * Creates an instance of this axes viewer.
  129044. * @returns a new axes viewer with instanced meshes
  129045. */
  129046. createInstance(): AxesViewer;
  129047. /** Releases resources */
  129048. dispose(): void;
  129049. private static _SetRenderingGroupId;
  129050. }
  129051. }
  129052. declare module BABYLON.Debug {
  129053. /**
  129054. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  129055. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  129056. */
  129057. export class BoneAxesViewer extends AxesViewer {
  129058. /**
  129059. * Gets or sets the target mesh where to display the axes viewer
  129060. */
  129061. mesh: Nullable<Mesh>;
  129062. /**
  129063. * Gets or sets the target bone where to display the axes viewer
  129064. */
  129065. bone: Nullable<Bone>;
  129066. /** Gets current position */
  129067. pos: Vector3;
  129068. /** Gets direction of X axis */
  129069. xaxis: Vector3;
  129070. /** Gets direction of Y axis */
  129071. yaxis: Vector3;
  129072. /** Gets direction of Z axis */
  129073. zaxis: Vector3;
  129074. /**
  129075. * Creates a new BoneAxesViewer
  129076. * @param scene defines the hosting scene
  129077. * @param bone defines the target bone
  129078. * @param mesh defines the target mesh
  129079. * @param scaleLines defines a scaling factor for line length (1 by default)
  129080. */
  129081. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  129082. /**
  129083. * Force the viewer to update
  129084. */
  129085. update(): void;
  129086. /** Releases resources */
  129087. dispose(): void;
  129088. }
  129089. }
  129090. declare module BABYLON {
  129091. /**
  129092. * Interface used to define scene explorer extensibility option
  129093. */
  129094. export interface IExplorerExtensibilityOption {
  129095. /**
  129096. * Define the option label
  129097. */
  129098. label: string;
  129099. /**
  129100. * Defines the action to execute on click
  129101. */
  129102. action: (entity: any) => void;
  129103. }
  129104. /**
  129105. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  129106. */
  129107. export interface IExplorerExtensibilityGroup {
  129108. /**
  129109. * Defines a predicate to test if a given type mut be extended
  129110. */
  129111. predicate: (entity: any) => boolean;
  129112. /**
  129113. * Gets the list of options added to a type
  129114. */
  129115. entries: IExplorerExtensibilityOption[];
  129116. }
  129117. /**
  129118. * Interface used to define the options to use to create the Inspector
  129119. */
  129120. export interface IInspectorOptions {
  129121. /**
  129122. * Display in overlay mode (default: false)
  129123. */
  129124. overlay?: boolean;
  129125. /**
  129126. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  129127. */
  129128. globalRoot?: HTMLElement;
  129129. /**
  129130. * Display the Scene explorer
  129131. */
  129132. showExplorer?: boolean;
  129133. /**
  129134. * Display the property inspector
  129135. */
  129136. showInspector?: boolean;
  129137. /**
  129138. * Display in embed mode (both panes on the right)
  129139. */
  129140. embedMode?: boolean;
  129141. /**
  129142. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  129143. */
  129144. handleResize?: boolean;
  129145. /**
  129146. * Allow the panes to popup (default: true)
  129147. */
  129148. enablePopup?: boolean;
  129149. /**
  129150. * Allow the panes to be closed by users (default: true)
  129151. */
  129152. enableClose?: boolean;
  129153. /**
  129154. * Optional list of extensibility entries
  129155. */
  129156. explorerExtensibility?: IExplorerExtensibilityGroup[];
  129157. /**
  129158. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  129159. */
  129160. inspectorURL?: string;
  129161. /**
  129162. * Optional initial tab (default to DebugLayerTab.Properties)
  129163. */
  129164. initialTab?: DebugLayerTab;
  129165. }
  129166. interface Scene {
  129167. /**
  129168. * @hidden
  129169. * Backing field
  129170. */
  129171. _debugLayer: DebugLayer;
  129172. /**
  129173. * Gets the debug layer (aka Inspector) associated with the scene
  129174. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129175. */
  129176. debugLayer: DebugLayer;
  129177. }
  129178. /**
  129179. * Enum of inspector action tab
  129180. */
  129181. export enum DebugLayerTab {
  129182. /**
  129183. * Properties tag (default)
  129184. */
  129185. Properties = 0,
  129186. /**
  129187. * Debug tab
  129188. */
  129189. Debug = 1,
  129190. /**
  129191. * Statistics tab
  129192. */
  129193. Statistics = 2,
  129194. /**
  129195. * Tools tab
  129196. */
  129197. Tools = 3,
  129198. /**
  129199. * Settings tab
  129200. */
  129201. Settings = 4
  129202. }
  129203. /**
  129204. * The debug layer (aka Inspector) is the go to tool in order to better understand
  129205. * what is happening in your scene
  129206. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129207. */
  129208. export class DebugLayer {
  129209. /**
  129210. * Define the url to get the inspector script from.
  129211. * By default it uses the babylonjs CDN.
  129212. * @ignoreNaming
  129213. */
  129214. static InspectorURL: string;
  129215. private _scene;
  129216. private BJSINSPECTOR;
  129217. private _onPropertyChangedObservable?;
  129218. /**
  129219. * Observable triggered when a property is changed through the inspector.
  129220. */
  129221. get onPropertyChangedObservable(): any;
  129222. /**
  129223. * Instantiates a new debug layer.
  129224. * The debug layer (aka Inspector) is the go to tool in order to better understand
  129225. * what is happening in your scene
  129226. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129227. * @param scene Defines the scene to inspect
  129228. */
  129229. constructor(scene: Scene);
  129230. /** Creates the inspector window. */
  129231. private _createInspector;
  129232. /**
  129233. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  129234. * @param entity defines the entity to select
  129235. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  129236. */
  129237. select(entity: any, lineContainerTitles?: string | string[]): void;
  129238. /** Get the inspector from bundle or global */
  129239. private _getGlobalInspector;
  129240. /**
  129241. * Get if the inspector is visible or not.
  129242. * @returns true if visible otherwise, false
  129243. */
  129244. isVisible(): boolean;
  129245. /**
  129246. * Hide the inspector and close its window.
  129247. */
  129248. hide(): void;
  129249. /**
  129250. * Update the scene in the inspector
  129251. */
  129252. setAsActiveScene(): void;
  129253. /**
  129254. * Launch the debugLayer.
  129255. * @param config Define the configuration of the inspector
  129256. * @return a promise fulfilled when the debug layer is visible
  129257. */
  129258. show(config?: IInspectorOptions): Promise<DebugLayer>;
  129259. }
  129260. }
  129261. declare module BABYLON {
  129262. /**
  129263. * Class containing static functions to help procedurally build meshes
  129264. */
  129265. export class BoxBuilder {
  129266. /**
  129267. * Creates a box mesh
  129268. * * The parameter `size` sets the size (float) of each box side (default 1)
  129269. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  129270. * * 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)
  129271. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129273. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129275. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129276. * @param name defines the name of the mesh
  129277. * @param options defines the options used to create the mesh
  129278. * @param scene defines the hosting scene
  129279. * @returns the box mesh
  129280. */
  129281. static CreateBox(name: string, options: {
  129282. size?: number;
  129283. width?: number;
  129284. height?: number;
  129285. depth?: number;
  129286. faceUV?: Vector4[];
  129287. faceColors?: Color4[];
  129288. sideOrientation?: number;
  129289. frontUVs?: Vector4;
  129290. backUVs?: Vector4;
  129291. wrap?: boolean;
  129292. topBaseAt?: number;
  129293. bottomBaseAt?: number;
  129294. updatable?: boolean;
  129295. }, scene?: Nullable<Scene>): Mesh;
  129296. }
  129297. }
  129298. declare module BABYLON.Debug {
  129299. /**
  129300. * Used to show the physics impostor around the specific mesh
  129301. */
  129302. export class PhysicsViewer {
  129303. /** @hidden */
  129304. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  129305. /** @hidden */
  129306. protected _meshes: Array<Nullable<AbstractMesh>>;
  129307. /** @hidden */
  129308. protected _scene: Nullable<Scene>;
  129309. /** @hidden */
  129310. protected _numMeshes: number;
  129311. /** @hidden */
  129312. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  129313. private _renderFunction;
  129314. private _utilityLayer;
  129315. private _debugBoxMesh;
  129316. private _debugSphereMesh;
  129317. private _debugCylinderMesh;
  129318. private _debugMaterial;
  129319. private _debugMeshMeshes;
  129320. /**
  129321. * Creates a new PhysicsViewer
  129322. * @param scene defines the hosting scene
  129323. */
  129324. constructor(scene: Scene);
  129325. /** @hidden */
  129326. protected _updateDebugMeshes(): void;
  129327. /**
  129328. * Renders a specified physic impostor
  129329. * @param impostor defines the impostor to render
  129330. * @param targetMesh defines the mesh represented by the impostor
  129331. * @returns the new debug mesh used to render the impostor
  129332. */
  129333. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  129334. /**
  129335. * Hides a specified physic impostor
  129336. * @param impostor defines the impostor to hide
  129337. */
  129338. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  129339. private _getDebugMaterial;
  129340. private _getDebugBoxMesh;
  129341. private _getDebugSphereMesh;
  129342. private _getDebugCylinderMesh;
  129343. private _getDebugMeshMesh;
  129344. private _getDebugMesh;
  129345. /** Releases all resources */
  129346. dispose(): void;
  129347. }
  129348. }
  129349. declare module BABYLON {
  129350. /**
  129351. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  129352. * in order to better appreciate the issue one might have.
  129353. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  129354. */
  129355. export class RayHelper {
  129356. /**
  129357. * Defines the ray we are currently tryin to visualize.
  129358. */
  129359. ray: Nullable<Ray>;
  129360. private _renderPoints;
  129361. private _renderLine;
  129362. private _renderFunction;
  129363. private _scene;
  129364. private _updateToMeshFunction;
  129365. private _attachedToMesh;
  129366. private _meshSpaceDirection;
  129367. private _meshSpaceOrigin;
  129368. /**
  129369. * Helper function to create a colored helper in a scene in one line.
  129370. * @param ray Defines the ray we are currently tryin to visualize
  129371. * @param scene Defines the scene the ray is used in
  129372. * @param color Defines the color we want to see the ray in
  129373. * @returns The newly created ray helper.
  129374. */
  129375. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  129376. /**
  129377. * Instantiate a new ray helper.
  129378. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  129379. * in order to better appreciate the issue one might have.
  129380. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  129381. * @param ray Defines the ray we are currently tryin to visualize
  129382. */
  129383. constructor(ray: Ray);
  129384. /**
  129385. * Shows the ray we are willing to debug.
  129386. * @param scene Defines the scene the ray needs to be rendered in
  129387. * @param color Defines the color the ray needs to be rendered in
  129388. */
  129389. show(scene: Scene, color?: Color3): void;
  129390. /**
  129391. * Hides the ray we are debugging.
  129392. */
  129393. hide(): void;
  129394. private _render;
  129395. /**
  129396. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  129397. * @param mesh Defines the mesh we want the helper attached to
  129398. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  129399. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  129400. * @param length Defines the length of the ray
  129401. */
  129402. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  129403. /**
  129404. * Detach the ray helper from the mesh it has previously been attached to.
  129405. */
  129406. detachFromMesh(): void;
  129407. private _updateToMesh;
  129408. /**
  129409. * Dispose the helper and release its associated resources.
  129410. */
  129411. dispose(): void;
  129412. }
  129413. }
  129414. declare module BABYLON.Debug {
  129415. /**
  129416. * Class used to render a debug view of a given skeleton
  129417. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  129418. */
  129419. export class SkeletonViewer {
  129420. /** defines the skeleton to render */
  129421. skeleton: Skeleton;
  129422. /** defines the mesh attached to the skeleton */
  129423. mesh: AbstractMesh;
  129424. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  129425. autoUpdateBonesMatrices: boolean;
  129426. /** defines the rendering group id to use with the viewer */
  129427. renderingGroupId: number;
  129428. /** Gets or sets the color used to render the skeleton */
  129429. color: Color3;
  129430. private _scene;
  129431. private _debugLines;
  129432. private _debugMesh;
  129433. private _isEnabled;
  129434. private _renderFunction;
  129435. private _utilityLayer;
  129436. /**
  129437. * Returns the mesh used to render the bones
  129438. */
  129439. get debugMesh(): Nullable<LinesMesh>;
  129440. /**
  129441. * Creates a new SkeletonViewer
  129442. * @param skeleton defines the skeleton to render
  129443. * @param mesh defines the mesh attached to the skeleton
  129444. * @param scene defines the hosting scene
  129445. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  129446. * @param renderingGroupId defines the rendering group id to use with the viewer
  129447. */
  129448. constructor(
  129449. /** defines the skeleton to render */
  129450. skeleton: Skeleton,
  129451. /** defines the mesh attached to the skeleton */
  129452. mesh: AbstractMesh, scene: Scene,
  129453. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  129454. autoUpdateBonesMatrices?: boolean,
  129455. /** defines the rendering group id to use with the viewer */
  129456. renderingGroupId?: number);
  129457. /** Gets or sets a boolean indicating if the viewer is enabled */
  129458. set isEnabled(value: boolean);
  129459. get isEnabled(): boolean;
  129460. private _getBonePosition;
  129461. private _getLinesForBonesWithLength;
  129462. private _getLinesForBonesNoLength;
  129463. /** Update the viewer to sync with current skeleton state */
  129464. update(): void;
  129465. /** Release associated resources */
  129466. dispose(): void;
  129467. }
  129468. }
  129469. declare module BABYLON {
  129470. /**
  129471. * Enum for Device Types
  129472. */
  129473. export enum DeviceType {
  129474. /** Generic */
  129475. Generic = 0,
  129476. /** Keyboard */
  129477. Keyboard = 1,
  129478. /** Mouse */
  129479. Mouse = 2,
  129480. /** Touch Pointers */
  129481. Touch = 3,
  129482. /** PS4 Dual Shock */
  129483. DualShock = 4,
  129484. /** Xbox */
  129485. Xbox = 5,
  129486. /** Switch Controller */
  129487. Switch = 6
  129488. }
  129489. /**
  129490. * Enum for All Pointers (Touch/Mouse)
  129491. */
  129492. export enum PointerInput {
  129493. /** Horizontal Axis */
  129494. Horizontal = 0,
  129495. /** Vertical Axis */
  129496. Vertical = 1,
  129497. /** Left Click or Touch */
  129498. LeftClick = 2,
  129499. /** Middle Click */
  129500. MiddleClick = 3,
  129501. /** Right Click */
  129502. RightClick = 4,
  129503. /** Browser Back */
  129504. BrowserBack = 5,
  129505. /** Browser Forward */
  129506. BrowserForward = 6
  129507. }
  129508. /**
  129509. * Enum for Dual Shock Gamepad
  129510. */
  129511. export enum DualShockInput {
  129512. /** Cross */
  129513. Cross = 0,
  129514. /** Circle */
  129515. Circle = 1,
  129516. /** Square */
  129517. Square = 2,
  129518. /** Triangle */
  129519. Triangle = 3,
  129520. /** L1 */
  129521. L1 = 4,
  129522. /** R1 */
  129523. R1 = 5,
  129524. /** L2 */
  129525. L2 = 6,
  129526. /** R2 */
  129527. R2 = 7,
  129528. /** Share */
  129529. Share = 8,
  129530. /** Options */
  129531. Options = 9,
  129532. /** L3 */
  129533. L3 = 10,
  129534. /** R3 */
  129535. R3 = 11,
  129536. /** DPadUp */
  129537. DPadUp = 12,
  129538. /** DPadDown */
  129539. DPadDown = 13,
  129540. /** DPadLeft */
  129541. DPadLeft = 14,
  129542. /** DRight */
  129543. DPadRight = 15,
  129544. /** Home */
  129545. Home = 16,
  129546. /** TouchPad */
  129547. TouchPad = 17,
  129548. /** LStickXAxis */
  129549. LStickXAxis = 18,
  129550. /** LStickYAxis */
  129551. LStickYAxis = 19,
  129552. /** RStickXAxis */
  129553. RStickXAxis = 20,
  129554. /** RStickYAxis */
  129555. RStickYAxis = 21
  129556. }
  129557. /**
  129558. * Enum for Xbox Gamepad
  129559. */
  129560. export enum XboxInput {
  129561. /** A */
  129562. A = 0,
  129563. /** B */
  129564. B = 1,
  129565. /** X */
  129566. X = 2,
  129567. /** Y */
  129568. Y = 3,
  129569. /** LB */
  129570. LB = 4,
  129571. /** RB */
  129572. RB = 5,
  129573. /** LT */
  129574. LT = 6,
  129575. /** RT */
  129576. RT = 7,
  129577. /** Back */
  129578. Back = 8,
  129579. /** Start */
  129580. Start = 9,
  129581. /** LS */
  129582. LS = 10,
  129583. /** RS */
  129584. RS = 11,
  129585. /** DPadUp */
  129586. DPadUp = 12,
  129587. /** DPadDown */
  129588. DPadDown = 13,
  129589. /** DPadLeft */
  129590. DPadLeft = 14,
  129591. /** DRight */
  129592. DPadRight = 15,
  129593. /** Home */
  129594. Home = 16,
  129595. /** LStickXAxis */
  129596. LStickXAxis = 17,
  129597. /** LStickYAxis */
  129598. LStickYAxis = 18,
  129599. /** RStickXAxis */
  129600. RStickXAxis = 19,
  129601. /** RStickYAxis */
  129602. RStickYAxis = 20
  129603. }
  129604. /**
  129605. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  129606. */
  129607. export enum SwitchInput {
  129608. /** B */
  129609. B = 0,
  129610. /** A */
  129611. A = 1,
  129612. /** Y */
  129613. Y = 2,
  129614. /** X */
  129615. X = 3,
  129616. /** L */
  129617. L = 4,
  129618. /** R */
  129619. R = 5,
  129620. /** ZL */
  129621. ZL = 6,
  129622. /** ZR */
  129623. ZR = 7,
  129624. /** Minus */
  129625. Minus = 8,
  129626. /** Plus */
  129627. Plus = 9,
  129628. /** LS */
  129629. LS = 10,
  129630. /** RS */
  129631. RS = 11,
  129632. /** DPadUp */
  129633. DPadUp = 12,
  129634. /** DPadDown */
  129635. DPadDown = 13,
  129636. /** DPadLeft */
  129637. DPadLeft = 14,
  129638. /** DRight */
  129639. DPadRight = 15,
  129640. /** Home */
  129641. Home = 16,
  129642. /** Capture */
  129643. Capture = 17,
  129644. /** LStickXAxis */
  129645. LStickXAxis = 18,
  129646. /** LStickYAxis */
  129647. LStickYAxis = 19,
  129648. /** RStickXAxis */
  129649. RStickXAxis = 20,
  129650. /** RStickYAxis */
  129651. RStickYAxis = 21
  129652. }
  129653. }
  129654. declare module BABYLON {
  129655. /**
  129656. * This class will take all inputs from Keyboard, Pointer, and
  129657. * any Gamepads and provide a polling system that all devices
  129658. * will use. This class assumes that there will only be one
  129659. * pointer device and one keyboard.
  129660. */
  129661. export class DeviceInputSystem implements IDisposable {
  129662. /**
  129663. * Callback to be triggered when a device is connected
  129664. */
  129665. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  129666. /**
  129667. * Callback to be triggered when a device is disconnected
  129668. */
  129669. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  129670. /**
  129671. * Callback to be triggered when event driven input is updated
  129672. */
  129673. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  129674. private _inputs;
  129675. private _gamepads;
  129676. private _keyboardActive;
  129677. private _pointerActive;
  129678. private _elementToAttachTo;
  129679. private _keyboardDownEvent;
  129680. private _keyboardUpEvent;
  129681. private _pointerMoveEvent;
  129682. private _pointerDownEvent;
  129683. private _pointerUpEvent;
  129684. private _gamepadConnectedEvent;
  129685. private _gamepadDisconnectedEvent;
  129686. private static _MAX_KEYCODES;
  129687. private static _MAX_POINTER_INPUTS;
  129688. private constructor();
  129689. /**
  129690. * Creates a new DeviceInputSystem instance
  129691. * @param engine Engine to pull input element from
  129692. * @returns The new instance
  129693. */
  129694. static Create(engine: Engine): DeviceInputSystem;
  129695. /**
  129696. * Checks for current device input value, given an id and input index
  129697. * @param deviceName Id of connected device
  129698. * @param inputIndex Index of device input
  129699. * @returns Current value of input
  129700. */
  129701. /**
  129702. * Checks for current device input value, given an id and input index
  129703. * @param deviceType Enum specifiying device type
  129704. * @param deviceSlot "Slot" or index that device is referenced in
  129705. * @param inputIndex Id of input to be checked
  129706. * @returns Current value of input
  129707. */
  129708. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  129709. /**
  129710. * Dispose of all the eventlisteners
  129711. */
  129712. dispose(): void;
  129713. /**
  129714. * Add device and inputs to device array
  129715. * @param deviceType Enum specifiying device type
  129716. * @param deviceSlot "Slot" or index that device is referenced in
  129717. * @param numberOfInputs Number of input entries to create for given device
  129718. */
  129719. private _registerDevice;
  129720. /**
  129721. * Given a specific device name, remove that device from the device map
  129722. * @param deviceType Enum specifiying device type
  129723. * @param deviceSlot "Slot" or index that device is referenced in
  129724. */
  129725. private _unregisterDevice;
  129726. /**
  129727. * Handle all actions that come from keyboard interaction
  129728. */
  129729. private _handleKeyActions;
  129730. /**
  129731. * Handle all actions that come from pointer interaction
  129732. */
  129733. private _handlePointerActions;
  129734. /**
  129735. * Handle all actions that come from gamepad interaction
  129736. */
  129737. private _handleGamepadActions;
  129738. /**
  129739. * Update all non-event based devices with each frame
  129740. * @param deviceType Enum specifiying device type
  129741. * @param deviceSlot "Slot" or index that device is referenced in
  129742. * @param inputIndex Id of input to be checked
  129743. */
  129744. private _updateDevice;
  129745. /**
  129746. * Gets DeviceType from the device name
  129747. * @param deviceName Name of Device from DeviceInputSystem
  129748. * @returns DeviceType enum value
  129749. */
  129750. private _getGamepadDeviceType;
  129751. }
  129752. }
  129753. declare module BABYLON {
  129754. /**
  129755. * Type to handle enforcement of inputs
  129756. */
  129757. 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;
  129758. }
  129759. declare module BABYLON {
  129760. /**
  129761. * Class that handles all input for a specific device
  129762. */
  129763. export class DeviceSource<T extends DeviceType> {
  129764. /** Type of device */
  129765. readonly deviceType: DeviceType;
  129766. /** "Slot" or index that device is referenced in */
  129767. readonly deviceSlot: number;
  129768. /**
  129769. * Observable to handle device input changes per device
  129770. */
  129771. readonly onInputChangedObservable: Observable<{
  129772. inputIndex: DeviceInput<T>;
  129773. previousState: Nullable<number>;
  129774. currentState: Nullable<number>;
  129775. }>;
  129776. private readonly _deviceInputSystem;
  129777. /**
  129778. * Default Constructor
  129779. * @param deviceInputSystem Reference to DeviceInputSystem
  129780. * @param deviceType Type of device
  129781. * @param deviceSlot "Slot" or index that device is referenced in
  129782. */
  129783. constructor(deviceInputSystem: DeviceInputSystem,
  129784. /** Type of device */
  129785. deviceType: DeviceType,
  129786. /** "Slot" or index that device is referenced in */
  129787. deviceSlot?: number);
  129788. /**
  129789. * Get input for specific input
  129790. * @param inputIndex index of specific input on device
  129791. * @returns Input value from DeviceInputSystem
  129792. */
  129793. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  129794. }
  129795. /**
  129796. * Class to keep track of devices
  129797. */
  129798. export class DeviceSourceManager implements IDisposable {
  129799. /**
  129800. * Observable to be triggered when before a device is connected
  129801. */
  129802. readonly onBeforeDeviceConnectedObservable: Observable<{
  129803. deviceType: DeviceType;
  129804. deviceSlot: number;
  129805. }>;
  129806. /**
  129807. * Observable to be triggered when before a device is disconnected
  129808. */
  129809. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  129810. deviceType: DeviceType;
  129811. deviceSlot: number;
  129812. }>;
  129813. /**
  129814. * Observable to be triggered when after a device is connected
  129815. */
  129816. readonly onAfterDeviceConnectedObservable: Observable<{
  129817. deviceType: DeviceType;
  129818. deviceSlot: number;
  129819. }>;
  129820. /**
  129821. * Observable to be triggered when after a device is disconnected
  129822. */
  129823. readonly onAfterDeviceDisconnectedObservable: Observable<{
  129824. deviceType: DeviceType;
  129825. deviceSlot: number;
  129826. }>;
  129827. private readonly _devices;
  129828. private readonly _firstDevice;
  129829. private readonly _deviceInputSystem;
  129830. /**
  129831. * Default Constructor
  129832. * @param engine engine to pull input element from
  129833. */
  129834. constructor(engine: Engine);
  129835. /**
  129836. * Gets a DeviceSource, given a type and slot
  129837. * @param deviceType Enum specifying device type
  129838. * @param deviceSlot "Slot" or index that device is referenced in
  129839. * @returns DeviceSource object
  129840. */
  129841. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  129842. /**
  129843. * Gets an array of DeviceSource objects for a given device type
  129844. * @param deviceType Enum specifying device type
  129845. * @returns Array of DeviceSource objects
  129846. */
  129847. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  129848. /**
  129849. * Dispose of DeviceInputSystem and other parts
  129850. */
  129851. dispose(): void;
  129852. /**
  129853. * Function to add device name to device list
  129854. * @param deviceType Enum specifying device type
  129855. * @param deviceSlot "Slot" or index that device is referenced in
  129856. */
  129857. private _addDevice;
  129858. /**
  129859. * Function to remove device name to device list
  129860. * @param deviceType Enum specifying device type
  129861. * @param deviceSlot "Slot" or index that device is referenced in
  129862. */
  129863. private _removeDevice;
  129864. /**
  129865. * Updates array storing first connected device of each type
  129866. * @param type Type of Device
  129867. */
  129868. private _updateFirstDevices;
  129869. }
  129870. }
  129871. declare module BABYLON {
  129872. /**
  129873. * Options to create the null engine
  129874. */
  129875. export class NullEngineOptions {
  129876. /**
  129877. * Render width (Default: 512)
  129878. */
  129879. renderWidth: number;
  129880. /**
  129881. * Render height (Default: 256)
  129882. */
  129883. renderHeight: number;
  129884. /**
  129885. * Texture size (Default: 512)
  129886. */
  129887. textureSize: number;
  129888. /**
  129889. * If delta time between frames should be constant
  129890. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129891. */
  129892. deterministicLockstep: boolean;
  129893. /**
  129894. * Maximum about of steps between frames (Default: 4)
  129895. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129896. */
  129897. lockstepMaxSteps: number;
  129898. /**
  129899. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  129900. */
  129901. useHighPrecisionMatrix?: boolean;
  129902. }
  129903. /**
  129904. * The null engine class provides support for headless version of babylon.js.
  129905. * This can be used in server side scenario or for testing purposes
  129906. */
  129907. export class NullEngine extends Engine {
  129908. private _options;
  129909. /**
  129910. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  129911. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129912. * @returns true if engine is in deterministic lock step mode
  129913. */
  129914. isDeterministicLockStep(): boolean;
  129915. /**
  129916. * Gets the max steps when engine is running in deterministic lock step
  129917. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129918. * @returns the max steps
  129919. */
  129920. getLockstepMaxSteps(): number;
  129921. /**
  129922. * Gets the current hardware scaling level.
  129923. * By default the hardware scaling level is computed from the window device ratio.
  129924. * 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.
  129925. * @returns a number indicating the current hardware scaling level
  129926. */
  129927. getHardwareScalingLevel(): number;
  129928. constructor(options?: NullEngineOptions);
  129929. /**
  129930. * Creates a vertex buffer
  129931. * @param vertices the data for the vertex buffer
  129932. * @returns the new WebGL static buffer
  129933. */
  129934. createVertexBuffer(vertices: FloatArray): DataBuffer;
  129935. /**
  129936. * Creates a new index buffer
  129937. * @param indices defines the content of the index buffer
  129938. * @param updatable defines if the index buffer must be updatable
  129939. * @returns a new webGL buffer
  129940. */
  129941. createIndexBuffer(indices: IndicesArray): DataBuffer;
  129942. /**
  129943. * Clear the current render buffer or the current render target (if any is set up)
  129944. * @param color defines the color to use
  129945. * @param backBuffer defines if the back buffer must be cleared
  129946. * @param depth defines if the depth buffer must be cleared
  129947. * @param stencil defines if the stencil buffer must be cleared
  129948. */
  129949. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  129950. /**
  129951. * Gets the current render width
  129952. * @param useScreen defines if screen size must be used (or the current render target if any)
  129953. * @returns a number defining the current render width
  129954. */
  129955. getRenderWidth(useScreen?: boolean): number;
  129956. /**
  129957. * Gets the current render height
  129958. * @param useScreen defines if screen size must be used (or the current render target if any)
  129959. * @returns a number defining the current render height
  129960. */
  129961. getRenderHeight(useScreen?: boolean): number;
  129962. /**
  129963. * Set the WebGL's viewport
  129964. * @param viewport defines the viewport element to be used
  129965. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  129966. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  129967. */
  129968. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  129969. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  129970. /**
  129971. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  129972. * @param pipelineContext defines the pipeline context to use
  129973. * @param uniformsNames defines the list of uniform names
  129974. * @returns an array of webGL uniform locations
  129975. */
  129976. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  129977. /**
  129978. * Gets the lsit of active attributes for a given webGL program
  129979. * @param pipelineContext defines the pipeline context to use
  129980. * @param attributesNames defines the list of attribute names to get
  129981. * @returns an array of indices indicating the offset of each attribute
  129982. */
  129983. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  129984. /**
  129985. * Binds an effect to the webGL context
  129986. * @param effect defines the effect to bind
  129987. */
  129988. bindSamplers(effect: Effect): void;
  129989. /**
  129990. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  129991. * @param effect defines the effect to activate
  129992. */
  129993. enableEffect(effect: Effect): void;
  129994. /**
  129995. * Set various states to the webGL context
  129996. * @param culling defines backface culling state
  129997. * @param zOffset defines the value to apply to zOffset (0 by default)
  129998. * @param force defines if states must be applied even if cache is up to date
  129999. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  130000. */
  130001. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  130002. /**
  130003. * Set the value of an uniform to an array of int32
  130004. * @param uniform defines the webGL uniform location where to store the value
  130005. * @param array defines the array of int32 to store
  130006. */
  130007. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  130008. /**
  130009. * Set the value of an uniform to an array of int32 (stored as vec2)
  130010. * @param uniform defines the webGL uniform location where to store the value
  130011. * @param array defines the array of int32 to store
  130012. */
  130013. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  130014. /**
  130015. * Set the value of an uniform to an array of int32 (stored as vec3)
  130016. * @param uniform defines the webGL uniform location where to store the value
  130017. * @param array defines the array of int32 to store
  130018. */
  130019. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  130020. /**
  130021. * Set the value of an uniform to an array of int32 (stored as vec4)
  130022. * @param uniform defines the webGL uniform location where to store the value
  130023. * @param array defines the array of int32 to store
  130024. */
  130025. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  130026. /**
  130027. * Set the value of an uniform to an array of float32
  130028. * @param uniform defines the webGL uniform location where to store the value
  130029. * @param array defines the array of float32 to store
  130030. */
  130031. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  130032. /**
  130033. * Set the value of an uniform to an array of float32 (stored as vec2)
  130034. * @param uniform defines the webGL uniform location where to store the value
  130035. * @param array defines the array of float32 to store
  130036. */
  130037. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  130038. /**
  130039. * Set the value of an uniform to an array of float32 (stored as vec3)
  130040. * @param uniform defines the webGL uniform location where to store the value
  130041. * @param array defines the array of float32 to store
  130042. */
  130043. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  130044. /**
  130045. * Set the value of an uniform to an array of float32 (stored as vec4)
  130046. * @param uniform defines the webGL uniform location where to store the value
  130047. * @param array defines the array of float32 to store
  130048. */
  130049. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  130050. /**
  130051. * Set the value of an uniform to an array of number
  130052. * @param uniform defines the webGL uniform location where to store the value
  130053. * @param array defines the array of number to store
  130054. */
  130055. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  130056. /**
  130057. * Set the value of an uniform to an array of number (stored as vec2)
  130058. * @param uniform defines the webGL uniform location where to store the value
  130059. * @param array defines the array of number to store
  130060. */
  130061. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  130062. /**
  130063. * Set the value of an uniform to an array of number (stored as vec3)
  130064. * @param uniform defines the webGL uniform location where to store the value
  130065. * @param array defines the array of number to store
  130066. */
  130067. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  130068. /**
  130069. * Set the value of an uniform to an array of number (stored as vec4)
  130070. * @param uniform defines the webGL uniform location where to store the value
  130071. * @param array defines the array of number to store
  130072. */
  130073. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  130074. /**
  130075. * Set the value of an uniform to an array of float32 (stored as matrices)
  130076. * @param uniform defines the webGL uniform location where to store the value
  130077. * @param matrices defines the array of float32 to store
  130078. */
  130079. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  130080. /**
  130081. * Set the value of an uniform to a matrix (3x3)
  130082. * @param uniform defines the webGL uniform location where to store the value
  130083. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  130084. */
  130085. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130086. /**
  130087. * Set the value of an uniform to a matrix (2x2)
  130088. * @param uniform defines the webGL uniform location where to store the value
  130089. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  130090. */
  130091. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130092. /**
  130093. * Set the value of an uniform to a number (float)
  130094. * @param uniform defines the webGL uniform location where to store the value
  130095. * @param value defines the float number to store
  130096. */
  130097. setFloat(uniform: WebGLUniformLocation, value: number): void;
  130098. /**
  130099. * Set the value of an uniform to a vec2
  130100. * @param uniform defines the webGL uniform location where to store the value
  130101. * @param x defines the 1st component of the value
  130102. * @param y defines the 2nd component of the value
  130103. */
  130104. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  130105. /**
  130106. * Set the value of an uniform to a vec3
  130107. * @param uniform defines the webGL uniform location where to store the value
  130108. * @param x defines the 1st component of the value
  130109. * @param y defines the 2nd component of the value
  130110. * @param z defines the 3rd component of the value
  130111. */
  130112. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  130113. /**
  130114. * Set the value of an uniform to a boolean
  130115. * @param uniform defines the webGL uniform location where to store the value
  130116. * @param bool defines the boolean to store
  130117. */
  130118. setBool(uniform: WebGLUniformLocation, bool: number): void;
  130119. /**
  130120. * Set the value of an uniform to a vec4
  130121. * @param uniform defines the webGL uniform location where to store the value
  130122. * @param x defines the 1st component of the value
  130123. * @param y defines the 2nd component of the value
  130124. * @param z defines the 3rd component of the value
  130125. * @param w defines the 4th component of the value
  130126. */
  130127. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  130128. /**
  130129. * Sets the current alpha mode
  130130. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  130131. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  130132. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130133. */
  130134. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  130135. /**
  130136. * Bind webGl buffers directly to the webGL context
  130137. * @param vertexBuffers defines the vertex buffer to bind
  130138. * @param indexBuffer defines the index buffer to bind
  130139. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  130140. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  130141. * @param effect defines the effect associated with the vertex buffer
  130142. */
  130143. bindBuffers(vertexBuffers: {
  130144. [key: string]: VertexBuffer;
  130145. }, indexBuffer: DataBuffer, effect: Effect): void;
  130146. /**
  130147. * Force the entire cache to be cleared
  130148. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  130149. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  130150. */
  130151. wipeCaches(bruteForce?: boolean): void;
  130152. /**
  130153. * Send a draw order
  130154. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  130155. * @param indexStart defines the starting index
  130156. * @param indexCount defines the number of index to draw
  130157. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130158. */
  130159. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  130160. /**
  130161. * Draw a list of indexed primitives
  130162. * @param fillMode defines the primitive to use
  130163. * @param indexStart defines the starting index
  130164. * @param indexCount defines the number of index to draw
  130165. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130166. */
  130167. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  130168. /**
  130169. * Draw a list of unindexed primitives
  130170. * @param fillMode defines the primitive to use
  130171. * @param verticesStart defines the index of first vertex to draw
  130172. * @param verticesCount defines the count of vertices to draw
  130173. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130174. */
  130175. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  130176. /** @hidden */
  130177. _createTexture(): WebGLTexture;
  130178. /** @hidden */
  130179. _releaseTexture(texture: InternalTexture): void;
  130180. /**
  130181. * Usually called from Texture.ts.
  130182. * Passed information to create a WebGLTexture
  130183. * @param urlArg defines a value which contains one of the following:
  130184. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  130185. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  130186. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  130187. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  130188. * @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)
  130189. * @param scene needed for loading to the correct scene
  130190. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  130191. * @param onLoad optional callback to be called upon successful completion
  130192. * @param onError optional callback to be called upon failure
  130193. * @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
  130194. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  130195. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  130196. * @param forcedExtension defines the extension to use to pick the right loader
  130197. * @param mimeType defines an optional mime type
  130198. * @returns a InternalTexture for assignment back into BABYLON.Texture
  130199. */
  130200. 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;
  130201. /**
  130202. * Creates a new render target texture
  130203. * @param size defines the size of the texture
  130204. * @param options defines the options used to create the texture
  130205. * @returns a new render target texture stored in an InternalTexture
  130206. */
  130207. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  130208. /**
  130209. * Update the sampling mode of a given texture
  130210. * @param samplingMode defines the required sampling mode
  130211. * @param texture defines the texture to update
  130212. */
  130213. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  130214. /**
  130215. * Binds the frame buffer to the specified texture.
  130216. * @param texture The texture to render to or null for the default canvas
  130217. * @param faceIndex The face of the texture to render to in case of cube texture
  130218. * @param requiredWidth The width of the target to render to
  130219. * @param requiredHeight The height of the target to render to
  130220. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  130221. * @param lodLevel defines le lod level to bind to the frame buffer
  130222. */
  130223. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  130224. /**
  130225. * Unbind the current render target texture from the webGL context
  130226. * @param texture defines the render target texture to unbind
  130227. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  130228. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  130229. */
  130230. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130231. /**
  130232. * Creates a dynamic vertex buffer
  130233. * @param vertices the data for the dynamic vertex buffer
  130234. * @returns the new WebGL dynamic buffer
  130235. */
  130236. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  130237. /**
  130238. * Update the content of a dynamic texture
  130239. * @param texture defines the texture to update
  130240. * @param canvas defines the canvas containing the source
  130241. * @param invertY defines if data must be stored with Y axis inverted
  130242. * @param premulAlpha defines if alpha is stored as premultiplied
  130243. * @param format defines the format of the data
  130244. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  130245. */
  130246. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  130247. /**
  130248. * Gets a boolean indicating if all created effects are ready
  130249. * @returns true if all effects are ready
  130250. */
  130251. areAllEffectsReady(): boolean;
  130252. /**
  130253. * @hidden
  130254. * Get the current error code of the webGL context
  130255. * @returns the error code
  130256. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  130257. */
  130258. getError(): number;
  130259. /** @hidden */
  130260. _getUnpackAlignement(): number;
  130261. /** @hidden */
  130262. _unpackFlipY(value: boolean): void;
  130263. /**
  130264. * Update a dynamic index buffer
  130265. * @param indexBuffer defines the target index buffer
  130266. * @param indices defines the data to update
  130267. * @param offset defines the offset in the target index buffer where update should start
  130268. */
  130269. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  130270. /**
  130271. * Updates a dynamic vertex buffer.
  130272. * @param vertexBuffer the vertex buffer to update
  130273. * @param vertices the data used to update the vertex buffer
  130274. * @param byteOffset the byte offset of the data (optional)
  130275. * @param byteLength the byte length of the data (optional)
  130276. */
  130277. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  130278. /** @hidden */
  130279. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  130280. /** @hidden */
  130281. _bindTexture(channel: number, texture: InternalTexture): void;
  130282. protected _deleteBuffer(buffer: WebGLBuffer): void;
  130283. /**
  130284. * 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
  130285. */
  130286. releaseEffects(): void;
  130287. displayLoadingUI(): void;
  130288. hideLoadingUI(): void;
  130289. /** @hidden */
  130290. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130291. /** @hidden */
  130292. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130293. /** @hidden */
  130294. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130295. /** @hidden */
  130296. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  130297. }
  130298. }
  130299. declare module BABYLON {
  130300. /**
  130301. * @hidden
  130302. **/
  130303. export class _TimeToken {
  130304. _startTimeQuery: Nullable<WebGLQuery>;
  130305. _endTimeQuery: Nullable<WebGLQuery>;
  130306. _timeElapsedQuery: Nullable<WebGLQuery>;
  130307. _timeElapsedQueryEnded: boolean;
  130308. }
  130309. }
  130310. declare module BABYLON {
  130311. /** @hidden */
  130312. export class _OcclusionDataStorage {
  130313. /** @hidden */
  130314. occlusionInternalRetryCounter: number;
  130315. /** @hidden */
  130316. isOcclusionQueryInProgress: boolean;
  130317. /** @hidden */
  130318. isOccluded: boolean;
  130319. /** @hidden */
  130320. occlusionRetryCount: number;
  130321. /** @hidden */
  130322. occlusionType: number;
  130323. /** @hidden */
  130324. occlusionQueryAlgorithmType: number;
  130325. }
  130326. interface Engine {
  130327. /**
  130328. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  130329. * @return the new query
  130330. */
  130331. createQuery(): WebGLQuery;
  130332. /**
  130333. * Delete and release a webGL query
  130334. * @param query defines the query to delete
  130335. * @return the current engine
  130336. */
  130337. deleteQuery(query: WebGLQuery): Engine;
  130338. /**
  130339. * Check if a given query has resolved and got its value
  130340. * @param query defines the query to check
  130341. * @returns true if the query got its value
  130342. */
  130343. isQueryResultAvailable(query: WebGLQuery): boolean;
  130344. /**
  130345. * Gets the value of a given query
  130346. * @param query defines the query to check
  130347. * @returns the value of the query
  130348. */
  130349. getQueryResult(query: WebGLQuery): number;
  130350. /**
  130351. * Initiates an occlusion query
  130352. * @param algorithmType defines the algorithm to use
  130353. * @param query defines the query to use
  130354. * @returns the current engine
  130355. * @see https://doc.babylonjs.com/features/occlusionquery
  130356. */
  130357. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  130358. /**
  130359. * Ends an occlusion query
  130360. * @see https://doc.babylonjs.com/features/occlusionquery
  130361. * @param algorithmType defines the algorithm to use
  130362. * @returns the current engine
  130363. */
  130364. endOcclusionQuery(algorithmType: number): Engine;
  130365. /**
  130366. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  130367. * Please note that only one query can be issued at a time
  130368. * @returns a time token used to track the time span
  130369. */
  130370. startTimeQuery(): Nullable<_TimeToken>;
  130371. /**
  130372. * Ends a time query
  130373. * @param token defines the token used to measure the time span
  130374. * @returns the time spent (in ns)
  130375. */
  130376. endTimeQuery(token: _TimeToken): int;
  130377. /** @hidden */
  130378. _currentNonTimestampToken: Nullable<_TimeToken>;
  130379. /** @hidden */
  130380. _createTimeQuery(): WebGLQuery;
  130381. /** @hidden */
  130382. _deleteTimeQuery(query: WebGLQuery): void;
  130383. /** @hidden */
  130384. _getGlAlgorithmType(algorithmType: number): number;
  130385. /** @hidden */
  130386. _getTimeQueryResult(query: WebGLQuery): any;
  130387. /** @hidden */
  130388. _getTimeQueryAvailability(query: WebGLQuery): any;
  130389. }
  130390. interface AbstractMesh {
  130391. /**
  130392. * Backing filed
  130393. * @hidden
  130394. */
  130395. __occlusionDataStorage: _OcclusionDataStorage;
  130396. /**
  130397. * Access property
  130398. * @hidden
  130399. */
  130400. _occlusionDataStorage: _OcclusionDataStorage;
  130401. /**
  130402. * 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.
  130403. * The default value is -1 which means don't break the query and wait till the result
  130404. * @see https://doc.babylonjs.com/features/occlusionquery
  130405. */
  130406. occlusionRetryCount: number;
  130407. /**
  130408. * 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:
  130409. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  130410. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  130411. * * 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.
  130412. * @see https://doc.babylonjs.com/features/occlusionquery
  130413. */
  130414. occlusionType: number;
  130415. /**
  130416. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  130417. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  130418. * * 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.
  130419. * @see https://doc.babylonjs.com/features/occlusionquery
  130420. */
  130421. occlusionQueryAlgorithmType: number;
  130422. /**
  130423. * 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
  130424. * @see https://doc.babylonjs.com/features/occlusionquery
  130425. */
  130426. isOccluded: boolean;
  130427. /**
  130428. * Flag to check the progress status of the query
  130429. * @see https://doc.babylonjs.com/features/occlusionquery
  130430. */
  130431. isOcclusionQueryInProgress: boolean;
  130432. }
  130433. }
  130434. declare module BABYLON {
  130435. /** @hidden */
  130436. export var _forceTransformFeedbackToBundle: boolean;
  130437. interface Engine {
  130438. /**
  130439. * Creates a webGL transform feedback object
  130440. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  130441. * @returns the webGL transform feedback object
  130442. */
  130443. createTransformFeedback(): WebGLTransformFeedback;
  130444. /**
  130445. * Delete a webGL transform feedback object
  130446. * @param value defines the webGL transform feedback object to delete
  130447. */
  130448. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  130449. /**
  130450. * Bind a webGL transform feedback object to the webgl context
  130451. * @param value defines the webGL transform feedback object to bind
  130452. */
  130453. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  130454. /**
  130455. * Begins a transform feedback operation
  130456. * @param usePoints defines if points or triangles must be used
  130457. */
  130458. beginTransformFeedback(usePoints: boolean): void;
  130459. /**
  130460. * Ends a transform feedback operation
  130461. */
  130462. endTransformFeedback(): void;
  130463. /**
  130464. * Specify the varyings to use with transform feedback
  130465. * @param program defines the associated webGL program
  130466. * @param value defines the list of strings representing the varying names
  130467. */
  130468. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  130469. /**
  130470. * Bind a webGL buffer for a transform feedback operation
  130471. * @param value defines the webGL buffer to bind
  130472. */
  130473. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  130474. }
  130475. }
  130476. declare module BABYLON {
  130477. /**
  130478. * Class used to define an additional view for the engine
  130479. * @see https://doc.babylonjs.com/how_to/multi_canvases
  130480. */
  130481. export class EngineView {
  130482. /** Defines the canvas where to render the view */
  130483. target: HTMLCanvasElement;
  130484. /** Defines an optional camera used to render the view (will use active camera else) */
  130485. camera?: Camera;
  130486. }
  130487. interface Engine {
  130488. /**
  130489. * Gets or sets the HTML element to use for attaching events
  130490. */
  130491. inputElement: Nullable<HTMLElement>;
  130492. /**
  130493. * Gets the current engine view
  130494. * @see https://doc.babylonjs.com/how_to/multi_canvases
  130495. */
  130496. activeView: Nullable<EngineView>;
  130497. /** Gets or sets the list of views */
  130498. views: EngineView[];
  130499. /**
  130500. * Register a new child canvas
  130501. * @param canvas defines the canvas to register
  130502. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  130503. * @returns the associated view
  130504. */
  130505. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  130506. /**
  130507. * Remove a registered child canvas
  130508. * @param canvas defines the canvas to remove
  130509. * @returns the current engine
  130510. */
  130511. unRegisterView(canvas: HTMLCanvasElement): Engine;
  130512. }
  130513. }
  130514. declare module BABYLON {
  130515. interface Engine {
  130516. /** @hidden */
  130517. _excludedCompressedTextures: string[];
  130518. /** @hidden */
  130519. _textureFormatInUse: string;
  130520. /**
  130521. * Gets the list of texture formats supported
  130522. */
  130523. readonly texturesSupported: Array<string>;
  130524. /**
  130525. * Gets the texture format in use
  130526. */
  130527. readonly textureFormatInUse: Nullable<string>;
  130528. /**
  130529. * Set the compressed texture extensions or file names to skip.
  130530. *
  130531. * @param skippedFiles defines the list of those texture files you want to skip
  130532. * Example: [".dds", ".env", "myfile.png"]
  130533. */
  130534. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  130535. /**
  130536. * Set the compressed texture format to use, based on the formats you have, and the formats
  130537. * supported by the hardware / browser.
  130538. *
  130539. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  130540. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  130541. * to API arguments needed to compressed textures. This puts the burden on the container
  130542. * generator to house the arcane code for determining these for current & future formats.
  130543. *
  130544. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  130545. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  130546. *
  130547. * Note: The result of this call is not taken into account when a texture is base64.
  130548. *
  130549. * @param formatsAvailable defines the list of those format families you have created
  130550. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  130551. *
  130552. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  130553. * @returns The extension selected.
  130554. */
  130555. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  130556. }
  130557. }
  130558. declare module BABYLON {
  130559. /**
  130560. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  130561. */
  130562. export interface CubeMapInfo {
  130563. /**
  130564. * The pixel array for the front face.
  130565. * This is stored in format, left to right, up to down format.
  130566. */
  130567. front: Nullable<ArrayBufferView>;
  130568. /**
  130569. * The pixel array for the back face.
  130570. * This is stored in format, left to right, up to down format.
  130571. */
  130572. back: Nullable<ArrayBufferView>;
  130573. /**
  130574. * The pixel array for the left face.
  130575. * This is stored in format, left to right, up to down format.
  130576. */
  130577. left: Nullable<ArrayBufferView>;
  130578. /**
  130579. * The pixel array for the right face.
  130580. * This is stored in format, left to right, up to down format.
  130581. */
  130582. right: Nullable<ArrayBufferView>;
  130583. /**
  130584. * The pixel array for the up face.
  130585. * This is stored in format, left to right, up to down format.
  130586. */
  130587. up: Nullable<ArrayBufferView>;
  130588. /**
  130589. * The pixel array for the down face.
  130590. * This is stored in format, left to right, up to down format.
  130591. */
  130592. down: Nullable<ArrayBufferView>;
  130593. /**
  130594. * The size of the cubemap stored.
  130595. *
  130596. * Each faces will be size * size pixels.
  130597. */
  130598. size: number;
  130599. /**
  130600. * The format of the texture.
  130601. *
  130602. * RGBA, RGB.
  130603. */
  130604. format: number;
  130605. /**
  130606. * The type of the texture data.
  130607. *
  130608. * UNSIGNED_INT, FLOAT.
  130609. */
  130610. type: number;
  130611. /**
  130612. * Specifies whether the texture is in gamma space.
  130613. */
  130614. gammaSpace: boolean;
  130615. }
  130616. /**
  130617. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  130618. */
  130619. export class PanoramaToCubeMapTools {
  130620. private static FACE_LEFT;
  130621. private static FACE_RIGHT;
  130622. private static FACE_FRONT;
  130623. private static FACE_BACK;
  130624. private static FACE_DOWN;
  130625. private static FACE_UP;
  130626. /**
  130627. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  130628. *
  130629. * @param float32Array The source data.
  130630. * @param inputWidth The width of the input panorama.
  130631. * @param inputHeight The height of the input panorama.
  130632. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  130633. * @return The cubemap data
  130634. */
  130635. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  130636. private static CreateCubemapTexture;
  130637. private static CalcProjectionSpherical;
  130638. }
  130639. }
  130640. declare module BABYLON {
  130641. /**
  130642. * Helper class dealing with the extraction of spherical polynomial dataArray
  130643. * from a cube map.
  130644. */
  130645. export class CubeMapToSphericalPolynomialTools {
  130646. private static FileFaces;
  130647. /**
  130648. * Converts a texture to the according Spherical Polynomial data.
  130649. * This extracts the first 3 orders only as they are the only one used in the lighting.
  130650. *
  130651. * @param texture The texture to extract the information from.
  130652. * @return The Spherical Polynomial data.
  130653. */
  130654. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  130655. /**
  130656. * Converts a cubemap to the according Spherical Polynomial data.
  130657. * This extracts the first 3 orders only as they are the only one used in the lighting.
  130658. *
  130659. * @param cubeInfo The Cube map to extract the information from.
  130660. * @return The Spherical Polynomial data.
  130661. */
  130662. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  130663. }
  130664. }
  130665. declare module BABYLON {
  130666. interface BaseTexture {
  130667. /**
  130668. * Get the polynomial representation of the texture data.
  130669. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  130670. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  130671. */
  130672. sphericalPolynomial: Nullable<SphericalPolynomial>;
  130673. }
  130674. }
  130675. declare module BABYLON {
  130676. /** @hidden */
  130677. export var rgbdEncodePixelShader: {
  130678. name: string;
  130679. shader: string;
  130680. };
  130681. }
  130682. declare module BABYLON {
  130683. /** @hidden */
  130684. export var rgbdDecodePixelShader: {
  130685. name: string;
  130686. shader: string;
  130687. };
  130688. }
  130689. declare module BABYLON {
  130690. /**
  130691. * Raw texture data and descriptor sufficient for WebGL texture upload
  130692. */
  130693. export interface EnvironmentTextureInfo {
  130694. /**
  130695. * Version of the environment map
  130696. */
  130697. version: number;
  130698. /**
  130699. * Width of image
  130700. */
  130701. width: number;
  130702. /**
  130703. * Irradiance information stored in the file.
  130704. */
  130705. irradiance: any;
  130706. /**
  130707. * Specular information stored in the file.
  130708. */
  130709. specular: any;
  130710. }
  130711. /**
  130712. * Defines One Image in the file. It requires only the position in the file
  130713. * as well as the length.
  130714. */
  130715. interface BufferImageData {
  130716. /**
  130717. * Length of the image data.
  130718. */
  130719. length: number;
  130720. /**
  130721. * Position of the data from the null terminator delimiting the end of the JSON.
  130722. */
  130723. position: number;
  130724. }
  130725. /**
  130726. * Defines the specular data enclosed in the file.
  130727. * This corresponds to the version 1 of the data.
  130728. */
  130729. export interface EnvironmentTextureSpecularInfoV1 {
  130730. /**
  130731. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  130732. */
  130733. specularDataPosition?: number;
  130734. /**
  130735. * This contains all the images data needed to reconstruct the cubemap.
  130736. */
  130737. mipmaps: Array<BufferImageData>;
  130738. /**
  130739. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  130740. */
  130741. lodGenerationScale: number;
  130742. }
  130743. /**
  130744. * Sets of helpers addressing the serialization and deserialization of environment texture
  130745. * stored in a BabylonJS env file.
  130746. * Those files are usually stored as .env files.
  130747. */
  130748. export class EnvironmentTextureTools {
  130749. /**
  130750. * Magic number identifying the env file.
  130751. */
  130752. private static _MagicBytes;
  130753. /**
  130754. * Gets the environment info from an env file.
  130755. * @param data The array buffer containing the .env bytes.
  130756. * @returns the environment file info (the json header) if successfully parsed.
  130757. */
  130758. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  130759. /**
  130760. * Creates an environment texture from a loaded cube texture.
  130761. * @param texture defines the cube texture to convert in env file
  130762. * @return a promise containing the environment data if succesfull.
  130763. */
  130764. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  130765. /**
  130766. * Creates a JSON representation of the spherical data.
  130767. * @param texture defines the texture containing the polynomials
  130768. * @return the JSON representation of the spherical info
  130769. */
  130770. private static _CreateEnvTextureIrradiance;
  130771. /**
  130772. * Creates the ArrayBufferViews used for initializing environment texture image data.
  130773. * @param data the image data
  130774. * @param info parameters that determine what views will be created for accessing the underlying buffer
  130775. * @return the views described by info providing access to the underlying buffer
  130776. */
  130777. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  130778. /**
  130779. * Uploads the texture info contained in the env file to the GPU.
  130780. * @param texture defines the internal texture to upload to
  130781. * @param data defines the data to load
  130782. * @param info defines the texture info retrieved through the GetEnvInfo method
  130783. * @returns a promise
  130784. */
  130785. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  130786. private static _OnImageReadyAsync;
  130787. /**
  130788. * Uploads the levels of image data to the GPU.
  130789. * @param texture defines the internal texture to upload to
  130790. * @param imageData defines the array buffer views of image data [mipmap][face]
  130791. * @returns a promise
  130792. */
  130793. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  130794. /**
  130795. * Uploads spherical polynomials information to the texture.
  130796. * @param texture defines the texture we are trying to upload the information to
  130797. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  130798. */
  130799. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  130800. /** @hidden */
  130801. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  130802. }
  130803. }
  130804. declare module BABYLON {
  130805. /**
  130806. * Class used to inline functions in shader code
  130807. */
  130808. export class ShaderCodeInliner {
  130809. private static readonly _RegexpFindFunctionNameAndType;
  130810. private _sourceCode;
  130811. private _functionDescr;
  130812. private _numMaxIterations;
  130813. /** Gets or sets the token used to mark the functions to inline */
  130814. inlineToken: string;
  130815. /** Gets or sets the debug mode */
  130816. debug: boolean;
  130817. /** Gets the code after the inlining process */
  130818. get code(): string;
  130819. /**
  130820. * Initializes the inliner
  130821. * @param sourceCode shader code source to inline
  130822. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  130823. */
  130824. constructor(sourceCode: string, numMaxIterations?: number);
  130825. /**
  130826. * Start the processing of the shader code
  130827. */
  130828. processCode(): void;
  130829. private _collectFunctions;
  130830. private _processInlining;
  130831. private _extractBetweenMarkers;
  130832. private _skipWhitespaces;
  130833. private _removeComments;
  130834. private _replaceFunctionCallsByCode;
  130835. private _findBackward;
  130836. private _escapeRegExp;
  130837. private _replaceNames;
  130838. }
  130839. }
  130840. declare module BABYLON {
  130841. /**
  130842. * Container for accessors for natively-stored mesh data buffers.
  130843. */
  130844. class NativeDataBuffer extends DataBuffer {
  130845. /**
  130846. * Accessor value used to identify/retrieve a natively-stored index buffer.
  130847. */
  130848. nativeIndexBuffer?: any;
  130849. /**
  130850. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  130851. */
  130852. nativeVertexBuffer?: any;
  130853. }
  130854. /** @hidden */
  130855. class NativeTexture extends InternalTexture {
  130856. getInternalTexture(): InternalTexture;
  130857. getViewCount(): number;
  130858. }
  130859. /** @hidden */
  130860. export class NativeEngine extends Engine {
  130861. private readonly _native;
  130862. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  130863. private readonly INVALID_HANDLE;
  130864. getHardwareScalingLevel(): number;
  130865. constructor();
  130866. dispose(): void;
  130867. /**
  130868. * Can be used to override the current requestAnimationFrame requester.
  130869. * @hidden
  130870. */
  130871. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  130872. /**
  130873. * Override default engine behavior.
  130874. * @param color
  130875. * @param backBuffer
  130876. * @param depth
  130877. * @param stencil
  130878. */
  130879. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  130880. /**
  130881. * Gets host document
  130882. * @returns the host document object
  130883. */
  130884. getHostDocument(): Nullable<Document>;
  130885. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  130886. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  130887. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  130888. recordVertexArrayObject(vertexBuffers: {
  130889. [key: string]: VertexBuffer;
  130890. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  130891. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  130892. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  130893. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  130894. /**
  130895. * Draw a list of indexed primitives
  130896. * @param fillMode defines the primitive to use
  130897. * @param indexStart defines the starting index
  130898. * @param indexCount defines the number of index to draw
  130899. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130900. */
  130901. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  130902. /**
  130903. * Draw a list of unindexed primitives
  130904. * @param fillMode defines the primitive to use
  130905. * @param verticesStart defines the index of first vertex to draw
  130906. * @param verticesCount defines the count of vertices to draw
  130907. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130908. */
  130909. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  130910. createPipelineContext(): IPipelineContext;
  130911. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  130912. /** @hidden */
  130913. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  130914. /** @hidden */
  130915. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  130916. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  130917. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  130918. protected _setProgram(program: WebGLProgram): void;
  130919. _releaseEffect(effect: Effect): void;
  130920. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  130921. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  130922. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  130923. bindSamplers(effect: Effect): void;
  130924. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  130925. getRenderWidth(useScreen?: boolean): number;
  130926. getRenderHeight(useScreen?: boolean): number;
  130927. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  130928. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  130929. /**
  130930. * Set the z offset to apply to current rendering
  130931. * @param value defines the offset to apply
  130932. */
  130933. setZOffset(value: number): void;
  130934. /**
  130935. * Gets the current value of the zOffset
  130936. * @returns the current zOffset state
  130937. */
  130938. getZOffset(): number;
  130939. /**
  130940. * Enable or disable depth buffering
  130941. * @param enable defines the state to set
  130942. */
  130943. setDepthBuffer(enable: boolean): void;
  130944. /**
  130945. * Gets a boolean indicating if depth writing is enabled
  130946. * @returns the current depth writing state
  130947. */
  130948. getDepthWrite(): boolean;
  130949. /**
  130950. * Enable or disable depth writing
  130951. * @param enable defines the state to set
  130952. */
  130953. setDepthWrite(enable: boolean): void;
  130954. /**
  130955. * Enable or disable color writing
  130956. * @param enable defines the state to set
  130957. */
  130958. setColorWrite(enable: boolean): void;
  130959. /**
  130960. * Gets a boolean indicating if color writing is enabled
  130961. * @returns the current color writing state
  130962. */
  130963. getColorWrite(): boolean;
  130964. /**
  130965. * Sets alpha constants used by some alpha blending modes
  130966. * @param r defines the red component
  130967. * @param g defines the green component
  130968. * @param b defines the blue component
  130969. * @param a defines the alpha component
  130970. */
  130971. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  130972. /**
  130973. * Sets the current alpha mode
  130974. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  130975. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  130976. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130977. */
  130978. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  130979. /**
  130980. * Gets the current alpha mode
  130981. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130982. * @returns the current alpha mode
  130983. */
  130984. getAlphaMode(): number;
  130985. setInt(uniform: WebGLUniformLocation, int: number): void;
  130986. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  130987. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  130988. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  130989. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  130990. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  130991. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  130992. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  130993. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  130994. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  130995. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  130996. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  130997. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  130998. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  130999. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131000. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131001. setFloat(uniform: WebGLUniformLocation, value: number): void;
  131002. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  131003. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  131004. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  131005. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  131006. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  131007. wipeCaches(bruteForce?: boolean): void;
  131008. _createTexture(): WebGLTexture;
  131009. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  131010. /**
  131011. * Usually called from Texture.ts.
  131012. * Passed information to create a WebGLTexture
  131013. * @param url defines a value which contains one of the following:
  131014. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  131015. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  131016. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  131017. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  131018. * @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)
  131019. * @param scene needed for loading to the correct scene
  131020. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  131021. * @param onLoad optional callback to be called upon successful completion
  131022. * @param onError optional callback to be called upon failure
  131023. * @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
  131024. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  131025. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  131026. * @param forcedExtension defines the extension to use to pick the right loader
  131027. * @param mimeType defines an optional mime type
  131028. * @returns a InternalTexture for assignment back into BABYLON.Texture
  131029. */
  131030. 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;
  131031. /**
  131032. * Creates a cube texture
  131033. * @param rootUrl defines the url where the files to load is located
  131034. * @param scene defines the current scene
  131035. * @param files defines the list of files to load (1 per face)
  131036. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  131037. * @param onLoad defines an optional callback raised when the texture is loaded
  131038. * @param onError defines an optional callback raised if there is an issue to load the texture
  131039. * @param format defines the format of the data
  131040. * @param forcedExtension defines the extension to use to pick the right loader
  131041. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  131042. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  131043. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  131044. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  131045. * @returns the cube texture as an InternalTexture
  131046. */
  131047. 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;
  131048. private _getSamplingFilter;
  131049. private static _GetNativeTextureFormat;
  131050. createRenderTargetTexture(size: number | {
  131051. width: number;
  131052. height: number;
  131053. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  131054. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  131055. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  131056. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  131057. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  131058. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  131059. /**
  131060. * Updates a dynamic vertex buffer.
  131061. * @param vertexBuffer the vertex buffer to update
  131062. * @param data the data used to update the vertex buffer
  131063. * @param byteOffset the byte offset of the data (optional)
  131064. * @param byteLength the byte length of the data (optional)
  131065. */
  131066. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  131067. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  131068. private _updateAnisotropicLevel;
  131069. private _getAddressMode;
  131070. /** @hidden */
  131071. _bindTexture(channel: number, texture: InternalTexture): void;
  131072. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  131073. releaseEffects(): void;
  131074. /** @hidden */
  131075. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131076. /** @hidden */
  131077. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131078. /** @hidden */
  131079. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131080. /** @hidden */
  131081. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  131082. }
  131083. }
  131084. declare module BABYLON {
  131085. /**
  131086. * Gather the list of clipboard event types as constants.
  131087. */
  131088. export class ClipboardEventTypes {
  131089. /**
  131090. * The clipboard event is fired when a copy command is active (pressed).
  131091. */
  131092. static readonly COPY: number;
  131093. /**
  131094. * The clipboard event is fired when a cut command is active (pressed).
  131095. */
  131096. static readonly CUT: number;
  131097. /**
  131098. * The clipboard event is fired when a paste command is active (pressed).
  131099. */
  131100. static readonly PASTE: number;
  131101. }
  131102. /**
  131103. * This class is used to store clipboard related info for the onClipboardObservable event.
  131104. */
  131105. export class ClipboardInfo {
  131106. /**
  131107. * Defines the type of event (BABYLON.ClipboardEventTypes)
  131108. */
  131109. type: number;
  131110. /**
  131111. * Defines the related dom event
  131112. */
  131113. event: ClipboardEvent;
  131114. /**
  131115. *Creates an instance of ClipboardInfo.
  131116. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  131117. * @param event Defines the related dom event
  131118. */
  131119. constructor(
  131120. /**
  131121. * Defines the type of event (BABYLON.ClipboardEventTypes)
  131122. */
  131123. type: number,
  131124. /**
  131125. * Defines the related dom event
  131126. */
  131127. event: ClipboardEvent);
  131128. /**
  131129. * Get the clipboard event's type from the keycode.
  131130. * @param keyCode Defines the keyCode for the current keyboard event.
  131131. * @return {number}
  131132. */
  131133. static GetTypeFromCharacter(keyCode: number): number;
  131134. }
  131135. }
  131136. declare module BABYLON {
  131137. /**
  131138. * Google Daydream controller
  131139. */
  131140. export class DaydreamController extends WebVRController {
  131141. /**
  131142. * Base Url for the controller model.
  131143. */
  131144. static MODEL_BASE_URL: string;
  131145. /**
  131146. * File name for the controller model.
  131147. */
  131148. static MODEL_FILENAME: string;
  131149. /**
  131150. * Gamepad Id prefix used to identify Daydream Controller.
  131151. */
  131152. static readonly GAMEPAD_ID_PREFIX: string;
  131153. /**
  131154. * Creates a new DaydreamController from a gamepad
  131155. * @param vrGamepad the gamepad that the controller should be created from
  131156. */
  131157. constructor(vrGamepad: any);
  131158. /**
  131159. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131160. * @param scene scene in which to add meshes
  131161. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131162. */
  131163. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131164. /**
  131165. * Called once for each button that changed state since the last frame
  131166. * @param buttonIdx Which button index changed
  131167. * @param state New state of the button
  131168. * @param changes Which properties on the state changed since last frame
  131169. */
  131170. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131171. }
  131172. }
  131173. declare module BABYLON {
  131174. /**
  131175. * Gear VR Controller
  131176. */
  131177. export class GearVRController extends WebVRController {
  131178. /**
  131179. * Base Url for the controller model.
  131180. */
  131181. static MODEL_BASE_URL: string;
  131182. /**
  131183. * File name for the controller model.
  131184. */
  131185. static MODEL_FILENAME: string;
  131186. /**
  131187. * Gamepad Id prefix used to identify this controller.
  131188. */
  131189. static readonly GAMEPAD_ID_PREFIX: string;
  131190. private readonly _buttonIndexToObservableNameMap;
  131191. /**
  131192. * Creates a new GearVRController from a gamepad
  131193. * @param vrGamepad the gamepad that the controller should be created from
  131194. */
  131195. constructor(vrGamepad: any);
  131196. /**
  131197. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131198. * @param scene scene in which to add meshes
  131199. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131200. */
  131201. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131202. /**
  131203. * Called once for each button that changed state since the last frame
  131204. * @param buttonIdx Which button index changed
  131205. * @param state New state of the button
  131206. * @param changes Which properties on the state changed since last frame
  131207. */
  131208. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131209. }
  131210. }
  131211. declare module BABYLON {
  131212. /**
  131213. * Generic Controller
  131214. */
  131215. export class GenericController extends WebVRController {
  131216. /**
  131217. * Base Url for the controller model.
  131218. */
  131219. static readonly MODEL_BASE_URL: string;
  131220. /**
  131221. * File name for the controller model.
  131222. */
  131223. static readonly MODEL_FILENAME: string;
  131224. /**
  131225. * Creates a new GenericController from a gamepad
  131226. * @param vrGamepad the gamepad that the controller should be created from
  131227. */
  131228. constructor(vrGamepad: any);
  131229. /**
  131230. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131231. * @param scene scene in which to add meshes
  131232. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131233. */
  131234. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131235. /**
  131236. * Called once for each button that changed state since the last frame
  131237. * @param buttonIdx Which button index changed
  131238. * @param state New state of the button
  131239. * @param changes Which properties on the state changed since last frame
  131240. */
  131241. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131242. }
  131243. }
  131244. declare module BABYLON {
  131245. /**
  131246. * Oculus Touch Controller
  131247. */
  131248. export class OculusTouchController extends WebVRController {
  131249. /**
  131250. * Base Url for the controller model.
  131251. */
  131252. static MODEL_BASE_URL: string;
  131253. /**
  131254. * File name for the left controller model.
  131255. */
  131256. static MODEL_LEFT_FILENAME: string;
  131257. /**
  131258. * File name for the right controller model.
  131259. */
  131260. static MODEL_RIGHT_FILENAME: string;
  131261. /**
  131262. * Base Url for the Quest controller model.
  131263. */
  131264. static QUEST_MODEL_BASE_URL: string;
  131265. /**
  131266. * @hidden
  131267. * If the controllers are running on a device that needs the updated Quest controller models
  131268. */
  131269. static _IsQuest: boolean;
  131270. /**
  131271. * Fired when the secondary trigger on this controller is modified
  131272. */
  131273. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  131274. /**
  131275. * Fired when the thumb rest on this controller is modified
  131276. */
  131277. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  131278. /**
  131279. * Creates a new OculusTouchController from a gamepad
  131280. * @param vrGamepad the gamepad that the controller should be created from
  131281. */
  131282. constructor(vrGamepad: any);
  131283. /**
  131284. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131285. * @param scene scene in which to add meshes
  131286. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131287. */
  131288. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131289. /**
  131290. * Fired when the A button on this controller is modified
  131291. */
  131292. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131293. /**
  131294. * Fired when the B button on this controller is modified
  131295. */
  131296. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131297. /**
  131298. * Fired when the X button on this controller is modified
  131299. */
  131300. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131301. /**
  131302. * Fired when the Y button on this controller is modified
  131303. */
  131304. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131305. /**
  131306. * Called once for each button that changed state since the last frame
  131307. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  131308. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  131309. * 2) secondary trigger (same)
  131310. * 3) A (right) X (left), touch, pressed = value
  131311. * 4) B / Y
  131312. * 5) thumb rest
  131313. * @param buttonIdx Which button index changed
  131314. * @param state New state of the button
  131315. * @param changes Which properties on the state changed since last frame
  131316. */
  131317. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131318. }
  131319. }
  131320. declare module BABYLON {
  131321. /**
  131322. * Vive Controller
  131323. */
  131324. export class ViveController extends WebVRController {
  131325. /**
  131326. * Base Url for the controller model.
  131327. */
  131328. static MODEL_BASE_URL: string;
  131329. /**
  131330. * File name for the controller model.
  131331. */
  131332. static MODEL_FILENAME: string;
  131333. /**
  131334. * Creates a new ViveController from a gamepad
  131335. * @param vrGamepad the gamepad that the controller should be created from
  131336. */
  131337. constructor(vrGamepad: any);
  131338. /**
  131339. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131340. * @param scene scene in which to add meshes
  131341. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131342. */
  131343. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131344. /**
  131345. * Fired when the left button on this controller is modified
  131346. */
  131347. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131348. /**
  131349. * Fired when the right button on this controller is modified
  131350. */
  131351. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131352. /**
  131353. * Fired when the menu button on this controller is modified
  131354. */
  131355. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131356. /**
  131357. * Called once for each button that changed state since the last frame
  131358. * Vive mapping:
  131359. * 0: touchpad
  131360. * 1: trigger
  131361. * 2: left AND right buttons
  131362. * 3: menu button
  131363. * @param buttonIdx Which button index changed
  131364. * @param state New state of the button
  131365. * @param changes Which properties on the state changed since last frame
  131366. */
  131367. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131368. }
  131369. }
  131370. declare module BABYLON {
  131371. /**
  131372. * Defines the WindowsMotionController object that the state of the windows motion controller
  131373. */
  131374. export class WindowsMotionController extends WebVRController {
  131375. /**
  131376. * The base url used to load the left and right controller models
  131377. */
  131378. static MODEL_BASE_URL: string;
  131379. /**
  131380. * The name of the left controller model file
  131381. */
  131382. static MODEL_LEFT_FILENAME: string;
  131383. /**
  131384. * The name of the right controller model file
  131385. */
  131386. static MODEL_RIGHT_FILENAME: string;
  131387. /**
  131388. * The controller name prefix for this controller type
  131389. */
  131390. static readonly GAMEPAD_ID_PREFIX: string;
  131391. /**
  131392. * The controller id pattern for this controller type
  131393. */
  131394. private static readonly GAMEPAD_ID_PATTERN;
  131395. private _loadedMeshInfo;
  131396. protected readonly _mapping: {
  131397. buttons: string[];
  131398. buttonMeshNames: {
  131399. trigger: string;
  131400. menu: string;
  131401. grip: string;
  131402. thumbstick: string;
  131403. trackpad: string;
  131404. };
  131405. buttonObservableNames: {
  131406. trigger: string;
  131407. menu: string;
  131408. grip: string;
  131409. thumbstick: string;
  131410. trackpad: string;
  131411. };
  131412. axisMeshNames: string[];
  131413. pointingPoseMeshName: string;
  131414. };
  131415. /**
  131416. * Fired when the trackpad on this controller is clicked
  131417. */
  131418. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  131419. /**
  131420. * Fired when the trackpad on this controller is modified
  131421. */
  131422. onTrackpadValuesChangedObservable: Observable<StickValues>;
  131423. /**
  131424. * The current x and y values of this controller's trackpad
  131425. */
  131426. trackpad: StickValues;
  131427. /**
  131428. * Creates a new WindowsMotionController from a gamepad
  131429. * @param vrGamepad the gamepad that the controller should be created from
  131430. */
  131431. constructor(vrGamepad: any);
  131432. /**
  131433. * Fired when the trigger on this controller is modified
  131434. */
  131435. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131436. /**
  131437. * Fired when the menu button on this controller is modified
  131438. */
  131439. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131440. /**
  131441. * Fired when the grip button on this controller is modified
  131442. */
  131443. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131444. /**
  131445. * Fired when the thumbstick button on this controller is modified
  131446. */
  131447. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131448. /**
  131449. * Fired when the touchpad button on this controller is modified
  131450. */
  131451. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131452. /**
  131453. * Fired when the touchpad values on this controller are modified
  131454. */
  131455. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  131456. protected _updateTrackpad(): void;
  131457. /**
  131458. * Called once per frame by the engine.
  131459. */
  131460. update(): void;
  131461. /**
  131462. * Called once for each button that changed state since the last frame
  131463. * @param buttonIdx Which button index changed
  131464. * @param state New state of the button
  131465. * @param changes Which properties on the state changed since last frame
  131466. */
  131467. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131468. /**
  131469. * Moves the buttons on the controller mesh based on their current state
  131470. * @param buttonName the name of the button to move
  131471. * @param buttonValue the value of the button which determines the buttons new position
  131472. */
  131473. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  131474. /**
  131475. * Moves the axis on the controller mesh based on its current state
  131476. * @param axis the index of the axis
  131477. * @param axisValue the value of the axis which determines the meshes new position
  131478. * @hidden
  131479. */
  131480. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  131481. /**
  131482. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131483. * @param scene scene in which to add meshes
  131484. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131485. */
  131486. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  131487. /**
  131488. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  131489. * can be transformed by button presses and axes values, based on this._mapping.
  131490. *
  131491. * @param scene scene in which the meshes exist
  131492. * @param meshes list of meshes that make up the controller model to process
  131493. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  131494. */
  131495. private processModel;
  131496. private createMeshInfo;
  131497. /**
  131498. * Gets the ray of the controller in the direction the controller is pointing
  131499. * @param length the length the resulting ray should be
  131500. * @returns a ray in the direction the controller is pointing
  131501. */
  131502. getForwardRay(length?: number): Ray;
  131503. /**
  131504. * Disposes of the controller
  131505. */
  131506. dispose(): void;
  131507. }
  131508. /**
  131509. * This class represents a new windows motion controller in XR.
  131510. */
  131511. export class XRWindowsMotionController extends WindowsMotionController {
  131512. /**
  131513. * Changing the original WIndowsMotionController mapping to fir the new mapping
  131514. */
  131515. protected readonly _mapping: {
  131516. buttons: string[];
  131517. buttonMeshNames: {
  131518. trigger: string;
  131519. menu: string;
  131520. grip: string;
  131521. thumbstick: string;
  131522. trackpad: string;
  131523. };
  131524. buttonObservableNames: {
  131525. trigger: string;
  131526. menu: string;
  131527. grip: string;
  131528. thumbstick: string;
  131529. trackpad: string;
  131530. };
  131531. axisMeshNames: string[];
  131532. pointingPoseMeshName: string;
  131533. };
  131534. /**
  131535. * Construct a new XR-Based windows motion controller
  131536. *
  131537. * @param gamepadInfo the gamepad object from the browser
  131538. */
  131539. constructor(gamepadInfo: any);
  131540. /**
  131541. * holds the thumbstick values (X,Y)
  131542. */
  131543. thumbstickValues: StickValues;
  131544. /**
  131545. * Fired when the thumbstick on this controller is clicked
  131546. */
  131547. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  131548. /**
  131549. * Fired when the thumbstick on this controller is modified
  131550. */
  131551. onThumbstickValuesChangedObservable: Observable<StickValues>;
  131552. /**
  131553. * Fired when the touchpad button on this controller is modified
  131554. */
  131555. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  131556. /**
  131557. * Fired when the touchpad values on this controller are modified
  131558. */
  131559. onTrackpadValuesChangedObservable: Observable<StickValues>;
  131560. /**
  131561. * Fired when the thumbstick button on this controller is modified
  131562. * here to prevent breaking changes
  131563. */
  131564. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131565. /**
  131566. * updating the thumbstick(!) and not the trackpad.
  131567. * This is named this way due to the difference between WebVR and XR and to avoid
  131568. * changing the parent class.
  131569. */
  131570. protected _updateTrackpad(): void;
  131571. /**
  131572. * Disposes the class with joy
  131573. */
  131574. dispose(): void;
  131575. }
  131576. }
  131577. declare module BABYLON {
  131578. /**
  131579. * Class containing static functions to help procedurally build meshes
  131580. */
  131581. export class PolyhedronBuilder {
  131582. /**
  131583. * Creates a polyhedron mesh
  131584. * * 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
  131585. * * The parameter `size` (positive float, default 1) sets the polygon size
  131586. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  131587. * * 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`
  131588. * * 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
  131589. * * 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)`)
  131590. * * 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
  131591. * * 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
  131592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131593. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131595. * @param name defines the name of the mesh
  131596. * @param options defines the options used to create the mesh
  131597. * @param scene defines the hosting scene
  131598. * @returns the polyhedron mesh
  131599. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  131600. */
  131601. static CreatePolyhedron(name: string, options: {
  131602. type?: number;
  131603. size?: number;
  131604. sizeX?: number;
  131605. sizeY?: number;
  131606. sizeZ?: number;
  131607. custom?: any;
  131608. faceUV?: Vector4[];
  131609. faceColors?: Color4[];
  131610. flat?: boolean;
  131611. updatable?: boolean;
  131612. sideOrientation?: number;
  131613. frontUVs?: Vector4;
  131614. backUVs?: Vector4;
  131615. }, scene?: Nullable<Scene>): Mesh;
  131616. }
  131617. }
  131618. declare module BABYLON {
  131619. /**
  131620. * Gizmo that enables scaling a mesh along 3 axis
  131621. */
  131622. export class ScaleGizmo extends Gizmo {
  131623. /**
  131624. * Internal gizmo used for interactions on the x axis
  131625. */
  131626. xGizmo: AxisScaleGizmo;
  131627. /**
  131628. * Internal gizmo used for interactions on the y axis
  131629. */
  131630. yGizmo: AxisScaleGizmo;
  131631. /**
  131632. * Internal gizmo used for interactions on the z axis
  131633. */
  131634. zGizmo: AxisScaleGizmo;
  131635. /**
  131636. * Internal gizmo used to scale all axis equally
  131637. */
  131638. uniformScaleGizmo: AxisScaleGizmo;
  131639. private _meshAttached;
  131640. private _nodeAttached;
  131641. private _updateGizmoRotationToMatchAttachedMesh;
  131642. private _snapDistance;
  131643. private _scaleRatio;
  131644. private _uniformScalingMesh;
  131645. private _octahedron;
  131646. private _sensitivity;
  131647. /** Fires an event when any of it's sub gizmos are dragged */
  131648. onDragStartObservable: Observable<unknown>;
  131649. /** Fires an event when any of it's sub gizmos are released from dragging */
  131650. onDragEndObservable: Observable<unknown>;
  131651. get attachedMesh(): Nullable<AbstractMesh>;
  131652. set attachedMesh(mesh: Nullable<AbstractMesh>);
  131653. get attachedNode(): Nullable<Node>;
  131654. set attachedNode(node: Nullable<Node>);
  131655. /**
  131656. * Creates a ScaleGizmo
  131657. * @param gizmoLayer The utility layer the gizmo will be added to
  131658. * @param thickness display gizmo axis thickness
  131659. */
  131660. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  131661. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  131662. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  131663. /**
  131664. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131665. */
  131666. set snapDistance(value: number);
  131667. get snapDistance(): number;
  131668. /**
  131669. * Ratio for the scale of the gizmo (Default: 1)
  131670. */
  131671. set scaleRatio(value: number);
  131672. get scaleRatio(): number;
  131673. /**
  131674. * Sensitivity factor for dragging (Default: 1)
  131675. */
  131676. set sensitivity(value: number);
  131677. get sensitivity(): number;
  131678. /**
  131679. * Disposes of the gizmo
  131680. */
  131681. dispose(): void;
  131682. }
  131683. }
  131684. declare module BABYLON {
  131685. /**
  131686. * Single axis scale gizmo
  131687. */
  131688. export class AxisScaleGizmo extends Gizmo {
  131689. /**
  131690. * Drag behavior responsible for the gizmos dragging interactions
  131691. */
  131692. dragBehavior: PointerDragBehavior;
  131693. private _pointerObserver;
  131694. /**
  131695. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131696. */
  131697. snapDistance: number;
  131698. /**
  131699. * Event that fires each time the gizmo snaps to a new location.
  131700. * * snapDistance is the the change in distance
  131701. */
  131702. onSnapObservable: Observable<{
  131703. snapDistance: number;
  131704. }>;
  131705. /**
  131706. * If the scaling operation should be done on all axis (default: false)
  131707. */
  131708. uniformScaling: boolean;
  131709. /**
  131710. * Custom sensitivity value for the drag strength
  131711. */
  131712. sensitivity: number;
  131713. private _isEnabled;
  131714. private _parent;
  131715. private _arrow;
  131716. private _coloredMaterial;
  131717. private _hoverMaterial;
  131718. /**
  131719. * Creates an AxisScaleGizmo
  131720. * @param gizmoLayer The utility layer the gizmo will be added to
  131721. * @param dragAxis The axis which the gizmo will be able to scale on
  131722. * @param color The color of the gizmo
  131723. * @param thickness display gizmo axis thickness
  131724. */
  131725. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  131726. protected _attachedNodeChanged(value: Nullable<Node>): void;
  131727. /**
  131728. * If the gizmo is enabled
  131729. */
  131730. set isEnabled(value: boolean);
  131731. get isEnabled(): boolean;
  131732. /**
  131733. * Disposes of the gizmo
  131734. */
  131735. dispose(): void;
  131736. /**
  131737. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  131738. * @param mesh The mesh to replace the default mesh of the gizmo
  131739. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  131740. */
  131741. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  131742. }
  131743. }
  131744. declare module BABYLON {
  131745. /**
  131746. * Bounding box gizmo
  131747. */
  131748. export class BoundingBoxGizmo extends Gizmo {
  131749. private _lineBoundingBox;
  131750. private _rotateSpheresParent;
  131751. private _scaleBoxesParent;
  131752. private _boundingDimensions;
  131753. private _renderObserver;
  131754. private _pointerObserver;
  131755. private _scaleDragSpeed;
  131756. private _tmpQuaternion;
  131757. private _tmpVector;
  131758. private _tmpRotationMatrix;
  131759. /**
  131760. * 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)
  131761. */
  131762. ignoreChildren: boolean;
  131763. /**
  131764. * 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)
  131765. */
  131766. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  131767. /**
  131768. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  131769. */
  131770. rotationSphereSize: number;
  131771. /**
  131772. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  131773. */
  131774. scaleBoxSize: number;
  131775. /**
  131776. * 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)
  131777. */
  131778. fixedDragMeshScreenSize: boolean;
  131779. /**
  131780. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  131781. */
  131782. fixedDragMeshScreenSizeDistanceFactor: number;
  131783. /**
  131784. * Fired when a rotation sphere or scale box is dragged
  131785. */
  131786. onDragStartObservable: Observable<{}>;
  131787. /**
  131788. * Fired when a scale box is dragged
  131789. */
  131790. onScaleBoxDragObservable: Observable<{}>;
  131791. /**
  131792. * Fired when a scale box drag is ended
  131793. */
  131794. onScaleBoxDragEndObservable: Observable<{}>;
  131795. /**
  131796. * Fired when a rotation sphere is dragged
  131797. */
  131798. onRotationSphereDragObservable: Observable<{}>;
  131799. /**
  131800. * Fired when a rotation sphere drag is ended
  131801. */
  131802. onRotationSphereDragEndObservable: Observable<{}>;
  131803. /**
  131804. * 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)
  131805. */
  131806. scalePivot: Nullable<Vector3>;
  131807. /**
  131808. * Mesh used as a pivot to rotate the attached node
  131809. */
  131810. private _anchorMesh;
  131811. private _existingMeshScale;
  131812. private _dragMesh;
  131813. private pointerDragBehavior;
  131814. private coloredMaterial;
  131815. private hoverColoredMaterial;
  131816. /**
  131817. * Sets the color of the bounding box gizmo
  131818. * @param color the color to set
  131819. */
  131820. setColor(color: Color3): void;
  131821. /**
  131822. * Creates an BoundingBoxGizmo
  131823. * @param gizmoLayer The utility layer the gizmo will be added to
  131824. * @param color The color of the gizmo
  131825. */
  131826. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  131827. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  131828. private _selectNode;
  131829. /**
  131830. * Updates the bounding box information for the Gizmo
  131831. */
  131832. updateBoundingBox(): void;
  131833. private _updateRotationSpheres;
  131834. private _updateScaleBoxes;
  131835. /**
  131836. * Enables rotation on the specified axis and disables rotation on the others
  131837. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  131838. */
  131839. setEnabledRotationAxis(axis: string): void;
  131840. /**
  131841. * Enables/disables scaling
  131842. * @param enable if scaling should be enabled
  131843. * @param homogeneousScaling defines if scaling should only be homogeneous
  131844. */
  131845. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  131846. private _updateDummy;
  131847. /**
  131848. * Enables a pointer drag behavior on the bounding box of the gizmo
  131849. */
  131850. enableDragBehavior(): void;
  131851. /**
  131852. * Disposes of the gizmo
  131853. */
  131854. dispose(): void;
  131855. /**
  131856. * 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)
  131857. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  131858. * @returns the bounding box mesh with the passed in mesh as a child
  131859. */
  131860. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  131861. /**
  131862. * CustomMeshes are not supported by this gizmo
  131863. * @param mesh The mesh to replace the default mesh of the gizmo
  131864. */
  131865. setCustomMesh(mesh: Mesh): void;
  131866. }
  131867. }
  131868. declare module BABYLON {
  131869. /**
  131870. * Single plane rotation gizmo
  131871. */
  131872. export class PlaneRotationGizmo extends Gizmo {
  131873. /**
  131874. * Drag behavior responsible for the gizmos dragging interactions
  131875. */
  131876. dragBehavior: PointerDragBehavior;
  131877. private _pointerObserver;
  131878. /**
  131879. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  131880. */
  131881. snapDistance: number;
  131882. /**
  131883. * Event that fires each time the gizmo snaps to a new location.
  131884. * * snapDistance is the the change in distance
  131885. */
  131886. onSnapObservable: Observable<{
  131887. snapDistance: number;
  131888. }>;
  131889. private _isEnabled;
  131890. private _parent;
  131891. /**
  131892. * Creates a PlaneRotationGizmo
  131893. * @param gizmoLayer The utility layer the gizmo will be added to
  131894. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  131895. * @param color The color of the gizmo
  131896. * @param tessellation Amount of tessellation to be used when creating rotation circles
  131897. * @param useEulerRotation Use and update Euler angle instead of quaternion
  131898. * @param thickness display gizmo axis thickness
  131899. */
  131900. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  131901. protected _attachedNodeChanged(value: Nullable<Node>): void;
  131902. /**
  131903. * If the gizmo is enabled
  131904. */
  131905. set isEnabled(value: boolean);
  131906. get isEnabled(): boolean;
  131907. /**
  131908. * Disposes of the gizmo
  131909. */
  131910. dispose(): void;
  131911. }
  131912. }
  131913. declare module BABYLON {
  131914. /**
  131915. * Gizmo that enables rotating a mesh along 3 axis
  131916. */
  131917. export class RotationGizmo extends Gizmo {
  131918. /**
  131919. * Internal gizmo used for interactions on the x axis
  131920. */
  131921. xGizmo: PlaneRotationGizmo;
  131922. /**
  131923. * Internal gizmo used for interactions on the y axis
  131924. */
  131925. yGizmo: PlaneRotationGizmo;
  131926. /**
  131927. * Internal gizmo used for interactions on the z axis
  131928. */
  131929. zGizmo: PlaneRotationGizmo;
  131930. /** Fires an event when any of it's sub gizmos are dragged */
  131931. onDragStartObservable: Observable<unknown>;
  131932. /** Fires an event when any of it's sub gizmos are released from dragging */
  131933. onDragEndObservable: Observable<unknown>;
  131934. private _meshAttached;
  131935. private _nodeAttached;
  131936. get attachedMesh(): Nullable<AbstractMesh>;
  131937. set attachedMesh(mesh: Nullable<AbstractMesh>);
  131938. get attachedNode(): Nullable<Node>;
  131939. set attachedNode(node: Nullable<Node>);
  131940. /**
  131941. * Creates a RotationGizmo
  131942. * @param gizmoLayer The utility layer the gizmo will be added to
  131943. * @param tessellation Amount of tessellation to be used when creating rotation circles
  131944. * @param useEulerRotation Use and update Euler angle instead of quaternion
  131945. * @param thickness display gizmo axis thickness
  131946. */
  131947. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  131948. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  131949. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  131950. /**
  131951. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131952. */
  131953. set snapDistance(value: number);
  131954. get snapDistance(): number;
  131955. /**
  131956. * Ratio for the scale of the gizmo (Default: 1)
  131957. */
  131958. set scaleRatio(value: number);
  131959. get scaleRatio(): number;
  131960. /**
  131961. * Disposes of the gizmo
  131962. */
  131963. dispose(): void;
  131964. /**
  131965. * CustomMeshes are not supported by this gizmo
  131966. * @param mesh The mesh to replace the default mesh of the gizmo
  131967. */
  131968. setCustomMesh(mesh: Mesh): void;
  131969. }
  131970. }
  131971. declare module BABYLON {
  131972. /**
  131973. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  131974. */
  131975. export class GizmoManager implements IDisposable {
  131976. private scene;
  131977. /**
  131978. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  131979. */
  131980. gizmos: {
  131981. positionGizmo: Nullable<PositionGizmo>;
  131982. rotationGizmo: Nullable<RotationGizmo>;
  131983. scaleGizmo: Nullable<ScaleGizmo>;
  131984. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  131985. };
  131986. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  131987. clearGizmoOnEmptyPointerEvent: boolean;
  131988. /** Fires an event when the manager is attached to a mesh */
  131989. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  131990. private _gizmosEnabled;
  131991. private _pointerObserver;
  131992. private _attachedMesh;
  131993. private _boundingBoxColor;
  131994. private _defaultUtilityLayer;
  131995. private _defaultKeepDepthUtilityLayer;
  131996. private _thickness;
  131997. /**
  131998. * When bounding box gizmo is enabled, this can be used to track drag/end events
  131999. */
  132000. boundingBoxDragBehavior: SixDofDragBehavior;
  132001. /**
  132002. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  132003. */
  132004. attachableMeshes: Nullable<Array<AbstractMesh>>;
  132005. /**
  132006. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  132007. */
  132008. usePointerToAttachGizmos: boolean;
  132009. /**
  132010. * Utility layer that the bounding box gizmo belongs to
  132011. */
  132012. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  132013. /**
  132014. * Utility layer that all gizmos besides bounding box belong to
  132015. */
  132016. get utilityLayer(): UtilityLayerRenderer;
  132017. /**
  132018. * Instatiates a gizmo manager
  132019. * @param scene the scene to overlay the gizmos on top of
  132020. * @param thickness display gizmo axis thickness
  132021. */
  132022. constructor(scene: Scene, thickness?: number);
  132023. /**
  132024. * Attaches a set of gizmos to the specified mesh
  132025. * @param mesh The mesh the gizmo's should be attached to
  132026. */
  132027. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  132028. /**
  132029. * If the position gizmo is enabled
  132030. */
  132031. set positionGizmoEnabled(value: boolean);
  132032. get positionGizmoEnabled(): boolean;
  132033. /**
  132034. * If the rotation gizmo is enabled
  132035. */
  132036. set rotationGizmoEnabled(value: boolean);
  132037. get rotationGizmoEnabled(): boolean;
  132038. /**
  132039. * If the scale gizmo is enabled
  132040. */
  132041. set scaleGizmoEnabled(value: boolean);
  132042. get scaleGizmoEnabled(): boolean;
  132043. /**
  132044. * If the boundingBox gizmo is enabled
  132045. */
  132046. set boundingBoxGizmoEnabled(value: boolean);
  132047. get boundingBoxGizmoEnabled(): boolean;
  132048. /**
  132049. * Disposes of the gizmo manager
  132050. */
  132051. dispose(): void;
  132052. }
  132053. }
  132054. declare module BABYLON {
  132055. /**
  132056. * A directional light is defined by a direction (what a surprise!).
  132057. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  132058. * 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.
  132059. * Documentation: https://doc.babylonjs.com/babylon101/lights
  132060. */
  132061. export class DirectionalLight extends ShadowLight {
  132062. private _shadowFrustumSize;
  132063. /**
  132064. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  132065. */
  132066. get shadowFrustumSize(): number;
  132067. /**
  132068. * Specifies a fix frustum size for the shadow generation.
  132069. */
  132070. set shadowFrustumSize(value: number);
  132071. private _shadowOrthoScale;
  132072. /**
  132073. * Gets the shadow projection scale against the optimal computed one.
  132074. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  132075. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  132076. */
  132077. get shadowOrthoScale(): number;
  132078. /**
  132079. * Sets the shadow projection scale against the optimal computed one.
  132080. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  132081. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  132082. */
  132083. set shadowOrthoScale(value: number);
  132084. /**
  132085. * Automatically compute the projection matrix to best fit (including all the casters)
  132086. * on each frame.
  132087. */
  132088. autoUpdateExtends: boolean;
  132089. /**
  132090. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  132091. * on each frame. autoUpdateExtends must be set to true for this to work
  132092. */
  132093. autoCalcShadowZBounds: boolean;
  132094. private _orthoLeft;
  132095. private _orthoRight;
  132096. private _orthoTop;
  132097. private _orthoBottom;
  132098. /**
  132099. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  132100. * The directional light is emitted from everywhere in the given direction.
  132101. * It can cast shadows.
  132102. * Documentation : https://doc.babylonjs.com/babylon101/lights
  132103. * @param name The friendly name of the light
  132104. * @param direction The direction of the light
  132105. * @param scene The scene the light belongs to
  132106. */
  132107. constructor(name: string, direction: Vector3, scene: Scene);
  132108. /**
  132109. * Returns the string "DirectionalLight".
  132110. * @return The class name
  132111. */
  132112. getClassName(): string;
  132113. /**
  132114. * Returns the integer 1.
  132115. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  132116. */
  132117. getTypeID(): number;
  132118. /**
  132119. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  132120. * Returns the DirectionalLight Shadow projection matrix.
  132121. */
  132122. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132123. /**
  132124. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  132125. * Returns the DirectionalLight Shadow projection matrix.
  132126. */
  132127. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  132128. /**
  132129. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  132130. * Returns the DirectionalLight Shadow projection matrix.
  132131. */
  132132. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132133. protected _buildUniformLayout(): void;
  132134. /**
  132135. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  132136. * @param effect The effect to update
  132137. * @param lightIndex The index of the light in the effect to update
  132138. * @returns The directional light
  132139. */
  132140. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  132141. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  132142. /**
  132143. * Gets the minZ used for shadow according to both the scene and the light.
  132144. *
  132145. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  132146. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  132147. * @param activeCamera The camera we are returning the min for
  132148. * @returns the depth min z
  132149. */
  132150. getDepthMinZ(activeCamera: Camera): number;
  132151. /**
  132152. * Gets the maxZ used for shadow according to both the scene and the light.
  132153. *
  132154. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  132155. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  132156. * @param activeCamera The camera we are returning the max for
  132157. * @returns the depth max z
  132158. */
  132159. getDepthMaxZ(activeCamera: Camera): number;
  132160. /**
  132161. * Prepares the list of defines specific to the light type.
  132162. * @param defines the list of defines
  132163. * @param lightIndex defines the index of the light for the effect
  132164. */
  132165. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  132166. }
  132167. }
  132168. declare module BABYLON {
  132169. /**
  132170. * Class containing static functions to help procedurally build meshes
  132171. */
  132172. export class HemisphereBuilder {
  132173. /**
  132174. * Creates a hemisphere mesh
  132175. * @param name defines the name of the mesh
  132176. * @param options defines the options used to create the mesh
  132177. * @param scene defines the hosting scene
  132178. * @returns the hemisphere mesh
  132179. */
  132180. static CreateHemisphere(name: string, options: {
  132181. segments?: number;
  132182. diameter?: number;
  132183. sideOrientation?: number;
  132184. }, scene: any): Mesh;
  132185. }
  132186. }
  132187. declare module BABYLON {
  132188. /**
  132189. * A spot light is defined by a position, a direction, an angle, and an exponent.
  132190. * These values define a cone of light starting from the position, emitting toward the direction.
  132191. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  132192. * and the exponent defines the speed of the decay of the light with distance (reach).
  132193. * Documentation: https://doc.babylonjs.com/babylon101/lights
  132194. */
  132195. export class SpotLight extends ShadowLight {
  132196. private _angle;
  132197. private _innerAngle;
  132198. private _cosHalfAngle;
  132199. private _lightAngleScale;
  132200. private _lightAngleOffset;
  132201. /**
  132202. * Gets the cone angle of the spot light in Radians.
  132203. */
  132204. get angle(): number;
  132205. /**
  132206. * Sets the cone angle of the spot light in Radians.
  132207. */
  132208. set angle(value: number);
  132209. /**
  132210. * Only used in gltf falloff mode, this defines the angle where
  132211. * the directional falloff will start before cutting at angle which could be seen
  132212. * as outer angle.
  132213. */
  132214. get innerAngle(): number;
  132215. /**
  132216. * Only used in gltf falloff mode, this defines the angle where
  132217. * the directional falloff will start before cutting at angle which could be seen
  132218. * as outer angle.
  132219. */
  132220. set innerAngle(value: number);
  132221. private _shadowAngleScale;
  132222. /**
  132223. * Allows scaling the angle of the light for shadow generation only.
  132224. */
  132225. get shadowAngleScale(): number;
  132226. /**
  132227. * Allows scaling the angle of the light for shadow generation only.
  132228. */
  132229. set shadowAngleScale(value: number);
  132230. /**
  132231. * The light decay speed with the distance from the emission spot.
  132232. */
  132233. exponent: number;
  132234. private _projectionTextureMatrix;
  132235. /**
  132236. * Allows reading the projecton texture
  132237. */
  132238. get projectionTextureMatrix(): Matrix;
  132239. protected _projectionTextureLightNear: number;
  132240. /**
  132241. * Gets the near clip of the Spotlight for texture projection.
  132242. */
  132243. get projectionTextureLightNear(): number;
  132244. /**
  132245. * Sets the near clip of the Spotlight for texture projection.
  132246. */
  132247. set projectionTextureLightNear(value: number);
  132248. protected _projectionTextureLightFar: number;
  132249. /**
  132250. * Gets the far clip of the Spotlight for texture projection.
  132251. */
  132252. get projectionTextureLightFar(): number;
  132253. /**
  132254. * Sets the far clip of the Spotlight for texture projection.
  132255. */
  132256. set projectionTextureLightFar(value: number);
  132257. protected _projectionTextureUpDirection: Vector3;
  132258. /**
  132259. * Gets the Up vector of the Spotlight for texture projection.
  132260. */
  132261. get projectionTextureUpDirection(): Vector3;
  132262. /**
  132263. * Sets the Up vector of the Spotlight for texture projection.
  132264. */
  132265. set projectionTextureUpDirection(value: Vector3);
  132266. private _projectionTexture;
  132267. /**
  132268. * Gets the projection texture of the light.
  132269. */
  132270. get projectionTexture(): Nullable<BaseTexture>;
  132271. /**
  132272. * Sets the projection texture of the light.
  132273. */
  132274. set projectionTexture(value: Nullable<BaseTexture>);
  132275. private _projectionTextureViewLightDirty;
  132276. private _projectionTextureProjectionLightDirty;
  132277. private _projectionTextureDirty;
  132278. private _projectionTextureViewTargetVector;
  132279. private _projectionTextureViewLightMatrix;
  132280. private _projectionTextureProjectionLightMatrix;
  132281. private _projectionTextureScalingMatrix;
  132282. /**
  132283. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  132284. * It can cast shadows.
  132285. * Documentation : https://doc.babylonjs.com/babylon101/lights
  132286. * @param name The light friendly name
  132287. * @param position The position of the spot light in the scene
  132288. * @param direction The direction of the light in the scene
  132289. * @param angle The cone angle of the light in Radians
  132290. * @param exponent The light decay speed with the distance from the emission spot
  132291. * @param scene The scene the lights belongs to
  132292. */
  132293. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  132294. /**
  132295. * Returns the string "SpotLight".
  132296. * @returns the class name
  132297. */
  132298. getClassName(): string;
  132299. /**
  132300. * Returns the integer 2.
  132301. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  132302. */
  132303. getTypeID(): number;
  132304. /**
  132305. * Overrides the direction setter to recompute the projection texture view light Matrix.
  132306. */
  132307. protected _setDirection(value: Vector3): void;
  132308. /**
  132309. * Overrides the position setter to recompute the projection texture view light Matrix.
  132310. */
  132311. protected _setPosition(value: Vector3): void;
  132312. /**
  132313. * 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.
  132314. * Returns the SpotLight.
  132315. */
  132316. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132317. protected _computeProjectionTextureViewLightMatrix(): void;
  132318. protected _computeProjectionTextureProjectionLightMatrix(): void;
  132319. /**
  132320. * Main function for light texture projection matrix computing.
  132321. */
  132322. protected _computeProjectionTextureMatrix(): void;
  132323. protected _buildUniformLayout(): void;
  132324. private _computeAngleValues;
  132325. /**
  132326. * Sets the passed Effect "effect" with the Light textures.
  132327. * @param effect The effect to update
  132328. * @param lightIndex The index of the light in the effect to update
  132329. * @returns The light
  132330. */
  132331. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  132332. /**
  132333. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  132334. * @param effect The effect to update
  132335. * @param lightIndex The index of the light in the effect to update
  132336. * @returns The spot light
  132337. */
  132338. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  132339. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  132340. /**
  132341. * Disposes the light and the associated resources.
  132342. */
  132343. dispose(): void;
  132344. /**
  132345. * Prepares the list of defines specific to the light type.
  132346. * @param defines the list of defines
  132347. * @param lightIndex defines the index of the light for the effect
  132348. */
  132349. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  132350. }
  132351. }
  132352. declare module BABYLON {
  132353. /**
  132354. * Gizmo that enables viewing a light
  132355. */
  132356. export class LightGizmo extends Gizmo {
  132357. private _lightMesh;
  132358. private _material;
  132359. private _cachedPosition;
  132360. private _cachedForward;
  132361. private _attachedMeshParent;
  132362. /**
  132363. * Creates a LightGizmo
  132364. * @param gizmoLayer The utility layer the gizmo will be added to
  132365. */
  132366. constructor(gizmoLayer?: UtilityLayerRenderer);
  132367. private _light;
  132368. /**
  132369. * The light that the gizmo is attached to
  132370. */
  132371. set light(light: Nullable<Light>);
  132372. get light(): Nullable<Light>;
  132373. /**
  132374. * Gets the material used to render the light gizmo
  132375. */
  132376. get material(): StandardMaterial;
  132377. /**
  132378. * @hidden
  132379. * Updates the gizmo to match the attached mesh's position/rotation
  132380. */
  132381. protected _update(): void;
  132382. private static _Scale;
  132383. /**
  132384. * Creates the lines for a light mesh
  132385. */
  132386. private static _CreateLightLines;
  132387. /**
  132388. * Disposes of the light gizmo
  132389. */
  132390. dispose(): void;
  132391. private static _CreateHemisphericLightMesh;
  132392. private static _CreatePointLightMesh;
  132393. private static _CreateSpotLightMesh;
  132394. private static _CreateDirectionalLightMesh;
  132395. }
  132396. }
  132397. declare module BABYLON {
  132398. /** @hidden */
  132399. export var backgroundFragmentDeclaration: {
  132400. name: string;
  132401. shader: string;
  132402. };
  132403. }
  132404. declare module BABYLON {
  132405. /** @hidden */
  132406. export var backgroundUboDeclaration: {
  132407. name: string;
  132408. shader: string;
  132409. };
  132410. }
  132411. declare module BABYLON {
  132412. /** @hidden */
  132413. export var backgroundPixelShader: {
  132414. name: string;
  132415. shader: string;
  132416. };
  132417. }
  132418. declare module BABYLON {
  132419. /** @hidden */
  132420. export var backgroundVertexDeclaration: {
  132421. name: string;
  132422. shader: string;
  132423. };
  132424. }
  132425. declare module BABYLON {
  132426. /** @hidden */
  132427. export var backgroundVertexShader: {
  132428. name: string;
  132429. shader: string;
  132430. };
  132431. }
  132432. declare module BABYLON {
  132433. /**
  132434. * Background material used to create an efficient environement around your scene.
  132435. */
  132436. export class BackgroundMaterial extends PushMaterial {
  132437. /**
  132438. * Standard reflectance value at parallel view angle.
  132439. */
  132440. static StandardReflectance0: number;
  132441. /**
  132442. * Standard reflectance value at grazing angle.
  132443. */
  132444. static StandardReflectance90: number;
  132445. protected _primaryColor: Color3;
  132446. /**
  132447. * Key light Color (multiply against the environement texture)
  132448. */
  132449. primaryColor: Color3;
  132450. protected __perceptualColor: Nullable<Color3>;
  132451. /**
  132452. * Experimental Internal Use Only.
  132453. *
  132454. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  132455. * This acts as a helper to set the primary color to a more "human friendly" value.
  132456. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  132457. * output color as close as possible from the chosen value.
  132458. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  132459. * part of lighting setup.)
  132460. */
  132461. get _perceptualColor(): Nullable<Color3>;
  132462. set _perceptualColor(value: Nullable<Color3>);
  132463. protected _primaryColorShadowLevel: float;
  132464. /**
  132465. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  132466. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  132467. */
  132468. get primaryColorShadowLevel(): float;
  132469. set primaryColorShadowLevel(value: float);
  132470. protected _primaryColorHighlightLevel: float;
  132471. /**
  132472. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  132473. * The primary color is used at the level chosen to define what the white area would look.
  132474. */
  132475. get primaryColorHighlightLevel(): float;
  132476. set primaryColorHighlightLevel(value: float);
  132477. protected _reflectionTexture: Nullable<BaseTexture>;
  132478. /**
  132479. * Reflection Texture used in the material.
  132480. * Should be author in a specific way for the best result (refer to the documentation).
  132481. */
  132482. reflectionTexture: Nullable<BaseTexture>;
  132483. protected _reflectionBlur: float;
  132484. /**
  132485. * Reflection Texture level of blur.
  132486. *
  132487. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  132488. * texture twice.
  132489. */
  132490. reflectionBlur: float;
  132491. protected _diffuseTexture: Nullable<BaseTexture>;
  132492. /**
  132493. * Diffuse Texture used in the material.
  132494. * Should be author in a specific way for the best result (refer to the documentation).
  132495. */
  132496. diffuseTexture: Nullable<BaseTexture>;
  132497. protected _shadowLights: Nullable<IShadowLight[]>;
  132498. /**
  132499. * Specify the list of lights casting shadow on the material.
  132500. * All scene shadow lights will be included if null.
  132501. */
  132502. shadowLights: Nullable<IShadowLight[]>;
  132503. protected _shadowLevel: float;
  132504. /**
  132505. * Helps adjusting the shadow to a softer level if required.
  132506. * 0 means black shadows and 1 means no shadows.
  132507. */
  132508. shadowLevel: float;
  132509. protected _sceneCenter: Vector3;
  132510. /**
  132511. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  132512. * It is usually zero but might be interesting to modify according to your setup.
  132513. */
  132514. sceneCenter: Vector3;
  132515. protected _opacityFresnel: boolean;
  132516. /**
  132517. * This helps specifying that the material is falling off to the sky box at grazing angle.
  132518. * This helps ensuring a nice transition when the camera goes under the ground.
  132519. */
  132520. opacityFresnel: boolean;
  132521. protected _reflectionFresnel: boolean;
  132522. /**
  132523. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  132524. * This helps adding a mirror texture on the ground.
  132525. */
  132526. reflectionFresnel: boolean;
  132527. protected _reflectionFalloffDistance: number;
  132528. /**
  132529. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  132530. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  132531. */
  132532. reflectionFalloffDistance: number;
  132533. protected _reflectionAmount: number;
  132534. /**
  132535. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  132536. */
  132537. reflectionAmount: number;
  132538. protected _reflectionReflectance0: number;
  132539. /**
  132540. * This specifies the weight of the reflection at grazing angle.
  132541. */
  132542. reflectionReflectance0: number;
  132543. protected _reflectionReflectance90: number;
  132544. /**
  132545. * This specifies the weight of the reflection at a perpendicular point of view.
  132546. */
  132547. reflectionReflectance90: number;
  132548. /**
  132549. * Sets the reflection reflectance fresnel values according to the default standard
  132550. * empirically know to work well :-)
  132551. */
  132552. set reflectionStandardFresnelWeight(value: number);
  132553. protected _useRGBColor: boolean;
  132554. /**
  132555. * Helps to directly use the maps channels instead of their level.
  132556. */
  132557. useRGBColor: boolean;
  132558. protected _enableNoise: boolean;
  132559. /**
  132560. * This helps reducing the banding effect that could occur on the background.
  132561. */
  132562. enableNoise: boolean;
  132563. /**
  132564. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  132565. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  132566. * Recommended to be keep at 1.0 except for special cases.
  132567. */
  132568. get fovMultiplier(): number;
  132569. set fovMultiplier(value: number);
  132570. private _fovMultiplier;
  132571. /**
  132572. * Enable the FOV adjustment feature controlled by fovMultiplier.
  132573. */
  132574. useEquirectangularFOV: boolean;
  132575. private _maxSimultaneousLights;
  132576. /**
  132577. * Number of Simultaneous lights allowed on the material.
  132578. */
  132579. maxSimultaneousLights: int;
  132580. private _shadowOnly;
  132581. /**
  132582. * Make the material only render shadows
  132583. */
  132584. shadowOnly: boolean;
  132585. /**
  132586. * Default configuration related to image processing available in the Background Material.
  132587. */
  132588. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  132589. /**
  132590. * Keep track of the image processing observer to allow dispose and replace.
  132591. */
  132592. private _imageProcessingObserver;
  132593. /**
  132594. * Attaches a new image processing configuration to the PBR Material.
  132595. * @param configuration (if null the scene configuration will be use)
  132596. */
  132597. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  132598. /**
  132599. * Gets the image processing configuration used either in this material.
  132600. */
  132601. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  132602. /**
  132603. * Sets the Default image processing configuration used either in the this material.
  132604. *
  132605. * If sets to null, the scene one is in use.
  132606. */
  132607. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  132608. /**
  132609. * Gets wether the color curves effect is enabled.
  132610. */
  132611. get cameraColorCurvesEnabled(): boolean;
  132612. /**
  132613. * Sets wether the color curves effect is enabled.
  132614. */
  132615. set cameraColorCurvesEnabled(value: boolean);
  132616. /**
  132617. * Gets wether the color grading effect is enabled.
  132618. */
  132619. get cameraColorGradingEnabled(): boolean;
  132620. /**
  132621. * Gets wether the color grading effect is enabled.
  132622. */
  132623. set cameraColorGradingEnabled(value: boolean);
  132624. /**
  132625. * Gets wether tonemapping is enabled or not.
  132626. */
  132627. get cameraToneMappingEnabled(): boolean;
  132628. /**
  132629. * Sets wether tonemapping is enabled or not
  132630. */
  132631. set cameraToneMappingEnabled(value: boolean);
  132632. /**
  132633. * The camera exposure used on this material.
  132634. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  132635. * This corresponds to a photographic exposure.
  132636. */
  132637. get cameraExposure(): float;
  132638. /**
  132639. * The camera exposure used on this material.
  132640. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  132641. * This corresponds to a photographic exposure.
  132642. */
  132643. set cameraExposure(value: float);
  132644. /**
  132645. * Gets The camera contrast used on this material.
  132646. */
  132647. get cameraContrast(): float;
  132648. /**
  132649. * Sets The camera contrast used on this material.
  132650. */
  132651. set cameraContrast(value: float);
  132652. /**
  132653. * Gets the Color Grading 2D Lookup Texture.
  132654. */
  132655. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  132656. /**
  132657. * Sets the Color Grading 2D Lookup Texture.
  132658. */
  132659. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  132660. /**
  132661. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  132662. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  132663. * 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;
  132664. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  132665. */
  132666. get cameraColorCurves(): Nullable<ColorCurves>;
  132667. /**
  132668. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  132669. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  132670. * 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;
  132671. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  132672. */
  132673. set cameraColorCurves(value: Nullable<ColorCurves>);
  132674. /**
  132675. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  132676. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  132677. */
  132678. switchToBGR: boolean;
  132679. private _renderTargets;
  132680. private _reflectionControls;
  132681. private _white;
  132682. private _primaryShadowColor;
  132683. private _primaryHighlightColor;
  132684. /**
  132685. * Instantiates a Background Material in the given scene
  132686. * @param name The friendly name of the material
  132687. * @param scene The scene to add the material to
  132688. */
  132689. constructor(name: string, scene: Scene);
  132690. /**
  132691. * Gets a boolean indicating that current material needs to register RTT
  132692. */
  132693. get hasRenderTargetTextures(): boolean;
  132694. /**
  132695. * The entire material has been created in order to prevent overdraw.
  132696. * @returns false
  132697. */
  132698. needAlphaTesting(): boolean;
  132699. /**
  132700. * The entire material has been created in order to prevent overdraw.
  132701. * @returns true if blending is enable
  132702. */
  132703. needAlphaBlending(): boolean;
  132704. /**
  132705. * Checks wether the material is ready to be rendered for a given mesh.
  132706. * @param mesh The mesh to render
  132707. * @param subMesh The submesh to check against
  132708. * @param useInstances Specify wether or not the material is used with instances
  132709. * @returns true if all the dependencies are ready (Textures, Effects...)
  132710. */
  132711. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  132712. /**
  132713. * Compute the primary color according to the chosen perceptual color.
  132714. */
  132715. private _computePrimaryColorFromPerceptualColor;
  132716. /**
  132717. * Compute the highlights and shadow colors according to their chosen levels.
  132718. */
  132719. private _computePrimaryColors;
  132720. /**
  132721. * Build the uniform buffer used in the material.
  132722. */
  132723. buildUniformLayout(): void;
  132724. /**
  132725. * Unbind the material.
  132726. */
  132727. unbind(): void;
  132728. /**
  132729. * Bind only the world matrix to the material.
  132730. * @param world The world matrix to bind.
  132731. */
  132732. bindOnlyWorldMatrix(world: Matrix): void;
  132733. /**
  132734. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  132735. * @param world The world matrix to bind.
  132736. * @param subMesh The submesh to bind for.
  132737. */
  132738. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  132739. /**
  132740. * Checks to see if a texture is used in the material.
  132741. * @param texture - Base texture to use.
  132742. * @returns - Boolean specifying if a texture is used in the material.
  132743. */
  132744. hasTexture(texture: BaseTexture): boolean;
  132745. /**
  132746. * Dispose the material.
  132747. * @param forceDisposeEffect Force disposal of the associated effect.
  132748. * @param forceDisposeTextures Force disposal of the associated textures.
  132749. */
  132750. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  132751. /**
  132752. * Clones the material.
  132753. * @param name The cloned name.
  132754. * @returns The cloned material.
  132755. */
  132756. clone(name: string): BackgroundMaterial;
  132757. /**
  132758. * Serializes the current material to its JSON representation.
  132759. * @returns The JSON representation.
  132760. */
  132761. serialize(): any;
  132762. /**
  132763. * Gets the class name of the material
  132764. * @returns "BackgroundMaterial"
  132765. */
  132766. getClassName(): string;
  132767. /**
  132768. * Parse a JSON input to create back a background material.
  132769. * @param source The JSON data to parse
  132770. * @param scene The scene to create the parsed material in
  132771. * @param rootUrl The root url of the assets the material depends upon
  132772. * @returns the instantiated BackgroundMaterial.
  132773. */
  132774. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  132775. }
  132776. }
  132777. declare module BABYLON {
  132778. /**
  132779. * Represents the different options available during the creation of
  132780. * a Environment helper.
  132781. *
  132782. * This can control the default ground, skybox and image processing setup of your scene.
  132783. */
  132784. export interface IEnvironmentHelperOptions {
  132785. /**
  132786. * Specifies whether or not to create a ground.
  132787. * True by default.
  132788. */
  132789. createGround: boolean;
  132790. /**
  132791. * Specifies the ground size.
  132792. * 15 by default.
  132793. */
  132794. groundSize: number;
  132795. /**
  132796. * The texture used on the ground for the main color.
  132797. * Comes from the BabylonJS CDN by default.
  132798. *
  132799. * Remarks: Can be either a texture or a url.
  132800. */
  132801. groundTexture: string | BaseTexture;
  132802. /**
  132803. * The color mixed in the ground texture by default.
  132804. * BabylonJS clearColor by default.
  132805. */
  132806. groundColor: Color3;
  132807. /**
  132808. * Specifies the ground opacity.
  132809. * 1 by default.
  132810. */
  132811. groundOpacity: number;
  132812. /**
  132813. * Enables the ground to receive shadows.
  132814. * True by default.
  132815. */
  132816. enableGroundShadow: boolean;
  132817. /**
  132818. * Helps preventing the shadow to be fully black on the ground.
  132819. * 0.5 by default.
  132820. */
  132821. groundShadowLevel: number;
  132822. /**
  132823. * Creates a mirror texture attach to the ground.
  132824. * false by default.
  132825. */
  132826. enableGroundMirror: boolean;
  132827. /**
  132828. * Specifies the ground mirror size ratio.
  132829. * 0.3 by default as the default kernel is 64.
  132830. */
  132831. groundMirrorSizeRatio: number;
  132832. /**
  132833. * Specifies the ground mirror blur kernel size.
  132834. * 64 by default.
  132835. */
  132836. groundMirrorBlurKernel: number;
  132837. /**
  132838. * Specifies the ground mirror visibility amount.
  132839. * 1 by default
  132840. */
  132841. groundMirrorAmount: number;
  132842. /**
  132843. * Specifies the ground mirror reflectance weight.
  132844. * This uses the standard weight of the background material to setup the fresnel effect
  132845. * of the mirror.
  132846. * 1 by default.
  132847. */
  132848. groundMirrorFresnelWeight: number;
  132849. /**
  132850. * Specifies the ground mirror Falloff distance.
  132851. * This can helps reducing the size of the reflection.
  132852. * 0 by Default.
  132853. */
  132854. groundMirrorFallOffDistance: number;
  132855. /**
  132856. * Specifies the ground mirror texture type.
  132857. * Unsigned Int by Default.
  132858. */
  132859. groundMirrorTextureType: number;
  132860. /**
  132861. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  132862. * the shown objects.
  132863. */
  132864. groundYBias: number;
  132865. /**
  132866. * Specifies whether or not to create a skybox.
  132867. * True by default.
  132868. */
  132869. createSkybox: boolean;
  132870. /**
  132871. * Specifies the skybox size.
  132872. * 20 by default.
  132873. */
  132874. skyboxSize: number;
  132875. /**
  132876. * The texture used on the skybox for the main color.
  132877. * Comes from the BabylonJS CDN by default.
  132878. *
  132879. * Remarks: Can be either a texture or a url.
  132880. */
  132881. skyboxTexture: string | BaseTexture;
  132882. /**
  132883. * The color mixed in the skybox texture by default.
  132884. * BabylonJS clearColor by default.
  132885. */
  132886. skyboxColor: Color3;
  132887. /**
  132888. * The background rotation around the Y axis of the scene.
  132889. * This helps aligning the key lights of your scene with the background.
  132890. * 0 by default.
  132891. */
  132892. backgroundYRotation: number;
  132893. /**
  132894. * Compute automatically the size of the elements to best fit with the scene.
  132895. */
  132896. sizeAuto: boolean;
  132897. /**
  132898. * Default position of the rootMesh if autoSize is not true.
  132899. */
  132900. rootPosition: Vector3;
  132901. /**
  132902. * Sets up the image processing in the scene.
  132903. * true by default.
  132904. */
  132905. setupImageProcessing: boolean;
  132906. /**
  132907. * The texture used as your environment texture in the scene.
  132908. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  132909. *
  132910. * Remarks: Can be either a texture or a url.
  132911. */
  132912. environmentTexture: string | BaseTexture;
  132913. /**
  132914. * The value of the exposure to apply to the scene.
  132915. * 0.6 by default if setupImageProcessing is true.
  132916. */
  132917. cameraExposure: number;
  132918. /**
  132919. * The value of the contrast to apply to the scene.
  132920. * 1.6 by default if setupImageProcessing is true.
  132921. */
  132922. cameraContrast: number;
  132923. /**
  132924. * Specifies whether or not tonemapping should be enabled in the scene.
  132925. * true by default if setupImageProcessing is true.
  132926. */
  132927. toneMappingEnabled: boolean;
  132928. }
  132929. /**
  132930. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  132931. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  132932. * It also helps with the default setup of your imageProcessing configuration.
  132933. */
  132934. export class EnvironmentHelper {
  132935. /**
  132936. * Default ground texture URL.
  132937. */
  132938. private static _groundTextureCDNUrl;
  132939. /**
  132940. * Default skybox texture URL.
  132941. */
  132942. private static _skyboxTextureCDNUrl;
  132943. /**
  132944. * Default environment texture URL.
  132945. */
  132946. private static _environmentTextureCDNUrl;
  132947. /**
  132948. * Creates the default options for the helper.
  132949. */
  132950. private static _getDefaultOptions;
  132951. private _rootMesh;
  132952. /**
  132953. * Gets the root mesh created by the helper.
  132954. */
  132955. get rootMesh(): Mesh;
  132956. private _skybox;
  132957. /**
  132958. * Gets the skybox created by the helper.
  132959. */
  132960. get skybox(): Nullable<Mesh>;
  132961. private _skyboxTexture;
  132962. /**
  132963. * Gets the skybox texture created by the helper.
  132964. */
  132965. get skyboxTexture(): Nullable<BaseTexture>;
  132966. private _skyboxMaterial;
  132967. /**
  132968. * Gets the skybox material created by the helper.
  132969. */
  132970. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  132971. private _ground;
  132972. /**
  132973. * Gets the ground mesh created by the helper.
  132974. */
  132975. get ground(): Nullable<Mesh>;
  132976. private _groundTexture;
  132977. /**
  132978. * Gets the ground texture created by the helper.
  132979. */
  132980. get groundTexture(): Nullable<BaseTexture>;
  132981. private _groundMirror;
  132982. /**
  132983. * Gets the ground mirror created by the helper.
  132984. */
  132985. get groundMirror(): Nullable<MirrorTexture>;
  132986. /**
  132987. * Gets the ground mirror render list to helps pushing the meshes
  132988. * you wish in the ground reflection.
  132989. */
  132990. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  132991. private _groundMaterial;
  132992. /**
  132993. * Gets the ground material created by the helper.
  132994. */
  132995. get groundMaterial(): Nullable<BackgroundMaterial>;
  132996. /**
  132997. * Stores the creation options.
  132998. */
  132999. private readonly _scene;
  133000. private _options;
  133001. /**
  133002. * This observable will be notified with any error during the creation of the environment,
  133003. * mainly texture creation errors.
  133004. */
  133005. onErrorObservable: Observable<{
  133006. message?: string;
  133007. exception?: any;
  133008. }>;
  133009. /**
  133010. * constructor
  133011. * @param options Defines the options we want to customize the helper
  133012. * @param scene The scene to add the material to
  133013. */
  133014. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  133015. /**
  133016. * Updates the background according to the new options
  133017. * @param options
  133018. */
  133019. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  133020. /**
  133021. * Sets the primary color of all the available elements.
  133022. * @param color the main color to affect to the ground and the background
  133023. */
  133024. setMainColor(color: Color3): void;
  133025. /**
  133026. * Setup the image processing according to the specified options.
  133027. */
  133028. private _setupImageProcessing;
  133029. /**
  133030. * Setup the environment texture according to the specified options.
  133031. */
  133032. private _setupEnvironmentTexture;
  133033. /**
  133034. * Setup the background according to the specified options.
  133035. */
  133036. private _setupBackground;
  133037. /**
  133038. * Get the scene sizes according to the setup.
  133039. */
  133040. private _getSceneSize;
  133041. /**
  133042. * Setup the ground according to the specified options.
  133043. */
  133044. private _setupGround;
  133045. /**
  133046. * Setup the ground material according to the specified options.
  133047. */
  133048. private _setupGroundMaterial;
  133049. /**
  133050. * Setup the ground diffuse texture according to the specified options.
  133051. */
  133052. private _setupGroundDiffuseTexture;
  133053. /**
  133054. * Setup the ground mirror texture according to the specified options.
  133055. */
  133056. private _setupGroundMirrorTexture;
  133057. /**
  133058. * Setup the ground to receive the mirror texture.
  133059. */
  133060. private _setupMirrorInGroundMaterial;
  133061. /**
  133062. * Setup the skybox according to the specified options.
  133063. */
  133064. private _setupSkybox;
  133065. /**
  133066. * Setup the skybox material according to the specified options.
  133067. */
  133068. private _setupSkyboxMaterial;
  133069. /**
  133070. * Setup the skybox reflection texture according to the specified options.
  133071. */
  133072. private _setupSkyboxReflectionTexture;
  133073. private _errorHandler;
  133074. /**
  133075. * Dispose all the elements created by the Helper.
  133076. */
  133077. dispose(): void;
  133078. }
  133079. }
  133080. declare module BABYLON {
  133081. /**
  133082. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  133083. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  133084. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  133085. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  133086. */
  133087. export class PhotoDome extends TransformNode {
  133088. /**
  133089. * Define the image as a Monoscopic panoramic 360 image.
  133090. */
  133091. static readonly MODE_MONOSCOPIC: number;
  133092. /**
  133093. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  133094. */
  133095. static readonly MODE_TOPBOTTOM: number;
  133096. /**
  133097. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  133098. */
  133099. static readonly MODE_SIDEBYSIDE: number;
  133100. private _useDirectMapping;
  133101. /**
  133102. * The texture being displayed on the sphere
  133103. */
  133104. protected _photoTexture: Texture;
  133105. /**
  133106. * Gets or sets the texture being displayed on the sphere
  133107. */
  133108. get photoTexture(): Texture;
  133109. set photoTexture(value: Texture);
  133110. /**
  133111. * Observable raised when an error occured while loading the 360 image
  133112. */
  133113. onLoadErrorObservable: Observable<string>;
  133114. /**
  133115. * The skybox material
  133116. */
  133117. protected _material: BackgroundMaterial;
  133118. /**
  133119. * The surface used for the skybox
  133120. */
  133121. protected _mesh: Mesh;
  133122. /**
  133123. * Gets the mesh used for the skybox.
  133124. */
  133125. get mesh(): Mesh;
  133126. /**
  133127. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  133128. * Also see the options.resolution property.
  133129. */
  133130. get fovMultiplier(): number;
  133131. set fovMultiplier(value: number);
  133132. private _imageMode;
  133133. /**
  133134. * Gets or set the current video mode for the video. It can be:
  133135. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  133136. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  133137. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  133138. */
  133139. get imageMode(): number;
  133140. set imageMode(value: number);
  133141. /**
  133142. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  133143. * @param name Element's name, child elements will append suffixes for their own names.
  133144. * @param urlsOfPhoto defines the url of the photo to display
  133145. * @param options defines an object containing optional or exposed sub element properties
  133146. * @param onError defines a callback called when an error occured while loading the texture
  133147. */
  133148. constructor(name: string, urlOfPhoto: string, options: {
  133149. resolution?: number;
  133150. size?: number;
  133151. useDirectMapping?: boolean;
  133152. faceForward?: boolean;
  133153. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  133154. private _onBeforeCameraRenderObserver;
  133155. private _changeImageMode;
  133156. /**
  133157. * Releases resources associated with this node.
  133158. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  133159. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  133160. */
  133161. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  133162. }
  133163. }
  133164. declare module BABYLON {
  133165. /**
  133166. * Class used to host RGBD texture specific utilities
  133167. */
  133168. export class RGBDTextureTools {
  133169. /**
  133170. * Expand the RGBD Texture from RGBD to Half Float if possible.
  133171. * @param texture the texture to expand.
  133172. */
  133173. static ExpandRGBDTexture(texture: Texture): void;
  133174. }
  133175. }
  133176. declare module BABYLON {
  133177. /**
  133178. * Class used to host texture specific utilities
  133179. */
  133180. export class BRDFTextureTools {
  133181. /**
  133182. * Prevents texture cache collision
  133183. */
  133184. private static _instanceNumber;
  133185. /**
  133186. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  133187. * @param scene defines the hosting scene
  133188. * @returns the environment BRDF texture
  133189. */
  133190. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  133191. private static _environmentBRDFBase64Texture;
  133192. }
  133193. }
  133194. declare module BABYLON {
  133195. /**
  133196. * @hidden
  133197. */
  133198. export interface IMaterialClearCoatDefines {
  133199. CLEARCOAT: boolean;
  133200. CLEARCOAT_DEFAULTIOR: boolean;
  133201. CLEARCOAT_TEXTURE: boolean;
  133202. CLEARCOAT_TEXTUREDIRECTUV: number;
  133203. CLEARCOAT_BUMP: boolean;
  133204. CLEARCOAT_BUMPDIRECTUV: number;
  133205. CLEARCOAT_TINT: boolean;
  133206. CLEARCOAT_TINT_TEXTURE: boolean;
  133207. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  133208. /** @hidden */
  133209. _areTexturesDirty: boolean;
  133210. }
  133211. /**
  133212. * Define the code related to the clear coat parameters of the pbr material.
  133213. */
  133214. export class PBRClearCoatConfiguration {
  133215. /**
  133216. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  133217. * The default fits with a polyurethane material.
  133218. */
  133219. private static readonly _DefaultIndexOfRefraction;
  133220. private _isEnabled;
  133221. /**
  133222. * Defines if the clear coat is enabled in the material.
  133223. */
  133224. isEnabled: boolean;
  133225. /**
  133226. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  133227. */
  133228. intensity: number;
  133229. /**
  133230. * Defines the clear coat layer roughness.
  133231. */
  133232. roughness: number;
  133233. private _indexOfRefraction;
  133234. /**
  133235. * Defines the index of refraction of the clear coat.
  133236. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  133237. * The default fits with a polyurethane material.
  133238. * Changing the default value is more performance intensive.
  133239. */
  133240. indexOfRefraction: number;
  133241. private _texture;
  133242. /**
  133243. * Stores the clear coat values in a texture.
  133244. */
  133245. texture: Nullable<BaseTexture>;
  133246. private _bumpTexture;
  133247. /**
  133248. * Define the clear coat specific bump texture.
  133249. */
  133250. bumpTexture: Nullable<BaseTexture>;
  133251. private _isTintEnabled;
  133252. /**
  133253. * Defines if the clear coat tint is enabled in the material.
  133254. */
  133255. isTintEnabled: boolean;
  133256. /**
  133257. * Defines the clear coat tint of the material.
  133258. * This is only use if tint is enabled
  133259. */
  133260. tintColor: Color3;
  133261. /**
  133262. * Defines the distance at which the tint color should be found in the
  133263. * clear coat media.
  133264. * This is only use if tint is enabled
  133265. */
  133266. tintColorAtDistance: number;
  133267. /**
  133268. * Defines the clear coat layer thickness.
  133269. * This is only use if tint is enabled
  133270. */
  133271. tintThickness: number;
  133272. private _tintTexture;
  133273. /**
  133274. * Stores the clear tint values in a texture.
  133275. * rgb is tint
  133276. * a is a thickness factor
  133277. */
  133278. tintTexture: Nullable<BaseTexture>;
  133279. /** @hidden */
  133280. private _internalMarkAllSubMeshesAsTexturesDirty;
  133281. /** @hidden */
  133282. _markAllSubMeshesAsTexturesDirty(): void;
  133283. /**
  133284. * Instantiate a new istance of clear coat configuration.
  133285. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133286. */
  133287. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  133288. /**
  133289. * Gets wehter the submesh is ready to be used or not.
  133290. * @param defines the list of "defines" to update.
  133291. * @param scene defines the scene the material belongs to.
  133292. * @param engine defines the engine the material belongs to.
  133293. * @param disableBumpMap defines wether the material disables bump or not.
  133294. * @returns - boolean indicating that the submesh is ready or not.
  133295. */
  133296. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  133297. /**
  133298. * Checks to see if a texture is used in the material.
  133299. * @param defines the list of "defines" to update.
  133300. * @param scene defines the scene to the material belongs to.
  133301. */
  133302. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  133303. /**
  133304. * Binds the material data.
  133305. * @param uniformBuffer defines the Uniform buffer to fill in.
  133306. * @param scene defines the scene the material belongs to.
  133307. * @param engine defines the engine the material belongs to.
  133308. * @param disableBumpMap defines wether the material disables bump or not.
  133309. * @param isFrozen defines wether the material is frozen or not.
  133310. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  133311. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  133312. */
  133313. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  133314. /**
  133315. * Checks to see if a texture is used in the material.
  133316. * @param texture - Base texture to use.
  133317. * @returns - Boolean specifying if a texture is used in the material.
  133318. */
  133319. hasTexture(texture: BaseTexture): boolean;
  133320. /**
  133321. * Returns an array of the actively used textures.
  133322. * @param activeTextures Array of BaseTextures
  133323. */
  133324. getActiveTextures(activeTextures: BaseTexture[]): void;
  133325. /**
  133326. * Returns the animatable textures.
  133327. * @param animatables Array of animatable textures.
  133328. */
  133329. getAnimatables(animatables: IAnimatable[]): void;
  133330. /**
  133331. * Disposes the resources of the material.
  133332. * @param forceDisposeTextures - Forces the disposal of all textures.
  133333. */
  133334. dispose(forceDisposeTextures?: boolean): void;
  133335. /**
  133336. * Get the current class name of the texture useful for serialization or dynamic coding.
  133337. * @returns "PBRClearCoatConfiguration"
  133338. */
  133339. getClassName(): string;
  133340. /**
  133341. * Add fallbacks to the effect fallbacks list.
  133342. * @param defines defines the Base texture to use.
  133343. * @param fallbacks defines the current fallback list.
  133344. * @param currentRank defines the current fallback rank.
  133345. * @returns the new fallback rank.
  133346. */
  133347. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133348. /**
  133349. * Add the required uniforms to the current list.
  133350. * @param uniforms defines the current uniform list.
  133351. */
  133352. static AddUniforms(uniforms: string[]): void;
  133353. /**
  133354. * Add the required samplers to the current list.
  133355. * @param samplers defines the current sampler list.
  133356. */
  133357. static AddSamplers(samplers: string[]): void;
  133358. /**
  133359. * Add the required uniforms to the current buffer.
  133360. * @param uniformBuffer defines the current uniform buffer.
  133361. */
  133362. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133363. /**
  133364. * Makes a duplicate of the current configuration into another one.
  133365. * @param clearCoatConfiguration define the config where to copy the info
  133366. */
  133367. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  133368. /**
  133369. * Serializes this clear coat configuration.
  133370. * @returns - An object with the serialized config.
  133371. */
  133372. serialize(): any;
  133373. /**
  133374. * Parses a anisotropy Configuration from a serialized object.
  133375. * @param source - Serialized object.
  133376. * @param scene Defines the scene we are parsing for
  133377. * @param rootUrl Defines the rootUrl to load from
  133378. */
  133379. parse(source: any, scene: Scene, rootUrl: string): void;
  133380. }
  133381. }
  133382. declare module BABYLON {
  133383. /**
  133384. * @hidden
  133385. */
  133386. export interface IMaterialAnisotropicDefines {
  133387. ANISOTROPIC: boolean;
  133388. ANISOTROPIC_TEXTURE: boolean;
  133389. ANISOTROPIC_TEXTUREDIRECTUV: number;
  133390. MAINUV1: boolean;
  133391. _areTexturesDirty: boolean;
  133392. _needUVs: boolean;
  133393. }
  133394. /**
  133395. * Define the code related to the anisotropic parameters of the pbr material.
  133396. */
  133397. export class PBRAnisotropicConfiguration {
  133398. private _isEnabled;
  133399. /**
  133400. * Defines if the anisotropy is enabled in the material.
  133401. */
  133402. isEnabled: boolean;
  133403. /**
  133404. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  133405. */
  133406. intensity: number;
  133407. /**
  133408. * Defines if the effect is along the tangents, bitangents or in between.
  133409. * By default, the effect is "strectching" the highlights along the tangents.
  133410. */
  133411. direction: Vector2;
  133412. private _texture;
  133413. /**
  133414. * Stores the anisotropy values in a texture.
  133415. * rg is direction (like normal from -1 to 1)
  133416. * b is a intensity
  133417. */
  133418. texture: Nullable<BaseTexture>;
  133419. /** @hidden */
  133420. private _internalMarkAllSubMeshesAsTexturesDirty;
  133421. /** @hidden */
  133422. _markAllSubMeshesAsTexturesDirty(): void;
  133423. /**
  133424. * Instantiate a new istance of anisotropy configuration.
  133425. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133426. */
  133427. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  133428. /**
  133429. * Specifies that the submesh is ready to be used.
  133430. * @param defines the list of "defines" to update.
  133431. * @param scene defines the scene the material belongs to.
  133432. * @returns - boolean indicating that the submesh is ready or not.
  133433. */
  133434. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  133435. /**
  133436. * Checks to see if a texture is used in the material.
  133437. * @param defines the list of "defines" to update.
  133438. * @param mesh the mesh we are preparing the defines for.
  133439. * @param scene defines the scene the material belongs to.
  133440. */
  133441. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  133442. /**
  133443. * Binds the material data.
  133444. * @param uniformBuffer defines the Uniform buffer to fill in.
  133445. * @param scene defines the scene the material belongs to.
  133446. * @param isFrozen defines wether the material is frozen or not.
  133447. */
  133448. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  133449. /**
  133450. * Checks to see if a texture is used in the material.
  133451. * @param texture - Base texture to use.
  133452. * @returns - Boolean specifying if a texture is used in the material.
  133453. */
  133454. hasTexture(texture: BaseTexture): boolean;
  133455. /**
  133456. * Returns an array of the actively used textures.
  133457. * @param activeTextures Array of BaseTextures
  133458. */
  133459. getActiveTextures(activeTextures: BaseTexture[]): void;
  133460. /**
  133461. * Returns the animatable textures.
  133462. * @param animatables Array of animatable textures.
  133463. */
  133464. getAnimatables(animatables: IAnimatable[]): void;
  133465. /**
  133466. * Disposes the resources of the material.
  133467. * @param forceDisposeTextures - Forces the disposal of all textures.
  133468. */
  133469. dispose(forceDisposeTextures?: boolean): void;
  133470. /**
  133471. * Get the current class name of the texture useful for serialization or dynamic coding.
  133472. * @returns "PBRAnisotropicConfiguration"
  133473. */
  133474. getClassName(): string;
  133475. /**
  133476. * Add fallbacks to the effect fallbacks list.
  133477. * @param defines defines the Base texture to use.
  133478. * @param fallbacks defines the current fallback list.
  133479. * @param currentRank defines the current fallback rank.
  133480. * @returns the new fallback rank.
  133481. */
  133482. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133483. /**
  133484. * Add the required uniforms to the current list.
  133485. * @param uniforms defines the current uniform list.
  133486. */
  133487. static AddUniforms(uniforms: string[]): void;
  133488. /**
  133489. * Add the required uniforms to the current buffer.
  133490. * @param uniformBuffer defines the current uniform buffer.
  133491. */
  133492. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133493. /**
  133494. * Add the required samplers to the current list.
  133495. * @param samplers defines the current sampler list.
  133496. */
  133497. static AddSamplers(samplers: string[]): void;
  133498. /**
  133499. * Makes a duplicate of the current configuration into another one.
  133500. * @param anisotropicConfiguration define the config where to copy the info
  133501. */
  133502. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  133503. /**
  133504. * Serializes this anisotropy configuration.
  133505. * @returns - An object with the serialized config.
  133506. */
  133507. serialize(): any;
  133508. /**
  133509. * Parses a anisotropy Configuration from a serialized object.
  133510. * @param source - Serialized object.
  133511. * @param scene Defines the scene we are parsing for
  133512. * @param rootUrl Defines the rootUrl to load from
  133513. */
  133514. parse(source: any, scene: Scene, rootUrl: string): void;
  133515. }
  133516. }
  133517. declare module BABYLON {
  133518. /**
  133519. * @hidden
  133520. */
  133521. export interface IMaterialBRDFDefines {
  133522. BRDF_V_HEIGHT_CORRELATED: boolean;
  133523. MS_BRDF_ENERGY_CONSERVATION: boolean;
  133524. SPHERICAL_HARMONICS: boolean;
  133525. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  133526. /** @hidden */
  133527. _areMiscDirty: boolean;
  133528. }
  133529. /**
  133530. * Define the code related to the BRDF parameters of the pbr material.
  133531. */
  133532. export class PBRBRDFConfiguration {
  133533. /**
  133534. * Default value used for the energy conservation.
  133535. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  133536. */
  133537. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  133538. /**
  133539. * Default value used for the Smith Visibility Height Correlated mode.
  133540. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  133541. */
  133542. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  133543. /**
  133544. * Default value used for the IBL diffuse part.
  133545. * This can help switching back to the polynomials mode globally which is a tiny bit
  133546. * less GPU intensive at the drawback of a lower quality.
  133547. */
  133548. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  133549. /**
  133550. * Default value used for activating energy conservation for the specular workflow.
  133551. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  133552. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  133553. */
  133554. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  133555. private _useEnergyConservation;
  133556. /**
  133557. * Defines if the material uses energy conservation.
  133558. */
  133559. useEnergyConservation: boolean;
  133560. private _useSmithVisibilityHeightCorrelated;
  133561. /**
  133562. * LEGACY Mode set to false
  133563. * Defines if the material uses height smith correlated visibility term.
  133564. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  133565. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  133566. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  133567. * Not relying on height correlated will also disable energy conservation.
  133568. */
  133569. useSmithVisibilityHeightCorrelated: boolean;
  133570. private _useSphericalHarmonics;
  133571. /**
  133572. * LEGACY Mode set to false
  133573. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  133574. * diffuse part of the IBL.
  133575. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  133576. * to the ground truth.
  133577. */
  133578. useSphericalHarmonics: boolean;
  133579. private _useSpecularGlossinessInputEnergyConservation;
  133580. /**
  133581. * Defines if the material uses energy conservation, when the specular workflow is active.
  133582. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  133583. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  133584. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  133585. */
  133586. useSpecularGlossinessInputEnergyConservation: boolean;
  133587. /** @hidden */
  133588. private _internalMarkAllSubMeshesAsMiscDirty;
  133589. /** @hidden */
  133590. _markAllSubMeshesAsMiscDirty(): void;
  133591. /**
  133592. * Instantiate a new istance of clear coat configuration.
  133593. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  133594. */
  133595. constructor(markAllSubMeshesAsMiscDirty: () => void);
  133596. /**
  133597. * Checks to see if a texture is used in the material.
  133598. * @param defines the list of "defines" to update.
  133599. */
  133600. prepareDefines(defines: IMaterialBRDFDefines): void;
  133601. /**
  133602. * Get the current class name of the texture useful for serialization or dynamic coding.
  133603. * @returns "PBRClearCoatConfiguration"
  133604. */
  133605. getClassName(): string;
  133606. /**
  133607. * Makes a duplicate of the current configuration into another one.
  133608. * @param brdfConfiguration define the config where to copy the info
  133609. */
  133610. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  133611. /**
  133612. * Serializes this BRDF configuration.
  133613. * @returns - An object with the serialized config.
  133614. */
  133615. serialize(): any;
  133616. /**
  133617. * Parses a anisotropy Configuration from a serialized object.
  133618. * @param source - Serialized object.
  133619. * @param scene Defines the scene we are parsing for
  133620. * @param rootUrl Defines the rootUrl to load from
  133621. */
  133622. parse(source: any, scene: Scene, rootUrl: string): void;
  133623. }
  133624. }
  133625. declare module BABYLON {
  133626. /**
  133627. * @hidden
  133628. */
  133629. export interface IMaterialSheenDefines {
  133630. SHEEN: boolean;
  133631. SHEEN_TEXTURE: boolean;
  133632. SHEEN_TEXTUREDIRECTUV: number;
  133633. SHEEN_LINKWITHALBEDO: boolean;
  133634. SHEEN_ROUGHNESS: boolean;
  133635. SHEEN_ALBEDOSCALING: boolean;
  133636. /** @hidden */
  133637. _areTexturesDirty: boolean;
  133638. }
  133639. /**
  133640. * Define the code related to the Sheen parameters of the pbr material.
  133641. */
  133642. export class PBRSheenConfiguration {
  133643. private _isEnabled;
  133644. /**
  133645. * Defines if the material uses sheen.
  133646. */
  133647. isEnabled: boolean;
  133648. private _linkSheenWithAlbedo;
  133649. /**
  133650. * Defines if the sheen is linked to the sheen color.
  133651. */
  133652. linkSheenWithAlbedo: boolean;
  133653. /**
  133654. * Defines the sheen intensity.
  133655. */
  133656. intensity: number;
  133657. /**
  133658. * Defines the sheen color.
  133659. */
  133660. color: Color3;
  133661. private _texture;
  133662. /**
  133663. * Stores the sheen tint values in a texture.
  133664. * rgb is tint
  133665. * a is a intensity or roughness if roughness has been defined
  133666. */
  133667. texture: Nullable<BaseTexture>;
  133668. private _roughness;
  133669. /**
  133670. * Defines the sheen roughness.
  133671. * It is not taken into account if linkSheenWithAlbedo is true.
  133672. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  133673. */
  133674. roughness: Nullable<number>;
  133675. private _albedoScaling;
  133676. /**
  133677. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  133678. * It allows the strength of the sheen effect to not depend on the base color of the material,
  133679. * making it easier to setup and tweak the effect
  133680. */
  133681. albedoScaling: boolean;
  133682. /** @hidden */
  133683. private _internalMarkAllSubMeshesAsTexturesDirty;
  133684. /** @hidden */
  133685. _markAllSubMeshesAsTexturesDirty(): void;
  133686. /**
  133687. * Instantiate a new istance of clear coat configuration.
  133688. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133689. */
  133690. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  133691. /**
  133692. * Specifies that the submesh is ready to be used.
  133693. * @param defines the list of "defines" to update.
  133694. * @param scene defines the scene the material belongs to.
  133695. * @returns - boolean indicating that the submesh is ready or not.
  133696. */
  133697. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  133698. /**
  133699. * Checks to see if a texture is used in the material.
  133700. * @param defines the list of "defines" to update.
  133701. * @param scene defines the scene the material belongs to.
  133702. */
  133703. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  133704. /**
  133705. * Binds the material data.
  133706. * @param uniformBuffer defines the Uniform buffer to fill in.
  133707. * @param scene defines the scene the material belongs to.
  133708. * @param isFrozen defines wether the material is frozen or not.
  133709. */
  133710. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  133711. /**
  133712. * Checks to see if a texture is used in the material.
  133713. * @param texture - Base texture to use.
  133714. * @returns - Boolean specifying if a texture is used in the material.
  133715. */
  133716. hasTexture(texture: BaseTexture): boolean;
  133717. /**
  133718. * Returns an array of the actively used textures.
  133719. * @param activeTextures Array of BaseTextures
  133720. */
  133721. getActiveTextures(activeTextures: BaseTexture[]): void;
  133722. /**
  133723. * Returns the animatable textures.
  133724. * @param animatables Array of animatable textures.
  133725. */
  133726. getAnimatables(animatables: IAnimatable[]): void;
  133727. /**
  133728. * Disposes the resources of the material.
  133729. * @param forceDisposeTextures - Forces the disposal of all textures.
  133730. */
  133731. dispose(forceDisposeTextures?: boolean): void;
  133732. /**
  133733. * Get the current class name of the texture useful for serialization or dynamic coding.
  133734. * @returns "PBRSheenConfiguration"
  133735. */
  133736. getClassName(): string;
  133737. /**
  133738. * Add fallbacks to the effect fallbacks list.
  133739. * @param defines defines the Base texture to use.
  133740. * @param fallbacks defines the current fallback list.
  133741. * @param currentRank defines the current fallback rank.
  133742. * @returns the new fallback rank.
  133743. */
  133744. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133745. /**
  133746. * Add the required uniforms to the current list.
  133747. * @param uniforms defines the current uniform list.
  133748. */
  133749. static AddUniforms(uniforms: string[]): void;
  133750. /**
  133751. * Add the required uniforms to the current buffer.
  133752. * @param uniformBuffer defines the current uniform buffer.
  133753. */
  133754. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133755. /**
  133756. * Add the required samplers to the current list.
  133757. * @param samplers defines the current sampler list.
  133758. */
  133759. static AddSamplers(samplers: string[]): void;
  133760. /**
  133761. * Makes a duplicate of the current configuration into another one.
  133762. * @param sheenConfiguration define the config where to copy the info
  133763. */
  133764. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  133765. /**
  133766. * Serializes this BRDF configuration.
  133767. * @returns - An object with the serialized config.
  133768. */
  133769. serialize(): any;
  133770. /**
  133771. * Parses a anisotropy Configuration from a serialized object.
  133772. * @param source - Serialized object.
  133773. * @param scene Defines the scene we are parsing for
  133774. * @param rootUrl Defines the rootUrl to load from
  133775. */
  133776. parse(source: any, scene: Scene, rootUrl: string): void;
  133777. }
  133778. }
  133779. declare module BABYLON {
  133780. /**
  133781. * @hidden
  133782. */
  133783. export interface IMaterialSubSurfaceDefines {
  133784. SUBSURFACE: boolean;
  133785. SS_REFRACTION: boolean;
  133786. SS_TRANSLUCENCY: boolean;
  133787. SS_SCATTERING: boolean;
  133788. SS_THICKNESSANDMASK_TEXTURE: boolean;
  133789. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  133790. SS_REFRACTIONMAP_3D: boolean;
  133791. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  133792. SS_LODINREFRACTIONALPHA: boolean;
  133793. SS_GAMMAREFRACTION: boolean;
  133794. SS_RGBDREFRACTION: boolean;
  133795. SS_LINEARSPECULARREFRACTION: boolean;
  133796. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  133797. SS_ALBEDOFORREFRACTIONTINT: boolean;
  133798. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  133799. /** @hidden */
  133800. _areTexturesDirty: boolean;
  133801. }
  133802. /**
  133803. * Define the code related to the sub surface parameters of the pbr material.
  133804. */
  133805. export class PBRSubSurfaceConfiguration {
  133806. private _isRefractionEnabled;
  133807. /**
  133808. * Defines if the refraction is enabled in the material.
  133809. */
  133810. isRefractionEnabled: boolean;
  133811. private _isTranslucencyEnabled;
  133812. /**
  133813. * Defines if the translucency is enabled in the material.
  133814. */
  133815. isTranslucencyEnabled: boolean;
  133816. private _isScatteringEnabled;
  133817. /**
  133818. * Defines if the sub surface scattering is enabled in the material.
  133819. */
  133820. isScatteringEnabled: boolean;
  133821. private _scatteringDiffusionProfileIndex;
  133822. /**
  133823. * Diffusion profile for subsurface scattering.
  133824. * Useful for better scattering in the skins or foliages.
  133825. */
  133826. get scatteringDiffusionProfile(): Nullable<Color3>;
  133827. set scatteringDiffusionProfile(c: Nullable<Color3>);
  133828. /**
  133829. * Defines the refraction intensity of the material.
  133830. * The refraction when enabled replaces the Diffuse part of the material.
  133831. * The intensity helps transitionning between diffuse and refraction.
  133832. */
  133833. refractionIntensity: number;
  133834. /**
  133835. * Defines the translucency intensity of the material.
  133836. * When translucency has been enabled, this defines how much of the "translucency"
  133837. * is addded to the diffuse part of the material.
  133838. */
  133839. translucencyIntensity: number;
  133840. /**
  133841. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  133842. */
  133843. useAlbedoToTintRefraction: boolean;
  133844. private _thicknessTexture;
  133845. /**
  133846. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  133847. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  133848. * 0 would mean minimumThickness
  133849. * 1 would mean maximumThickness
  133850. * The other channels might be use as a mask to vary the different effects intensity.
  133851. */
  133852. thicknessTexture: Nullable<BaseTexture>;
  133853. private _refractionTexture;
  133854. /**
  133855. * Defines the texture to use for refraction.
  133856. */
  133857. refractionTexture: Nullable<BaseTexture>;
  133858. private _indexOfRefraction;
  133859. /**
  133860. * Index of refraction of the material base layer.
  133861. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  133862. *
  133863. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  133864. *
  133865. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  133866. */
  133867. indexOfRefraction: number;
  133868. private _volumeIndexOfRefraction;
  133869. /**
  133870. * Index of refraction of the material's volume.
  133871. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  133872. *
  133873. * This ONLY impacts refraction. If not provided or given a non-valid value,
  133874. * the volume will use the same IOR as the surface.
  133875. */
  133876. get volumeIndexOfRefraction(): number;
  133877. set volumeIndexOfRefraction(value: number);
  133878. private _invertRefractionY;
  133879. /**
  133880. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  133881. */
  133882. invertRefractionY: boolean;
  133883. private _linkRefractionWithTransparency;
  133884. /**
  133885. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  133886. * Materials half opaque for instance using refraction could benefit from this control.
  133887. */
  133888. linkRefractionWithTransparency: boolean;
  133889. /**
  133890. * Defines the minimum thickness stored in the thickness map.
  133891. * If no thickness map is defined, this value will be used to simulate thickness.
  133892. */
  133893. minimumThickness: number;
  133894. /**
  133895. * Defines the maximum thickness stored in the thickness map.
  133896. */
  133897. maximumThickness: number;
  133898. /**
  133899. * Defines the volume tint of the material.
  133900. * This is used for both translucency and scattering.
  133901. */
  133902. tintColor: Color3;
  133903. /**
  133904. * Defines the distance at which the tint color should be found in the media.
  133905. * This is used for refraction only.
  133906. */
  133907. tintColorAtDistance: number;
  133908. /**
  133909. * Defines how far each channel transmit through the media.
  133910. * It is defined as a color to simplify it selection.
  133911. */
  133912. diffusionDistance: Color3;
  133913. private _useMaskFromThicknessTexture;
  133914. /**
  133915. * Stores the intensity of the different subsurface effects in the thickness texture.
  133916. * * the green channel is the translucency intensity.
  133917. * * the blue channel is the scattering intensity.
  133918. * * the alpha channel is the refraction intensity.
  133919. */
  133920. useMaskFromThicknessTexture: boolean;
  133921. private _scene;
  133922. /** @hidden */
  133923. private _internalMarkAllSubMeshesAsTexturesDirty;
  133924. private _internalMarkScenePrePassDirty;
  133925. /** @hidden */
  133926. _markAllSubMeshesAsTexturesDirty(): void;
  133927. /** @hidden */
  133928. _markScenePrePassDirty(): void;
  133929. /**
  133930. * Instantiate a new istance of sub surface configuration.
  133931. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133932. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  133933. * @param scene The scene
  133934. */
  133935. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  133936. /**
  133937. * Gets wehter the submesh is ready to be used or not.
  133938. * @param defines the list of "defines" to update.
  133939. * @param scene defines the scene the material belongs to.
  133940. * @returns - boolean indicating that the submesh is ready or not.
  133941. */
  133942. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  133943. /**
  133944. * Checks to see if a texture is used in the material.
  133945. * @param defines the list of "defines" to update.
  133946. * @param scene defines the scene to the material belongs to.
  133947. */
  133948. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  133949. /**
  133950. * Binds the material data.
  133951. * @param uniformBuffer defines the Uniform buffer to fill in.
  133952. * @param scene defines the scene the material belongs to.
  133953. * @param engine defines the engine the material belongs to.
  133954. * @param isFrozen defines whether the material is frozen or not.
  133955. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  133956. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  133957. */
  133958. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  133959. /**
  133960. * Unbinds the material from the mesh.
  133961. * @param activeEffect defines the effect that should be unbound from.
  133962. * @returns true if unbound, otherwise false
  133963. */
  133964. unbind(activeEffect: Effect): boolean;
  133965. /**
  133966. * Returns the texture used for refraction or null if none is used.
  133967. * @param scene defines the scene the material belongs to.
  133968. * @returns - Refraction texture if present. If no refraction texture and refraction
  133969. * is linked with transparency, returns environment texture. Otherwise, returns null.
  133970. */
  133971. private _getRefractionTexture;
  133972. /**
  133973. * Returns true if alpha blending should be disabled.
  133974. */
  133975. get disableAlphaBlending(): boolean;
  133976. /**
  133977. * Fills the list of render target textures.
  133978. * @param renderTargets the list of render targets to update
  133979. */
  133980. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  133981. /**
  133982. * Checks to see if a texture is used in the material.
  133983. * @param texture - Base texture to use.
  133984. * @returns - Boolean specifying if a texture is used in the material.
  133985. */
  133986. hasTexture(texture: BaseTexture): boolean;
  133987. /**
  133988. * Gets a boolean indicating that current material needs to register RTT
  133989. * @returns true if this uses a render target otherwise false.
  133990. */
  133991. hasRenderTargetTextures(): boolean;
  133992. /**
  133993. * Returns an array of the actively used textures.
  133994. * @param activeTextures Array of BaseTextures
  133995. */
  133996. getActiveTextures(activeTextures: BaseTexture[]): void;
  133997. /**
  133998. * Returns the animatable textures.
  133999. * @param animatables Array of animatable textures.
  134000. */
  134001. getAnimatables(animatables: IAnimatable[]): void;
  134002. /**
  134003. * Disposes the resources of the material.
  134004. * @param forceDisposeTextures - Forces the disposal of all textures.
  134005. */
  134006. dispose(forceDisposeTextures?: boolean): void;
  134007. /**
  134008. * Get the current class name of the texture useful for serialization or dynamic coding.
  134009. * @returns "PBRSubSurfaceConfiguration"
  134010. */
  134011. getClassName(): string;
  134012. /**
  134013. * Add fallbacks to the effect fallbacks list.
  134014. * @param defines defines the Base texture to use.
  134015. * @param fallbacks defines the current fallback list.
  134016. * @param currentRank defines the current fallback rank.
  134017. * @returns the new fallback rank.
  134018. */
  134019. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134020. /**
  134021. * Add the required uniforms to the current list.
  134022. * @param uniforms defines the current uniform list.
  134023. */
  134024. static AddUniforms(uniforms: string[]): void;
  134025. /**
  134026. * Add the required samplers to the current list.
  134027. * @param samplers defines the current sampler list.
  134028. */
  134029. static AddSamplers(samplers: string[]): void;
  134030. /**
  134031. * Add the required uniforms to the current buffer.
  134032. * @param uniformBuffer defines the current uniform buffer.
  134033. */
  134034. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134035. /**
  134036. * Makes a duplicate of the current configuration into another one.
  134037. * @param configuration define the config where to copy the info
  134038. */
  134039. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  134040. /**
  134041. * Serializes this Sub Surface configuration.
  134042. * @returns - An object with the serialized config.
  134043. */
  134044. serialize(): any;
  134045. /**
  134046. * Parses a anisotropy Configuration from a serialized object.
  134047. * @param source - Serialized object.
  134048. * @param scene Defines the scene we are parsing for
  134049. * @param rootUrl Defines the rootUrl to load from
  134050. */
  134051. parse(source: any, scene: Scene, rootUrl: string): void;
  134052. }
  134053. }
  134054. declare module BABYLON {
  134055. /** @hidden */
  134056. export var pbrFragmentDeclaration: {
  134057. name: string;
  134058. shader: string;
  134059. };
  134060. }
  134061. declare module BABYLON {
  134062. /** @hidden */
  134063. export var pbrUboDeclaration: {
  134064. name: string;
  134065. shader: string;
  134066. };
  134067. }
  134068. declare module BABYLON {
  134069. /** @hidden */
  134070. export var pbrFragmentExtraDeclaration: {
  134071. name: string;
  134072. shader: string;
  134073. };
  134074. }
  134075. declare module BABYLON {
  134076. /** @hidden */
  134077. export var pbrFragmentSamplersDeclaration: {
  134078. name: string;
  134079. shader: string;
  134080. };
  134081. }
  134082. declare module BABYLON {
  134083. /** @hidden */
  134084. export var importanceSampling: {
  134085. name: string;
  134086. shader: string;
  134087. };
  134088. }
  134089. declare module BABYLON {
  134090. /** @hidden */
  134091. export var pbrHelperFunctions: {
  134092. name: string;
  134093. shader: string;
  134094. };
  134095. }
  134096. declare module BABYLON {
  134097. /** @hidden */
  134098. export var harmonicsFunctions: {
  134099. name: string;
  134100. shader: string;
  134101. };
  134102. }
  134103. declare module BABYLON {
  134104. /** @hidden */
  134105. export var pbrDirectLightingSetupFunctions: {
  134106. name: string;
  134107. shader: string;
  134108. };
  134109. }
  134110. declare module BABYLON {
  134111. /** @hidden */
  134112. export var pbrDirectLightingFalloffFunctions: {
  134113. name: string;
  134114. shader: string;
  134115. };
  134116. }
  134117. declare module BABYLON {
  134118. /** @hidden */
  134119. export var pbrBRDFFunctions: {
  134120. name: string;
  134121. shader: string;
  134122. };
  134123. }
  134124. declare module BABYLON {
  134125. /** @hidden */
  134126. export var hdrFilteringFunctions: {
  134127. name: string;
  134128. shader: string;
  134129. };
  134130. }
  134131. declare module BABYLON {
  134132. /** @hidden */
  134133. export var pbrDirectLightingFunctions: {
  134134. name: string;
  134135. shader: string;
  134136. };
  134137. }
  134138. declare module BABYLON {
  134139. /** @hidden */
  134140. export var pbrIBLFunctions: {
  134141. name: string;
  134142. shader: string;
  134143. };
  134144. }
  134145. declare module BABYLON {
  134146. /** @hidden */
  134147. export var pbrBlockAlbedoOpacity: {
  134148. name: string;
  134149. shader: string;
  134150. };
  134151. }
  134152. declare module BABYLON {
  134153. /** @hidden */
  134154. export var pbrBlockReflectivity: {
  134155. name: string;
  134156. shader: string;
  134157. };
  134158. }
  134159. declare module BABYLON {
  134160. /** @hidden */
  134161. export var pbrBlockAmbientOcclusion: {
  134162. name: string;
  134163. shader: string;
  134164. };
  134165. }
  134166. declare module BABYLON {
  134167. /** @hidden */
  134168. export var pbrBlockAlphaFresnel: {
  134169. name: string;
  134170. shader: string;
  134171. };
  134172. }
  134173. declare module BABYLON {
  134174. /** @hidden */
  134175. export var pbrBlockAnisotropic: {
  134176. name: string;
  134177. shader: string;
  134178. };
  134179. }
  134180. declare module BABYLON {
  134181. /** @hidden */
  134182. export var pbrBlockReflection: {
  134183. name: string;
  134184. shader: string;
  134185. };
  134186. }
  134187. declare module BABYLON {
  134188. /** @hidden */
  134189. export var pbrBlockSheen: {
  134190. name: string;
  134191. shader: string;
  134192. };
  134193. }
  134194. declare module BABYLON {
  134195. /** @hidden */
  134196. export var pbrBlockClearcoat: {
  134197. name: string;
  134198. shader: string;
  134199. };
  134200. }
  134201. declare module BABYLON {
  134202. /** @hidden */
  134203. export var pbrBlockSubSurface: {
  134204. name: string;
  134205. shader: string;
  134206. };
  134207. }
  134208. declare module BABYLON {
  134209. /** @hidden */
  134210. export var pbrBlockNormalGeometric: {
  134211. name: string;
  134212. shader: string;
  134213. };
  134214. }
  134215. declare module BABYLON {
  134216. /** @hidden */
  134217. export var pbrBlockNormalFinal: {
  134218. name: string;
  134219. shader: string;
  134220. };
  134221. }
  134222. declare module BABYLON {
  134223. /** @hidden */
  134224. export var pbrBlockLightmapInit: {
  134225. name: string;
  134226. shader: string;
  134227. };
  134228. }
  134229. declare module BABYLON {
  134230. /** @hidden */
  134231. export var pbrBlockGeometryInfo: {
  134232. name: string;
  134233. shader: string;
  134234. };
  134235. }
  134236. declare module BABYLON {
  134237. /** @hidden */
  134238. export var pbrBlockReflectance0: {
  134239. name: string;
  134240. shader: string;
  134241. };
  134242. }
  134243. declare module BABYLON {
  134244. /** @hidden */
  134245. export var pbrBlockReflectance: {
  134246. name: string;
  134247. shader: string;
  134248. };
  134249. }
  134250. declare module BABYLON {
  134251. /** @hidden */
  134252. export var pbrBlockDirectLighting: {
  134253. name: string;
  134254. shader: string;
  134255. };
  134256. }
  134257. declare module BABYLON {
  134258. /** @hidden */
  134259. export var pbrBlockFinalLitComponents: {
  134260. name: string;
  134261. shader: string;
  134262. };
  134263. }
  134264. declare module BABYLON {
  134265. /** @hidden */
  134266. export var pbrBlockFinalUnlitComponents: {
  134267. name: string;
  134268. shader: string;
  134269. };
  134270. }
  134271. declare module BABYLON {
  134272. /** @hidden */
  134273. export var pbrBlockFinalColorComposition: {
  134274. name: string;
  134275. shader: string;
  134276. };
  134277. }
  134278. declare module BABYLON {
  134279. /** @hidden */
  134280. export var pbrBlockImageProcessing: {
  134281. name: string;
  134282. shader: string;
  134283. };
  134284. }
  134285. declare module BABYLON {
  134286. /** @hidden */
  134287. export var pbrDebug: {
  134288. name: string;
  134289. shader: string;
  134290. };
  134291. }
  134292. declare module BABYLON {
  134293. /** @hidden */
  134294. export var pbrPixelShader: {
  134295. name: string;
  134296. shader: string;
  134297. };
  134298. }
  134299. declare module BABYLON {
  134300. /** @hidden */
  134301. export var pbrVertexDeclaration: {
  134302. name: string;
  134303. shader: string;
  134304. };
  134305. }
  134306. declare module BABYLON {
  134307. /** @hidden */
  134308. export var pbrVertexShader: {
  134309. name: string;
  134310. shader: string;
  134311. };
  134312. }
  134313. declare module BABYLON {
  134314. /**
  134315. * Manages the defines for the PBR Material.
  134316. * @hidden
  134317. */
  134318. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  134319. PBR: boolean;
  134320. NUM_SAMPLES: string;
  134321. REALTIME_FILTERING: boolean;
  134322. MAINUV1: boolean;
  134323. MAINUV2: boolean;
  134324. UV1: boolean;
  134325. UV2: boolean;
  134326. ALBEDO: boolean;
  134327. GAMMAALBEDO: boolean;
  134328. ALBEDODIRECTUV: number;
  134329. VERTEXCOLOR: boolean;
  134330. DETAIL: boolean;
  134331. DETAILDIRECTUV: number;
  134332. DETAIL_NORMALBLENDMETHOD: number;
  134333. AMBIENT: boolean;
  134334. AMBIENTDIRECTUV: number;
  134335. AMBIENTINGRAYSCALE: boolean;
  134336. OPACITY: boolean;
  134337. VERTEXALPHA: boolean;
  134338. OPACITYDIRECTUV: number;
  134339. OPACITYRGB: boolean;
  134340. ALPHATEST: boolean;
  134341. DEPTHPREPASS: boolean;
  134342. ALPHABLEND: boolean;
  134343. ALPHAFROMALBEDO: boolean;
  134344. ALPHATESTVALUE: string;
  134345. SPECULAROVERALPHA: boolean;
  134346. RADIANCEOVERALPHA: boolean;
  134347. ALPHAFRESNEL: boolean;
  134348. LINEARALPHAFRESNEL: boolean;
  134349. PREMULTIPLYALPHA: boolean;
  134350. EMISSIVE: boolean;
  134351. EMISSIVEDIRECTUV: number;
  134352. REFLECTIVITY: boolean;
  134353. REFLECTIVITYDIRECTUV: number;
  134354. SPECULARTERM: boolean;
  134355. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  134356. MICROSURFACEAUTOMATIC: boolean;
  134357. LODBASEDMICROSFURACE: boolean;
  134358. MICROSURFACEMAP: boolean;
  134359. MICROSURFACEMAPDIRECTUV: number;
  134360. METALLICWORKFLOW: boolean;
  134361. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  134362. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  134363. METALLNESSSTOREINMETALMAPBLUE: boolean;
  134364. AOSTOREINMETALMAPRED: boolean;
  134365. METALLIC_REFLECTANCE: boolean;
  134366. METALLIC_REFLECTANCEDIRECTUV: number;
  134367. ENVIRONMENTBRDF: boolean;
  134368. ENVIRONMENTBRDF_RGBD: boolean;
  134369. NORMAL: boolean;
  134370. TANGENT: boolean;
  134371. BUMP: boolean;
  134372. BUMPDIRECTUV: number;
  134373. OBJECTSPACE_NORMALMAP: boolean;
  134374. PARALLAX: boolean;
  134375. PARALLAXOCCLUSION: boolean;
  134376. NORMALXYSCALE: boolean;
  134377. LIGHTMAP: boolean;
  134378. LIGHTMAPDIRECTUV: number;
  134379. USELIGHTMAPASSHADOWMAP: boolean;
  134380. GAMMALIGHTMAP: boolean;
  134381. RGBDLIGHTMAP: boolean;
  134382. REFLECTION: boolean;
  134383. REFLECTIONMAP_3D: boolean;
  134384. REFLECTIONMAP_SPHERICAL: boolean;
  134385. REFLECTIONMAP_PLANAR: boolean;
  134386. REFLECTIONMAP_CUBIC: boolean;
  134387. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  134388. REFLECTIONMAP_PROJECTION: boolean;
  134389. REFLECTIONMAP_SKYBOX: boolean;
  134390. REFLECTIONMAP_EXPLICIT: boolean;
  134391. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  134392. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  134393. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  134394. INVERTCUBICMAP: boolean;
  134395. USESPHERICALFROMREFLECTIONMAP: boolean;
  134396. USEIRRADIANCEMAP: boolean;
  134397. SPHERICAL_HARMONICS: boolean;
  134398. USESPHERICALINVERTEX: boolean;
  134399. REFLECTIONMAP_OPPOSITEZ: boolean;
  134400. LODINREFLECTIONALPHA: boolean;
  134401. GAMMAREFLECTION: boolean;
  134402. RGBDREFLECTION: boolean;
  134403. LINEARSPECULARREFLECTION: boolean;
  134404. RADIANCEOCCLUSION: boolean;
  134405. HORIZONOCCLUSION: boolean;
  134406. INSTANCES: boolean;
  134407. THIN_INSTANCES: boolean;
  134408. PREPASS: boolean;
  134409. SCENE_MRT_COUNT: number;
  134410. NUM_BONE_INFLUENCERS: number;
  134411. BonesPerMesh: number;
  134412. BONETEXTURE: boolean;
  134413. NONUNIFORMSCALING: boolean;
  134414. MORPHTARGETS: boolean;
  134415. MORPHTARGETS_NORMAL: boolean;
  134416. MORPHTARGETS_TANGENT: boolean;
  134417. MORPHTARGETS_UV: boolean;
  134418. NUM_MORPH_INFLUENCERS: number;
  134419. IMAGEPROCESSING: boolean;
  134420. VIGNETTE: boolean;
  134421. VIGNETTEBLENDMODEMULTIPLY: boolean;
  134422. VIGNETTEBLENDMODEOPAQUE: boolean;
  134423. TONEMAPPING: boolean;
  134424. TONEMAPPING_ACES: boolean;
  134425. CONTRAST: boolean;
  134426. COLORCURVES: boolean;
  134427. COLORGRADING: boolean;
  134428. COLORGRADING3D: boolean;
  134429. SAMPLER3DGREENDEPTH: boolean;
  134430. SAMPLER3DBGRMAP: boolean;
  134431. IMAGEPROCESSINGPOSTPROCESS: boolean;
  134432. EXPOSURE: boolean;
  134433. MULTIVIEW: boolean;
  134434. USEPHYSICALLIGHTFALLOFF: boolean;
  134435. USEGLTFLIGHTFALLOFF: boolean;
  134436. TWOSIDEDLIGHTING: boolean;
  134437. SHADOWFLOAT: boolean;
  134438. CLIPPLANE: boolean;
  134439. CLIPPLANE2: boolean;
  134440. CLIPPLANE3: boolean;
  134441. CLIPPLANE4: boolean;
  134442. CLIPPLANE5: boolean;
  134443. CLIPPLANE6: boolean;
  134444. POINTSIZE: boolean;
  134445. FOG: boolean;
  134446. LOGARITHMICDEPTH: boolean;
  134447. FORCENORMALFORWARD: boolean;
  134448. SPECULARAA: boolean;
  134449. CLEARCOAT: boolean;
  134450. CLEARCOAT_DEFAULTIOR: boolean;
  134451. CLEARCOAT_TEXTURE: boolean;
  134452. CLEARCOAT_TEXTUREDIRECTUV: number;
  134453. CLEARCOAT_BUMP: boolean;
  134454. CLEARCOAT_BUMPDIRECTUV: number;
  134455. CLEARCOAT_TINT: boolean;
  134456. CLEARCOAT_TINT_TEXTURE: boolean;
  134457. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  134458. ANISOTROPIC: boolean;
  134459. ANISOTROPIC_TEXTURE: boolean;
  134460. ANISOTROPIC_TEXTUREDIRECTUV: number;
  134461. BRDF_V_HEIGHT_CORRELATED: boolean;
  134462. MS_BRDF_ENERGY_CONSERVATION: boolean;
  134463. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  134464. SHEEN: boolean;
  134465. SHEEN_TEXTURE: boolean;
  134466. SHEEN_TEXTUREDIRECTUV: number;
  134467. SHEEN_LINKWITHALBEDO: boolean;
  134468. SHEEN_ROUGHNESS: boolean;
  134469. SHEEN_ALBEDOSCALING: boolean;
  134470. SUBSURFACE: boolean;
  134471. SS_REFRACTION: boolean;
  134472. SS_TRANSLUCENCY: boolean;
  134473. SS_SCATTERING: boolean;
  134474. SS_THICKNESSANDMASK_TEXTURE: boolean;
  134475. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  134476. SS_REFRACTIONMAP_3D: boolean;
  134477. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  134478. SS_LODINREFRACTIONALPHA: boolean;
  134479. SS_GAMMAREFRACTION: boolean;
  134480. SS_RGBDREFRACTION: boolean;
  134481. SS_LINEARSPECULARREFRACTION: boolean;
  134482. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  134483. SS_ALBEDOFORREFRACTIONTINT: boolean;
  134484. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  134485. UNLIT: boolean;
  134486. DEBUGMODE: number;
  134487. /**
  134488. * Initializes the PBR Material defines.
  134489. */
  134490. constructor();
  134491. /**
  134492. * Resets the PBR Material defines.
  134493. */
  134494. reset(): void;
  134495. }
  134496. /**
  134497. * The Physically based material base class of BJS.
  134498. *
  134499. * This offers the main features of a standard PBR material.
  134500. * For more information, please refer to the documentation :
  134501. * https://doc.babylonjs.com/how_to/physically_based_rendering
  134502. */
  134503. export abstract class PBRBaseMaterial extends PushMaterial {
  134504. /**
  134505. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  134506. */
  134507. static readonly PBRMATERIAL_OPAQUE: number;
  134508. /**
  134509. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  134510. */
  134511. static readonly PBRMATERIAL_ALPHATEST: number;
  134512. /**
  134513. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134514. */
  134515. static readonly PBRMATERIAL_ALPHABLEND: number;
  134516. /**
  134517. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134518. * They are also discarded below the alpha cutoff threshold to improve performances.
  134519. */
  134520. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  134521. /**
  134522. * Defines the default value of how much AO map is occluding the analytical lights
  134523. * (point spot...).
  134524. */
  134525. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  134526. /**
  134527. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  134528. */
  134529. static readonly LIGHTFALLOFF_PHYSICAL: number;
  134530. /**
  134531. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  134532. * to enhance interoperability with other engines.
  134533. */
  134534. static readonly LIGHTFALLOFF_GLTF: number;
  134535. /**
  134536. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  134537. * to enhance interoperability with other materials.
  134538. */
  134539. static readonly LIGHTFALLOFF_STANDARD: number;
  134540. /**
  134541. * Intensity of the direct lights e.g. the four lights available in your scene.
  134542. * This impacts both the direct diffuse and specular highlights.
  134543. */
  134544. protected _directIntensity: number;
  134545. /**
  134546. * Intensity of the emissive part of the material.
  134547. * This helps controlling the emissive effect without modifying the emissive color.
  134548. */
  134549. protected _emissiveIntensity: number;
  134550. /**
  134551. * Intensity of the environment e.g. how much the environment will light the object
  134552. * either through harmonics for rough material or through the refelction for shiny ones.
  134553. */
  134554. protected _environmentIntensity: number;
  134555. /**
  134556. * This is a special control allowing the reduction of the specular highlights coming from the
  134557. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  134558. */
  134559. protected _specularIntensity: number;
  134560. /**
  134561. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  134562. */
  134563. private _lightingInfos;
  134564. /**
  134565. * Debug Control allowing disabling the bump map on this material.
  134566. */
  134567. protected _disableBumpMap: boolean;
  134568. /**
  134569. * AKA Diffuse Texture in standard nomenclature.
  134570. */
  134571. protected _albedoTexture: Nullable<BaseTexture>;
  134572. /**
  134573. * AKA Occlusion Texture in other nomenclature.
  134574. */
  134575. protected _ambientTexture: Nullable<BaseTexture>;
  134576. /**
  134577. * AKA Occlusion Texture Intensity in other nomenclature.
  134578. */
  134579. protected _ambientTextureStrength: number;
  134580. /**
  134581. * Defines how much the AO map is occluding the analytical lights (point spot...).
  134582. * 1 means it completely occludes it
  134583. * 0 mean it has no impact
  134584. */
  134585. protected _ambientTextureImpactOnAnalyticalLights: number;
  134586. /**
  134587. * Stores the alpha values in a texture.
  134588. */
  134589. protected _opacityTexture: Nullable<BaseTexture>;
  134590. /**
  134591. * Stores the reflection values in a texture.
  134592. */
  134593. protected _reflectionTexture: Nullable<BaseTexture>;
  134594. /**
  134595. * Stores the emissive values in a texture.
  134596. */
  134597. protected _emissiveTexture: Nullable<BaseTexture>;
  134598. /**
  134599. * AKA Specular texture in other nomenclature.
  134600. */
  134601. protected _reflectivityTexture: Nullable<BaseTexture>;
  134602. /**
  134603. * Used to switch from specular/glossiness to metallic/roughness workflow.
  134604. */
  134605. protected _metallicTexture: Nullable<BaseTexture>;
  134606. /**
  134607. * Specifies the metallic scalar of the metallic/roughness workflow.
  134608. * Can also be used to scale the metalness values of the metallic texture.
  134609. */
  134610. protected _metallic: Nullable<number>;
  134611. /**
  134612. * Specifies the roughness scalar of the metallic/roughness workflow.
  134613. * Can also be used to scale the roughness values of the metallic texture.
  134614. */
  134615. protected _roughness: Nullable<number>;
  134616. /**
  134617. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  134618. * By default the indexOfrefraction is used to compute F0;
  134619. *
  134620. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  134621. *
  134622. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  134623. * F90 = metallicReflectanceColor;
  134624. */
  134625. protected _metallicF0Factor: number;
  134626. /**
  134627. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  134628. * By default the F90 is always 1;
  134629. *
  134630. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  134631. *
  134632. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  134633. * F90 = metallicReflectanceColor;
  134634. */
  134635. protected _metallicReflectanceColor: Color3;
  134636. /**
  134637. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  134638. * This is multiply against the scalar values defined in the material.
  134639. */
  134640. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  134641. /**
  134642. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  134643. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  134644. */
  134645. protected _microSurfaceTexture: Nullable<BaseTexture>;
  134646. /**
  134647. * Stores surface normal data used to displace a mesh in a texture.
  134648. */
  134649. protected _bumpTexture: Nullable<BaseTexture>;
  134650. /**
  134651. * Stores the pre-calculated light information of a mesh in a texture.
  134652. */
  134653. protected _lightmapTexture: Nullable<BaseTexture>;
  134654. /**
  134655. * The color of a material in ambient lighting.
  134656. */
  134657. protected _ambientColor: Color3;
  134658. /**
  134659. * AKA Diffuse Color in other nomenclature.
  134660. */
  134661. protected _albedoColor: Color3;
  134662. /**
  134663. * AKA Specular Color in other nomenclature.
  134664. */
  134665. protected _reflectivityColor: Color3;
  134666. /**
  134667. * The color applied when light is reflected from a material.
  134668. */
  134669. protected _reflectionColor: Color3;
  134670. /**
  134671. * The color applied when light is emitted from a material.
  134672. */
  134673. protected _emissiveColor: Color3;
  134674. /**
  134675. * AKA Glossiness in other nomenclature.
  134676. */
  134677. protected _microSurface: number;
  134678. /**
  134679. * Specifies that the material will use the light map as a show map.
  134680. */
  134681. protected _useLightmapAsShadowmap: boolean;
  134682. /**
  134683. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  134684. * makes the reflect vector face the model (under horizon).
  134685. */
  134686. protected _useHorizonOcclusion: boolean;
  134687. /**
  134688. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  134689. * too much the area relying on ambient texture to define their ambient occlusion.
  134690. */
  134691. protected _useRadianceOcclusion: boolean;
  134692. /**
  134693. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  134694. */
  134695. protected _useAlphaFromAlbedoTexture: boolean;
  134696. /**
  134697. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  134698. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  134699. */
  134700. protected _useSpecularOverAlpha: boolean;
  134701. /**
  134702. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  134703. */
  134704. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  134705. /**
  134706. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  134707. */
  134708. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  134709. /**
  134710. * Specifies if the metallic texture contains the roughness information in its green channel.
  134711. */
  134712. protected _useRoughnessFromMetallicTextureGreen: boolean;
  134713. /**
  134714. * Specifies if the metallic texture contains the metallness information in its blue channel.
  134715. */
  134716. protected _useMetallnessFromMetallicTextureBlue: boolean;
  134717. /**
  134718. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  134719. */
  134720. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  134721. /**
  134722. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  134723. */
  134724. protected _useAmbientInGrayScale: boolean;
  134725. /**
  134726. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  134727. * The material will try to infer what glossiness each pixel should be.
  134728. */
  134729. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  134730. /**
  134731. * Defines the falloff type used in this material.
  134732. * It by default is Physical.
  134733. */
  134734. protected _lightFalloff: number;
  134735. /**
  134736. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  134737. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  134738. */
  134739. protected _useRadianceOverAlpha: boolean;
  134740. /**
  134741. * Allows using an object space normal map (instead of tangent space).
  134742. */
  134743. protected _useObjectSpaceNormalMap: boolean;
  134744. /**
  134745. * Allows using the bump map in parallax mode.
  134746. */
  134747. protected _useParallax: boolean;
  134748. /**
  134749. * Allows using the bump map in parallax occlusion mode.
  134750. */
  134751. protected _useParallaxOcclusion: boolean;
  134752. /**
  134753. * Controls the scale bias of the parallax mode.
  134754. */
  134755. protected _parallaxScaleBias: number;
  134756. /**
  134757. * If sets to true, disables all the lights affecting the material.
  134758. */
  134759. protected _disableLighting: boolean;
  134760. /**
  134761. * Number of Simultaneous lights allowed on the material.
  134762. */
  134763. protected _maxSimultaneousLights: number;
  134764. /**
  134765. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  134766. */
  134767. protected _invertNormalMapX: boolean;
  134768. /**
  134769. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  134770. */
  134771. protected _invertNormalMapY: boolean;
  134772. /**
  134773. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  134774. */
  134775. protected _twoSidedLighting: boolean;
  134776. /**
  134777. * Defines the alpha limits in alpha test mode.
  134778. */
  134779. protected _alphaCutOff: number;
  134780. /**
  134781. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  134782. */
  134783. protected _forceAlphaTest: boolean;
  134784. /**
  134785. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134786. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  134787. */
  134788. protected _useAlphaFresnel: boolean;
  134789. /**
  134790. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134791. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  134792. */
  134793. protected _useLinearAlphaFresnel: boolean;
  134794. /**
  134795. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  134796. * from cos thetav and roughness:
  134797. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  134798. */
  134799. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  134800. /**
  134801. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  134802. */
  134803. protected _forceIrradianceInFragment: boolean;
  134804. private _realTimeFiltering;
  134805. /**
  134806. * Enables realtime filtering on the texture.
  134807. */
  134808. get realTimeFiltering(): boolean;
  134809. set realTimeFiltering(b: boolean);
  134810. private _realTimeFilteringQuality;
  134811. /**
  134812. * Quality switch for realtime filtering
  134813. */
  134814. get realTimeFilteringQuality(): number;
  134815. set realTimeFilteringQuality(n: number);
  134816. /**
  134817. * Can this material render to several textures at once
  134818. */
  134819. get canRenderToMRT(): boolean;
  134820. /**
  134821. * Force normal to face away from face.
  134822. */
  134823. protected _forceNormalForward: boolean;
  134824. /**
  134825. * Enables specular anti aliasing in the PBR shader.
  134826. * It will both interacts on the Geometry for analytical and IBL lighting.
  134827. * It also prefilter the roughness map based on the bump values.
  134828. */
  134829. protected _enableSpecularAntiAliasing: boolean;
  134830. /**
  134831. * Default configuration related to image processing available in the PBR Material.
  134832. */
  134833. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134834. /**
  134835. * Keep track of the image processing observer to allow dispose and replace.
  134836. */
  134837. private _imageProcessingObserver;
  134838. /**
  134839. * Attaches a new image processing configuration to the PBR Material.
  134840. * @param configuration
  134841. */
  134842. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134843. /**
  134844. * Stores the available render targets.
  134845. */
  134846. private _renderTargets;
  134847. /**
  134848. * Sets the global ambient color for the material used in lighting calculations.
  134849. */
  134850. private _globalAmbientColor;
  134851. /**
  134852. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  134853. */
  134854. private _useLogarithmicDepth;
  134855. /**
  134856. * If set to true, no lighting calculations will be applied.
  134857. */
  134858. private _unlit;
  134859. private _debugMode;
  134860. /**
  134861. * @hidden
  134862. * This is reserved for the inspector.
  134863. * Defines the material debug mode.
  134864. * It helps seeing only some components of the material while troubleshooting.
  134865. */
  134866. debugMode: number;
  134867. /**
  134868. * @hidden
  134869. * This is reserved for the inspector.
  134870. * Specify from where on screen the debug mode should start.
  134871. * The value goes from -1 (full screen) to 1 (not visible)
  134872. * It helps with side by side comparison against the final render
  134873. * This defaults to -1
  134874. */
  134875. private debugLimit;
  134876. /**
  134877. * @hidden
  134878. * This is reserved for the inspector.
  134879. * As the default viewing range might not be enough (if the ambient is really small for instance)
  134880. * You can use the factor to better multiply the final value.
  134881. */
  134882. private debugFactor;
  134883. /**
  134884. * Defines the clear coat layer parameters for the material.
  134885. */
  134886. readonly clearCoat: PBRClearCoatConfiguration;
  134887. /**
  134888. * Defines the anisotropic parameters for the material.
  134889. */
  134890. readonly anisotropy: PBRAnisotropicConfiguration;
  134891. /**
  134892. * Defines the BRDF parameters for the material.
  134893. */
  134894. readonly brdf: PBRBRDFConfiguration;
  134895. /**
  134896. * Defines the Sheen parameters for the material.
  134897. */
  134898. readonly sheen: PBRSheenConfiguration;
  134899. /**
  134900. * Defines the SubSurface parameters for the material.
  134901. */
  134902. readonly subSurface: PBRSubSurfaceConfiguration;
  134903. /**
  134904. * Defines the detail map parameters for the material.
  134905. */
  134906. readonly detailMap: DetailMapConfiguration;
  134907. protected _rebuildInParallel: boolean;
  134908. /**
  134909. * Instantiates a new PBRMaterial instance.
  134910. *
  134911. * @param name The material name
  134912. * @param scene The scene the material will be use in.
  134913. */
  134914. constructor(name: string, scene: Scene);
  134915. /**
  134916. * Gets a boolean indicating that current material needs to register RTT
  134917. */
  134918. get hasRenderTargetTextures(): boolean;
  134919. /**
  134920. * Gets the name of the material class.
  134921. */
  134922. getClassName(): string;
  134923. /**
  134924. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  134925. */
  134926. get useLogarithmicDepth(): boolean;
  134927. /**
  134928. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  134929. */
  134930. set useLogarithmicDepth(value: boolean);
  134931. /**
  134932. * Returns true if alpha blending should be disabled.
  134933. */
  134934. protected get _disableAlphaBlending(): boolean;
  134935. /**
  134936. * Specifies whether or not this material should be rendered in alpha blend mode.
  134937. */
  134938. needAlphaBlending(): boolean;
  134939. /**
  134940. * Specifies whether or not this material should be rendered in alpha test mode.
  134941. */
  134942. needAlphaTesting(): boolean;
  134943. /**
  134944. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  134945. */
  134946. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  134947. /**
  134948. * Gets the texture used for the alpha test.
  134949. */
  134950. getAlphaTestTexture(): Nullable<BaseTexture>;
  134951. /**
  134952. * Specifies that the submesh is ready to be used.
  134953. * @param mesh - BJS mesh.
  134954. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  134955. * @param useInstances - Specifies that instances should be used.
  134956. * @returns - boolean indicating that the submesh is ready or not.
  134957. */
  134958. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  134959. /**
  134960. * Specifies if the material uses metallic roughness workflow.
  134961. * @returns boolean specifiying if the material uses metallic roughness workflow.
  134962. */
  134963. isMetallicWorkflow(): boolean;
  134964. private _prepareEffect;
  134965. private _prepareDefines;
  134966. /**
  134967. * Force shader compilation
  134968. */
  134969. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  134970. /**
  134971. * Initializes the uniform buffer layout for the shader.
  134972. */
  134973. buildUniformLayout(): void;
  134974. /**
  134975. * Unbinds the material from the mesh
  134976. */
  134977. unbind(): void;
  134978. /**
  134979. * Binds the submesh data.
  134980. * @param world - The world matrix.
  134981. * @param mesh - The BJS mesh.
  134982. * @param subMesh - A submesh of the BJS mesh.
  134983. */
  134984. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134985. /**
  134986. * Returns the animatable textures.
  134987. * @returns - Array of animatable textures.
  134988. */
  134989. getAnimatables(): IAnimatable[];
  134990. /**
  134991. * Returns the texture used for reflections.
  134992. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  134993. */
  134994. private _getReflectionTexture;
  134995. /**
  134996. * Returns an array of the actively used textures.
  134997. * @returns - Array of BaseTextures
  134998. */
  134999. getActiveTextures(): BaseTexture[];
  135000. /**
  135001. * Checks to see if a texture is used in the material.
  135002. * @param texture - Base texture to use.
  135003. * @returns - Boolean specifying if a texture is used in the material.
  135004. */
  135005. hasTexture(texture: BaseTexture): boolean;
  135006. /**
  135007. * Sets the required values to the prepass renderer.
  135008. * @param prePassRenderer defines the prepass renderer to setup
  135009. */
  135010. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  135011. /**
  135012. * Disposes the resources of the material.
  135013. * @param forceDisposeEffect - Forces the disposal of effects.
  135014. * @param forceDisposeTextures - Forces the disposal of all textures.
  135015. */
  135016. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  135017. }
  135018. }
  135019. declare module BABYLON {
  135020. /**
  135021. * The Physically based material of BJS.
  135022. *
  135023. * This offers the main features of a standard PBR material.
  135024. * For more information, please refer to the documentation :
  135025. * https://doc.babylonjs.com/how_to/physically_based_rendering
  135026. */
  135027. export class PBRMaterial extends PBRBaseMaterial {
  135028. /**
  135029. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  135030. */
  135031. static readonly PBRMATERIAL_OPAQUE: number;
  135032. /**
  135033. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  135034. */
  135035. static readonly PBRMATERIAL_ALPHATEST: number;
  135036. /**
  135037. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135038. */
  135039. static readonly PBRMATERIAL_ALPHABLEND: number;
  135040. /**
  135041. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135042. * They are also discarded below the alpha cutoff threshold to improve performances.
  135043. */
  135044. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  135045. /**
  135046. * Defines the default value of how much AO map is occluding the analytical lights
  135047. * (point spot...).
  135048. */
  135049. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  135050. /**
  135051. * Intensity of the direct lights e.g. the four lights available in your scene.
  135052. * This impacts both the direct diffuse and specular highlights.
  135053. */
  135054. directIntensity: number;
  135055. /**
  135056. * Intensity of the emissive part of the material.
  135057. * This helps controlling the emissive effect without modifying the emissive color.
  135058. */
  135059. emissiveIntensity: number;
  135060. /**
  135061. * Intensity of the environment e.g. how much the environment will light the object
  135062. * either through harmonics for rough material or through the refelction for shiny ones.
  135063. */
  135064. environmentIntensity: number;
  135065. /**
  135066. * This is a special control allowing the reduction of the specular highlights coming from the
  135067. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  135068. */
  135069. specularIntensity: number;
  135070. /**
  135071. * Debug Control allowing disabling the bump map on this material.
  135072. */
  135073. disableBumpMap: boolean;
  135074. /**
  135075. * AKA Diffuse Texture in standard nomenclature.
  135076. */
  135077. albedoTexture: BaseTexture;
  135078. /**
  135079. * AKA Occlusion Texture in other nomenclature.
  135080. */
  135081. ambientTexture: BaseTexture;
  135082. /**
  135083. * AKA Occlusion Texture Intensity in other nomenclature.
  135084. */
  135085. ambientTextureStrength: number;
  135086. /**
  135087. * Defines how much the AO map is occluding the analytical lights (point spot...).
  135088. * 1 means it completely occludes it
  135089. * 0 mean it has no impact
  135090. */
  135091. ambientTextureImpactOnAnalyticalLights: number;
  135092. /**
  135093. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  135094. */
  135095. opacityTexture: BaseTexture;
  135096. /**
  135097. * Stores the reflection values in a texture.
  135098. */
  135099. reflectionTexture: Nullable<BaseTexture>;
  135100. /**
  135101. * Stores the emissive values in a texture.
  135102. */
  135103. emissiveTexture: BaseTexture;
  135104. /**
  135105. * AKA Specular texture in other nomenclature.
  135106. */
  135107. reflectivityTexture: BaseTexture;
  135108. /**
  135109. * Used to switch from specular/glossiness to metallic/roughness workflow.
  135110. */
  135111. metallicTexture: BaseTexture;
  135112. /**
  135113. * Specifies the metallic scalar of the metallic/roughness workflow.
  135114. * Can also be used to scale the metalness values of the metallic texture.
  135115. */
  135116. metallic: Nullable<number>;
  135117. /**
  135118. * Specifies the roughness scalar of the metallic/roughness workflow.
  135119. * Can also be used to scale the roughness values of the metallic texture.
  135120. */
  135121. roughness: Nullable<number>;
  135122. /**
  135123. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  135124. * By default the indexOfrefraction is used to compute F0;
  135125. *
  135126. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  135127. *
  135128. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  135129. * F90 = metallicReflectanceColor;
  135130. */
  135131. metallicF0Factor: number;
  135132. /**
  135133. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  135134. * By default the F90 is always 1;
  135135. *
  135136. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  135137. *
  135138. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  135139. * F90 = metallicReflectanceColor;
  135140. */
  135141. metallicReflectanceColor: Color3;
  135142. /**
  135143. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  135144. * This is multiply against the scalar values defined in the material.
  135145. */
  135146. metallicReflectanceTexture: Nullable<BaseTexture>;
  135147. /**
  135148. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  135149. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  135150. */
  135151. microSurfaceTexture: BaseTexture;
  135152. /**
  135153. * Stores surface normal data used to displace a mesh in a texture.
  135154. */
  135155. bumpTexture: BaseTexture;
  135156. /**
  135157. * Stores the pre-calculated light information of a mesh in a texture.
  135158. */
  135159. lightmapTexture: BaseTexture;
  135160. /**
  135161. * Stores the refracted light information in a texture.
  135162. */
  135163. get refractionTexture(): Nullable<BaseTexture>;
  135164. set refractionTexture(value: Nullable<BaseTexture>);
  135165. /**
  135166. * The color of a material in ambient lighting.
  135167. */
  135168. ambientColor: Color3;
  135169. /**
  135170. * AKA Diffuse Color in other nomenclature.
  135171. */
  135172. albedoColor: Color3;
  135173. /**
  135174. * AKA Specular Color in other nomenclature.
  135175. */
  135176. reflectivityColor: Color3;
  135177. /**
  135178. * The color reflected from the material.
  135179. */
  135180. reflectionColor: Color3;
  135181. /**
  135182. * The color emitted from the material.
  135183. */
  135184. emissiveColor: Color3;
  135185. /**
  135186. * AKA Glossiness in other nomenclature.
  135187. */
  135188. microSurface: number;
  135189. /**
  135190. * Index of refraction of the material base layer.
  135191. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135192. *
  135193. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  135194. *
  135195. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  135196. */
  135197. get indexOfRefraction(): number;
  135198. set indexOfRefraction(value: number);
  135199. /**
  135200. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  135201. */
  135202. get invertRefractionY(): boolean;
  135203. set invertRefractionY(value: boolean);
  135204. /**
  135205. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  135206. * Materials half opaque for instance using refraction could benefit from this control.
  135207. */
  135208. get linkRefractionWithTransparency(): boolean;
  135209. set linkRefractionWithTransparency(value: boolean);
  135210. /**
  135211. * If true, the light map contains occlusion information instead of lighting info.
  135212. */
  135213. useLightmapAsShadowmap: boolean;
  135214. /**
  135215. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  135216. */
  135217. useAlphaFromAlbedoTexture: boolean;
  135218. /**
  135219. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  135220. */
  135221. forceAlphaTest: boolean;
  135222. /**
  135223. * Defines the alpha limits in alpha test mode.
  135224. */
  135225. alphaCutOff: number;
  135226. /**
  135227. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  135228. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  135229. */
  135230. useSpecularOverAlpha: boolean;
  135231. /**
  135232. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  135233. */
  135234. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  135235. /**
  135236. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  135237. */
  135238. useRoughnessFromMetallicTextureAlpha: boolean;
  135239. /**
  135240. * Specifies if the metallic texture contains the roughness information in its green channel.
  135241. */
  135242. useRoughnessFromMetallicTextureGreen: boolean;
  135243. /**
  135244. * Specifies if the metallic texture contains the metallness information in its blue channel.
  135245. */
  135246. useMetallnessFromMetallicTextureBlue: boolean;
  135247. /**
  135248. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  135249. */
  135250. useAmbientOcclusionFromMetallicTextureRed: boolean;
  135251. /**
  135252. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  135253. */
  135254. useAmbientInGrayScale: boolean;
  135255. /**
  135256. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  135257. * The material will try to infer what glossiness each pixel should be.
  135258. */
  135259. useAutoMicroSurfaceFromReflectivityMap: boolean;
  135260. /**
  135261. * BJS is using an harcoded light falloff based on a manually sets up range.
  135262. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  135263. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  135264. */
  135265. get usePhysicalLightFalloff(): boolean;
  135266. /**
  135267. * BJS is using an harcoded light falloff based on a manually sets up range.
  135268. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  135269. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  135270. */
  135271. set usePhysicalLightFalloff(value: boolean);
  135272. /**
  135273. * In order to support the falloff compatibility with gltf, a special mode has been added
  135274. * to reproduce the gltf light falloff.
  135275. */
  135276. get useGLTFLightFalloff(): boolean;
  135277. /**
  135278. * In order to support the falloff compatibility with gltf, a special mode has been added
  135279. * to reproduce the gltf light falloff.
  135280. */
  135281. set useGLTFLightFalloff(value: boolean);
  135282. /**
  135283. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  135284. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  135285. */
  135286. useRadianceOverAlpha: boolean;
  135287. /**
  135288. * Allows using an object space normal map (instead of tangent space).
  135289. */
  135290. useObjectSpaceNormalMap: boolean;
  135291. /**
  135292. * Allows using the bump map in parallax mode.
  135293. */
  135294. useParallax: boolean;
  135295. /**
  135296. * Allows using the bump map in parallax occlusion mode.
  135297. */
  135298. useParallaxOcclusion: boolean;
  135299. /**
  135300. * Controls the scale bias of the parallax mode.
  135301. */
  135302. parallaxScaleBias: number;
  135303. /**
  135304. * If sets to true, disables all the lights affecting the material.
  135305. */
  135306. disableLighting: boolean;
  135307. /**
  135308. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  135309. */
  135310. forceIrradianceInFragment: boolean;
  135311. /**
  135312. * Number of Simultaneous lights allowed on the material.
  135313. */
  135314. maxSimultaneousLights: number;
  135315. /**
  135316. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  135317. */
  135318. invertNormalMapX: boolean;
  135319. /**
  135320. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  135321. */
  135322. invertNormalMapY: boolean;
  135323. /**
  135324. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  135325. */
  135326. twoSidedLighting: boolean;
  135327. /**
  135328. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135329. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  135330. */
  135331. useAlphaFresnel: boolean;
  135332. /**
  135333. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135334. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  135335. */
  135336. useLinearAlphaFresnel: boolean;
  135337. /**
  135338. * Let user defines the brdf lookup texture used for IBL.
  135339. * A default 8bit version is embedded but you could point at :
  135340. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  135341. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  135342. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  135343. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  135344. */
  135345. environmentBRDFTexture: Nullable<BaseTexture>;
  135346. /**
  135347. * Force normal to face away from face.
  135348. */
  135349. forceNormalForward: boolean;
  135350. /**
  135351. * Enables specular anti aliasing in the PBR shader.
  135352. * It will both interacts on the Geometry for analytical and IBL lighting.
  135353. * It also prefilter the roughness map based on the bump values.
  135354. */
  135355. enableSpecularAntiAliasing: boolean;
  135356. /**
  135357. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  135358. * makes the reflect vector face the model (under horizon).
  135359. */
  135360. useHorizonOcclusion: boolean;
  135361. /**
  135362. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  135363. * too much the area relying on ambient texture to define their ambient occlusion.
  135364. */
  135365. useRadianceOcclusion: boolean;
  135366. /**
  135367. * If set to true, no lighting calculations will be applied.
  135368. */
  135369. unlit: boolean;
  135370. /**
  135371. * Gets the image processing configuration used either in this material.
  135372. */
  135373. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  135374. /**
  135375. * Sets the Default image processing configuration used either in the this material.
  135376. *
  135377. * If sets to null, the scene one is in use.
  135378. */
  135379. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  135380. /**
  135381. * Gets wether the color curves effect is enabled.
  135382. */
  135383. get cameraColorCurvesEnabled(): boolean;
  135384. /**
  135385. * Sets wether the color curves effect is enabled.
  135386. */
  135387. set cameraColorCurvesEnabled(value: boolean);
  135388. /**
  135389. * Gets wether the color grading effect is enabled.
  135390. */
  135391. get cameraColorGradingEnabled(): boolean;
  135392. /**
  135393. * Gets wether the color grading effect is enabled.
  135394. */
  135395. set cameraColorGradingEnabled(value: boolean);
  135396. /**
  135397. * Gets wether tonemapping is enabled or not.
  135398. */
  135399. get cameraToneMappingEnabled(): boolean;
  135400. /**
  135401. * Sets wether tonemapping is enabled or not
  135402. */
  135403. set cameraToneMappingEnabled(value: boolean);
  135404. /**
  135405. * The camera exposure used on this material.
  135406. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135407. * This corresponds to a photographic exposure.
  135408. */
  135409. get cameraExposure(): number;
  135410. /**
  135411. * The camera exposure used on this material.
  135412. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135413. * This corresponds to a photographic exposure.
  135414. */
  135415. set cameraExposure(value: number);
  135416. /**
  135417. * Gets The camera contrast used on this material.
  135418. */
  135419. get cameraContrast(): number;
  135420. /**
  135421. * Sets The camera contrast used on this material.
  135422. */
  135423. set cameraContrast(value: number);
  135424. /**
  135425. * Gets the Color Grading 2D Lookup Texture.
  135426. */
  135427. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  135428. /**
  135429. * Sets the Color Grading 2D Lookup Texture.
  135430. */
  135431. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  135432. /**
  135433. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135434. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135435. * 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;
  135436. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135437. */
  135438. get cameraColorCurves(): Nullable<ColorCurves>;
  135439. /**
  135440. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135441. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135442. * 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;
  135443. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135444. */
  135445. set cameraColorCurves(value: Nullable<ColorCurves>);
  135446. /**
  135447. * Instantiates a new PBRMaterial instance.
  135448. *
  135449. * @param name The material name
  135450. * @param scene The scene the material will be use in.
  135451. */
  135452. constructor(name: string, scene: Scene);
  135453. /**
  135454. * Returns the name of this material class.
  135455. */
  135456. getClassName(): string;
  135457. /**
  135458. * Makes a duplicate of the current material.
  135459. * @param name - name to use for the new material.
  135460. */
  135461. clone(name: string): PBRMaterial;
  135462. /**
  135463. * Serializes this PBR Material.
  135464. * @returns - An object with the serialized material.
  135465. */
  135466. serialize(): any;
  135467. /**
  135468. * Parses a PBR Material from a serialized object.
  135469. * @param source - Serialized object.
  135470. * @param scene - BJS scene instance.
  135471. * @param rootUrl - url for the scene object
  135472. * @returns - PBRMaterial
  135473. */
  135474. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  135475. }
  135476. }
  135477. declare module BABYLON {
  135478. /**
  135479. * Direct draw surface info
  135480. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  135481. */
  135482. export interface DDSInfo {
  135483. /**
  135484. * Width of the texture
  135485. */
  135486. width: number;
  135487. /**
  135488. * Width of the texture
  135489. */
  135490. height: number;
  135491. /**
  135492. * Number of Mipmaps for the texture
  135493. * @see https://en.wikipedia.org/wiki/Mipmap
  135494. */
  135495. mipmapCount: number;
  135496. /**
  135497. * If the textures format is a known fourCC format
  135498. * @see https://www.fourcc.org/
  135499. */
  135500. isFourCC: boolean;
  135501. /**
  135502. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  135503. */
  135504. isRGB: boolean;
  135505. /**
  135506. * If the texture is a lumincance format
  135507. */
  135508. isLuminance: boolean;
  135509. /**
  135510. * If this is a cube texture
  135511. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  135512. */
  135513. isCube: boolean;
  135514. /**
  135515. * If the texture is a compressed format eg. FOURCC_DXT1
  135516. */
  135517. isCompressed: boolean;
  135518. /**
  135519. * The dxgiFormat of the texture
  135520. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  135521. */
  135522. dxgiFormat: number;
  135523. /**
  135524. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  135525. */
  135526. textureType: number;
  135527. /**
  135528. * Sphericle polynomial created for the dds texture
  135529. */
  135530. sphericalPolynomial?: SphericalPolynomial;
  135531. }
  135532. /**
  135533. * Class used to provide DDS decompression tools
  135534. */
  135535. export class DDSTools {
  135536. /**
  135537. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  135538. */
  135539. static StoreLODInAlphaChannel: boolean;
  135540. /**
  135541. * Gets DDS information from an array buffer
  135542. * @param data defines the array buffer view to read data from
  135543. * @returns the DDS information
  135544. */
  135545. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  135546. private static _FloatView;
  135547. private static _Int32View;
  135548. private static _ToHalfFloat;
  135549. private static _FromHalfFloat;
  135550. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  135551. private static _GetHalfFloatRGBAArrayBuffer;
  135552. private static _GetFloatRGBAArrayBuffer;
  135553. private static _GetFloatAsUIntRGBAArrayBuffer;
  135554. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  135555. private static _GetRGBAArrayBuffer;
  135556. private static _ExtractLongWordOrder;
  135557. private static _GetRGBArrayBuffer;
  135558. private static _GetLuminanceArrayBuffer;
  135559. /**
  135560. * Uploads DDS Levels to a Babylon Texture
  135561. * @hidden
  135562. */
  135563. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  135564. }
  135565. interface ThinEngine {
  135566. /**
  135567. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  135568. * @param rootUrl defines the url where the file to load is located
  135569. * @param scene defines the current scene
  135570. * @param lodScale defines scale to apply to the mip map selection
  135571. * @param lodOffset defines offset to apply to the mip map selection
  135572. * @param onLoad defines an optional callback raised when the texture is loaded
  135573. * @param onError defines an optional callback raised if there is an issue to load the texture
  135574. * @param format defines the format of the data
  135575. * @param forcedExtension defines the extension to use to pick the right loader
  135576. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  135577. * @returns the cube texture as an InternalTexture
  135578. */
  135579. 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;
  135580. }
  135581. }
  135582. declare module BABYLON {
  135583. /**
  135584. * Implementation of the DDS Texture Loader.
  135585. * @hidden
  135586. */
  135587. export class _DDSTextureLoader implements IInternalTextureLoader {
  135588. /**
  135589. * Defines wether the loader supports cascade loading the different faces.
  135590. */
  135591. readonly supportCascades: boolean;
  135592. /**
  135593. * This returns if the loader support the current file information.
  135594. * @param extension defines the file extension of the file being loaded
  135595. * @returns true if the loader can load the specified file
  135596. */
  135597. canLoad(extension: string): boolean;
  135598. /**
  135599. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  135600. * @param data contains the texture data
  135601. * @param texture defines the BabylonJS internal texture
  135602. * @param createPolynomials will be true if polynomials have been requested
  135603. * @param onLoad defines the callback to trigger once the texture is ready
  135604. * @param onError defines the callback to trigger in case of error
  135605. */
  135606. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  135607. /**
  135608. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  135609. * @param data contains the texture data
  135610. * @param texture defines the BabylonJS internal texture
  135611. * @param callback defines the method to call once ready to upload
  135612. */
  135613. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  135614. }
  135615. }
  135616. declare module BABYLON {
  135617. /**
  135618. * Implementation of the ENV Texture Loader.
  135619. * @hidden
  135620. */
  135621. export class _ENVTextureLoader implements IInternalTextureLoader {
  135622. /**
  135623. * Defines wether the loader supports cascade loading the different faces.
  135624. */
  135625. readonly supportCascades: boolean;
  135626. /**
  135627. * This returns if the loader support the current file information.
  135628. * @param extension defines the file extension of the file being loaded
  135629. * @returns true if the loader can load the specified file
  135630. */
  135631. canLoad(extension: string): boolean;
  135632. /**
  135633. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  135634. * @param data contains the texture data
  135635. * @param texture defines the BabylonJS internal texture
  135636. * @param createPolynomials will be true if polynomials have been requested
  135637. * @param onLoad defines the callback to trigger once the texture is ready
  135638. * @param onError defines the callback to trigger in case of error
  135639. */
  135640. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  135641. /**
  135642. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  135643. * @param data contains the texture data
  135644. * @param texture defines the BabylonJS internal texture
  135645. * @param callback defines the method to call once ready to upload
  135646. */
  135647. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  135648. }
  135649. }
  135650. declare module BABYLON {
  135651. /**
  135652. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  135653. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  135654. */
  135655. export class KhronosTextureContainer {
  135656. /** contents of the KTX container file */
  135657. data: ArrayBufferView;
  135658. private static HEADER_LEN;
  135659. private static COMPRESSED_2D;
  135660. private static COMPRESSED_3D;
  135661. private static TEX_2D;
  135662. private static TEX_3D;
  135663. /**
  135664. * Gets the openGL type
  135665. */
  135666. glType: number;
  135667. /**
  135668. * Gets the openGL type size
  135669. */
  135670. glTypeSize: number;
  135671. /**
  135672. * Gets the openGL format
  135673. */
  135674. glFormat: number;
  135675. /**
  135676. * Gets the openGL internal format
  135677. */
  135678. glInternalFormat: number;
  135679. /**
  135680. * Gets the base internal format
  135681. */
  135682. glBaseInternalFormat: number;
  135683. /**
  135684. * Gets image width in pixel
  135685. */
  135686. pixelWidth: number;
  135687. /**
  135688. * Gets image height in pixel
  135689. */
  135690. pixelHeight: number;
  135691. /**
  135692. * Gets image depth in pixels
  135693. */
  135694. pixelDepth: number;
  135695. /**
  135696. * Gets the number of array elements
  135697. */
  135698. numberOfArrayElements: number;
  135699. /**
  135700. * Gets the number of faces
  135701. */
  135702. numberOfFaces: number;
  135703. /**
  135704. * Gets the number of mipmap levels
  135705. */
  135706. numberOfMipmapLevels: number;
  135707. /**
  135708. * Gets the bytes of key value data
  135709. */
  135710. bytesOfKeyValueData: number;
  135711. /**
  135712. * Gets the load type
  135713. */
  135714. loadType: number;
  135715. /**
  135716. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  135717. */
  135718. isInvalid: boolean;
  135719. /**
  135720. * Creates a new KhronosTextureContainer
  135721. * @param data contents of the KTX container file
  135722. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  135723. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  135724. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  135725. */
  135726. constructor(
  135727. /** contents of the KTX container file */
  135728. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  135729. /**
  135730. * Uploads KTX content to a Babylon Texture.
  135731. * It is assumed that the texture has already been created & is currently bound
  135732. * @hidden
  135733. */
  135734. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  135735. private _upload2DCompressedLevels;
  135736. /**
  135737. * Checks if the given data starts with a KTX file identifier.
  135738. * @param data the data to check
  135739. * @returns true if the data is a KTX file or false otherwise
  135740. */
  135741. static IsValid(data: ArrayBufferView): boolean;
  135742. }
  135743. }
  135744. declare module BABYLON {
  135745. /**
  135746. * Class for loading KTX2 files
  135747. * !!! Experimental Extension Subject to Changes !!!
  135748. * @hidden
  135749. */
  135750. export class KhronosTextureContainer2 {
  135751. private static _ModulePromise;
  135752. private static _TranscodeFormat;
  135753. constructor(engine: ThinEngine);
  135754. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  135755. private _determineTranscodeFormat;
  135756. /**
  135757. * Checks if the given data starts with a KTX2 file identifier.
  135758. * @param data the data to check
  135759. * @returns true if the data is a KTX2 file or false otherwise
  135760. */
  135761. static IsValid(data: ArrayBufferView): boolean;
  135762. }
  135763. }
  135764. declare module BABYLON {
  135765. /**
  135766. * Implementation of the KTX Texture Loader.
  135767. * @hidden
  135768. */
  135769. export class _KTXTextureLoader implements IInternalTextureLoader {
  135770. /**
  135771. * Defines wether the loader supports cascade loading the different faces.
  135772. */
  135773. readonly supportCascades: boolean;
  135774. /**
  135775. * This returns if the loader support the current file information.
  135776. * @param extension defines the file extension of the file being loaded
  135777. * @param mimeType defines the optional mime type of the file being loaded
  135778. * @returns true if the loader can load the specified file
  135779. */
  135780. canLoad(extension: string, mimeType?: string): boolean;
  135781. /**
  135782. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  135783. * @param data contains the texture data
  135784. * @param texture defines the BabylonJS internal texture
  135785. * @param createPolynomials will be true if polynomials have been requested
  135786. * @param onLoad defines the callback to trigger once the texture is ready
  135787. * @param onError defines the callback to trigger in case of error
  135788. */
  135789. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  135790. /**
  135791. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  135792. * @param data contains the texture data
  135793. * @param texture defines the BabylonJS internal texture
  135794. * @param callback defines the method to call once ready to upload
  135795. */
  135796. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  135797. }
  135798. }
  135799. declare module BABYLON {
  135800. /** @hidden */
  135801. export var _forceSceneHelpersToBundle: boolean;
  135802. interface Scene {
  135803. /**
  135804. * Creates a default light for the scene.
  135805. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  135806. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  135807. */
  135808. createDefaultLight(replace?: boolean): void;
  135809. /**
  135810. * Creates a default camera for the scene.
  135811. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  135812. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  135813. * @param replace has default false, when true replaces the active camera in the scene
  135814. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  135815. */
  135816. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  135817. /**
  135818. * Creates a default camera and a default light.
  135819. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  135820. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  135821. * @param replace has the default false, when true replaces the active camera/light in the scene
  135822. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  135823. */
  135824. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  135825. /**
  135826. * Creates a new sky box
  135827. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  135828. * @param environmentTexture defines the texture to use as environment texture
  135829. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  135830. * @param scale defines the overall scale of the skybox
  135831. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  135832. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  135833. * @returns a new mesh holding the sky box
  135834. */
  135835. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  135836. /**
  135837. * Creates a new environment
  135838. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  135839. * @param options defines the options you can use to configure the environment
  135840. * @returns the new EnvironmentHelper
  135841. */
  135842. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  135843. /**
  135844. * Creates a new VREXperienceHelper
  135845. * @see https://doc.babylonjs.com/how_to/webvr_helper
  135846. * @param webVROptions defines the options used to create the new VREXperienceHelper
  135847. * @returns a new VREXperienceHelper
  135848. */
  135849. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  135850. /**
  135851. * Creates a new WebXRDefaultExperience
  135852. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  135853. * @param options experience options
  135854. * @returns a promise for a new WebXRDefaultExperience
  135855. */
  135856. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  135857. }
  135858. }
  135859. declare module BABYLON {
  135860. /**
  135861. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  135862. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  135863. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  135864. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135865. */
  135866. export class VideoDome extends TransformNode {
  135867. /**
  135868. * Define the video source as a Monoscopic panoramic 360 video.
  135869. */
  135870. static readonly MODE_MONOSCOPIC: number;
  135871. /**
  135872. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  135873. */
  135874. static readonly MODE_TOPBOTTOM: number;
  135875. /**
  135876. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  135877. */
  135878. static readonly MODE_SIDEBYSIDE: number;
  135879. private _halfDome;
  135880. private _useDirectMapping;
  135881. /**
  135882. * The video texture being displayed on the sphere
  135883. */
  135884. protected _videoTexture: VideoTexture;
  135885. /**
  135886. * Gets the video texture being displayed on the sphere
  135887. */
  135888. get videoTexture(): VideoTexture;
  135889. /**
  135890. * The skybox material
  135891. */
  135892. protected _material: BackgroundMaterial;
  135893. /**
  135894. * The surface used for the video dome
  135895. */
  135896. protected _mesh: Mesh;
  135897. /**
  135898. * Gets the mesh used for the video dome.
  135899. */
  135900. get mesh(): Mesh;
  135901. /**
  135902. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  135903. */
  135904. private _halfDomeMask;
  135905. /**
  135906. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135907. * Also see the options.resolution property.
  135908. */
  135909. get fovMultiplier(): number;
  135910. set fovMultiplier(value: number);
  135911. private _videoMode;
  135912. /**
  135913. * Gets or set the current video mode for the video. It can be:
  135914. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  135915. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  135916. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  135917. */
  135918. get videoMode(): number;
  135919. set videoMode(value: number);
  135920. /**
  135921. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  135922. *
  135923. */
  135924. get halfDome(): boolean;
  135925. /**
  135926. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  135927. */
  135928. set halfDome(enabled: boolean);
  135929. /**
  135930. * Oberserver used in Stereoscopic VR Mode.
  135931. */
  135932. private _onBeforeCameraRenderObserver;
  135933. /**
  135934. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  135935. * @param name Element's name, child elements will append suffixes for their own names.
  135936. * @param urlsOrVideo defines the url(s) or the video element to use
  135937. * @param options An object containing optional or exposed sub element properties
  135938. */
  135939. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  135940. resolution?: number;
  135941. clickToPlay?: boolean;
  135942. autoPlay?: boolean;
  135943. loop?: boolean;
  135944. size?: number;
  135945. poster?: string;
  135946. faceForward?: boolean;
  135947. useDirectMapping?: boolean;
  135948. halfDomeMode?: boolean;
  135949. }, scene: Scene);
  135950. private _changeVideoMode;
  135951. /**
  135952. * Releases resources associated with this node.
  135953. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  135954. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  135955. */
  135956. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  135957. }
  135958. }
  135959. declare module BABYLON {
  135960. /**
  135961. * This class can be used to get instrumentation data from a Babylon engine
  135962. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  135963. */
  135964. export class EngineInstrumentation implements IDisposable {
  135965. /**
  135966. * Define the instrumented engine.
  135967. */
  135968. engine: Engine;
  135969. private _captureGPUFrameTime;
  135970. private _gpuFrameTimeToken;
  135971. private _gpuFrameTime;
  135972. private _captureShaderCompilationTime;
  135973. private _shaderCompilationTime;
  135974. private _onBeginFrameObserver;
  135975. private _onEndFrameObserver;
  135976. private _onBeforeShaderCompilationObserver;
  135977. private _onAfterShaderCompilationObserver;
  135978. /**
  135979. * Gets the perf counter used for GPU frame time
  135980. */
  135981. get gpuFrameTimeCounter(): PerfCounter;
  135982. /**
  135983. * Gets the GPU frame time capture status
  135984. */
  135985. get captureGPUFrameTime(): boolean;
  135986. /**
  135987. * Enable or disable the GPU frame time capture
  135988. */
  135989. set captureGPUFrameTime(value: boolean);
  135990. /**
  135991. * Gets the perf counter used for shader compilation time
  135992. */
  135993. get shaderCompilationTimeCounter(): PerfCounter;
  135994. /**
  135995. * Gets the shader compilation time capture status
  135996. */
  135997. get captureShaderCompilationTime(): boolean;
  135998. /**
  135999. * Enable or disable the shader compilation time capture
  136000. */
  136001. set captureShaderCompilationTime(value: boolean);
  136002. /**
  136003. * Instantiates a new engine instrumentation.
  136004. * This class can be used to get instrumentation data from a Babylon engine
  136005. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  136006. * @param engine Defines the engine to instrument
  136007. */
  136008. constructor(
  136009. /**
  136010. * Define the instrumented engine.
  136011. */
  136012. engine: Engine);
  136013. /**
  136014. * Dispose and release associated resources.
  136015. */
  136016. dispose(): void;
  136017. }
  136018. }
  136019. declare module BABYLON {
  136020. /**
  136021. * This class can be used to get instrumentation data from a Babylon engine
  136022. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  136023. */
  136024. export class SceneInstrumentation implements IDisposable {
  136025. /**
  136026. * Defines the scene to instrument
  136027. */
  136028. scene: Scene;
  136029. private _captureActiveMeshesEvaluationTime;
  136030. private _activeMeshesEvaluationTime;
  136031. private _captureRenderTargetsRenderTime;
  136032. private _renderTargetsRenderTime;
  136033. private _captureFrameTime;
  136034. private _frameTime;
  136035. private _captureRenderTime;
  136036. private _renderTime;
  136037. private _captureInterFrameTime;
  136038. private _interFrameTime;
  136039. private _captureParticlesRenderTime;
  136040. private _particlesRenderTime;
  136041. private _captureSpritesRenderTime;
  136042. private _spritesRenderTime;
  136043. private _capturePhysicsTime;
  136044. private _physicsTime;
  136045. private _captureAnimationsTime;
  136046. private _animationsTime;
  136047. private _captureCameraRenderTime;
  136048. private _cameraRenderTime;
  136049. private _onBeforeActiveMeshesEvaluationObserver;
  136050. private _onAfterActiveMeshesEvaluationObserver;
  136051. private _onBeforeRenderTargetsRenderObserver;
  136052. private _onAfterRenderTargetsRenderObserver;
  136053. private _onAfterRenderObserver;
  136054. private _onBeforeDrawPhaseObserver;
  136055. private _onAfterDrawPhaseObserver;
  136056. private _onBeforeAnimationsObserver;
  136057. private _onBeforeParticlesRenderingObserver;
  136058. private _onAfterParticlesRenderingObserver;
  136059. private _onBeforeSpritesRenderingObserver;
  136060. private _onAfterSpritesRenderingObserver;
  136061. private _onBeforePhysicsObserver;
  136062. private _onAfterPhysicsObserver;
  136063. private _onAfterAnimationsObserver;
  136064. private _onBeforeCameraRenderObserver;
  136065. private _onAfterCameraRenderObserver;
  136066. /**
  136067. * Gets the perf counter used for active meshes evaluation time
  136068. */
  136069. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  136070. /**
  136071. * Gets the active meshes evaluation time capture status
  136072. */
  136073. get captureActiveMeshesEvaluationTime(): boolean;
  136074. /**
  136075. * Enable or disable the active meshes evaluation time capture
  136076. */
  136077. set captureActiveMeshesEvaluationTime(value: boolean);
  136078. /**
  136079. * Gets the perf counter used for render targets render time
  136080. */
  136081. get renderTargetsRenderTimeCounter(): PerfCounter;
  136082. /**
  136083. * Gets the render targets render time capture status
  136084. */
  136085. get captureRenderTargetsRenderTime(): boolean;
  136086. /**
  136087. * Enable or disable the render targets render time capture
  136088. */
  136089. set captureRenderTargetsRenderTime(value: boolean);
  136090. /**
  136091. * Gets the perf counter used for particles render time
  136092. */
  136093. get particlesRenderTimeCounter(): PerfCounter;
  136094. /**
  136095. * Gets the particles render time capture status
  136096. */
  136097. get captureParticlesRenderTime(): boolean;
  136098. /**
  136099. * Enable or disable the particles render time capture
  136100. */
  136101. set captureParticlesRenderTime(value: boolean);
  136102. /**
  136103. * Gets the perf counter used for sprites render time
  136104. */
  136105. get spritesRenderTimeCounter(): PerfCounter;
  136106. /**
  136107. * Gets the sprites render time capture status
  136108. */
  136109. get captureSpritesRenderTime(): boolean;
  136110. /**
  136111. * Enable or disable the sprites render time capture
  136112. */
  136113. set captureSpritesRenderTime(value: boolean);
  136114. /**
  136115. * Gets the perf counter used for physics time
  136116. */
  136117. get physicsTimeCounter(): PerfCounter;
  136118. /**
  136119. * Gets the physics time capture status
  136120. */
  136121. get capturePhysicsTime(): boolean;
  136122. /**
  136123. * Enable or disable the physics time capture
  136124. */
  136125. set capturePhysicsTime(value: boolean);
  136126. /**
  136127. * Gets the perf counter used for animations time
  136128. */
  136129. get animationsTimeCounter(): PerfCounter;
  136130. /**
  136131. * Gets the animations time capture status
  136132. */
  136133. get captureAnimationsTime(): boolean;
  136134. /**
  136135. * Enable or disable the animations time capture
  136136. */
  136137. set captureAnimationsTime(value: boolean);
  136138. /**
  136139. * Gets the perf counter used for frame time capture
  136140. */
  136141. get frameTimeCounter(): PerfCounter;
  136142. /**
  136143. * Gets the frame time capture status
  136144. */
  136145. get captureFrameTime(): boolean;
  136146. /**
  136147. * Enable or disable the frame time capture
  136148. */
  136149. set captureFrameTime(value: boolean);
  136150. /**
  136151. * Gets the perf counter used for inter-frames time capture
  136152. */
  136153. get interFrameTimeCounter(): PerfCounter;
  136154. /**
  136155. * Gets the inter-frames time capture status
  136156. */
  136157. get captureInterFrameTime(): boolean;
  136158. /**
  136159. * Enable or disable the inter-frames time capture
  136160. */
  136161. set captureInterFrameTime(value: boolean);
  136162. /**
  136163. * Gets the perf counter used for render time capture
  136164. */
  136165. get renderTimeCounter(): PerfCounter;
  136166. /**
  136167. * Gets the render time capture status
  136168. */
  136169. get captureRenderTime(): boolean;
  136170. /**
  136171. * Enable or disable the render time capture
  136172. */
  136173. set captureRenderTime(value: boolean);
  136174. /**
  136175. * Gets the perf counter used for camera render time capture
  136176. */
  136177. get cameraRenderTimeCounter(): PerfCounter;
  136178. /**
  136179. * Gets the camera render time capture status
  136180. */
  136181. get captureCameraRenderTime(): boolean;
  136182. /**
  136183. * Enable or disable the camera render time capture
  136184. */
  136185. set captureCameraRenderTime(value: boolean);
  136186. /**
  136187. * Gets the perf counter used for draw calls
  136188. */
  136189. get drawCallsCounter(): PerfCounter;
  136190. /**
  136191. * Instantiates a new scene instrumentation.
  136192. * This class can be used to get instrumentation data from a Babylon engine
  136193. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  136194. * @param scene Defines the scene to instrument
  136195. */
  136196. constructor(
  136197. /**
  136198. * Defines the scene to instrument
  136199. */
  136200. scene: Scene);
  136201. /**
  136202. * Dispose and release associated resources.
  136203. */
  136204. dispose(): void;
  136205. }
  136206. }
  136207. declare module BABYLON {
  136208. /** @hidden */
  136209. export var glowMapGenerationPixelShader: {
  136210. name: string;
  136211. shader: string;
  136212. };
  136213. }
  136214. declare module BABYLON {
  136215. /** @hidden */
  136216. export var glowMapGenerationVertexShader: {
  136217. name: string;
  136218. shader: string;
  136219. };
  136220. }
  136221. declare module BABYLON {
  136222. /**
  136223. * Effect layer options. This helps customizing the behaviour
  136224. * of the effect layer.
  136225. */
  136226. export interface IEffectLayerOptions {
  136227. /**
  136228. * Multiplication factor apply to the canvas size to compute the render target size
  136229. * used to generated the objects (the smaller the faster).
  136230. */
  136231. mainTextureRatio: number;
  136232. /**
  136233. * Enforces a fixed size texture to ensure effect stability across devices.
  136234. */
  136235. mainTextureFixedSize?: number;
  136236. /**
  136237. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  136238. */
  136239. alphaBlendingMode: number;
  136240. /**
  136241. * The camera attached to the layer.
  136242. */
  136243. camera: Nullable<Camera>;
  136244. /**
  136245. * The rendering group to draw the layer in.
  136246. */
  136247. renderingGroupId: number;
  136248. }
  136249. /**
  136250. * The effect layer Helps adding post process effect blended with the main pass.
  136251. *
  136252. * This can be for instance use to generate glow or higlight effects on the scene.
  136253. *
  136254. * The effect layer class can not be used directly and is intented to inherited from to be
  136255. * customized per effects.
  136256. */
  136257. export abstract class EffectLayer {
  136258. private _vertexBuffers;
  136259. private _indexBuffer;
  136260. private _cachedDefines;
  136261. private _effectLayerMapGenerationEffect;
  136262. private _effectLayerOptions;
  136263. private _mergeEffect;
  136264. protected _scene: Scene;
  136265. protected _engine: Engine;
  136266. protected _maxSize: number;
  136267. protected _mainTextureDesiredSize: ISize;
  136268. protected _mainTexture: RenderTargetTexture;
  136269. protected _shouldRender: boolean;
  136270. protected _postProcesses: PostProcess[];
  136271. protected _textures: BaseTexture[];
  136272. protected _emissiveTextureAndColor: {
  136273. texture: Nullable<BaseTexture>;
  136274. color: Color4;
  136275. };
  136276. /**
  136277. * The name of the layer
  136278. */
  136279. name: string;
  136280. /**
  136281. * The clear color of the texture used to generate the glow map.
  136282. */
  136283. neutralColor: Color4;
  136284. /**
  136285. * Specifies whether the highlight layer is enabled or not.
  136286. */
  136287. isEnabled: boolean;
  136288. /**
  136289. * Gets the camera attached to the layer.
  136290. */
  136291. get camera(): Nullable<Camera>;
  136292. /**
  136293. * Gets the rendering group id the layer should render in.
  136294. */
  136295. get renderingGroupId(): number;
  136296. set renderingGroupId(renderingGroupId: number);
  136297. /**
  136298. * An event triggered when the effect layer has been disposed.
  136299. */
  136300. onDisposeObservable: Observable<EffectLayer>;
  136301. /**
  136302. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  136303. */
  136304. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  136305. /**
  136306. * An event triggered when the generated texture is being merged in the scene.
  136307. */
  136308. onBeforeComposeObservable: Observable<EffectLayer>;
  136309. /**
  136310. * An event triggered when the mesh is rendered into the effect render target.
  136311. */
  136312. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  136313. /**
  136314. * An event triggered after the mesh has been rendered into the effect render target.
  136315. */
  136316. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  136317. /**
  136318. * An event triggered when the generated texture has been merged in the scene.
  136319. */
  136320. onAfterComposeObservable: Observable<EffectLayer>;
  136321. /**
  136322. * An event triggered when the efffect layer changes its size.
  136323. */
  136324. onSizeChangedObservable: Observable<EffectLayer>;
  136325. /** @hidden */
  136326. static _SceneComponentInitialization: (scene: Scene) => void;
  136327. /**
  136328. * Instantiates a new effect Layer and references it in the scene.
  136329. * @param name The name of the layer
  136330. * @param scene The scene to use the layer in
  136331. */
  136332. constructor(
  136333. /** The Friendly of the effect in the scene */
  136334. name: string, scene: Scene);
  136335. /**
  136336. * Get the effect name of the layer.
  136337. * @return The effect name
  136338. */
  136339. abstract getEffectName(): string;
  136340. /**
  136341. * Checks for the readiness of the element composing the layer.
  136342. * @param subMesh the mesh to check for
  136343. * @param useInstances specify whether or not to use instances to render the mesh
  136344. * @return true if ready otherwise, false
  136345. */
  136346. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136347. /**
  136348. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  136349. * @returns true if the effect requires stencil during the main canvas render pass.
  136350. */
  136351. abstract needStencil(): boolean;
  136352. /**
  136353. * Create the merge effect. This is the shader use to blit the information back
  136354. * to the main canvas at the end of the scene rendering.
  136355. * @returns The effect containing the shader used to merge the effect on the main canvas
  136356. */
  136357. protected abstract _createMergeEffect(): Effect;
  136358. /**
  136359. * Creates the render target textures and post processes used in the effect layer.
  136360. */
  136361. protected abstract _createTextureAndPostProcesses(): void;
  136362. /**
  136363. * Implementation specific of rendering the generating effect on the main canvas.
  136364. * @param effect The effect used to render through
  136365. */
  136366. protected abstract _internalRender(effect: Effect): void;
  136367. /**
  136368. * Sets the required values for both the emissive texture and and the main color.
  136369. */
  136370. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  136371. /**
  136372. * Free any resources and references associated to a mesh.
  136373. * Internal use
  136374. * @param mesh The mesh to free.
  136375. */
  136376. abstract _disposeMesh(mesh: Mesh): void;
  136377. /**
  136378. * Serializes this layer (Glow or Highlight for example)
  136379. * @returns a serialized layer object
  136380. */
  136381. abstract serialize?(): any;
  136382. /**
  136383. * Initializes the effect layer with the required options.
  136384. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  136385. */
  136386. protected _init(options: Partial<IEffectLayerOptions>): void;
  136387. /**
  136388. * Generates the index buffer of the full screen quad blending to the main canvas.
  136389. */
  136390. private _generateIndexBuffer;
  136391. /**
  136392. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  136393. */
  136394. private _generateVertexBuffer;
  136395. /**
  136396. * Sets the main texture desired size which is the closest power of two
  136397. * of the engine canvas size.
  136398. */
  136399. private _setMainTextureSize;
  136400. /**
  136401. * Creates the main texture for the effect layer.
  136402. */
  136403. protected _createMainTexture(): void;
  136404. /**
  136405. * Adds specific effects defines.
  136406. * @param defines The defines to add specifics to.
  136407. */
  136408. protected _addCustomEffectDefines(defines: string[]): void;
  136409. /**
  136410. * Checks for the readiness of the element composing the layer.
  136411. * @param subMesh the mesh to check for
  136412. * @param useInstances specify whether or not to use instances to render the mesh
  136413. * @param emissiveTexture the associated emissive texture used to generate the glow
  136414. * @return true if ready otherwise, false
  136415. */
  136416. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  136417. /**
  136418. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  136419. */
  136420. render(): void;
  136421. /**
  136422. * Determine if a given mesh will be used in the current effect.
  136423. * @param mesh mesh to test
  136424. * @returns true if the mesh will be used
  136425. */
  136426. hasMesh(mesh: AbstractMesh): boolean;
  136427. /**
  136428. * Returns true if the layer contains information to display, otherwise false.
  136429. * @returns true if the glow layer should be rendered
  136430. */
  136431. shouldRender(): boolean;
  136432. /**
  136433. * Returns true if the mesh should render, otherwise false.
  136434. * @param mesh The mesh to render
  136435. * @returns true if it should render otherwise false
  136436. */
  136437. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  136438. /**
  136439. * Returns true if the mesh can be rendered, otherwise false.
  136440. * @param mesh The mesh to render
  136441. * @param material The material used on the mesh
  136442. * @returns true if it can be rendered otherwise false
  136443. */
  136444. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  136445. /**
  136446. * Returns true if the mesh should render, otherwise false.
  136447. * @param mesh The mesh to render
  136448. * @returns true if it should render otherwise false
  136449. */
  136450. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  136451. /**
  136452. * Renders the submesh passed in parameter to the generation map.
  136453. */
  136454. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  136455. /**
  136456. * Defines whether the current material of the mesh should be use to render the effect.
  136457. * @param mesh defines the current mesh to render
  136458. */
  136459. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  136460. /**
  136461. * Rebuild the required buffers.
  136462. * @hidden Internal use only.
  136463. */
  136464. _rebuild(): void;
  136465. /**
  136466. * Dispose only the render target textures and post process.
  136467. */
  136468. private _disposeTextureAndPostProcesses;
  136469. /**
  136470. * Dispose the highlight layer and free resources.
  136471. */
  136472. dispose(): void;
  136473. /**
  136474. * Gets the class name of the effect layer
  136475. * @returns the string with the class name of the effect layer
  136476. */
  136477. getClassName(): string;
  136478. /**
  136479. * Creates an effect layer from parsed effect layer data
  136480. * @param parsedEffectLayer defines effect layer data
  136481. * @param scene defines the current scene
  136482. * @param rootUrl defines the root URL containing the effect layer information
  136483. * @returns a parsed effect Layer
  136484. */
  136485. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  136486. }
  136487. }
  136488. declare module BABYLON {
  136489. interface AbstractScene {
  136490. /**
  136491. * The list of effect layers (highlights/glow) added to the scene
  136492. * @see https://doc.babylonjs.com/how_to/highlight_layer
  136493. * @see https://doc.babylonjs.com/how_to/glow_layer
  136494. */
  136495. effectLayers: Array<EffectLayer>;
  136496. /**
  136497. * Removes the given effect layer from this scene.
  136498. * @param toRemove defines the effect layer to remove
  136499. * @returns the index of the removed effect layer
  136500. */
  136501. removeEffectLayer(toRemove: EffectLayer): number;
  136502. /**
  136503. * Adds the given effect layer to this scene
  136504. * @param newEffectLayer defines the effect layer to add
  136505. */
  136506. addEffectLayer(newEffectLayer: EffectLayer): void;
  136507. }
  136508. /**
  136509. * Defines the layer scene component responsible to manage any effect layers
  136510. * in a given scene.
  136511. */
  136512. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  136513. /**
  136514. * The component name helpfull to identify the component in the list of scene components.
  136515. */
  136516. readonly name: string;
  136517. /**
  136518. * The scene the component belongs to.
  136519. */
  136520. scene: Scene;
  136521. private _engine;
  136522. private _renderEffects;
  136523. private _needStencil;
  136524. private _previousStencilState;
  136525. /**
  136526. * Creates a new instance of the component for the given scene
  136527. * @param scene Defines the scene to register the component in
  136528. */
  136529. constructor(scene: Scene);
  136530. /**
  136531. * Registers the component in a given scene
  136532. */
  136533. register(): void;
  136534. /**
  136535. * Rebuilds the elements related to this component in case of
  136536. * context lost for instance.
  136537. */
  136538. rebuild(): void;
  136539. /**
  136540. * Serializes the component data to the specified json object
  136541. * @param serializationObject The object to serialize to
  136542. */
  136543. serialize(serializationObject: any): void;
  136544. /**
  136545. * Adds all the elements from the container to the scene
  136546. * @param container the container holding the elements
  136547. */
  136548. addFromContainer(container: AbstractScene): void;
  136549. /**
  136550. * Removes all the elements in the container from the scene
  136551. * @param container contains the elements to remove
  136552. * @param dispose if the removed element should be disposed (default: false)
  136553. */
  136554. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136555. /**
  136556. * Disposes the component and the associated ressources.
  136557. */
  136558. dispose(): void;
  136559. private _isReadyForMesh;
  136560. private _renderMainTexture;
  136561. private _setStencil;
  136562. private _setStencilBack;
  136563. private _draw;
  136564. private _drawCamera;
  136565. private _drawRenderingGroup;
  136566. }
  136567. }
  136568. declare module BABYLON {
  136569. /** @hidden */
  136570. export var glowMapMergePixelShader: {
  136571. name: string;
  136572. shader: string;
  136573. };
  136574. }
  136575. declare module BABYLON {
  136576. /** @hidden */
  136577. export var glowMapMergeVertexShader: {
  136578. name: string;
  136579. shader: string;
  136580. };
  136581. }
  136582. declare module BABYLON {
  136583. interface AbstractScene {
  136584. /**
  136585. * Return a the first highlight layer of the scene with a given name.
  136586. * @param name The name of the highlight layer to look for.
  136587. * @return The highlight layer if found otherwise null.
  136588. */
  136589. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  136590. }
  136591. /**
  136592. * Glow layer options. This helps customizing the behaviour
  136593. * of the glow layer.
  136594. */
  136595. export interface IGlowLayerOptions {
  136596. /**
  136597. * Multiplication factor apply to the canvas size to compute the render target size
  136598. * used to generated the glowing objects (the smaller the faster).
  136599. */
  136600. mainTextureRatio: number;
  136601. /**
  136602. * Enforces a fixed size texture to ensure resize independant blur.
  136603. */
  136604. mainTextureFixedSize?: number;
  136605. /**
  136606. * How big is the kernel of the blur texture.
  136607. */
  136608. blurKernelSize: number;
  136609. /**
  136610. * The camera attached to the layer.
  136611. */
  136612. camera: Nullable<Camera>;
  136613. /**
  136614. * Enable MSAA by chosing the number of samples.
  136615. */
  136616. mainTextureSamples?: number;
  136617. /**
  136618. * The rendering group to draw the layer in.
  136619. */
  136620. renderingGroupId: number;
  136621. }
  136622. /**
  136623. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  136624. *
  136625. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  136626. *
  136627. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  136628. */
  136629. export class GlowLayer extends EffectLayer {
  136630. /**
  136631. * Effect Name of the layer.
  136632. */
  136633. static readonly EffectName: string;
  136634. /**
  136635. * The default blur kernel size used for the glow.
  136636. */
  136637. static DefaultBlurKernelSize: number;
  136638. /**
  136639. * The default texture size ratio used for the glow.
  136640. */
  136641. static DefaultTextureRatio: number;
  136642. /**
  136643. * Sets the kernel size of the blur.
  136644. */
  136645. set blurKernelSize(value: number);
  136646. /**
  136647. * Gets the kernel size of the blur.
  136648. */
  136649. get blurKernelSize(): number;
  136650. /**
  136651. * Sets the glow intensity.
  136652. */
  136653. set intensity(value: number);
  136654. /**
  136655. * Gets the glow intensity.
  136656. */
  136657. get intensity(): number;
  136658. private _options;
  136659. private _intensity;
  136660. private _horizontalBlurPostprocess1;
  136661. private _verticalBlurPostprocess1;
  136662. private _horizontalBlurPostprocess2;
  136663. private _verticalBlurPostprocess2;
  136664. private _blurTexture1;
  136665. private _blurTexture2;
  136666. private _postProcesses1;
  136667. private _postProcesses2;
  136668. private _includedOnlyMeshes;
  136669. private _excludedMeshes;
  136670. private _meshesUsingTheirOwnMaterials;
  136671. /**
  136672. * Callback used to let the user override the color selection on a per mesh basis
  136673. */
  136674. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  136675. /**
  136676. * Callback used to let the user override the texture selection on a per mesh basis
  136677. */
  136678. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  136679. /**
  136680. * Instantiates a new glow Layer and references it to the scene.
  136681. * @param name The name of the layer
  136682. * @param scene The scene to use the layer in
  136683. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  136684. */
  136685. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  136686. /**
  136687. * Get the effect name of the layer.
  136688. * @return The effect name
  136689. */
  136690. getEffectName(): string;
  136691. /**
  136692. * Create the merge effect. This is the shader use to blit the information back
  136693. * to the main canvas at the end of the scene rendering.
  136694. */
  136695. protected _createMergeEffect(): Effect;
  136696. /**
  136697. * Creates the render target textures and post processes used in the glow layer.
  136698. */
  136699. protected _createTextureAndPostProcesses(): void;
  136700. /**
  136701. * Checks for the readiness of the element composing the layer.
  136702. * @param subMesh the mesh to check for
  136703. * @param useInstances specify wether or not to use instances to render the mesh
  136704. * @param emissiveTexture the associated emissive texture used to generate the glow
  136705. * @return true if ready otherwise, false
  136706. */
  136707. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136708. /**
  136709. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  136710. */
  136711. needStencil(): boolean;
  136712. /**
  136713. * Returns true if the mesh can be rendered, otherwise false.
  136714. * @param mesh The mesh to render
  136715. * @param material The material used on the mesh
  136716. * @returns true if it can be rendered otherwise false
  136717. */
  136718. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  136719. /**
  136720. * Implementation specific of rendering the generating effect on the main canvas.
  136721. * @param effect The effect used to render through
  136722. */
  136723. protected _internalRender(effect: Effect): void;
  136724. /**
  136725. * Sets the required values for both the emissive texture and and the main color.
  136726. */
  136727. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  136728. /**
  136729. * Returns true if the mesh should render, otherwise false.
  136730. * @param mesh The mesh to render
  136731. * @returns true if it should render otherwise false
  136732. */
  136733. protected _shouldRenderMesh(mesh: Mesh): boolean;
  136734. /**
  136735. * Adds specific effects defines.
  136736. * @param defines The defines to add specifics to.
  136737. */
  136738. protected _addCustomEffectDefines(defines: string[]): void;
  136739. /**
  136740. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  136741. * @param mesh The mesh to exclude from the glow layer
  136742. */
  136743. addExcludedMesh(mesh: Mesh): void;
  136744. /**
  136745. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  136746. * @param mesh The mesh to remove
  136747. */
  136748. removeExcludedMesh(mesh: Mesh): void;
  136749. /**
  136750. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  136751. * @param mesh The mesh to include in the glow layer
  136752. */
  136753. addIncludedOnlyMesh(mesh: Mesh): void;
  136754. /**
  136755. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  136756. * @param mesh The mesh to remove
  136757. */
  136758. removeIncludedOnlyMesh(mesh: Mesh): void;
  136759. /**
  136760. * Determine if a given mesh will be used in the glow layer
  136761. * @param mesh The mesh to test
  136762. * @returns true if the mesh will be highlighted by the current glow layer
  136763. */
  136764. hasMesh(mesh: AbstractMesh): boolean;
  136765. /**
  136766. * Defines whether the current material of the mesh should be use to render the effect.
  136767. * @param mesh defines the current mesh to render
  136768. */
  136769. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  136770. /**
  136771. * Add a mesh to be rendered through its own material and not with emissive only.
  136772. * @param mesh The mesh for which we need to use its material
  136773. */
  136774. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  136775. /**
  136776. * Remove a mesh from being rendered through its own material and not with emissive only.
  136777. * @param mesh The mesh for which we need to not use its material
  136778. */
  136779. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  136780. /**
  136781. * Free any resources and references associated to a mesh.
  136782. * Internal use
  136783. * @param mesh The mesh to free.
  136784. * @hidden
  136785. */
  136786. _disposeMesh(mesh: Mesh): void;
  136787. /**
  136788. * Gets the class name of the effect layer
  136789. * @returns the string with the class name of the effect layer
  136790. */
  136791. getClassName(): string;
  136792. /**
  136793. * Serializes this glow layer
  136794. * @returns a serialized glow layer object
  136795. */
  136796. serialize(): any;
  136797. /**
  136798. * Creates a Glow Layer from parsed glow layer data
  136799. * @param parsedGlowLayer defines glow layer data
  136800. * @param scene defines the current scene
  136801. * @param rootUrl defines the root URL containing the glow layer information
  136802. * @returns a parsed Glow Layer
  136803. */
  136804. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  136805. }
  136806. }
  136807. declare module BABYLON {
  136808. /** @hidden */
  136809. export var glowBlurPostProcessPixelShader: {
  136810. name: string;
  136811. shader: string;
  136812. };
  136813. }
  136814. declare module BABYLON {
  136815. interface AbstractScene {
  136816. /**
  136817. * Return a the first highlight layer of the scene with a given name.
  136818. * @param name The name of the highlight layer to look for.
  136819. * @return The highlight layer if found otherwise null.
  136820. */
  136821. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  136822. }
  136823. /**
  136824. * Highlight layer options. This helps customizing the behaviour
  136825. * of the highlight layer.
  136826. */
  136827. export interface IHighlightLayerOptions {
  136828. /**
  136829. * Multiplication factor apply to the canvas size to compute the render target size
  136830. * used to generated the glowing objects (the smaller the faster).
  136831. */
  136832. mainTextureRatio: number;
  136833. /**
  136834. * Enforces a fixed size texture to ensure resize independant blur.
  136835. */
  136836. mainTextureFixedSize?: number;
  136837. /**
  136838. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  136839. * of the picture to blur (the smaller the faster).
  136840. */
  136841. blurTextureSizeRatio: number;
  136842. /**
  136843. * How big in texel of the blur texture is the vertical blur.
  136844. */
  136845. blurVerticalSize: number;
  136846. /**
  136847. * How big in texel of the blur texture is the horizontal blur.
  136848. */
  136849. blurHorizontalSize: number;
  136850. /**
  136851. * Alpha blending mode used to apply the blur. Default is combine.
  136852. */
  136853. alphaBlendingMode: number;
  136854. /**
  136855. * The camera attached to the layer.
  136856. */
  136857. camera: Nullable<Camera>;
  136858. /**
  136859. * Should we display highlight as a solid stroke?
  136860. */
  136861. isStroke?: boolean;
  136862. /**
  136863. * The rendering group to draw the layer in.
  136864. */
  136865. renderingGroupId: number;
  136866. }
  136867. /**
  136868. * The highlight layer Helps adding a glow effect around a mesh.
  136869. *
  136870. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  136871. * glowy meshes to your scene.
  136872. *
  136873. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  136874. */
  136875. export class HighlightLayer extends EffectLayer {
  136876. name: string;
  136877. /**
  136878. * Effect Name of the highlight layer.
  136879. */
  136880. static readonly EffectName: string;
  136881. /**
  136882. * The neutral color used during the preparation of the glow effect.
  136883. * This is black by default as the blend operation is a blend operation.
  136884. */
  136885. static NeutralColor: Color4;
  136886. /**
  136887. * Stencil value used for glowing meshes.
  136888. */
  136889. static GlowingMeshStencilReference: number;
  136890. /**
  136891. * Stencil value used for the other meshes in the scene.
  136892. */
  136893. static NormalMeshStencilReference: number;
  136894. /**
  136895. * Specifies whether or not the inner glow is ACTIVE in the layer.
  136896. */
  136897. innerGlow: boolean;
  136898. /**
  136899. * Specifies whether or not the outer glow is ACTIVE in the layer.
  136900. */
  136901. outerGlow: boolean;
  136902. /**
  136903. * Specifies the horizontal size of the blur.
  136904. */
  136905. set blurHorizontalSize(value: number);
  136906. /**
  136907. * Specifies the vertical size of the blur.
  136908. */
  136909. set blurVerticalSize(value: number);
  136910. /**
  136911. * Gets the horizontal size of the blur.
  136912. */
  136913. get blurHorizontalSize(): number;
  136914. /**
  136915. * Gets the vertical size of the blur.
  136916. */
  136917. get blurVerticalSize(): number;
  136918. /**
  136919. * An event triggered when the highlight layer is being blurred.
  136920. */
  136921. onBeforeBlurObservable: Observable<HighlightLayer>;
  136922. /**
  136923. * An event triggered when the highlight layer has been blurred.
  136924. */
  136925. onAfterBlurObservable: Observable<HighlightLayer>;
  136926. private _instanceGlowingMeshStencilReference;
  136927. private _options;
  136928. private _downSamplePostprocess;
  136929. private _horizontalBlurPostprocess;
  136930. private _verticalBlurPostprocess;
  136931. private _blurTexture;
  136932. private _meshes;
  136933. private _excludedMeshes;
  136934. /**
  136935. * Instantiates a new highlight Layer and references it to the scene..
  136936. * @param name The name of the layer
  136937. * @param scene The scene to use the layer in
  136938. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  136939. */
  136940. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  136941. /**
  136942. * Get the effect name of the layer.
  136943. * @return The effect name
  136944. */
  136945. getEffectName(): string;
  136946. /**
  136947. * Create the merge effect. This is the shader use to blit the information back
  136948. * to the main canvas at the end of the scene rendering.
  136949. */
  136950. protected _createMergeEffect(): Effect;
  136951. /**
  136952. * Creates the render target textures and post processes used in the highlight layer.
  136953. */
  136954. protected _createTextureAndPostProcesses(): void;
  136955. /**
  136956. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  136957. */
  136958. needStencil(): boolean;
  136959. /**
  136960. * Checks for the readiness of the element composing the layer.
  136961. * @param subMesh the mesh to check for
  136962. * @param useInstances specify wether or not to use instances to render the mesh
  136963. * @param emissiveTexture the associated emissive texture used to generate the glow
  136964. * @return true if ready otherwise, false
  136965. */
  136966. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136967. /**
  136968. * Implementation specific of rendering the generating effect on the main canvas.
  136969. * @param effect The effect used to render through
  136970. */
  136971. protected _internalRender(effect: Effect): void;
  136972. /**
  136973. * Returns true if the layer contains information to display, otherwise false.
  136974. */
  136975. shouldRender(): boolean;
  136976. /**
  136977. * Returns true if the mesh should render, otherwise false.
  136978. * @param mesh The mesh to render
  136979. * @returns true if it should render otherwise false
  136980. */
  136981. protected _shouldRenderMesh(mesh: Mesh): boolean;
  136982. /**
  136983. * Returns true if the mesh can be rendered, otherwise false.
  136984. * @param mesh The mesh to render
  136985. * @param material The material used on the mesh
  136986. * @returns true if it can be rendered otherwise false
  136987. */
  136988. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  136989. /**
  136990. * Adds specific effects defines.
  136991. * @param defines The defines to add specifics to.
  136992. */
  136993. protected _addCustomEffectDefines(defines: string[]): void;
  136994. /**
  136995. * Sets the required values for both the emissive texture and and the main color.
  136996. */
  136997. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  136998. /**
  136999. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  137000. * @param mesh The mesh to exclude from the highlight layer
  137001. */
  137002. addExcludedMesh(mesh: Mesh): void;
  137003. /**
  137004. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  137005. * @param mesh The mesh to highlight
  137006. */
  137007. removeExcludedMesh(mesh: Mesh): void;
  137008. /**
  137009. * Determine if a given mesh will be highlighted by the current HighlightLayer
  137010. * @param mesh mesh to test
  137011. * @returns true if the mesh will be highlighted by the current HighlightLayer
  137012. */
  137013. hasMesh(mesh: AbstractMesh): boolean;
  137014. /**
  137015. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  137016. * @param mesh The mesh to highlight
  137017. * @param color The color of the highlight
  137018. * @param glowEmissiveOnly Extract the glow from the emissive texture
  137019. */
  137020. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  137021. /**
  137022. * Remove a mesh from the highlight layer in order to make it stop glowing.
  137023. * @param mesh The mesh to highlight
  137024. */
  137025. removeMesh(mesh: Mesh): void;
  137026. /**
  137027. * Remove all the meshes currently referenced in the highlight layer
  137028. */
  137029. removeAllMeshes(): void;
  137030. /**
  137031. * Force the stencil to the normal expected value for none glowing parts
  137032. */
  137033. private _defaultStencilReference;
  137034. /**
  137035. * Free any resources and references associated to a mesh.
  137036. * Internal use
  137037. * @param mesh The mesh to free.
  137038. * @hidden
  137039. */
  137040. _disposeMesh(mesh: Mesh): void;
  137041. /**
  137042. * Dispose the highlight layer and free resources.
  137043. */
  137044. dispose(): void;
  137045. /**
  137046. * Gets the class name of the effect layer
  137047. * @returns the string with the class name of the effect layer
  137048. */
  137049. getClassName(): string;
  137050. /**
  137051. * Serializes this Highlight layer
  137052. * @returns a serialized Highlight layer object
  137053. */
  137054. serialize(): any;
  137055. /**
  137056. * Creates a Highlight layer from parsed Highlight layer data
  137057. * @param parsedHightlightLayer defines the Highlight layer data
  137058. * @param scene defines the current scene
  137059. * @param rootUrl defines the root URL containing the Highlight layer information
  137060. * @returns a parsed Highlight layer
  137061. */
  137062. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  137063. }
  137064. }
  137065. declare module BABYLON {
  137066. interface AbstractScene {
  137067. /**
  137068. * The list of layers (background and foreground) of the scene
  137069. */
  137070. layers: Array<Layer>;
  137071. }
  137072. /**
  137073. * Defines the layer scene component responsible to manage any layers
  137074. * in a given scene.
  137075. */
  137076. export class LayerSceneComponent implements ISceneComponent {
  137077. /**
  137078. * The component name helpfull to identify the component in the list of scene components.
  137079. */
  137080. readonly name: string;
  137081. /**
  137082. * The scene the component belongs to.
  137083. */
  137084. scene: Scene;
  137085. private _engine;
  137086. /**
  137087. * Creates a new instance of the component for the given scene
  137088. * @param scene Defines the scene to register the component in
  137089. */
  137090. constructor(scene: Scene);
  137091. /**
  137092. * Registers the component in a given scene
  137093. */
  137094. register(): void;
  137095. /**
  137096. * Rebuilds the elements related to this component in case of
  137097. * context lost for instance.
  137098. */
  137099. rebuild(): void;
  137100. /**
  137101. * Disposes the component and the associated ressources.
  137102. */
  137103. dispose(): void;
  137104. private _draw;
  137105. private _drawCameraPredicate;
  137106. private _drawCameraBackground;
  137107. private _drawCameraForeground;
  137108. private _drawRenderTargetPredicate;
  137109. private _drawRenderTargetBackground;
  137110. private _drawRenderTargetForeground;
  137111. /**
  137112. * Adds all the elements from the container to the scene
  137113. * @param container the container holding the elements
  137114. */
  137115. addFromContainer(container: AbstractScene): void;
  137116. /**
  137117. * Removes all the elements in the container from the scene
  137118. * @param container contains the elements to remove
  137119. * @param dispose if the removed element should be disposed (default: false)
  137120. */
  137121. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137122. }
  137123. }
  137124. declare module BABYLON {
  137125. /** @hidden */
  137126. export var layerPixelShader: {
  137127. name: string;
  137128. shader: string;
  137129. };
  137130. }
  137131. declare module BABYLON {
  137132. /** @hidden */
  137133. export var layerVertexShader: {
  137134. name: string;
  137135. shader: string;
  137136. };
  137137. }
  137138. declare module BABYLON {
  137139. /**
  137140. * This represents a full screen 2d layer.
  137141. * This can be useful to display a picture in the background of your scene for instance.
  137142. * @see https://www.babylonjs-playground.com/#08A2BS#1
  137143. */
  137144. export class Layer {
  137145. /**
  137146. * Define the name of the layer.
  137147. */
  137148. name: string;
  137149. /**
  137150. * Define the texture the layer should display.
  137151. */
  137152. texture: Nullable<Texture>;
  137153. /**
  137154. * Is the layer in background or foreground.
  137155. */
  137156. isBackground: boolean;
  137157. /**
  137158. * Define the color of the layer (instead of texture).
  137159. */
  137160. color: Color4;
  137161. /**
  137162. * Define the scale of the layer in order to zoom in out of the texture.
  137163. */
  137164. scale: Vector2;
  137165. /**
  137166. * Define an offset for the layer in order to shift the texture.
  137167. */
  137168. offset: Vector2;
  137169. /**
  137170. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  137171. */
  137172. alphaBlendingMode: number;
  137173. /**
  137174. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  137175. * Alpha test will not mix with the background color in case of transparency.
  137176. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  137177. */
  137178. alphaTest: boolean;
  137179. /**
  137180. * Define a mask to restrict the layer to only some of the scene cameras.
  137181. */
  137182. layerMask: number;
  137183. /**
  137184. * Define the list of render target the layer is visible into.
  137185. */
  137186. renderTargetTextures: RenderTargetTexture[];
  137187. /**
  137188. * Define if the layer is only used in renderTarget or if it also
  137189. * renders in the main frame buffer of the canvas.
  137190. */
  137191. renderOnlyInRenderTargetTextures: boolean;
  137192. private _scene;
  137193. private _vertexBuffers;
  137194. private _indexBuffer;
  137195. private _effect;
  137196. private _previousDefines;
  137197. /**
  137198. * An event triggered when the layer is disposed.
  137199. */
  137200. onDisposeObservable: Observable<Layer>;
  137201. private _onDisposeObserver;
  137202. /**
  137203. * Back compatibility with callback before the onDisposeObservable existed.
  137204. * The set callback will be triggered when the layer has been disposed.
  137205. */
  137206. set onDispose(callback: () => void);
  137207. /**
  137208. * An event triggered before rendering the scene
  137209. */
  137210. onBeforeRenderObservable: Observable<Layer>;
  137211. private _onBeforeRenderObserver;
  137212. /**
  137213. * Back compatibility with callback before the onBeforeRenderObservable existed.
  137214. * The set callback will be triggered just before rendering the layer.
  137215. */
  137216. set onBeforeRender(callback: () => void);
  137217. /**
  137218. * An event triggered after rendering the scene
  137219. */
  137220. onAfterRenderObservable: Observable<Layer>;
  137221. private _onAfterRenderObserver;
  137222. /**
  137223. * Back compatibility with callback before the onAfterRenderObservable existed.
  137224. * The set callback will be triggered just after rendering the layer.
  137225. */
  137226. set onAfterRender(callback: () => void);
  137227. /**
  137228. * Instantiates a new layer.
  137229. * This represents a full screen 2d layer.
  137230. * This can be useful to display a picture in the background of your scene for instance.
  137231. * @see https://www.babylonjs-playground.com/#08A2BS#1
  137232. * @param name Define the name of the layer in the scene
  137233. * @param imgUrl Define the url of the texture to display in the layer
  137234. * @param scene Define the scene the layer belongs to
  137235. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  137236. * @param color Defines a color for the layer
  137237. */
  137238. constructor(
  137239. /**
  137240. * Define the name of the layer.
  137241. */
  137242. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  137243. private _createIndexBuffer;
  137244. /** @hidden */
  137245. _rebuild(): void;
  137246. /**
  137247. * Renders the layer in the scene.
  137248. */
  137249. render(): void;
  137250. /**
  137251. * Disposes and releases the associated ressources.
  137252. */
  137253. dispose(): void;
  137254. }
  137255. }
  137256. declare module BABYLON {
  137257. /** @hidden */
  137258. export var lensFlarePixelShader: {
  137259. name: string;
  137260. shader: string;
  137261. };
  137262. }
  137263. declare module BABYLON {
  137264. /** @hidden */
  137265. export var lensFlareVertexShader: {
  137266. name: string;
  137267. shader: string;
  137268. };
  137269. }
  137270. declare module BABYLON {
  137271. /**
  137272. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  137273. * It is usually composed of several `lensFlare`.
  137274. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137275. */
  137276. export class LensFlareSystem {
  137277. /**
  137278. * Define the name of the lens flare system
  137279. */
  137280. name: string;
  137281. /**
  137282. * List of lens flares used in this system.
  137283. */
  137284. lensFlares: LensFlare[];
  137285. /**
  137286. * Define a limit from the border the lens flare can be visible.
  137287. */
  137288. borderLimit: number;
  137289. /**
  137290. * Define a viewport border we do not want to see the lens flare in.
  137291. */
  137292. viewportBorder: number;
  137293. /**
  137294. * Define a predicate which could limit the list of meshes able to occlude the effect.
  137295. */
  137296. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  137297. /**
  137298. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  137299. */
  137300. layerMask: number;
  137301. /**
  137302. * Define the id of the lens flare system in the scene.
  137303. * (equal to name by default)
  137304. */
  137305. id: string;
  137306. private _scene;
  137307. private _emitter;
  137308. private _vertexBuffers;
  137309. private _indexBuffer;
  137310. private _effect;
  137311. private _positionX;
  137312. private _positionY;
  137313. private _isEnabled;
  137314. /** @hidden */
  137315. static _SceneComponentInitialization: (scene: Scene) => void;
  137316. /**
  137317. * Instantiates a lens flare system.
  137318. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  137319. * It is usually composed of several `lensFlare`.
  137320. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137321. * @param name Define the name of the lens flare system in the scene
  137322. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  137323. * @param scene Define the scene the lens flare system belongs to
  137324. */
  137325. constructor(
  137326. /**
  137327. * Define the name of the lens flare system
  137328. */
  137329. name: string, emitter: any, scene: Scene);
  137330. /**
  137331. * Define if the lens flare system is enabled.
  137332. */
  137333. get isEnabled(): boolean;
  137334. set isEnabled(value: boolean);
  137335. /**
  137336. * Get the scene the effects belongs to.
  137337. * @returns the scene holding the lens flare system
  137338. */
  137339. getScene(): Scene;
  137340. /**
  137341. * Get the emitter of the lens flare system.
  137342. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  137343. * @returns the emitter of the lens flare system
  137344. */
  137345. getEmitter(): any;
  137346. /**
  137347. * Set the emitter of the lens flare system.
  137348. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  137349. * @param newEmitter Define the new emitter of the system
  137350. */
  137351. setEmitter(newEmitter: any): void;
  137352. /**
  137353. * Get the lens flare system emitter position.
  137354. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  137355. * @returns the position
  137356. */
  137357. getEmitterPosition(): Vector3;
  137358. /**
  137359. * @hidden
  137360. */
  137361. computeEffectivePosition(globalViewport: Viewport): boolean;
  137362. /** @hidden */
  137363. _isVisible(): boolean;
  137364. /**
  137365. * @hidden
  137366. */
  137367. render(): boolean;
  137368. /**
  137369. * Dispose and release the lens flare with its associated resources.
  137370. */
  137371. dispose(): void;
  137372. /**
  137373. * Parse a lens flare system from a JSON repressentation
  137374. * @param parsedLensFlareSystem Define the JSON to parse
  137375. * @param scene Define the scene the parsed system should be instantiated in
  137376. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  137377. * @returns the parsed system
  137378. */
  137379. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  137380. /**
  137381. * Serialize the current Lens Flare System into a JSON representation.
  137382. * @returns the serialized JSON
  137383. */
  137384. serialize(): any;
  137385. }
  137386. }
  137387. declare module BABYLON {
  137388. /**
  137389. * This represents one of the lens effect in a `lensFlareSystem`.
  137390. * It controls one of the indiviual texture used in the effect.
  137391. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137392. */
  137393. export class LensFlare {
  137394. /**
  137395. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  137396. */
  137397. size: number;
  137398. /**
  137399. * 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.
  137400. */
  137401. position: number;
  137402. /**
  137403. * Define the lens color.
  137404. */
  137405. color: Color3;
  137406. /**
  137407. * Define the lens texture.
  137408. */
  137409. texture: Nullable<Texture>;
  137410. /**
  137411. * Define the alpha mode to render this particular lens.
  137412. */
  137413. alphaMode: number;
  137414. private _system;
  137415. /**
  137416. * Creates a new Lens Flare.
  137417. * This represents one of the lens effect in a `lensFlareSystem`.
  137418. * It controls one of the indiviual texture used in the effect.
  137419. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137420. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  137421. * @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.
  137422. * @param color Define the lens color
  137423. * @param imgUrl Define the lens texture url
  137424. * @param system Define the `lensFlareSystem` this flare is part of
  137425. * @returns The newly created Lens Flare
  137426. */
  137427. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  137428. /**
  137429. * Instantiates a new Lens Flare.
  137430. * This represents one of the lens effect in a `lensFlareSystem`.
  137431. * It controls one of the indiviual texture used in the effect.
  137432. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137433. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  137434. * @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.
  137435. * @param color Define the lens color
  137436. * @param imgUrl Define the lens texture url
  137437. * @param system Define the `lensFlareSystem` this flare is part of
  137438. */
  137439. constructor(
  137440. /**
  137441. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  137442. */
  137443. size: number,
  137444. /**
  137445. * 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.
  137446. */
  137447. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  137448. /**
  137449. * Dispose and release the lens flare with its associated resources.
  137450. */
  137451. dispose(): void;
  137452. }
  137453. }
  137454. declare module BABYLON {
  137455. interface AbstractScene {
  137456. /**
  137457. * The list of lens flare system added to the scene
  137458. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137459. */
  137460. lensFlareSystems: Array<LensFlareSystem>;
  137461. /**
  137462. * Removes the given lens flare system from this scene.
  137463. * @param toRemove The lens flare system to remove
  137464. * @returns The index of the removed lens flare system
  137465. */
  137466. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  137467. /**
  137468. * Adds the given lens flare system to this scene
  137469. * @param newLensFlareSystem The lens flare system to add
  137470. */
  137471. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  137472. /**
  137473. * Gets a lens flare system using its name
  137474. * @param name defines the name to look for
  137475. * @returns the lens flare system or null if not found
  137476. */
  137477. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  137478. /**
  137479. * Gets a lens flare system using its id
  137480. * @param id defines the id to look for
  137481. * @returns the lens flare system or null if not found
  137482. */
  137483. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  137484. }
  137485. /**
  137486. * Defines the lens flare scene component responsible to manage any lens flares
  137487. * in a given scene.
  137488. */
  137489. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  137490. /**
  137491. * The component name helpfull to identify the component in the list of scene components.
  137492. */
  137493. readonly name: string;
  137494. /**
  137495. * The scene the component belongs to.
  137496. */
  137497. scene: Scene;
  137498. /**
  137499. * Creates a new instance of the component for the given scene
  137500. * @param scene Defines the scene to register the component in
  137501. */
  137502. constructor(scene: Scene);
  137503. /**
  137504. * Registers the component in a given scene
  137505. */
  137506. register(): void;
  137507. /**
  137508. * Rebuilds the elements related to this component in case of
  137509. * context lost for instance.
  137510. */
  137511. rebuild(): void;
  137512. /**
  137513. * Adds all the elements from the container to the scene
  137514. * @param container the container holding the elements
  137515. */
  137516. addFromContainer(container: AbstractScene): void;
  137517. /**
  137518. * Removes all the elements in the container from the scene
  137519. * @param container contains the elements to remove
  137520. * @param dispose if the removed element should be disposed (default: false)
  137521. */
  137522. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137523. /**
  137524. * Serializes the component data to the specified json object
  137525. * @param serializationObject The object to serialize to
  137526. */
  137527. serialize(serializationObject: any): void;
  137528. /**
  137529. * Disposes the component and the associated ressources.
  137530. */
  137531. dispose(): void;
  137532. private _draw;
  137533. }
  137534. }
  137535. declare module BABYLON {
  137536. /** @hidden */
  137537. export var depthPixelShader: {
  137538. name: string;
  137539. shader: string;
  137540. };
  137541. }
  137542. declare module BABYLON {
  137543. /** @hidden */
  137544. export var depthVertexShader: {
  137545. name: string;
  137546. shader: string;
  137547. };
  137548. }
  137549. declare module BABYLON {
  137550. /**
  137551. * This represents a depth renderer in Babylon.
  137552. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  137553. */
  137554. export class DepthRenderer {
  137555. private _scene;
  137556. private _depthMap;
  137557. private _effect;
  137558. private readonly _storeNonLinearDepth;
  137559. private readonly _clearColor;
  137560. /** Get if the depth renderer is using packed depth or not */
  137561. readonly isPacked: boolean;
  137562. private _cachedDefines;
  137563. private _camera;
  137564. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  137565. enabled: boolean;
  137566. /**
  137567. * Specifiess that the depth renderer will only be used within
  137568. * the camera it is created for.
  137569. * This can help forcing its rendering during the camera processing.
  137570. */
  137571. useOnlyInActiveCamera: boolean;
  137572. /** @hidden */
  137573. static _SceneComponentInitialization: (scene: Scene) => void;
  137574. /**
  137575. * Instantiates a depth renderer
  137576. * @param scene The scene the renderer belongs to
  137577. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  137578. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  137579. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  137580. */
  137581. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  137582. /**
  137583. * Creates the depth rendering effect and checks if the effect is ready.
  137584. * @param subMesh The submesh to be used to render the depth map of
  137585. * @param useInstances If multiple world instances should be used
  137586. * @returns if the depth renderer is ready to render the depth map
  137587. */
  137588. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137589. /**
  137590. * Gets the texture which the depth map will be written to.
  137591. * @returns The depth map texture
  137592. */
  137593. getDepthMap(): RenderTargetTexture;
  137594. /**
  137595. * Disposes of the depth renderer.
  137596. */
  137597. dispose(): void;
  137598. }
  137599. }
  137600. declare module BABYLON {
  137601. /** @hidden */
  137602. export var minmaxReduxPixelShader: {
  137603. name: string;
  137604. shader: string;
  137605. };
  137606. }
  137607. declare module BABYLON {
  137608. /**
  137609. * This class computes a min/max reduction from a texture: it means it computes the minimum
  137610. * and maximum values from all values of the texture.
  137611. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  137612. * The source values are read from the red channel of the texture.
  137613. */
  137614. export class MinMaxReducer {
  137615. /**
  137616. * Observable triggered when the computation has been performed
  137617. */
  137618. onAfterReductionPerformed: Observable<{
  137619. min: number;
  137620. max: number;
  137621. }>;
  137622. protected _camera: Camera;
  137623. protected _sourceTexture: Nullable<RenderTargetTexture>;
  137624. protected _reductionSteps: Nullable<Array<PostProcess>>;
  137625. protected _postProcessManager: PostProcessManager;
  137626. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  137627. protected _forceFullscreenViewport: boolean;
  137628. /**
  137629. * Creates a min/max reducer
  137630. * @param camera The camera to use for the post processes
  137631. */
  137632. constructor(camera: Camera);
  137633. /**
  137634. * Gets the texture used to read the values from.
  137635. */
  137636. get sourceTexture(): Nullable<RenderTargetTexture>;
  137637. /**
  137638. * Sets the source texture to read the values from.
  137639. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  137640. * because in such textures '1' value must not be taken into account to compute the maximum
  137641. * as this value is used to clear the texture.
  137642. * Note that the computation is not activated by calling this function, you must call activate() for that!
  137643. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  137644. * @param depthRedux Indicates if the texture is a depth texture or not
  137645. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  137646. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  137647. */
  137648. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  137649. /**
  137650. * Defines the refresh rate of the computation.
  137651. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  137652. */
  137653. get refreshRate(): number;
  137654. set refreshRate(value: number);
  137655. protected _activated: boolean;
  137656. /**
  137657. * Gets the activation status of the reducer
  137658. */
  137659. get activated(): boolean;
  137660. /**
  137661. * Activates the reduction computation.
  137662. * When activated, the observers registered in onAfterReductionPerformed are
  137663. * called after the compuation is performed
  137664. */
  137665. activate(): void;
  137666. /**
  137667. * Deactivates the reduction computation.
  137668. */
  137669. deactivate(): void;
  137670. /**
  137671. * Disposes the min/max reducer
  137672. * @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.
  137673. */
  137674. dispose(disposeAll?: boolean): void;
  137675. }
  137676. }
  137677. declare module BABYLON {
  137678. /**
  137679. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  137680. */
  137681. export class DepthReducer extends MinMaxReducer {
  137682. private _depthRenderer;
  137683. private _depthRendererId;
  137684. /**
  137685. * Gets the depth renderer used for the computation.
  137686. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  137687. */
  137688. get depthRenderer(): Nullable<DepthRenderer>;
  137689. /**
  137690. * Creates a depth reducer
  137691. * @param camera The camera used to render the depth texture
  137692. */
  137693. constructor(camera: Camera);
  137694. /**
  137695. * Sets the depth renderer to use to generate the depth map
  137696. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  137697. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  137698. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  137699. */
  137700. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  137701. /** @hidden */
  137702. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  137703. /**
  137704. * Activates the reduction computation.
  137705. * When activated, the observers registered in onAfterReductionPerformed are
  137706. * called after the compuation is performed
  137707. */
  137708. activate(): void;
  137709. /**
  137710. * Deactivates the reduction computation.
  137711. */
  137712. deactivate(): void;
  137713. /**
  137714. * Disposes the depth reducer
  137715. * @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.
  137716. */
  137717. dispose(disposeAll?: boolean): void;
  137718. }
  137719. }
  137720. declare module BABYLON {
  137721. /**
  137722. * A CSM implementation allowing casting shadows on large scenes.
  137723. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  137724. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  137725. */
  137726. export class CascadedShadowGenerator extends ShadowGenerator {
  137727. private static readonly frustumCornersNDCSpace;
  137728. /**
  137729. * Name of the CSM class
  137730. */
  137731. static CLASSNAME: string;
  137732. /**
  137733. * Defines the default number of cascades used by the CSM.
  137734. */
  137735. static readonly DEFAULT_CASCADES_COUNT: number;
  137736. /**
  137737. * Defines the minimum number of cascades used by the CSM.
  137738. */
  137739. static readonly MIN_CASCADES_COUNT: number;
  137740. /**
  137741. * Defines the maximum number of cascades used by the CSM.
  137742. */
  137743. static readonly MAX_CASCADES_COUNT: number;
  137744. protected _validateFilter(filter: number): number;
  137745. /**
  137746. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  137747. */
  137748. penumbraDarkness: number;
  137749. private _numCascades;
  137750. /**
  137751. * Gets or set the number of cascades used by the CSM.
  137752. */
  137753. get numCascades(): number;
  137754. set numCascades(value: number);
  137755. /**
  137756. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  137757. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  137758. */
  137759. stabilizeCascades: boolean;
  137760. private _freezeShadowCastersBoundingInfo;
  137761. private _freezeShadowCastersBoundingInfoObservable;
  137762. /**
  137763. * Enables or disables the shadow casters bounding info computation.
  137764. * If your shadow casters don't move, you can disable this feature.
  137765. * If it is enabled, the bounding box computation is done every frame.
  137766. */
  137767. get freezeShadowCastersBoundingInfo(): boolean;
  137768. set freezeShadowCastersBoundingInfo(freeze: boolean);
  137769. private _scbiMin;
  137770. private _scbiMax;
  137771. protected _computeShadowCastersBoundingInfo(): void;
  137772. protected _shadowCastersBoundingInfo: BoundingInfo;
  137773. /**
  137774. * Gets or sets the shadow casters bounding info.
  137775. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  137776. * so that the system won't overwrite the bounds you provide
  137777. */
  137778. get shadowCastersBoundingInfo(): BoundingInfo;
  137779. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  137780. protected _breaksAreDirty: boolean;
  137781. protected _minDistance: number;
  137782. protected _maxDistance: number;
  137783. /**
  137784. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  137785. *
  137786. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  137787. * If you don't know these values, simply leave them to their defaults and don't call this function.
  137788. * @param min minimal distance for the breaks (default to 0.)
  137789. * @param max maximal distance for the breaks (default to 1.)
  137790. */
  137791. setMinMaxDistance(min: number, max: number): void;
  137792. /** Gets the minimal distance used in the cascade break computation */
  137793. get minDistance(): number;
  137794. /** Gets the maximal distance used in the cascade break computation */
  137795. get maxDistance(): number;
  137796. /**
  137797. * Gets the class name of that object
  137798. * @returns "CascadedShadowGenerator"
  137799. */
  137800. getClassName(): string;
  137801. private _cascadeMinExtents;
  137802. private _cascadeMaxExtents;
  137803. /**
  137804. * Gets a cascade minimum extents
  137805. * @param cascadeIndex index of the cascade
  137806. * @returns the minimum cascade extents
  137807. */
  137808. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  137809. /**
  137810. * Gets a cascade maximum extents
  137811. * @param cascadeIndex index of the cascade
  137812. * @returns the maximum cascade extents
  137813. */
  137814. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  137815. private _cascades;
  137816. private _currentLayer;
  137817. private _viewSpaceFrustumsZ;
  137818. private _viewMatrices;
  137819. private _projectionMatrices;
  137820. private _transformMatrices;
  137821. private _transformMatricesAsArray;
  137822. private _frustumLengths;
  137823. private _lightSizeUVCorrection;
  137824. private _depthCorrection;
  137825. private _frustumCornersWorldSpace;
  137826. private _frustumCenter;
  137827. private _shadowCameraPos;
  137828. private _shadowMaxZ;
  137829. /**
  137830. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  137831. * It defaults to camera.maxZ
  137832. */
  137833. get shadowMaxZ(): number;
  137834. /**
  137835. * Sets the shadow max z distance.
  137836. */
  137837. set shadowMaxZ(value: number);
  137838. protected _debug: boolean;
  137839. /**
  137840. * Gets or sets the debug flag.
  137841. * When enabled, the cascades are materialized by different colors on the screen.
  137842. */
  137843. get debug(): boolean;
  137844. set debug(dbg: boolean);
  137845. private _depthClamp;
  137846. /**
  137847. * Gets or sets the depth clamping value.
  137848. *
  137849. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  137850. * to account for the shadow casters far away.
  137851. *
  137852. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  137853. */
  137854. get depthClamp(): boolean;
  137855. set depthClamp(value: boolean);
  137856. private _cascadeBlendPercentage;
  137857. /**
  137858. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  137859. * It defaults to 0.1 (10% blending).
  137860. */
  137861. get cascadeBlendPercentage(): number;
  137862. set cascadeBlendPercentage(value: number);
  137863. private _lambda;
  137864. /**
  137865. * Gets or set the lambda parameter.
  137866. * This parameter is used to split the camera frustum and create the cascades.
  137867. * 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.
  137868. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  137869. */
  137870. get lambda(): number;
  137871. set lambda(value: number);
  137872. /**
  137873. * Gets the view matrix corresponding to a given cascade
  137874. * @param cascadeNum cascade to retrieve the view matrix from
  137875. * @returns the cascade view matrix
  137876. */
  137877. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  137878. /**
  137879. * Gets the projection matrix corresponding to a given cascade
  137880. * @param cascadeNum cascade to retrieve the projection matrix from
  137881. * @returns the cascade projection matrix
  137882. */
  137883. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  137884. /**
  137885. * Gets the transformation matrix corresponding to a given cascade
  137886. * @param cascadeNum cascade to retrieve the transformation matrix from
  137887. * @returns the cascade transformation matrix
  137888. */
  137889. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  137890. private _depthRenderer;
  137891. /**
  137892. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  137893. *
  137894. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  137895. *
  137896. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  137897. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  137898. * @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
  137899. */
  137900. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  137901. private _depthReducer;
  137902. private _autoCalcDepthBounds;
  137903. /**
  137904. * Gets or sets the autoCalcDepthBounds property.
  137905. *
  137906. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  137907. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  137908. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  137909. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  137910. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  137911. */
  137912. get autoCalcDepthBounds(): boolean;
  137913. set autoCalcDepthBounds(value: boolean);
  137914. /**
  137915. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  137916. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  137917. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  137918. * for setting the refresh rate on the renderer yourself!
  137919. */
  137920. get autoCalcDepthBoundsRefreshRate(): number;
  137921. set autoCalcDepthBoundsRefreshRate(value: number);
  137922. /**
  137923. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  137924. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  137925. * you change the camera near/far planes!
  137926. */
  137927. splitFrustum(): void;
  137928. private _splitFrustum;
  137929. private _computeMatrices;
  137930. private _computeFrustumInWorldSpace;
  137931. private _computeCascadeFrustum;
  137932. /**
  137933. * Support test.
  137934. */
  137935. static get IsSupported(): boolean;
  137936. /** @hidden */
  137937. static _SceneComponentInitialization: (scene: Scene) => void;
  137938. /**
  137939. * Creates a Cascaded Shadow Generator object.
  137940. * A ShadowGenerator is the required tool to use the shadows.
  137941. * Each directional light casting shadows needs to use its own ShadowGenerator.
  137942. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  137943. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  137944. * @param light The directional light object generating the shadows.
  137945. * @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.
  137946. */
  137947. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  137948. protected _initializeGenerator(): void;
  137949. protected _createTargetRenderTexture(): void;
  137950. protected _initializeShadowMap(): void;
  137951. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  137952. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  137953. /**
  137954. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  137955. * @param defines Defines of the material we want to update
  137956. * @param lightIndex Index of the light in the enabled light list of the material
  137957. */
  137958. prepareDefines(defines: any, lightIndex: number): void;
  137959. /**
  137960. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  137961. * defined in the generator but impacting the effect).
  137962. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  137963. * @param effect The effect we are binfing the information for
  137964. */
  137965. bindShadowLight(lightIndex: string, effect: Effect): void;
  137966. /**
  137967. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  137968. * (eq to view projection * shadow projection matrices)
  137969. * @returns The transform matrix used to create the shadow map
  137970. */
  137971. getTransformMatrix(): Matrix;
  137972. /**
  137973. * Disposes the ShadowGenerator.
  137974. * Returns nothing.
  137975. */
  137976. dispose(): void;
  137977. /**
  137978. * Serializes the shadow generator setup to a json object.
  137979. * @returns The serialized JSON object
  137980. */
  137981. serialize(): any;
  137982. /**
  137983. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  137984. * @param parsedShadowGenerator The JSON object to parse
  137985. * @param scene The scene to create the shadow map for
  137986. * @returns The parsed shadow generator
  137987. */
  137988. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  137989. }
  137990. }
  137991. declare module BABYLON {
  137992. /**
  137993. * Defines the shadow generator component responsible to manage any shadow generators
  137994. * in a given scene.
  137995. */
  137996. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  137997. /**
  137998. * The component name helpfull to identify the component in the list of scene components.
  137999. */
  138000. readonly name: string;
  138001. /**
  138002. * The scene the component belongs to.
  138003. */
  138004. scene: Scene;
  138005. /**
  138006. * Creates a new instance of the component for the given scene
  138007. * @param scene Defines the scene to register the component in
  138008. */
  138009. constructor(scene: Scene);
  138010. /**
  138011. * Registers the component in a given scene
  138012. */
  138013. register(): void;
  138014. /**
  138015. * Rebuilds the elements related to this component in case of
  138016. * context lost for instance.
  138017. */
  138018. rebuild(): void;
  138019. /**
  138020. * Serializes the component data to the specified json object
  138021. * @param serializationObject The object to serialize to
  138022. */
  138023. serialize(serializationObject: any): void;
  138024. /**
  138025. * Adds all the elements from the container to the scene
  138026. * @param container the container holding the elements
  138027. */
  138028. addFromContainer(container: AbstractScene): void;
  138029. /**
  138030. * Removes all the elements in the container from the scene
  138031. * @param container contains the elements to remove
  138032. * @param dispose if the removed element should be disposed (default: false)
  138033. */
  138034. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138035. /**
  138036. * Rebuilds the elements related to this component in case of
  138037. * context lost for instance.
  138038. */
  138039. dispose(): void;
  138040. private _gatherRenderTargets;
  138041. }
  138042. }
  138043. declare module BABYLON {
  138044. /**
  138045. * A point light is a light defined by an unique point in world space.
  138046. * The light is emitted in every direction from this point.
  138047. * A good example of a point light is a standard light bulb.
  138048. * Documentation: https://doc.babylonjs.com/babylon101/lights
  138049. */
  138050. export class PointLight extends ShadowLight {
  138051. private _shadowAngle;
  138052. /**
  138053. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138054. * This specifies what angle the shadow will use to be created.
  138055. *
  138056. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  138057. */
  138058. get shadowAngle(): number;
  138059. /**
  138060. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138061. * This specifies what angle the shadow will use to be created.
  138062. *
  138063. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  138064. */
  138065. set shadowAngle(value: number);
  138066. /**
  138067. * Gets the direction if it has been set.
  138068. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138069. */
  138070. get direction(): Vector3;
  138071. /**
  138072. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138073. */
  138074. set direction(value: Vector3);
  138075. /**
  138076. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  138077. * A PointLight emits the light in every direction.
  138078. * It can cast shadows.
  138079. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  138080. * ```javascript
  138081. * var pointLight = new PointLight("pl", camera.position, scene);
  138082. * ```
  138083. * Documentation : https://doc.babylonjs.com/babylon101/lights
  138084. * @param name The light friendly name
  138085. * @param position The position of the point light in the scene
  138086. * @param scene The scene the lights belongs to
  138087. */
  138088. constructor(name: string, position: Vector3, scene: Scene);
  138089. /**
  138090. * Returns the string "PointLight"
  138091. * @returns the class name
  138092. */
  138093. getClassName(): string;
  138094. /**
  138095. * Returns the integer 0.
  138096. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  138097. */
  138098. getTypeID(): number;
  138099. /**
  138100. * Specifies wether or not the shadowmap should be a cube texture.
  138101. * @returns true if the shadowmap needs to be a cube texture.
  138102. */
  138103. needCube(): boolean;
  138104. /**
  138105. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  138106. * @param faceIndex The index of the face we are computed the direction to generate shadow
  138107. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  138108. */
  138109. getShadowDirection(faceIndex?: number): Vector3;
  138110. /**
  138111. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  138112. * - fov = PI / 2
  138113. * - aspect ratio : 1.0
  138114. * - z-near and far equal to the active camera minZ and maxZ.
  138115. * Returns the PointLight.
  138116. */
  138117. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138118. protected _buildUniformLayout(): void;
  138119. /**
  138120. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  138121. * @param effect The effect to update
  138122. * @param lightIndex The index of the light in the effect to update
  138123. * @returns The point light
  138124. */
  138125. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  138126. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  138127. /**
  138128. * Prepares the list of defines specific to the light type.
  138129. * @param defines the list of defines
  138130. * @param lightIndex defines the index of the light for the effect
  138131. */
  138132. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  138133. }
  138134. }
  138135. declare module BABYLON {
  138136. /**
  138137. * Header information of HDR texture files.
  138138. */
  138139. export interface HDRInfo {
  138140. /**
  138141. * The height of the texture in pixels.
  138142. */
  138143. height: number;
  138144. /**
  138145. * The width of the texture in pixels.
  138146. */
  138147. width: number;
  138148. /**
  138149. * The index of the beginning of the data in the binary file.
  138150. */
  138151. dataPosition: number;
  138152. }
  138153. /**
  138154. * This groups tools to convert HDR texture to native colors array.
  138155. */
  138156. export class HDRTools {
  138157. private static Ldexp;
  138158. private static Rgbe2float;
  138159. private static readStringLine;
  138160. /**
  138161. * Reads header information from an RGBE texture stored in a native array.
  138162. * More information on this format are available here:
  138163. * https://en.wikipedia.org/wiki/RGBE_image_format
  138164. *
  138165. * @param uint8array The binary file stored in native array.
  138166. * @return The header information.
  138167. */
  138168. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  138169. /**
  138170. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  138171. * This RGBE texture needs to store the information as a panorama.
  138172. *
  138173. * More information on this format are available here:
  138174. * https://en.wikipedia.org/wiki/RGBE_image_format
  138175. *
  138176. * @param buffer The binary file stored in an array buffer.
  138177. * @param size The expected size of the extracted cubemap.
  138178. * @return The Cube Map information.
  138179. */
  138180. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  138181. /**
  138182. * Returns the pixels data extracted from an RGBE texture.
  138183. * This pixels will be stored left to right up to down in the R G B order in one array.
  138184. *
  138185. * More information on this format are available here:
  138186. * https://en.wikipedia.org/wiki/RGBE_image_format
  138187. *
  138188. * @param uint8array The binary file stored in an array buffer.
  138189. * @param hdrInfo The header information of the file.
  138190. * @return The pixels data in RGB right to left up to down order.
  138191. */
  138192. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  138193. private static RGBE_ReadPixels_RLE;
  138194. private static RGBE_ReadPixels_NOT_RLE;
  138195. }
  138196. }
  138197. declare module BABYLON {
  138198. /**
  138199. * Effect Render Options
  138200. */
  138201. export interface IEffectRendererOptions {
  138202. /**
  138203. * Defines the vertices positions.
  138204. */
  138205. positions?: number[];
  138206. /**
  138207. * Defines the indices.
  138208. */
  138209. indices?: number[];
  138210. }
  138211. /**
  138212. * Helper class to render one or more effects.
  138213. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  138214. */
  138215. export class EffectRenderer {
  138216. private engine;
  138217. private static _DefaultOptions;
  138218. private _vertexBuffers;
  138219. private _indexBuffer;
  138220. private _fullscreenViewport;
  138221. /**
  138222. * Creates an effect renderer
  138223. * @param engine the engine to use for rendering
  138224. * @param options defines the options of the effect renderer
  138225. */
  138226. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  138227. /**
  138228. * Sets the current viewport in normalized coordinates 0-1
  138229. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  138230. */
  138231. setViewport(viewport?: Viewport): void;
  138232. /**
  138233. * Binds the embedded attributes buffer to the effect.
  138234. * @param effect Defines the effect to bind the attributes for
  138235. */
  138236. bindBuffers(effect: Effect): void;
  138237. /**
  138238. * Sets the current effect wrapper to use during draw.
  138239. * The effect needs to be ready before calling this api.
  138240. * This also sets the default full screen position attribute.
  138241. * @param effectWrapper Defines the effect to draw with
  138242. */
  138243. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  138244. /**
  138245. * Restores engine states
  138246. */
  138247. restoreStates(): void;
  138248. /**
  138249. * Draws a full screen quad.
  138250. */
  138251. draw(): void;
  138252. private isRenderTargetTexture;
  138253. /**
  138254. * renders one or more effects to a specified texture
  138255. * @param effectWrapper the effect to renderer
  138256. * @param outputTexture texture to draw to, if null it will render to the screen.
  138257. */
  138258. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  138259. /**
  138260. * Disposes of the effect renderer
  138261. */
  138262. dispose(): void;
  138263. }
  138264. /**
  138265. * Options to create an EffectWrapper
  138266. */
  138267. interface EffectWrapperCreationOptions {
  138268. /**
  138269. * Engine to use to create the effect
  138270. */
  138271. engine: ThinEngine;
  138272. /**
  138273. * Fragment shader for the effect
  138274. */
  138275. fragmentShader: string;
  138276. /**
  138277. * Use the shader store instead of direct source code
  138278. */
  138279. useShaderStore?: boolean;
  138280. /**
  138281. * Vertex shader for the effect
  138282. */
  138283. vertexShader?: string;
  138284. /**
  138285. * Attributes to use in the shader
  138286. */
  138287. attributeNames?: Array<string>;
  138288. /**
  138289. * Uniforms to use in the shader
  138290. */
  138291. uniformNames?: Array<string>;
  138292. /**
  138293. * Texture sampler names to use in the shader
  138294. */
  138295. samplerNames?: Array<string>;
  138296. /**
  138297. * Defines to use in the shader
  138298. */
  138299. defines?: Array<string>;
  138300. /**
  138301. * Callback when effect is compiled
  138302. */
  138303. onCompiled?: Nullable<(effect: Effect) => void>;
  138304. /**
  138305. * The friendly name of the effect displayed in Spector.
  138306. */
  138307. name?: string;
  138308. }
  138309. /**
  138310. * Wraps an effect to be used for rendering
  138311. */
  138312. export class EffectWrapper {
  138313. /**
  138314. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  138315. */
  138316. onApplyObservable: Observable<{}>;
  138317. /**
  138318. * The underlying effect
  138319. */
  138320. effect: Effect;
  138321. /**
  138322. * Creates an effect to be renderer
  138323. * @param creationOptions options to create the effect
  138324. */
  138325. constructor(creationOptions: EffectWrapperCreationOptions);
  138326. /**
  138327. * Disposes of the effect wrapper
  138328. */
  138329. dispose(): void;
  138330. }
  138331. }
  138332. declare module BABYLON {
  138333. /** @hidden */
  138334. export var hdrFilteringVertexShader: {
  138335. name: string;
  138336. shader: string;
  138337. };
  138338. }
  138339. declare module BABYLON {
  138340. /** @hidden */
  138341. export var hdrFilteringPixelShader: {
  138342. name: string;
  138343. shader: string;
  138344. };
  138345. }
  138346. declare module BABYLON {
  138347. /**
  138348. * Options for texture filtering
  138349. */
  138350. interface IHDRFilteringOptions {
  138351. /**
  138352. * Scales pixel intensity for the input HDR map.
  138353. */
  138354. hdrScale?: number;
  138355. /**
  138356. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  138357. */
  138358. quality?: number;
  138359. }
  138360. /**
  138361. * Filters HDR maps to get correct renderings of PBR reflections
  138362. */
  138363. export class HDRFiltering {
  138364. private _engine;
  138365. private _effectRenderer;
  138366. private _effectWrapper;
  138367. private _lodGenerationOffset;
  138368. private _lodGenerationScale;
  138369. /**
  138370. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  138371. * you care about baking speed.
  138372. */
  138373. quality: number;
  138374. /**
  138375. * Scales pixel intensity for the input HDR map.
  138376. */
  138377. hdrScale: number;
  138378. /**
  138379. * Instantiates HDR filter for reflection maps
  138380. *
  138381. * @param engine Thin engine
  138382. * @param options Options
  138383. */
  138384. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  138385. private _createRenderTarget;
  138386. private _prefilterInternal;
  138387. private _createEffect;
  138388. /**
  138389. * Get a value indicating if the filter is ready to be used
  138390. * @param texture Texture to filter
  138391. * @returns true if the filter is ready
  138392. */
  138393. isReady(texture: BaseTexture): boolean;
  138394. /**
  138395. * Prefilters a cube texture to have mipmap levels representing roughness values.
  138396. * Prefiltering will be invoked at the end of next rendering pass.
  138397. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  138398. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  138399. * @param texture Texture to filter
  138400. * @param onFinished Callback when filtering is done
  138401. * @return Promise called when prefiltering is done
  138402. */
  138403. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  138404. }
  138405. }
  138406. declare module BABYLON {
  138407. /**
  138408. * This represents a texture coming from an HDR input.
  138409. *
  138410. * The only supported format is currently panorama picture stored in RGBE format.
  138411. * Example of such files can be found on HDRLib: http://hdrlib.com/
  138412. */
  138413. export class HDRCubeTexture extends BaseTexture {
  138414. private static _facesMapping;
  138415. private _generateHarmonics;
  138416. private _noMipmap;
  138417. private _prefilterOnLoad;
  138418. private _textureMatrix;
  138419. private _size;
  138420. private _onLoad;
  138421. private _onError;
  138422. /**
  138423. * The texture URL.
  138424. */
  138425. url: string;
  138426. /**
  138427. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  138428. */
  138429. coordinatesMode: number;
  138430. protected _isBlocking: boolean;
  138431. /**
  138432. * Sets wether or not the texture is blocking during loading.
  138433. */
  138434. set isBlocking(value: boolean);
  138435. /**
  138436. * Gets wether or not the texture is blocking during loading.
  138437. */
  138438. get isBlocking(): boolean;
  138439. protected _rotationY: number;
  138440. /**
  138441. * Sets texture matrix rotation angle around Y axis in radians.
  138442. */
  138443. set rotationY(value: number);
  138444. /**
  138445. * Gets texture matrix rotation angle around Y axis radians.
  138446. */
  138447. get rotationY(): number;
  138448. /**
  138449. * Gets or sets the center of the bounding box associated with the cube texture
  138450. * It must define where the camera used to render the texture was set
  138451. */
  138452. boundingBoxPosition: Vector3;
  138453. private _boundingBoxSize;
  138454. /**
  138455. * Gets or sets the size of the bounding box associated with the cube texture
  138456. * When defined, the cubemap will switch to local mode
  138457. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  138458. * @example https://www.babylonjs-playground.com/#RNASML
  138459. */
  138460. set boundingBoxSize(value: Vector3);
  138461. get boundingBoxSize(): Vector3;
  138462. /**
  138463. * Instantiates an HDRTexture from the following parameters.
  138464. *
  138465. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  138466. * @param sceneOrEngine The scene or engine the texture will be used in
  138467. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  138468. * @param noMipmap Forces to not generate the mipmap if true
  138469. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  138470. * @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)
  138471. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  138472. */
  138473. 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>);
  138474. /**
  138475. * Get the current class name of the texture useful for serialization or dynamic coding.
  138476. * @returns "HDRCubeTexture"
  138477. */
  138478. getClassName(): string;
  138479. /**
  138480. * Occurs when the file is raw .hdr file.
  138481. */
  138482. private loadTexture;
  138483. clone(): HDRCubeTexture;
  138484. delayLoad(): void;
  138485. /**
  138486. * Get the texture reflection matrix used to rotate/transform the reflection.
  138487. * @returns the reflection matrix
  138488. */
  138489. getReflectionTextureMatrix(): Matrix;
  138490. /**
  138491. * Set the texture reflection matrix used to rotate/transform the reflection.
  138492. * @param value Define the reflection matrix to set
  138493. */
  138494. setReflectionTextureMatrix(value: Matrix): void;
  138495. /**
  138496. * Parses a JSON representation of an HDR Texture in order to create the texture
  138497. * @param parsedTexture Define the JSON representation
  138498. * @param scene Define the scene the texture should be created in
  138499. * @param rootUrl Define the root url in case we need to load relative dependencies
  138500. * @returns the newly created texture after parsing
  138501. */
  138502. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  138503. serialize(): any;
  138504. }
  138505. }
  138506. declare module BABYLON {
  138507. /**
  138508. * Class used to control physics engine
  138509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  138510. */
  138511. export class PhysicsEngine implements IPhysicsEngine {
  138512. private _physicsPlugin;
  138513. /**
  138514. * Global value used to control the smallest number supported by the simulation
  138515. */
  138516. static Epsilon: number;
  138517. private _impostors;
  138518. private _joints;
  138519. private _subTimeStep;
  138520. /**
  138521. * Gets the gravity vector used by the simulation
  138522. */
  138523. gravity: Vector3;
  138524. /**
  138525. * Factory used to create the default physics plugin.
  138526. * @returns The default physics plugin
  138527. */
  138528. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  138529. /**
  138530. * Creates a new Physics Engine
  138531. * @param gravity defines the gravity vector used by the simulation
  138532. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  138533. */
  138534. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  138535. /**
  138536. * Sets the gravity vector used by the simulation
  138537. * @param gravity defines the gravity vector to use
  138538. */
  138539. setGravity(gravity: Vector3): void;
  138540. /**
  138541. * Set the time step of the physics engine.
  138542. * Default is 1/60.
  138543. * To slow it down, enter 1/600 for example.
  138544. * To speed it up, 1/30
  138545. * @param newTimeStep defines the new timestep to apply to this world.
  138546. */
  138547. setTimeStep(newTimeStep?: number): void;
  138548. /**
  138549. * Get the time step of the physics engine.
  138550. * @returns the current time step
  138551. */
  138552. getTimeStep(): number;
  138553. /**
  138554. * Set the sub time step of the physics engine.
  138555. * Default is 0 meaning there is no sub steps
  138556. * To increase physics resolution precision, set a small value (like 1 ms)
  138557. * @param subTimeStep defines the new sub timestep used for physics resolution.
  138558. */
  138559. setSubTimeStep(subTimeStep?: number): void;
  138560. /**
  138561. * Get the sub time step of the physics engine.
  138562. * @returns the current sub time step
  138563. */
  138564. getSubTimeStep(): number;
  138565. /**
  138566. * Release all resources
  138567. */
  138568. dispose(): void;
  138569. /**
  138570. * Gets the name of the current physics plugin
  138571. * @returns the name of the plugin
  138572. */
  138573. getPhysicsPluginName(): string;
  138574. /**
  138575. * Adding a new impostor for the impostor tracking.
  138576. * This will be done by the impostor itself.
  138577. * @param impostor the impostor to add
  138578. */
  138579. addImpostor(impostor: PhysicsImpostor): void;
  138580. /**
  138581. * Remove an impostor from the engine.
  138582. * This impostor and its mesh will not longer be updated by the physics engine.
  138583. * @param impostor the impostor to remove
  138584. */
  138585. removeImpostor(impostor: PhysicsImpostor): void;
  138586. /**
  138587. * Add a joint to the physics engine
  138588. * @param mainImpostor defines the main impostor to which the joint is added.
  138589. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  138590. * @param joint defines the joint that will connect both impostors.
  138591. */
  138592. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  138593. /**
  138594. * Removes a joint from the simulation
  138595. * @param mainImpostor defines the impostor used with the joint
  138596. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  138597. * @param joint defines the joint to remove
  138598. */
  138599. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  138600. /**
  138601. * Called by the scene. No need to call it.
  138602. * @param delta defines the timespam between frames
  138603. */
  138604. _step(delta: number): void;
  138605. /**
  138606. * Gets the current plugin used to run the simulation
  138607. * @returns current plugin
  138608. */
  138609. getPhysicsPlugin(): IPhysicsEnginePlugin;
  138610. /**
  138611. * Gets the list of physic impostors
  138612. * @returns an array of PhysicsImpostor
  138613. */
  138614. getImpostors(): Array<PhysicsImpostor>;
  138615. /**
  138616. * Gets the impostor for a physics enabled object
  138617. * @param object defines the object impersonated by the impostor
  138618. * @returns the PhysicsImpostor or null if not found
  138619. */
  138620. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  138621. /**
  138622. * Gets the impostor for a physics body object
  138623. * @param body defines physics body used by the impostor
  138624. * @returns the PhysicsImpostor or null if not found
  138625. */
  138626. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  138627. /**
  138628. * Does a raycast in the physics world
  138629. * @param from when should the ray start?
  138630. * @param to when should the ray end?
  138631. * @returns PhysicsRaycastResult
  138632. */
  138633. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  138634. }
  138635. }
  138636. declare module BABYLON {
  138637. /** @hidden */
  138638. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  138639. private _useDeltaForWorldStep;
  138640. world: any;
  138641. name: string;
  138642. private _physicsMaterials;
  138643. private _fixedTimeStep;
  138644. private _cannonRaycastResult;
  138645. private _raycastResult;
  138646. private _physicsBodysToRemoveAfterStep;
  138647. private _firstFrame;
  138648. BJSCANNON: any;
  138649. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  138650. setGravity(gravity: Vector3): void;
  138651. setTimeStep(timeStep: number): void;
  138652. getTimeStep(): number;
  138653. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  138654. private _removeMarkedPhysicsBodiesFromWorld;
  138655. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138656. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138657. generatePhysicsBody(impostor: PhysicsImpostor): void;
  138658. private _processChildMeshes;
  138659. removePhysicsBody(impostor: PhysicsImpostor): void;
  138660. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  138661. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  138662. private _addMaterial;
  138663. private _checkWithEpsilon;
  138664. private _createShape;
  138665. private _createHeightmap;
  138666. private _minus90X;
  138667. private _plus90X;
  138668. private _tmpPosition;
  138669. private _tmpDeltaPosition;
  138670. private _tmpUnityRotation;
  138671. private _updatePhysicsBodyTransformation;
  138672. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  138673. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  138674. isSupported(): boolean;
  138675. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138676. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138677. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138678. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138679. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  138680. getBodyMass(impostor: PhysicsImpostor): number;
  138681. getBodyFriction(impostor: PhysicsImpostor): number;
  138682. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  138683. getBodyRestitution(impostor: PhysicsImpostor): number;
  138684. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  138685. sleepBody(impostor: PhysicsImpostor): void;
  138686. wakeUpBody(impostor: PhysicsImpostor): void;
  138687. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  138688. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  138689. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  138690. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  138691. getRadius(impostor: PhysicsImpostor): number;
  138692. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  138693. dispose(): void;
  138694. private _extendNamespace;
  138695. /**
  138696. * Does a raycast in the physics world
  138697. * @param from when should the ray start?
  138698. * @param to when should the ray end?
  138699. * @returns PhysicsRaycastResult
  138700. */
  138701. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  138702. }
  138703. }
  138704. declare module BABYLON {
  138705. /** @hidden */
  138706. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  138707. private _useDeltaForWorldStep;
  138708. world: any;
  138709. name: string;
  138710. BJSOIMO: any;
  138711. private _raycastResult;
  138712. private _fixedTimeStep;
  138713. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  138714. setGravity(gravity: Vector3): void;
  138715. setTimeStep(timeStep: number): void;
  138716. getTimeStep(): number;
  138717. private _tmpImpostorsArray;
  138718. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  138719. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138720. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138721. generatePhysicsBody(impostor: PhysicsImpostor): void;
  138722. private _tmpPositionVector;
  138723. removePhysicsBody(impostor: PhysicsImpostor): void;
  138724. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  138725. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  138726. isSupported(): boolean;
  138727. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  138728. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  138729. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138730. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138731. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138732. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138733. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  138734. getBodyMass(impostor: PhysicsImpostor): number;
  138735. getBodyFriction(impostor: PhysicsImpostor): number;
  138736. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  138737. getBodyRestitution(impostor: PhysicsImpostor): number;
  138738. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  138739. sleepBody(impostor: PhysicsImpostor): void;
  138740. wakeUpBody(impostor: PhysicsImpostor): void;
  138741. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  138742. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  138743. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  138744. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  138745. getRadius(impostor: PhysicsImpostor): number;
  138746. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  138747. dispose(): void;
  138748. /**
  138749. * Does a raycast in the physics world
  138750. * @param from when should the ray start?
  138751. * @param to when should the ray end?
  138752. * @returns PhysicsRaycastResult
  138753. */
  138754. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  138755. }
  138756. }
  138757. declare module BABYLON {
  138758. /**
  138759. * Class containing static functions to help procedurally build meshes
  138760. */
  138761. export class RibbonBuilder {
  138762. /**
  138763. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  138764. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  138765. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  138766. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  138767. * * 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
  138768. * * 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
  138769. * * 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
  138770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138772. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138773. * * 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
  138774. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  138775. * * 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
  138776. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  138777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138778. * @param name defines the name of the mesh
  138779. * @param options defines the options used to create the mesh
  138780. * @param scene defines the hosting scene
  138781. * @returns the ribbon mesh
  138782. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  138783. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138784. */
  138785. static CreateRibbon(name: string, options: {
  138786. pathArray: Vector3[][];
  138787. closeArray?: boolean;
  138788. closePath?: boolean;
  138789. offset?: number;
  138790. updatable?: boolean;
  138791. sideOrientation?: number;
  138792. frontUVs?: Vector4;
  138793. backUVs?: Vector4;
  138794. instance?: Mesh;
  138795. invertUV?: boolean;
  138796. uvs?: Vector2[];
  138797. colors?: Color4[];
  138798. }, scene?: Nullable<Scene>): Mesh;
  138799. }
  138800. }
  138801. declare module BABYLON {
  138802. /**
  138803. * Class containing static functions to help procedurally build meshes
  138804. */
  138805. export class ShapeBuilder {
  138806. /**
  138807. * 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.
  138808. * * 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.
  138809. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  138810. * * 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.
  138811. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  138812. * * 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
  138813. * * 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
  138814. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  138815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138816. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138817. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  138818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138819. * @param name defines the name of the mesh
  138820. * @param options defines the options used to create the mesh
  138821. * @param scene defines the hosting scene
  138822. * @returns the extruded shape mesh
  138823. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138824. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  138825. */
  138826. static ExtrudeShape(name: string, options: {
  138827. shape: Vector3[];
  138828. path: Vector3[];
  138829. scale?: number;
  138830. rotation?: number;
  138831. cap?: number;
  138832. updatable?: boolean;
  138833. sideOrientation?: number;
  138834. frontUVs?: Vector4;
  138835. backUVs?: Vector4;
  138836. instance?: Mesh;
  138837. invertUV?: boolean;
  138838. }, scene?: Nullable<Scene>): Mesh;
  138839. /**
  138840. * Creates an custom extruded shape mesh.
  138841. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  138842. * * 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.
  138843. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  138844. * * 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
  138845. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  138846. * * 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
  138847. * * It must returns a float value that will be the scale value applied to the shape on each path point
  138848. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  138849. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  138850. * * 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
  138851. * * 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
  138852. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  138853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138854. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138855. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138857. * @param name defines the name of the mesh
  138858. * @param options defines the options used to create the mesh
  138859. * @param scene defines the hosting scene
  138860. * @returns the custom extruded shape mesh
  138861. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  138862. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138863. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  138864. */
  138865. static ExtrudeShapeCustom(name: string, options: {
  138866. shape: Vector3[];
  138867. path: Vector3[];
  138868. scaleFunction?: any;
  138869. rotationFunction?: any;
  138870. ribbonCloseArray?: boolean;
  138871. ribbonClosePath?: boolean;
  138872. cap?: number;
  138873. updatable?: boolean;
  138874. sideOrientation?: number;
  138875. frontUVs?: Vector4;
  138876. backUVs?: Vector4;
  138877. instance?: Mesh;
  138878. invertUV?: boolean;
  138879. }, scene?: Nullable<Scene>): Mesh;
  138880. private static _ExtrudeShapeGeneric;
  138881. }
  138882. }
  138883. declare module BABYLON {
  138884. /**
  138885. * AmmoJS Physics plugin
  138886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  138887. * @see https://github.com/kripken/ammo.js/
  138888. */
  138889. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  138890. private _useDeltaForWorldStep;
  138891. /**
  138892. * Reference to the Ammo library
  138893. */
  138894. bjsAMMO: any;
  138895. /**
  138896. * Created ammoJS world which physics bodies are added to
  138897. */
  138898. world: any;
  138899. /**
  138900. * Name of the plugin
  138901. */
  138902. name: string;
  138903. private _timeStep;
  138904. private _fixedTimeStep;
  138905. private _maxSteps;
  138906. private _tmpQuaternion;
  138907. private _tmpAmmoTransform;
  138908. private _tmpAmmoQuaternion;
  138909. private _tmpAmmoConcreteContactResultCallback;
  138910. private _collisionConfiguration;
  138911. private _dispatcher;
  138912. private _overlappingPairCache;
  138913. private _solver;
  138914. private _softBodySolver;
  138915. private _tmpAmmoVectorA;
  138916. private _tmpAmmoVectorB;
  138917. private _tmpAmmoVectorC;
  138918. private _tmpAmmoVectorD;
  138919. private _tmpContactCallbackResult;
  138920. private _tmpAmmoVectorRCA;
  138921. private _tmpAmmoVectorRCB;
  138922. private _raycastResult;
  138923. private static readonly DISABLE_COLLISION_FLAG;
  138924. private static readonly KINEMATIC_FLAG;
  138925. private static readonly DISABLE_DEACTIVATION_FLAG;
  138926. /**
  138927. * Initializes the ammoJS plugin
  138928. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  138929. * @param ammoInjection can be used to inject your own ammo reference
  138930. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  138931. */
  138932. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  138933. /**
  138934. * Sets the gravity of the physics world (m/(s^2))
  138935. * @param gravity Gravity to set
  138936. */
  138937. setGravity(gravity: Vector3): void;
  138938. /**
  138939. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  138940. * @param timeStep timestep to use in seconds
  138941. */
  138942. setTimeStep(timeStep: number): void;
  138943. /**
  138944. * 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)
  138945. * @param fixedTimeStep fixedTimeStep to use in seconds
  138946. */
  138947. setFixedTimeStep(fixedTimeStep: number): void;
  138948. /**
  138949. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  138950. * @param maxSteps the maximum number of steps by the physics engine per frame
  138951. */
  138952. setMaxSteps(maxSteps: number): void;
  138953. /**
  138954. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  138955. * @returns the current timestep in seconds
  138956. */
  138957. getTimeStep(): number;
  138958. /**
  138959. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  138960. */
  138961. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  138962. private _isImpostorInContact;
  138963. private _isImpostorPairInContact;
  138964. private _stepSimulation;
  138965. /**
  138966. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  138967. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  138968. * After the step the babylon meshes are set to the position of the physics imposters
  138969. * @param delta amount of time to step forward
  138970. * @param impostors array of imposters to update before/after the step
  138971. */
  138972. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  138973. /**
  138974. * Update babylon mesh to match physics world object
  138975. * @param impostor imposter to match
  138976. */
  138977. private _afterSoftStep;
  138978. /**
  138979. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  138980. * @param impostor imposter to match
  138981. */
  138982. private _ropeStep;
  138983. /**
  138984. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  138985. * @param impostor imposter to match
  138986. */
  138987. private _softbodyOrClothStep;
  138988. private _tmpMatrix;
  138989. /**
  138990. * Applies an impulse on the imposter
  138991. * @param impostor imposter to apply impulse to
  138992. * @param force amount of force to be applied to the imposter
  138993. * @param contactPoint the location to apply the impulse on the imposter
  138994. */
  138995. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138996. /**
  138997. * Applies a force on the imposter
  138998. * @param impostor imposter to apply force
  138999. * @param force amount of force to be applied to the imposter
  139000. * @param contactPoint the location to apply the force on the imposter
  139001. */
  139002. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139003. /**
  139004. * Creates a physics body using the plugin
  139005. * @param impostor the imposter to create the physics body on
  139006. */
  139007. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139008. /**
  139009. * Removes the physics body from the imposter and disposes of the body's memory
  139010. * @param impostor imposter to remove the physics body from
  139011. */
  139012. removePhysicsBody(impostor: PhysicsImpostor): void;
  139013. /**
  139014. * Generates a joint
  139015. * @param impostorJoint the imposter joint to create the joint with
  139016. */
  139017. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139018. /**
  139019. * Removes a joint
  139020. * @param impostorJoint the imposter joint to remove the joint from
  139021. */
  139022. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139023. private _addMeshVerts;
  139024. /**
  139025. * Initialise the soft body vertices to match its object's (mesh) vertices
  139026. * Softbody vertices (nodes) are in world space and to match this
  139027. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  139028. * @param impostor to create the softbody for
  139029. */
  139030. private _softVertexData;
  139031. /**
  139032. * Create an impostor's soft body
  139033. * @param impostor to create the softbody for
  139034. */
  139035. private _createSoftbody;
  139036. /**
  139037. * Create cloth for an impostor
  139038. * @param impostor to create the softbody for
  139039. */
  139040. private _createCloth;
  139041. /**
  139042. * Create rope for an impostor
  139043. * @param impostor to create the softbody for
  139044. */
  139045. private _createRope;
  139046. /**
  139047. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  139048. * @param impostor to create the custom physics shape for
  139049. */
  139050. private _createCustom;
  139051. private _addHullVerts;
  139052. private _createShape;
  139053. /**
  139054. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  139055. * @param impostor imposter containing the physics body and babylon object
  139056. */
  139057. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139058. /**
  139059. * Sets the babylon object's position/rotation from the physics body's position/rotation
  139060. * @param impostor imposter containing the physics body and babylon object
  139061. * @param newPosition new position
  139062. * @param newRotation new rotation
  139063. */
  139064. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139065. /**
  139066. * If this plugin is supported
  139067. * @returns true if its supported
  139068. */
  139069. isSupported(): boolean;
  139070. /**
  139071. * Sets the linear velocity of the physics body
  139072. * @param impostor imposter to set the velocity on
  139073. * @param velocity velocity to set
  139074. */
  139075. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139076. /**
  139077. * Sets the angular velocity of the physics body
  139078. * @param impostor imposter to set the velocity on
  139079. * @param velocity velocity to set
  139080. */
  139081. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139082. /**
  139083. * gets the linear velocity
  139084. * @param impostor imposter to get linear velocity from
  139085. * @returns linear velocity
  139086. */
  139087. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139088. /**
  139089. * gets the angular velocity
  139090. * @param impostor imposter to get angular velocity from
  139091. * @returns angular velocity
  139092. */
  139093. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139094. /**
  139095. * Sets the mass of physics body
  139096. * @param impostor imposter to set the mass on
  139097. * @param mass mass to set
  139098. */
  139099. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139100. /**
  139101. * Gets the mass of the physics body
  139102. * @param impostor imposter to get the mass from
  139103. * @returns mass
  139104. */
  139105. getBodyMass(impostor: PhysicsImpostor): number;
  139106. /**
  139107. * Gets friction of the impostor
  139108. * @param impostor impostor to get friction from
  139109. * @returns friction value
  139110. */
  139111. getBodyFriction(impostor: PhysicsImpostor): number;
  139112. /**
  139113. * Sets friction of the impostor
  139114. * @param impostor impostor to set friction on
  139115. * @param friction friction value
  139116. */
  139117. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139118. /**
  139119. * Gets restitution of the impostor
  139120. * @param impostor impostor to get restitution from
  139121. * @returns restitution value
  139122. */
  139123. getBodyRestitution(impostor: PhysicsImpostor): number;
  139124. /**
  139125. * Sets resitution of the impostor
  139126. * @param impostor impostor to set resitution on
  139127. * @param restitution resitution value
  139128. */
  139129. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139130. /**
  139131. * Gets pressure inside the impostor
  139132. * @param impostor impostor to get pressure from
  139133. * @returns pressure value
  139134. */
  139135. getBodyPressure(impostor: PhysicsImpostor): number;
  139136. /**
  139137. * Sets pressure inside a soft body impostor
  139138. * Cloth and rope must remain 0 pressure
  139139. * @param impostor impostor to set pressure on
  139140. * @param pressure pressure value
  139141. */
  139142. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  139143. /**
  139144. * Gets stiffness of the impostor
  139145. * @param impostor impostor to get stiffness from
  139146. * @returns pressure value
  139147. */
  139148. getBodyStiffness(impostor: PhysicsImpostor): number;
  139149. /**
  139150. * Sets stiffness of the impostor
  139151. * @param impostor impostor to set stiffness on
  139152. * @param stiffness stiffness value from 0 to 1
  139153. */
  139154. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  139155. /**
  139156. * Gets velocityIterations of the impostor
  139157. * @param impostor impostor to get velocity iterations from
  139158. * @returns velocityIterations value
  139159. */
  139160. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  139161. /**
  139162. * Sets velocityIterations of the impostor
  139163. * @param impostor impostor to set velocity iterations on
  139164. * @param velocityIterations velocityIterations value
  139165. */
  139166. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  139167. /**
  139168. * Gets positionIterations of the impostor
  139169. * @param impostor impostor to get position iterations from
  139170. * @returns positionIterations value
  139171. */
  139172. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  139173. /**
  139174. * Sets positionIterations of the impostor
  139175. * @param impostor impostor to set position on
  139176. * @param positionIterations positionIterations value
  139177. */
  139178. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  139179. /**
  139180. * Append an anchor to a cloth object
  139181. * @param impostor is the cloth impostor to add anchor to
  139182. * @param otherImpostor is the rigid impostor to anchor to
  139183. * @param width ratio across width from 0 to 1
  139184. * @param height ratio up height from 0 to 1
  139185. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  139186. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  139187. */
  139188. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  139189. /**
  139190. * Append an hook to a rope object
  139191. * @param impostor is the rope impostor to add hook to
  139192. * @param otherImpostor is the rigid impostor to hook to
  139193. * @param length ratio along the rope from 0 to 1
  139194. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  139195. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  139196. */
  139197. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  139198. /**
  139199. * Sleeps the physics body and stops it from being active
  139200. * @param impostor impostor to sleep
  139201. */
  139202. sleepBody(impostor: PhysicsImpostor): void;
  139203. /**
  139204. * Activates the physics body
  139205. * @param impostor impostor to activate
  139206. */
  139207. wakeUpBody(impostor: PhysicsImpostor): void;
  139208. /**
  139209. * Updates the distance parameters of the joint
  139210. * @param joint joint to update
  139211. * @param maxDistance maximum distance of the joint
  139212. * @param minDistance minimum distance of the joint
  139213. */
  139214. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  139215. /**
  139216. * Sets a motor on the joint
  139217. * @param joint joint to set motor on
  139218. * @param speed speed of the motor
  139219. * @param maxForce maximum force of the motor
  139220. * @param motorIndex index of the motor
  139221. */
  139222. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  139223. /**
  139224. * Sets the motors limit
  139225. * @param joint joint to set limit on
  139226. * @param upperLimit upper limit
  139227. * @param lowerLimit lower limit
  139228. */
  139229. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  139230. /**
  139231. * Syncs the position and rotation of a mesh with the impostor
  139232. * @param mesh mesh to sync
  139233. * @param impostor impostor to update the mesh with
  139234. */
  139235. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139236. /**
  139237. * Gets the radius of the impostor
  139238. * @param impostor impostor to get radius from
  139239. * @returns the radius
  139240. */
  139241. getRadius(impostor: PhysicsImpostor): number;
  139242. /**
  139243. * Gets the box size of the impostor
  139244. * @param impostor impostor to get box size from
  139245. * @param result the resulting box size
  139246. */
  139247. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139248. /**
  139249. * Disposes of the impostor
  139250. */
  139251. dispose(): void;
  139252. /**
  139253. * Does a raycast in the physics world
  139254. * @param from when should the ray start?
  139255. * @param to when should the ray end?
  139256. * @returns PhysicsRaycastResult
  139257. */
  139258. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139259. }
  139260. }
  139261. declare module BABYLON {
  139262. interface AbstractScene {
  139263. /**
  139264. * The list of reflection probes added to the scene
  139265. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  139266. */
  139267. reflectionProbes: Array<ReflectionProbe>;
  139268. /**
  139269. * Removes the given reflection probe from this scene.
  139270. * @param toRemove The reflection probe to remove
  139271. * @returns The index of the removed reflection probe
  139272. */
  139273. removeReflectionProbe(toRemove: ReflectionProbe): number;
  139274. /**
  139275. * Adds the given reflection probe to this scene.
  139276. * @param newReflectionProbe The reflection probe to add
  139277. */
  139278. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  139279. }
  139280. /**
  139281. * Class used to generate realtime reflection / refraction cube textures
  139282. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  139283. */
  139284. export class ReflectionProbe {
  139285. /** defines the name of the probe */
  139286. name: string;
  139287. private _scene;
  139288. private _renderTargetTexture;
  139289. private _projectionMatrix;
  139290. private _viewMatrix;
  139291. private _target;
  139292. private _add;
  139293. private _attachedMesh;
  139294. private _invertYAxis;
  139295. /** Gets or sets probe position (center of the cube map) */
  139296. position: Vector3;
  139297. /**
  139298. * Creates a new reflection probe
  139299. * @param name defines the name of the probe
  139300. * @param size defines the texture resolution (for each face)
  139301. * @param scene defines the hosting scene
  139302. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  139303. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  139304. */
  139305. constructor(
  139306. /** defines the name of the probe */
  139307. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  139308. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  139309. get samples(): number;
  139310. set samples(value: number);
  139311. /** Gets or sets the refresh rate to use (on every frame by default) */
  139312. get refreshRate(): number;
  139313. set refreshRate(value: number);
  139314. /**
  139315. * Gets the hosting scene
  139316. * @returns a Scene
  139317. */
  139318. getScene(): Scene;
  139319. /** Gets the internal CubeTexture used to render to */
  139320. get cubeTexture(): RenderTargetTexture;
  139321. /** Gets the list of meshes to render */
  139322. get renderList(): Nullable<AbstractMesh[]>;
  139323. /**
  139324. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  139325. * @param mesh defines the mesh to attach to
  139326. */
  139327. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  139328. /**
  139329. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  139330. * @param renderingGroupId The rendering group id corresponding to its index
  139331. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  139332. */
  139333. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  139334. /**
  139335. * Clean all associated resources
  139336. */
  139337. dispose(): void;
  139338. /**
  139339. * Converts the reflection probe information to a readable string for debug purpose.
  139340. * @param fullDetails Supports for multiple levels of logging within scene loading
  139341. * @returns the human readable reflection probe info
  139342. */
  139343. toString(fullDetails?: boolean): string;
  139344. /**
  139345. * Get the class name of the relfection probe.
  139346. * @returns "ReflectionProbe"
  139347. */
  139348. getClassName(): string;
  139349. /**
  139350. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  139351. * @returns The JSON representation of the texture
  139352. */
  139353. serialize(): any;
  139354. /**
  139355. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  139356. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  139357. * @param scene Define the scene the parsed reflection probe should be instantiated in
  139358. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  139359. * @returns The parsed reflection probe if successful
  139360. */
  139361. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  139362. }
  139363. }
  139364. declare module BABYLON {
  139365. /** @hidden */
  139366. export var _BabylonLoaderRegistered: boolean;
  139367. /**
  139368. * Helps setting up some configuration for the babylon file loader.
  139369. */
  139370. export class BabylonFileLoaderConfiguration {
  139371. /**
  139372. * The loader does not allow injecting custom physix engine into the plugins.
  139373. * Unfortunately in ES6, we need to manually inject them into the plugin.
  139374. * So you could set this variable to your engine import to make it work.
  139375. */
  139376. static LoaderInjectedPhysicsEngine: any;
  139377. }
  139378. }
  139379. declare module BABYLON {
  139380. /**
  139381. * The Physically based simple base material of BJS.
  139382. *
  139383. * This enables better naming and convention enforcements on top of the pbrMaterial.
  139384. * It is used as the base class for both the specGloss and metalRough conventions.
  139385. */
  139386. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  139387. /**
  139388. * Number of Simultaneous lights allowed on the material.
  139389. */
  139390. maxSimultaneousLights: number;
  139391. /**
  139392. * If sets to true, disables all the lights affecting the material.
  139393. */
  139394. disableLighting: boolean;
  139395. /**
  139396. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  139397. */
  139398. environmentTexture: BaseTexture;
  139399. /**
  139400. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  139401. */
  139402. invertNormalMapX: boolean;
  139403. /**
  139404. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  139405. */
  139406. invertNormalMapY: boolean;
  139407. /**
  139408. * Normal map used in the model.
  139409. */
  139410. normalTexture: BaseTexture;
  139411. /**
  139412. * Emissivie color used to self-illuminate the model.
  139413. */
  139414. emissiveColor: Color3;
  139415. /**
  139416. * Emissivie texture used to self-illuminate the model.
  139417. */
  139418. emissiveTexture: BaseTexture;
  139419. /**
  139420. * Occlusion Channel Strenght.
  139421. */
  139422. occlusionStrength: number;
  139423. /**
  139424. * Occlusion Texture of the material (adding extra occlusion effects).
  139425. */
  139426. occlusionTexture: BaseTexture;
  139427. /**
  139428. * Defines the alpha limits in alpha test mode.
  139429. */
  139430. alphaCutOff: number;
  139431. /**
  139432. * Gets the current double sided mode.
  139433. */
  139434. get doubleSided(): boolean;
  139435. /**
  139436. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  139437. */
  139438. set doubleSided(value: boolean);
  139439. /**
  139440. * Stores the pre-calculated light information of a mesh in a texture.
  139441. */
  139442. lightmapTexture: BaseTexture;
  139443. /**
  139444. * If true, the light map contains occlusion information instead of lighting info.
  139445. */
  139446. useLightmapAsShadowmap: boolean;
  139447. /**
  139448. * Instantiates a new PBRMaterial instance.
  139449. *
  139450. * @param name The material name
  139451. * @param scene The scene the material will be use in.
  139452. */
  139453. constructor(name: string, scene: Scene);
  139454. getClassName(): string;
  139455. }
  139456. }
  139457. declare module BABYLON {
  139458. /**
  139459. * The PBR material of BJS following the metal roughness convention.
  139460. *
  139461. * This fits to the PBR convention in the GLTF definition:
  139462. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  139463. */
  139464. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  139465. /**
  139466. * The base color has two different interpretations depending on the value of metalness.
  139467. * When the material is a metal, the base color is the specific measured reflectance value
  139468. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  139469. * of the material.
  139470. */
  139471. baseColor: Color3;
  139472. /**
  139473. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  139474. * well as opacity information in the alpha channel.
  139475. */
  139476. baseTexture: BaseTexture;
  139477. /**
  139478. * Specifies the metallic scalar value of the material.
  139479. * Can also be used to scale the metalness values of the metallic texture.
  139480. */
  139481. metallic: number;
  139482. /**
  139483. * Specifies the roughness scalar value of the material.
  139484. * Can also be used to scale the roughness values of the metallic texture.
  139485. */
  139486. roughness: number;
  139487. /**
  139488. * Texture containing both the metallic value in the B channel and the
  139489. * roughness value in the G channel to keep better precision.
  139490. */
  139491. metallicRoughnessTexture: BaseTexture;
  139492. /**
  139493. * Instantiates a new PBRMetalRoughnessMaterial instance.
  139494. *
  139495. * @param name The material name
  139496. * @param scene The scene the material will be use in.
  139497. */
  139498. constructor(name: string, scene: Scene);
  139499. /**
  139500. * Return the currrent class name of the material.
  139501. */
  139502. getClassName(): string;
  139503. /**
  139504. * Makes a duplicate of the current material.
  139505. * @param name - name to use for the new material.
  139506. */
  139507. clone(name: string): PBRMetallicRoughnessMaterial;
  139508. /**
  139509. * Serialize the material to a parsable JSON object.
  139510. */
  139511. serialize(): any;
  139512. /**
  139513. * Parses a JSON object correponding to the serialize function.
  139514. */
  139515. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  139516. }
  139517. }
  139518. declare module BABYLON {
  139519. /**
  139520. * The PBR material of BJS following the specular glossiness convention.
  139521. *
  139522. * This fits to the PBR convention in the GLTF definition:
  139523. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  139524. */
  139525. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  139526. /**
  139527. * Specifies the diffuse color of the material.
  139528. */
  139529. diffuseColor: Color3;
  139530. /**
  139531. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  139532. * channel.
  139533. */
  139534. diffuseTexture: BaseTexture;
  139535. /**
  139536. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  139537. */
  139538. specularColor: Color3;
  139539. /**
  139540. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  139541. */
  139542. glossiness: number;
  139543. /**
  139544. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  139545. */
  139546. specularGlossinessTexture: BaseTexture;
  139547. /**
  139548. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  139549. *
  139550. * @param name The material name
  139551. * @param scene The scene the material will be use in.
  139552. */
  139553. constructor(name: string, scene: Scene);
  139554. /**
  139555. * Return the currrent class name of the material.
  139556. */
  139557. getClassName(): string;
  139558. /**
  139559. * Makes a duplicate of the current material.
  139560. * @param name - name to use for the new material.
  139561. */
  139562. clone(name: string): PBRSpecularGlossinessMaterial;
  139563. /**
  139564. * Serialize the material to a parsable JSON object.
  139565. */
  139566. serialize(): any;
  139567. /**
  139568. * Parses a JSON object correponding to the serialize function.
  139569. */
  139570. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  139571. }
  139572. }
  139573. declare module BABYLON {
  139574. /**
  139575. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  139576. * It can help converting any input color in a desired output one. This can then be used to create effects
  139577. * from sepia, black and white to sixties or futuristic rendering...
  139578. *
  139579. * The only supported format is currently 3dl.
  139580. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  139581. */
  139582. export class ColorGradingTexture extends BaseTexture {
  139583. /**
  139584. * The texture URL.
  139585. */
  139586. url: string;
  139587. /**
  139588. * Empty line regex stored for GC.
  139589. */
  139590. private static _noneEmptyLineRegex;
  139591. private _textureMatrix;
  139592. private _onLoad;
  139593. /**
  139594. * Instantiates a ColorGradingTexture from the following parameters.
  139595. *
  139596. * @param url The location of the color gradind data (currently only supporting 3dl)
  139597. * @param sceneOrEngine The scene or engine the texture will be used in
  139598. * @param onLoad defines a callback triggered when the texture has been loaded
  139599. */
  139600. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  139601. /**
  139602. * Fires the onload event from the constructor if requested.
  139603. */
  139604. private _triggerOnLoad;
  139605. /**
  139606. * Returns the texture matrix used in most of the material.
  139607. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  139608. */
  139609. getTextureMatrix(): Matrix;
  139610. /**
  139611. * Occurs when the file being loaded is a .3dl LUT file.
  139612. */
  139613. private load3dlTexture;
  139614. /**
  139615. * Starts the loading process of the texture.
  139616. */
  139617. private loadTexture;
  139618. /**
  139619. * Clones the color gradind texture.
  139620. */
  139621. clone(): ColorGradingTexture;
  139622. /**
  139623. * Called during delayed load for textures.
  139624. */
  139625. delayLoad(): void;
  139626. /**
  139627. * Parses a color grading texture serialized by Babylon.
  139628. * @param parsedTexture The texture information being parsedTexture
  139629. * @param scene The scene to load the texture in
  139630. * @param rootUrl The root url of the data assets to load
  139631. * @return A color gradind texture
  139632. */
  139633. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  139634. /**
  139635. * Serializes the LUT texture to json format.
  139636. */
  139637. serialize(): any;
  139638. }
  139639. }
  139640. declare module BABYLON {
  139641. /**
  139642. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  139643. */
  139644. export class EquiRectangularCubeTexture extends BaseTexture {
  139645. /** The six faces of the cube. */
  139646. private static _FacesMapping;
  139647. private _noMipmap;
  139648. private _onLoad;
  139649. private _onError;
  139650. /** The size of the cubemap. */
  139651. private _size;
  139652. /** The buffer of the image. */
  139653. private _buffer;
  139654. /** The width of the input image. */
  139655. private _width;
  139656. /** The height of the input image. */
  139657. private _height;
  139658. /** The URL to the image. */
  139659. url: string;
  139660. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  139661. coordinatesMode: number;
  139662. /**
  139663. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  139664. * @param url The location of the image
  139665. * @param scene The scene the texture will be used in
  139666. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  139667. * @param noMipmap Forces to not generate the mipmap if true
  139668. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  139669. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  139670. * @param onLoad — defines a callback called when texture is loaded
  139671. * @param onError — defines a callback called if there is an error
  139672. */
  139673. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  139674. /**
  139675. * Load the image data, by putting the image on a canvas and extracting its buffer.
  139676. */
  139677. private loadImage;
  139678. /**
  139679. * Convert the image buffer into a cubemap and create a CubeTexture.
  139680. */
  139681. private loadTexture;
  139682. /**
  139683. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  139684. * @param buffer The ArrayBuffer that should be converted.
  139685. * @returns The buffer as Float32Array.
  139686. */
  139687. private getFloat32ArrayFromArrayBuffer;
  139688. /**
  139689. * Get the current class name of the texture useful for serialization or dynamic coding.
  139690. * @returns "EquiRectangularCubeTexture"
  139691. */
  139692. getClassName(): string;
  139693. /**
  139694. * Create a clone of the current EquiRectangularCubeTexture and return it.
  139695. * @returns A clone of the current EquiRectangularCubeTexture.
  139696. */
  139697. clone(): EquiRectangularCubeTexture;
  139698. }
  139699. }
  139700. declare module BABYLON {
  139701. /**
  139702. * Defines the options related to the creation of an HtmlElementTexture
  139703. */
  139704. export interface IHtmlElementTextureOptions {
  139705. /**
  139706. * Defines wether mip maps should be created or not.
  139707. */
  139708. generateMipMaps?: boolean;
  139709. /**
  139710. * Defines the sampling mode of the texture.
  139711. */
  139712. samplingMode?: number;
  139713. /**
  139714. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  139715. */
  139716. engine: Nullable<ThinEngine>;
  139717. /**
  139718. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  139719. */
  139720. scene: Nullable<Scene>;
  139721. }
  139722. /**
  139723. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  139724. * To be as efficient as possible depending on your constraints nothing aside the first upload
  139725. * is automatically managed.
  139726. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  139727. * in your application.
  139728. *
  139729. * As the update is not automatic, you need to call them manually.
  139730. */
  139731. export class HtmlElementTexture extends BaseTexture {
  139732. /**
  139733. * The texture URL.
  139734. */
  139735. element: HTMLVideoElement | HTMLCanvasElement;
  139736. private static readonly DefaultOptions;
  139737. private _textureMatrix;
  139738. private _isVideo;
  139739. private _generateMipMaps;
  139740. private _samplingMode;
  139741. /**
  139742. * Instantiates a HtmlElementTexture from the following parameters.
  139743. *
  139744. * @param name Defines the name of the texture
  139745. * @param element Defines the video or canvas the texture is filled with
  139746. * @param options Defines the other none mandatory texture creation options
  139747. */
  139748. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  139749. private _createInternalTexture;
  139750. /**
  139751. * Returns the texture matrix used in most of the material.
  139752. */
  139753. getTextureMatrix(): Matrix;
  139754. /**
  139755. * Updates the content of the texture.
  139756. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  139757. */
  139758. update(invertY?: Nullable<boolean>): void;
  139759. }
  139760. }
  139761. declare module BABYLON {
  139762. /**
  139763. * Based on jsTGALoader - Javascript loader for TGA file
  139764. * By Vincent Thibault
  139765. * @see http://blog.robrowser.com/javascript-tga-loader.html
  139766. */
  139767. export class TGATools {
  139768. private static _TYPE_INDEXED;
  139769. private static _TYPE_RGB;
  139770. private static _TYPE_GREY;
  139771. private static _TYPE_RLE_INDEXED;
  139772. private static _TYPE_RLE_RGB;
  139773. private static _TYPE_RLE_GREY;
  139774. private static _ORIGIN_MASK;
  139775. private static _ORIGIN_SHIFT;
  139776. private static _ORIGIN_BL;
  139777. private static _ORIGIN_BR;
  139778. private static _ORIGIN_UL;
  139779. private static _ORIGIN_UR;
  139780. /**
  139781. * Gets the header of a TGA file
  139782. * @param data defines the TGA data
  139783. * @returns the header
  139784. */
  139785. static GetTGAHeader(data: Uint8Array): any;
  139786. /**
  139787. * Uploads TGA content to a Babylon Texture
  139788. * @hidden
  139789. */
  139790. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  139791. /** @hidden */
  139792. 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;
  139793. /** @hidden */
  139794. 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;
  139795. /** @hidden */
  139796. 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;
  139797. /** @hidden */
  139798. 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;
  139799. /** @hidden */
  139800. 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;
  139801. /** @hidden */
  139802. 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;
  139803. }
  139804. }
  139805. declare module BABYLON {
  139806. /**
  139807. * Implementation of the TGA Texture Loader.
  139808. * @hidden
  139809. */
  139810. export class _TGATextureLoader implements IInternalTextureLoader {
  139811. /**
  139812. * Defines wether the loader supports cascade loading the different faces.
  139813. */
  139814. readonly supportCascades: boolean;
  139815. /**
  139816. * This returns if the loader support the current file information.
  139817. * @param extension defines the file extension of the file being loaded
  139818. * @returns true if the loader can load the specified file
  139819. */
  139820. canLoad(extension: string): boolean;
  139821. /**
  139822. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139823. * @param data contains the texture data
  139824. * @param texture defines the BabylonJS internal texture
  139825. * @param createPolynomials will be true if polynomials have been requested
  139826. * @param onLoad defines the callback to trigger once the texture is ready
  139827. * @param onError defines the callback to trigger in case of error
  139828. */
  139829. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139830. /**
  139831. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139832. * @param data contains the texture data
  139833. * @param texture defines the BabylonJS internal texture
  139834. * @param callback defines the method to call once ready to upload
  139835. */
  139836. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139837. }
  139838. }
  139839. declare module BABYLON {
  139840. /**
  139841. * Info about the .basis files
  139842. */
  139843. class BasisFileInfo {
  139844. /**
  139845. * If the file has alpha
  139846. */
  139847. hasAlpha: boolean;
  139848. /**
  139849. * Info about each image of the basis file
  139850. */
  139851. images: Array<{
  139852. levels: Array<{
  139853. width: number;
  139854. height: number;
  139855. transcodedPixels: ArrayBufferView;
  139856. }>;
  139857. }>;
  139858. }
  139859. /**
  139860. * Result of transcoding a basis file
  139861. */
  139862. class TranscodeResult {
  139863. /**
  139864. * Info about the .basis file
  139865. */
  139866. fileInfo: BasisFileInfo;
  139867. /**
  139868. * Format to use when loading the file
  139869. */
  139870. format: number;
  139871. }
  139872. /**
  139873. * Configuration options for the Basis transcoder
  139874. */
  139875. export class BasisTranscodeConfiguration {
  139876. /**
  139877. * Supported compression formats used to determine the supported output format of the transcoder
  139878. */
  139879. supportedCompressionFormats?: {
  139880. /**
  139881. * etc1 compression format
  139882. */
  139883. etc1?: boolean;
  139884. /**
  139885. * s3tc compression format
  139886. */
  139887. s3tc?: boolean;
  139888. /**
  139889. * pvrtc compression format
  139890. */
  139891. pvrtc?: boolean;
  139892. /**
  139893. * etc2 compression format
  139894. */
  139895. etc2?: boolean;
  139896. };
  139897. /**
  139898. * If mipmap levels should be loaded for transcoded images (Default: true)
  139899. */
  139900. loadMipmapLevels?: boolean;
  139901. /**
  139902. * Index of a single image to load (Default: all images)
  139903. */
  139904. loadSingleImage?: number;
  139905. }
  139906. /**
  139907. * Used to load .Basis files
  139908. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  139909. */
  139910. export class BasisTools {
  139911. private static _IgnoreSupportedFormats;
  139912. /**
  139913. * URL to use when loading the basis transcoder
  139914. */
  139915. static JSModuleURL: string;
  139916. /**
  139917. * URL to use when loading the wasm module for the transcoder
  139918. */
  139919. static WasmModuleURL: string;
  139920. /**
  139921. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  139922. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  139923. * @returns internal format corresponding to the Basis format
  139924. */
  139925. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  139926. private static _WorkerPromise;
  139927. private static _Worker;
  139928. private static _actionId;
  139929. private static _CreateWorkerAsync;
  139930. /**
  139931. * Transcodes a loaded image file to compressed pixel data
  139932. * @param data image data to transcode
  139933. * @param config configuration options for the transcoding
  139934. * @returns a promise resulting in the transcoded image
  139935. */
  139936. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  139937. /**
  139938. * Loads a texture from the transcode result
  139939. * @param texture texture load to
  139940. * @param transcodeResult the result of transcoding the basis file to load from
  139941. */
  139942. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  139943. }
  139944. }
  139945. declare module BABYLON {
  139946. /**
  139947. * Loader for .basis file format
  139948. */
  139949. export class _BasisTextureLoader implements IInternalTextureLoader {
  139950. /**
  139951. * Defines whether the loader supports cascade loading the different faces.
  139952. */
  139953. readonly supportCascades: boolean;
  139954. /**
  139955. * This returns if the loader support the current file information.
  139956. * @param extension defines the file extension of the file being loaded
  139957. * @returns true if the loader can load the specified file
  139958. */
  139959. canLoad(extension: string): boolean;
  139960. /**
  139961. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139962. * @param data contains the texture data
  139963. * @param texture defines the BabylonJS internal texture
  139964. * @param createPolynomials will be true if polynomials have been requested
  139965. * @param onLoad defines the callback to trigger once the texture is ready
  139966. * @param onError defines the callback to trigger in case of error
  139967. */
  139968. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139969. /**
  139970. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139971. * @param data contains the texture data
  139972. * @param texture defines the BabylonJS internal texture
  139973. * @param callback defines the method to call once ready to upload
  139974. */
  139975. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139976. }
  139977. }
  139978. declare module BABYLON {
  139979. /**
  139980. * Defines the basic options interface of a TexturePacker Frame
  139981. */
  139982. export interface ITexturePackerFrame {
  139983. /**
  139984. * The frame ID
  139985. */
  139986. id: number;
  139987. /**
  139988. * The frames Scale
  139989. */
  139990. scale: Vector2;
  139991. /**
  139992. * The Frames offset
  139993. */
  139994. offset: Vector2;
  139995. }
  139996. /**
  139997. * This is a support class for frame Data on texture packer sets.
  139998. */
  139999. export class TexturePackerFrame implements ITexturePackerFrame {
  140000. /**
  140001. * The frame ID
  140002. */
  140003. id: number;
  140004. /**
  140005. * The frames Scale
  140006. */
  140007. scale: Vector2;
  140008. /**
  140009. * The Frames offset
  140010. */
  140011. offset: Vector2;
  140012. /**
  140013. * Initializes a texture package frame.
  140014. * @param id The numerical frame identifier
  140015. * @param scale Scalar Vector2 for UV frame
  140016. * @param offset Vector2 for the frame position in UV units.
  140017. * @returns TexturePackerFrame
  140018. */
  140019. constructor(id: number, scale: Vector2, offset: Vector2);
  140020. }
  140021. }
  140022. declare module BABYLON {
  140023. /**
  140024. * Defines the basic options interface of a TexturePacker
  140025. */
  140026. export interface ITexturePackerOptions {
  140027. /**
  140028. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  140029. */
  140030. map?: string[];
  140031. /**
  140032. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  140033. */
  140034. uvsIn?: string;
  140035. /**
  140036. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  140037. */
  140038. uvsOut?: string;
  140039. /**
  140040. * number representing the layout style. Defaults to LAYOUT_STRIP
  140041. */
  140042. layout?: number;
  140043. /**
  140044. * number of columns if using custom column count layout(2). This defaults to 4.
  140045. */
  140046. colnum?: number;
  140047. /**
  140048. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  140049. */
  140050. updateInputMeshes?: boolean;
  140051. /**
  140052. * boolean flag to dispose all the source textures. Defaults to true.
  140053. */
  140054. disposeSources?: boolean;
  140055. /**
  140056. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  140057. */
  140058. fillBlanks?: boolean;
  140059. /**
  140060. * string value representing the context fill style color. Defaults to 'black'.
  140061. */
  140062. customFillColor?: string;
  140063. /**
  140064. * Width and Height Value of each Frame in the TexturePacker Sets
  140065. */
  140066. frameSize?: number;
  140067. /**
  140068. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  140069. */
  140070. paddingRatio?: number;
  140071. /**
  140072. * Number that declares the fill method for the padding gutter.
  140073. */
  140074. paddingMode?: number;
  140075. /**
  140076. * If in SUBUV_COLOR padding mode what color to use.
  140077. */
  140078. paddingColor?: Color3 | Color4;
  140079. }
  140080. /**
  140081. * Defines the basic interface of a TexturePacker JSON File
  140082. */
  140083. export interface ITexturePackerJSON {
  140084. /**
  140085. * The frame ID
  140086. */
  140087. name: string;
  140088. /**
  140089. * The base64 channel data
  140090. */
  140091. sets: any;
  140092. /**
  140093. * The options of the Packer
  140094. */
  140095. options: ITexturePackerOptions;
  140096. /**
  140097. * The frame data of the Packer
  140098. */
  140099. frames: Array<number>;
  140100. }
  140101. /**
  140102. * This is a support class that generates a series of packed texture sets.
  140103. * @see https://doc.babylonjs.com/babylon101/materials
  140104. */
  140105. export class TexturePacker {
  140106. /** Packer Layout Constant 0 */
  140107. static readonly LAYOUT_STRIP: number;
  140108. /** Packer Layout Constant 1 */
  140109. static readonly LAYOUT_POWER2: number;
  140110. /** Packer Layout Constant 2 */
  140111. static readonly LAYOUT_COLNUM: number;
  140112. /** Packer Layout Constant 0 */
  140113. static readonly SUBUV_WRAP: number;
  140114. /** Packer Layout Constant 1 */
  140115. static readonly SUBUV_EXTEND: number;
  140116. /** Packer Layout Constant 2 */
  140117. static readonly SUBUV_COLOR: number;
  140118. /** The Name of the Texture Package */
  140119. name: string;
  140120. /** The scene scope of the TexturePacker */
  140121. scene: Scene;
  140122. /** The Meshes to target */
  140123. meshes: AbstractMesh[];
  140124. /** Arguments passed with the Constructor */
  140125. options: ITexturePackerOptions;
  140126. /** The promise that is started upon initialization */
  140127. promise: Nullable<Promise<TexturePacker | string>>;
  140128. /** The Container object for the channel sets that are generated */
  140129. sets: object;
  140130. /** The Container array for the frames that are generated */
  140131. frames: TexturePackerFrame[];
  140132. /** The expected number of textures the system is parsing. */
  140133. private _expecting;
  140134. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  140135. private _paddingValue;
  140136. /**
  140137. * Initializes a texture package series from an array of meshes or a single mesh.
  140138. * @param name The name of the package
  140139. * @param meshes The target meshes to compose the package from
  140140. * @param options The arguments that texture packer should follow while building.
  140141. * @param scene The scene which the textures are scoped to.
  140142. * @returns TexturePacker
  140143. */
  140144. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  140145. /**
  140146. * Starts the package process
  140147. * @param resolve The promises resolution function
  140148. * @returns TexturePacker
  140149. */
  140150. private _createFrames;
  140151. /**
  140152. * Calculates the Size of the Channel Sets
  140153. * @returns Vector2
  140154. */
  140155. private _calculateSize;
  140156. /**
  140157. * Calculates the UV data for the frames.
  140158. * @param baseSize the base frameSize
  140159. * @param padding the base frame padding
  140160. * @param dtSize size of the Dynamic Texture for that channel
  140161. * @param dtUnits is 1/dtSize
  140162. * @param update flag to update the input meshes
  140163. */
  140164. private _calculateMeshUVFrames;
  140165. /**
  140166. * Calculates the frames Offset.
  140167. * @param index of the frame
  140168. * @returns Vector2
  140169. */
  140170. private _getFrameOffset;
  140171. /**
  140172. * Updates a Mesh to the frame data
  140173. * @param mesh that is the target
  140174. * @param frameID or the frame index
  140175. */
  140176. private _updateMeshUV;
  140177. /**
  140178. * Updates a Meshes materials to use the texture packer channels
  140179. * @param m is the mesh to target
  140180. * @param force all channels on the packer to be set.
  140181. */
  140182. private _updateTextureReferences;
  140183. /**
  140184. * Public method to set a Mesh to a frame
  140185. * @param m that is the target
  140186. * @param frameID or the frame index
  140187. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  140188. */
  140189. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  140190. /**
  140191. * Starts the async promise to compile the texture packer.
  140192. * @returns Promise<void>
  140193. */
  140194. processAsync(): Promise<void>;
  140195. /**
  140196. * Disposes all textures associated with this packer
  140197. */
  140198. dispose(): void;
  140199. /**
  140200. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  140201. * @param imageType is the image type to use.
  140202. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  140203. */
  140204. download(imageType?: string, quality?: number): void;
  140205. /**
  140206. * Public method to load a texturePacker JSON file.
  140207. * @param data of the JSON file in string format.
  140208. */
  140209. updateFromJSON(data: string): void;
  140210. }
  140211. }
  140212. declare module BABYLON {
  140213. /**
  140214. * 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.
  140215. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  140216. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  140217. */
  140218. export class CustomProceduralTexture extends ProceduralTexture {
  140219. private _animate;
  140220. private _time;
  140221. private _config;
  140222. private _texturePath;
  140223. /**
  140224. * Instantiates a new Custom Procedural Texture.
  140225. * 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.
  140226. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  140227. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  140228. * @param name Define the name of the texture
  140229. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  140230. * @param size Define the size of the texture to create
  140231. * @param scene Define the scene the texture belongs to
  140232. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  140233. * @param generateMipMaps Define if the texture should creates mip maps or not
  140234. */
  140235. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  140236. private _loadJson;
  140237. /**
  140238. * Is the texture ready to be used ? (rendered at least once)
  140239. * @returns true if ready, otherwise, false.
  140240. */
  140241. isReady(): boolean;
  140242. /**
  140243. * Render the texture to its associated render target.
  140244. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  140245. */
  140246. render(useCameraPostProcess?: boolean): void;
  140247. /**
  140248. * Update the list of dependant textures samplers in the shader.
  140249. */
  140250. updateTextures(): void;
  140251. /**
  140252. * Update the uniform values of the procedural texture in the shader.
  140253. */
  140254. updateShaderUniforms(): void;
  140255. /**
  140256. * Define if the texture animates or not.
  140257. */
  140258. get animate(): boolean;
  140259. set animate(value: boolean);
  140260. }
  140261. }
  140262. declare module BABYLON {
  140263. /** @hidden */
  140264. export var noisePixelShader: {
  140265. name: string;
  140266. shader: string;
  140267. };
  140268. }
  140269. declare module BABYLON {
  140270. /**
  140271. * Class used to generate noise procedural textures
  140272. */
  140273. export class NoiseProceduralTexture extends ProceduralTexture {
  140274. private _time;
  140275. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  140276. brightness: number;
  140277. /** Defines the number of octaves to process */
  140278. octaves: number;
  140279. /** Defines the level of persistence (0.8 by default) */
  140280. persistence: number;
  140281. /** Gets or sets animation speed factor (default is 1) */
  140282. animationSpeedFactor: number;
  140283. /**
  140284. * Creates a new NoiseProceduralTexture
  140285. * @param name defines the name fo the texture
  140286. * @param size defines the size of the texture (default is 256)
  140287. * @param scene defines the hosting scene
  140288. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  140289. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  140290. */
  140291. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  140292. private _updateShaderUniforms;
  140293. protected _getDefines(): string;
  140294. /** Generate the current state of the procedural texture */
  140295. render(useCameraPostProcess?: boolean): void;
  140296. /**
  140297. * Serializes this noise procedural texture
  140298. * @returns a serialized noise procedural texture object
  140299. */
  140300. serialize(): any;
  140301. /**
  140302. * Clone the texture.
  140303. * @returns the cloned texture
  140304. */
  140305. clone(): NoiseProceduralTexture;
  140306. /**
  140307. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  140308. * @param parsedTexture defines parsed texture data
  140309. * @param scene defines the current scene
  140310. * @param rootUrl defines the root URL containing noise procedural texture information
  140311. * @returns a parsed NoiseProceduralTexture
  140312. */
  140313. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  140314. }
  140315. }
  140316. declare module BABYLON {
  140317. /**
  140318. * Raw cube texture where the raw buffers are passed in
  140319. */
  140320. export class RawCubeTexture extends CubeTexture {
  140321. /**
  140322. * Creates a cube texture where the raw buffers are passed in.
  140323. * @param scene defines the scene the texture is attached to
  140324. * @param data defines the array of data to use to create each face
  140325. * @param size defines the size of the textures
  140326. * @param format defines the format of the data
  140327. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  140328. * @param generateMipMaps defines if the engine should generate the mip levels
  140329. * @param invertY defines if data must be stored with Y axis inverted
  140330. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  140331. * @param compression defines the compression used (null by default)
  140332. */
  140333. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  140334. /**
  140335. * Updates the raw cube texture.
  140336. * @param data defines the data to store
  140337. * @param format defines the data format
  140338. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  140339. * @param invertY defines if data must be stored with Y axis inverted
  140340. * @param compression defines the compression used (null by default)
  140341. * @param level defines which level of the texture to update
  140342. */
  140343. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  140344. /**
  140345. * Updates a raw cube texture with RGBD encoded data.
  140346. * @param data defines the array of data [mipmap][face] to use to create each face
  140347. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  140348. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  140349. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  140350. * @returns a promsie that resolves when the operation is complete
  140351. */
  140352. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  140353. /**
  140354. * Clones the raw cube texture.
  140355. * @return a new cube texture
  140356. */
  140357. clone(): CubeTexture;
  140358. /** @hidden */
  140359. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  140360. }
  140361. }
  140362. declare module BABYLON {
  140363. /**
  140364. * Class used to store 2D array textures containing user data
  140365. */
  140366. export class RawTexture2DArray extends Texture {
  140367. /** Gets or sets the texture format to use */
  140368. format: number;
  140369. /**
  140370. * Create a new RawTexture2DArray
  140371. * @param data defines the data of the texture
  140372. * @param width defines the width of the texture
  140373. * @param height defines the height of the texture
  140374. * @param depth defines the number of layers of the texture
  140375. * @param format defines the texture format to use
  140376. * @param scene defines the hosting scene
  140377. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  140378. * @param invertY defines if texture must be stored with Y axis inverted
  140379. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140380. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  140381. */
  140382. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  140383. /** Gets or sets the texture format to use */
  140384. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  140385. /**
  140386. * Update the texture with new data
  140387. * @param data defines the data to store in the texture
  140388. */
  140389. update(data: ArrayBufferView): void;
  140390. }
  140391. }
  140392. declare module BABYLON {
  140393. /**
  140394. * Class used to store 3D textures containing user data
  140395. */
  140396. export class RawTexture3D extends Texture {
  140397. /** Gets or sets the texture format to use */
  140398. format: number;
  140399. /**
  140400. * Create a new RawTexture3D
  140401. * @param data defines the data of the texture
  140402. * @param width defines the width of the texture
  140403. * @param height defines the height of the texture
  140404. * @param depth defines the depth of the texture
  140405. * @param format defines the texture format to use
  140406. * @param scene defines the hosting scene
  140407. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  140408. * @param invertY defines if texture must be stored with Y axis inverted
  140409. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140410. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  140411. */
  140412. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  140413. /** Gets or sets the texture format to use */
  140414. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  140415. /**
  140416. * Update the texture with new data
  140417. * @param data defines the data to store in the texture
  140418. */
  140419. update(data: ArrayBufferView): void;
  140420. }
  140421. }
  140422. declare module BABYLON {
  140423. /**
  140424. * Creates a refraction texture used by refraction channel of the standard material.
  140425. * It is like a mirror but to see through a material.
  140426. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140427. */
  140428. export class RefractionTexture extends RenderTargetTexture {
  140429. /**
  140430. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  140431. * 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.
  140432. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140433. */
  140434. refractionPlane: Plane;
  140435. /**
  140436. * Define how deep under the surface we should see.
  140437. */
  140438. depth: number;
  140439. /**
  140440. * Creates a refraction texture used by refraction channel of the standard material.
  140441. * It is like a mirror but to see through a material.
  140442. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140443. * @param name Define the texture name
  140444. * @param size Define the size of the underlying texture
  140445. * @param scene Define the scene the refraction belongs to
  140446. * @param generateMipMaps Define if we need to generate mips level for the refraction
  140447. */
  140448. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  140449. /**
  140450. * Clone the refraction texture.
  140451. * @returns the cloned texture
  140452. */
  140453. clone(): RefractionTexture;
  140454. /**
  140455. * Serialize the texture to a JSON representation you could use in Parse later on
  140456. * @returns the serialized JSON representation
  140457. */
  140458. serialize(): any;
  140459. }
  140460. }
  140461. declare module BABYLON {
  140462. /**
  140463. * Block used to add support for vertex skinning (bones)
  140464. */
  140465. export class BonesBlock extends NodeMaterialBlock {
  140466. /**
  140467. * Creates a new BonesBlock
  140468. * @param name defines the block name
  140469. */
  140470. constructor(name: string);
  140471. /**
  140472. * Initialize the block and prepare the context for build
  140473. * @param state defines the state that will be used for the build
  140474. */
  140475. initialize(state: NodeMaterialBuildState): void;
  140476. /**
  140477. * Gets the current class name
  140478. * @returns the class name
  140479. */
  140480. getClassName(): string;
  140481. /**
  140482. * Gets the matrix indices input component
  140483. */
  140484. get matricesIndices(): NodeMaterialConnectionPoint;
  140485. /**
  140486. * Gets the matrix weights input component
  140487. */
  140488. get matricesWeights(): NodeMaterialConnectionPoint;
  140489. /**
  140490. * Gets the extra matrix indices input component
  140491. */
  140492. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  140493. /**
  140494. * Gets the extra matrix weights input component
  140495. */
  140496. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  140497. /**
  140498. * Gets the world input component
  140499. */
  140500. get world(): NodeMaterialConnectionPoint;
  140501. /**
  140502. * Gets the output component
  140503. */
  140504. get output(): NodeMaterialConnectionPoint;
  140505. autoConfigure(material: NodeMaterial): void;
  140506. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  140507. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140508. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140509. protected _buildBlock(state: NodeMaterialBuildState): this;
  140510. }
  140511. }
  140512. declare module BABYLON {
  140513. /**
  140514. * Block used to add support for instances
  140515. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  140516. */
  140517. export class InstancesBlock extends NodeMaterialBlock {
  140518. /**
  140519. * Creates a new InstancesBlock
  140520. * @param name defines the block name
  140521. */
  140522. constructor(name: string);
  140523. /**
  140524. * Gets the current class name
  140525. * @returns the class name
  140526. */
  140527. getClassName(): string;
  140528. /**
  140529. * Gets the first world row input component
  140530. */
  140531. get world0(): NodeMaterialConnectionPoint;
  140532. /**
  140533. * Gets the second world row input component
  140534. */
  140535. get world1(): NodeMaterialConnectionPoint;
  140536. /**
  140537. * Gets the third world row input component
  140538. */
  140539. get world2(): NodeMaterialConnectionPoint;
  140540. /**
  140541. * Gets the forth world row input component
  140542. */
  140543. get world3(): NodeMaterialConnectionPoint;
  140544. /**
  140545. * Gets the world input component
  140546. */
  140547. get world(): NodeMaterialConnectionPoint;
  140548. /**
  140549. * Gets the output component
  140550. */
  140551. get output(): NodeMaterialConnectionPoint;
  140552. /**
  140553. * Gets the isntanceID component
  140554. */
  140555. get instanceID(): NodeMaterialConnectionPoint;
  140556. autoConfigure(material: NodeMaterial): void;
  140557. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  140558. protected _buildBlock(state: NodeMaterialBuildState): this;
  140559. }
  140560. }
  140561. declare module BABYLON {
  140562. /**
  140563. * Block used to add morph targets support to vertex shader
  140564. */
  140565. export class MorphTargetsBlock extends NodeMaterialBlock {
  140566. private _repeatableContentAnchor;
  140567. /**
  140568. * Create a new MorphTargetsBlock
  140569. * @param name defines the block name
  140570. */
  140571. constructor(name: string);
  140572. /**
  140573. * Gets the current class name
  140574. * @returns the class name
  140575. */
  140576. getClassName(): string;
  140577. /**
  140578. * Gets the position input component
  140579. */
  140580. get position(): NodeMaterialConnectionPoint;
  140581. /**
  140582. * Gets the normal input component
  140583. */
  140584. get normal(): NodeMaterialConnectionPoint;
  140585. /**
  140586. * Gets the tangent input component
  140587. */
  140588. get tangent(): NodeMaterialConnectionPoint;
  140589. /**
  140590. * Gets the tangent input component
  140591. */
  140592. get uv(): NodeMaterialConnectionPoint;
  140593. /**
  140594. * Gets the position output component
  140595. */
  140596. get positionOutput(): NodeMaterialConnectionPoint;
  140597. /**
  140598. * Gets the normal output component
  140599. */
  140600. get normalOutput(): NodeMaterialConnectionPoint;
  140601. /**
  140602. * Gets the tangent output component
  140603. */
  140604. get tangentOutput(): NodeMaterialConnectionPoint;
  140605. /**
  140606. * Gets the tangent output component
  140607. */
  140608. get uvOutput(): NodeMaterialConnectionPoint;
  140609. initialize(state: NodeMaterialBuildState): void;
  140610. autoConfigure(material: NodeMaterial): void;
  140611. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140612. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140613. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  140614. protected _buildBlock(state: NodeMaterialBuildState): this;
  140615. }
  140616. }
  140617. declare module BABYLON {
  140618. /**
  140619. * Block used to get data information from a light
  140620. */
  140621. export class LightInformationBlock extends NodeMaterialBlock {
  140622. private _lightDataUniformName;
  140623. private _lightColorUniformName;
  140624. private _lightTypeDefineName;
  140625. /**
  140626. * Gets or sets the light associated with this block
  140627. */
  140628. light: Nullable<Light>;
  140629. /**
  140630. * Creates a new LightInformationBlock
  140631. * @param name defines the block name
  140632. */
  140633. constructor(name: string);
  140634. /**
  140635. * Gets the current class name
  140636. * @returns the class name
  140637. */
  140638. getClassName(): string;
  140639. /**
  140640. * Gets the world position input component
  140641. */
  140642. get worldPosition(): NodeMaterialConnectionPoint;
  140643. /**
  140644. * Gets the direction output component
  140645. */
  140646. get direction(): NodeMaterialConnectionPoint;
  140647. /**
  140648. * Gets the direction output component
  140649. */
  140650. get color(): NodeMaterialConnectionPoint;
  140651. /**
  140652. * Gets the direction output component
  140653. */
  140654. get intensity(): NodeMaterialConnectionPoint;
  140655. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140656. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140657. protected _buildBlock(state: NodeMaterialBuildState): this;
  140658. serialize(): any;
  140659. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140660. }
  140661. }
  140662. declare module BABYLON {
  140663. /**
  140664. * Block used to add image processing support to fragment shader
  140665. */
  140666. export class ImageProcessingBlock extends NodeMaterialBlock {
  140667. /**
  140668. * Create a new ImageProcessingBlock
  140669. * @param name defines the block name
  140670. */
  140671. constructor(name: string);
  140672. /**
  140673. * Gets the current class name
  140674. * @returns the class name
  140675. */
  140676. getClassName(): string;
  140677. /**
  140678. * Gets the color input component
  140679. */
  140680. get color(): NodeMaterialConnectionPoint;
  140681. /**
  140682. * Gets the output component
  140683. */
  140684. get output(): NodeMaterialConnectionPoint;
  140685. /**
  140686. * Initialize the block and prepare the context for build
  140687. * @param state defines the state that will be used for the build
  140688. */
  140689. initialize(state: NodeMaterialBuildState): void;
  140690. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  140691. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140692. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140693. protected _buildBlock(state: NodeMaterialBuildState): this;
  140694. }
  140695. }
  140696. declare module BABYLON {
  140697. /**
  140698. * Block used to pertub normals based on a normal map
  140699. */
  140700. export class PerturbNormalBlock extends NodeMaterialBlock {
  140701. private _tangentSpaceParameterName;
  140702. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  140703. invertX: boolean;
  140704. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  140705. invertY: boolean;
  140706. /**
  140707. * Create a new PerturbNormalBlock
  140708. * @param name defines the block name
  140709. */
  140710. constructor(name: string);
  140711. /**
  140712. * Gets the current class name
  140713. * @returns the class name
  140714. */
  140715. getClassName(): string;
  140716. /**
  140717. * Gets the world position input component
  140718. */
  140719. get worldPosition(): NodeMaterialConnectionPoint;
  140720. /**
  140721. * Gets the world normal input component
  140722. */
  140723. get worldNormal(): NodeMaterialConnectionPoint;
  140724. /**
  140725. * Gets the world tangent input component
  140726. */
  140727. get worldTangent(): NodeMaterialConnectionPoint;
  140728. /**
  140729. * Gets the uv input component
  140730. */
  140731. get uv(): NodeMaterialConnectionPoint;
  140732. /**
  140733. * Gets the normal map color input component
  140734. */
  140735. get normalMapColor(): NodeMaterialConnectionPoint;
  140736. /**
  140737. * Gets the strength input component
  140738. */
  140739. get strength(): NodeMaterialConnectionPoint;
  140740. /**
  140741. * Gets the output component
  140742. */
  140743. get output(): NodeMaterialConnectionPoint;
  140744. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140745. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140746. autoConfigure(material: NodeMaterial): void;
  140747. protected _buildBlock(state: NodeMaterialBuildState): this;
  140748. protected _dumpPropertiesCode(): string;
  140749. serialize(): any;
  140750. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140751. }
  140752. }
  140753. declare module BABYLON {
  140754. /**
  140755. * Block used to discard a pixel if a value is smaller than a cutoff
  140756. */
  140757. export class DiscardBlock extends NodeMaterialBlock {
  140758. /**
  140759. * Create a new DiscardBlock
  140760. * @param name defines the block name
  140761. */
  140762. constructor(name: string);
  140763. /**
  140764. * Gets the current class name
  140765. * @returns the class name
  140766. */
  140767. getClassName(): string;
  140768. /**
  140769. * Gets the color input component
  140770. */
  140771. get value(): NodeMaterialConnectionPoint;
  140772. /**
  140773. * Gets the cutoff input component
  140774. */
  140775. get cutoff(): NodeMaterialConnectionPoint;
  140776. protected _buildBlock(state: NodeMaterialBuildState): this;
  140777. }
  140778. }
  140779. declare module BABYLON {
  140780. /**
  140781. * Block used to test if the fragment shader is front facing
  140782. */
  140783. export class FrontFacingBlock extends NodeMaterialBlock {
  140784. /**
  140785. * Creates a new FrontFacingBlock
  140786. * @param name defines the block name
  140787. */
  140788. constructor(name: string);
  140789. /**
  140790. * Gets the current class name
  140791. * @returns the class name
  140792. */
  140793. getClassName(): string;
  140794. /**
  140795. * Gets the output component
  140796. */
  140797. get output(): NodeMaterialConnectionPoint;
  140798. protected _buildBlock(state: NodeMaterialBuildState): this;
  140799. }
  140800. }
  140801. declare module BABYLON {
  140802. /**
  140803. * Block used to get the derivative value on x and y of a given input
  140804. */
  140805. export class DerivativeBlock extends NodeMaterialBlock {
  140806. /**
  140807. * Create a new DerivativeBlock
  140808. * @param name defines the block name
  140809. */
  140810. constructor(name: string);
  140811. /**
  140812. * Gets the current class name
  140813. * @returns the class name
  140814. */
  140815. getClassName(): string;
  140816. /**
  140817. * Gets the input component
  140818. */
  140819. get input(): NodeMaterialConnectionPoint;
  140820. /**
  140821. * Gets the derivative output on x
  140822. */
  140823. get dx(): NodeMaterialConnectionPoint;
  140824. /**
  140825. * Gets the derivative output on y
  140826. */
  140827. get dy(): NodeMaterialConnectionPoint;
  140828. protected _buildBlock(state: NodeMaterialBuildState): this;
  140829. }
  140830. }
  140831. declare module BABYLON {
  140832. /**
  140833. * Block used to make gl_FragCoord available
  140834. */
  140835. export class FragCoordBlock extends NodeMaterialBlock {
  140836. /**
  140837. * Creates a new FragCoordBlock
  140838. * @param name defines the block name
  140839. */
  140840. constructor(name: string);
  140841. /**
  140842. * Gets the current class name
  140843. * @returns the class name
  140844. */
  140845. getClassName(): string;
  140846. /**
  140847. * Gets the xy component
  140848. */
  140849. get xy(): NodeMaterialConnectionPoint;
  140850. /**
  140851. * Gets the xyz component
  140852. */
  140853. get xyz(): NodeMaterialConnectionPoint;
  140854. /**
  140855. * Gets the xyzw component
  140856. */
  140857. get xyzw(): NodeMaterialConnectionPoint;
  140858. /**
  140859. * Gets the x component
  140860. */
  140861. get x(): NodeMaterialConnectionPoint;
  140862. /**
  140863. * Gets the y component
  140864. */
  140865. get y(): NodeMaterialConnectionPoint;
  140866. /**
  140867. * Gets the z component
  140868. */
  140869. get z(): NodeMaterialConnectionPoint;
  140870. /**
  140871. * Gets the w component
  140872. */
  140873. get output(): NodeMaterialConnectionPoint;
  140874. protected writeOutputs(state: NodeMaterialBuildState): string;
  140875. protected _buildBlock(state: NodeMaterialBuildState): this;
  140876. }
  140877. }
  140878. declare module BABYLON {
  140879. /**
  140880. * Block used to get the screen sizes
  140881. */
  140882. export class ScreenSizeBlock extends NodeMaterialBlock {
  140883. private _varName;
  140884. private _scene;
  140885. /**
  140886. * Creates a new ScreenSizeBlock
  140887. * @param name defines the block name
  140888. */
  140889. constructor(name: string);
  140890. /**
  140891. * Gets the current class name
  140892. * @returns the class name
  140893. */
  140894. getClassName(): string;
  140895. /**
  140896. * Gets the xy component
  140897. */
  140898. get xy(): NodeMaterialConnectionPoint;
  140899. /**
  140900. * Gets the x component
  140901. */
  140902. get x(): NodeMaterialConnectionPoint;
  140903. /**
  140904. * Gets the y component
  140905. */
  140906. get y(): NodeMaterialConnectionPoint;
  140907. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140908. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  140909. protected _buildBlock(state: NodeMaterialBuildState): this;
  140910. }
  140911. }
  140912. declare module BABYLON {
  140913. /**
  140914. * Block used to add support for scene fog
  140915. */
  140916. export class FogBlock extends NodeMaterialBlock {
  140917. private _fogDistanceName;
  140918. private _fogParameters;
  140919. /**
  140920. * Create a new FogBlock
  140921. * @param name defines the block name
  140922. */
  140923. constructor(name: string);
  140924. /**
  140925. * Gets the current class name
  140926. * @returns the class name
  140927. */
  140928. getClassName(): string;
  140929. /**
  140930. * Gets the world position input component
  140931. */
  140932. get worldPosition(): NodeMaterialConnectionPoint;
  140933. /**
  140934. * Gets the view input component
  140935. */
  140936. get view(): NodeMaterialConnectionPoint;
  140937. /**
  140938. * Gets the color input component
  140939. */
  140940. get input(): NodeMaterialConnectionPoint;
  140941. /**
  140942. * Gets the fog color input component
  140943. */
  140944. get fogColor(): NodeMaterialConnectionPoint;
  140945. /**
  140946. * Gets the output component
  140947. */
  140948. get output(): NodeMaterialConnectionPoint;
  140949. autoConfigure(material: NodeMaterial): void;
  140950. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140951. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140952. protected _buildBlock(state: NodeMaterialBuildState): this;
  140953. }
  140954. }
  140955. declare module BABYLON {
  140956. /**
  140957. * Block used to add light in the fragment shader
  140958. */
  140959. export class LightBlock extends NodeMaterialBlock {
  140960. private _lightId;
  140961. /**
  140962. * Gets or sets the light associated with this block
  140963. */
  140964. light: Nullable<Light>;
  140965. /**
  140966. * Create a new LightBlock
  140967. * @param name defines the block name
  140968. */
  140969. constructor(name: string);
  140970. /**
  140971. * Gets the current class name
  140972. * @returns the class name
  140973. */
  140974. getClassName(): string;
  140975. /**
  140976. * Gets the world position input component
  140977. */
  140978. get worldPosition(): NodeMaterialConnectionPoint;
  140979. /**
  140980. * Gets the world normal input component
  140981. */
  140982. get worldNormal(): NodeMaterialConnectionPoint;
  140983. /**
  140984. * Gets the camera (or eye) position component
  140985. */
  140986. get cameraPosition(): NodeMaterialConnectionPoint;
  140987. /**
  140988. * Gets the glossiness component
  140989. */
  140990. get glossiness(): NodeMaterialConnectionPoint;
  140991. /**
  140992. * Gets the glossinness power component
  140993. */
  140994. get glossPower(): NodeMaterialConnectionPoint;
  140995. /**
  140996. * Gets the diffuse color component
  140997. */
  140998. get diffuseColor(): NodeMaterialConnectionPoint;
  140999. /**
  141000. * Gets the specular color component
  141001. */
  141002. get specularColor(): NodeMaterialConnectionPoint;
  141003. /**
  141004. * Gets the diffuse output component
  141005. */
  141006. get diffuseOutput(): NodeMaterialConnectionPoint;
  141007. /**
  141008. * Gets the specular output component
  141009. */
  141010. get specularOutput(): NodeMaterialConnectionPoint;
  141011. /**
  141012. * Gets the shadow output component
  141013. */
  141014. get shadow(): NodeMaterialConnectionPoint;
  141015. autoConfigure(material: NodeMaterial): void;
  141016. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141017. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  141018. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141019. private _injectVertexCode;
  141020. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141021. serialize(): any;
  141022. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141023. }
  141024. }
  141025. declare module BABYLON {
  141026. /**
  141027. * Block used to read a reflection texture from a sampler
  141028. */
  141029. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  141030. /**
  141031. * Create a new ReflectionTextureBlock
  141032. * @param name defines the block name
  141033. */
  141034. constructor(name: string);
  141035. /**
  141036. * Gets the current class name
  141037. * @returns the class name
  141038. */
  141039. getClassName(): string;
  141040. /**
  141041. * Gets the world position input component
  141042. */
  141043. get position(): NodeMaterialConnectionPoint;
  141044. /**
  141045. * Gets the world position input component
  141046. */
  141047. get worldPosition(): NodeMaterialConnectionPoint;
  141048. /**
  141049. * Gets the world normal input component
  141050. */
  141051. get worldNormal(): NodeMaterialConnectionPoint;
  141052. /**
  141053. * Gets the world input component
  141054. */
  141055. get world(): NodeMaterialConnectionPoint;
  141056. /**
  141057. * Gets the camera (or eye) position component
  141058. */
  141059. get cameraPosition(): NodeMaterialConnectionPoint;
  141060. /**
  141061. * Gets the view input component
  141062. */
  141063. get view(): NodeMaterialConnectionPoint;
  141064. /**
  141065. * Gets the rgb output component
  141066. */
  141067. get rgb(): NodeMaterialConnectionPoint;
  141068. /**
  141069. * Gets the rgba output component
  141070. */
  141071. get rgba(): NodeMaterialConnectionPoint;
  141072. /**
  141073. * Gets the r output component
  141074. */
  141075. get r(): NodeMaterialConnectionPoint;
  141076. /**
  141077. * Gets the g output component
  141078. */
  141079. get g(): NodeMaterialConnectionPoint;
  141080. /**
  141081. * Gets the b output component
  141082. */
  141083. get b(): NodeMaterialConnectionPoint;
  141084. /**
  141085. * Gets the a output component
  141086. */
  141087. get a(): NodeMaterialConnectionPoint;
  141088. autoConfigure(material: NodeMaterial): void;
  141089. protected _buildBlock(state: NodeMaterialBuildState): this;
  141090. }
  141091. }
  141092. declare module BABYLON {
  141093. /**
  141094. * Block used to add 2 vectors
  141095. */
  141096. export class AddBlock extends NodeMaterialBlock {
  141097. /**
  141098. * Creates a new AddBlock
  141099. * @param name defines the block name
  141100. */
  141101. constructor(name: string);
  141102. /**
  141103. * Gets the current class name
  141104. * @returns the class name
  141105. */
  141106. getClassName(): string;
  141107. /**
  141108. * Gets the left operand input component
  141109. */
  141110. get left(): NodeMaterialConnectionPoint;
  141111. /**
  141112. * Gets the right operand input component
  141113. */
  141114. get right(): NodeMaterialConnectionPoint;
  141115. /**
  141116. * Gets the output component
  141117. */
  141118. get output(): NodeMaterialConnectionPoint;
  141119. protected _buildBlock(state: NodeMaterialBuildState): this;
  141120. }
  141121. }
  141122. declare module BABYLON {
  141123. /**
  141124. * Block used to scale a vector by a float
  141125. */
  141126. export class ScaleBlock extends NodeMaterialBlock {
  141127. /**
  141128. * Creates a new ScaleBlock
  141129. * @param name defines the block name
  141130. */
  141131. constructor(name: string);
  141132. /**
  141133. * Gets the current class name
  141134. * @returns the class name
  141135. */
  141136. getClassName(): string;
  141137. /**
  141138. * Gets the input component
  141139. */
  141140. get input(): NodeMaterialConnectionPoint;
  141141. /**
  141142. * Gets the factor input component
  141143. */
  141144. get factor(): NodeMaterialConnectionPoint;
  141145. /**
  141146. * Gets the output component
  141147. */
  141148. get output(): NodeMaterialConnectionPoint;
  141149. protected _buildBlock(state: NodeMaterialBuildState): this;
  141150. }
  141151. }
  141152. declare module BABYLON {
  141153. /**
  141154. * Block used to clamp a float
  141155. */
  141156. export class ClampBlock extends NodeMaterialBlock {
  141157. /** Gets or sets the minimum range */
  141158. minimum: number;
  141159. /** Gets or sets the maximum range */
  141160. maximum: number;
  141161. /**
  141162. * Creates a new ClampBlock
  141163. * @param name defines the block name
  141164. */
  141165. constructor(name: string);
  141166. /**
  141167. * Gets the current class name
  141168. * @returns the class name
  141169. */
  141170. getClassName(): string;
  141171. /**
  141172. * Gets the value input component
  141173. */
  141174. get value(): NodeMaterialConnectionPoint;
  141175. /**
  141176. * Gets the output component
  141177. */
  141178. get output(): NodeMaterialConnectionPoint;
  141179. protected _buildBlock(state: NodeMaterialBuildState): this;
  141180. protected _dumpPropertiesCode(): string;
  141181. serialize(): any;
  141182. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141183. }
  141184. }
  141185. declare module BABYLON {
  141186. /**
  141187. * Block used to apply a cross product between 2 vectors
  141188. */
  141189. export class CrossBlock extends NodeMaterialBlock {
  141190. /**
  141191. * Creates a new CrossBlock
  141192. * @param name defines the block name
  141193. */
  141194. constructor(name: string);
  141195. /**
  141196. * Gets the current class name
  141197. * @returns the class name
  141198. */
  141199. getClassName(): string;
  141200. /**
  141201. * Gets the left operand input component
  141202. */
  141203. get left(): NodeMaterialConnectionPoint;
  141204. /**
  141205. * Gets the right operand input component
  141206. */
  141207. get right(): NodeMaterialConnectionPoint;
  141208. /**
  141209. * Gets the output component
  141210. */
  141211. get output(): NodeMaterialConnectionPoint;
  141212. protected _buildBlock(state: NodeMaterialBuildState): this;
  141213. }
  141214. }
  141215. declare module BABYLON {
  141216. /**
  141217. * Block used to apply a dot product between 2 vectors
  141218. */
  141219. export class DotBlock extends NodeMaterialBlock {
  141220. /**
  141221. * Creates a new DotBlock
  141222. * @param name defines the block name
  141223. */
  141224. constructor(name: string);
  141225. /**
  141226. * Gets the current class name
  141227. * @returns the class name
  141228. */
  141229. getClassName(): string;
  141230. /**
  141231. * Gets the left operand input component
  141232. */
  141233. get left(): NodeMaterialConnectionPoint;
  141234. /**
  141235. * Gets the right operand input component
  141236. */
  141237. get right(): NodeMaterialConnectionPoint;
  141238. /**
  141239. * Gets the output component
  141240. */
  141241. get output(): NodeMaterialConnectionPoint;
  141242. protected _buildBlock(state: NodeMaterialBuildState): this;
  141243. }
  141244. }
  141245. declare module BABYLON {
  141246. /**
  141247. * Block used to normalize a vector
  141248. */
  141249. export class NormalizeBlock extends NodeMaterialBlock {
  141250. /**
  141251. * Creates a new NormalizeBlock
  141252. * @param name defines the block name
  141253. */
  141254. constructor(name: string);
  141255. /**
  141256. * Gets the current class name
  141257. * @returns the class name
  141258. */
  141259. getClassName(): string;
  141260. /**
  141261. * Gets the input component
  141262. */
  141263. get input(): NodeMaterialConnectionPoint;
  141264. /**
  141265. * Gets the output component
  141266. */
  141267. get output(): NodeMaterialConnectionPoint;
  141268. protected _buildBlock(state: NodeMaterialBuildState): this;
  141269. }
  141270. }
  141271. declare module BABYLON {
  141272. /**
  141273. * Operations supported by the Trigonometry block
  141274. */
  141275. export enum TrigonometryBlockOperations {
  141276. /** Cos */
  141277. Cos = 0,
  141278. /** Sin */
  141279. Sin = 1,
  141280. /** Abs */
  141281. Abs = 2,
  141282. /** Exp */
  141283. Exp = 3,
  141284. /** Exp2 */
  141285. Exp2 = 4,
  141286. /** Round */
  141287. Round = 5,
  141288. /** Floor */
  141289. Floor = 6,
  141290. /** Ceiling */
  141291. Ceiling = 7,
  141292. /** Square root */
  141293. Sqrt = 8,
  141294. /** Log */
  141295. Log = 9,
  141296. /** Tangent */
  141297. Tan = 10,
  141298. /** Arc tangent */
  141299. ArcTan = 11,
  141300. /** Arc cosinus */
  141301. ArcCos = 12,
  141302. /** Arc sinus */
  141303. ArcSin = 13,
  141304. /** Fraction */
  141305. Fract = 14,
  141306. /** Sign */
  141307. Sign = 15,
  141308. /** To radians (from degrees) */
  141309. Radians = 16,
  141310. /** To degrees (from radians) */
  141311. Degrees = 17
  141312. }
  141313. /**
  141314. * Block used to apply trigonometry operation to floats
  141315. */
  141316. export class TrigonometryBlock extends NodeMaterialBlock {
  141317. /**
  141318. * Gets or sets the operation applied by the block
  141319. */
  141320. operation: TrigonometryBlockOperations;
  141321. /**
  141322. * Creates a new TrigonometryBlock
  141323. * @param name defines the block name
  141324. */
  141325. constructor(name: string);
  141326. /**
  141327. * Gets the current class name
  141328. * @returns the class name
  141329. */
  141330. getClassName(): string;
  141331. /**
  141332. * Gets the input component
  141333. */
  141334. get input(): NodeMaterialConnectionPoint;
  141335. /**
  141336. * Gets the output component
  141337. */
  141338. get output(): NodeMaterialConnectionPoint;
  141339. protected _buildBlock(state: NodeMaterialBuildState): this;
  141340. serialize(): any;
  141341. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141342. protected _dumpPropertiesCode(): string;
  141343. }
  141344. }
  141345. declare module BABYLON {
  141346. /**
  141347. * Block used to create a Color3/4 out of individual inputs (one for each component)
  141348. */
  141349. export class ColorMergerBlock extends NodeMaterialBlock {
  141350. /**
  141351. * Create a new ColorMergerBlock
  141352. * @param name defines the block name
  141353. */
  141354. constructor(name: string);
  141355. /**
  141356. * Gets the current class name
  141357. * @returns the class name
  141358. */
  141359. getClassName(): string;
  141360. /**
  141361. * Gets the rgb component (input)
  141362. */
  141363. get rgbIn(): NodeMaterialConnectionPoint;
  141364. /**
  141365. * Gets the r component (input)
  141366. */
  141367. get r(): NodeMaterialConnectionPoint;
  141368. /**
  141369. * Gets the g component (input)
  141370. */
  141371. get g(): NodeMaterialConnectionPoint;
  141372. /**
  141373. * Gets the b component (input)
  141374. */
  141375. get b(): NodeMaterialConnectionPoint;
  141376. /**
  141377. * Gets the a component (input)
  141378. */
  141379. get a(): NodeMaterialConnectionPoint;
  141380. /**
  141381. * Gets the rgba component (output)
  141382. */
  141383. get rgba(): NodeMaterialConnectionPoint;
  141384. /**
  141385. * Gets the rgb component (output)
  141386. */
  141387. get rgbOut(): NodeMaterialConnectionPoint;
  141388. /**
  141389. * Gets the rgb component (output)
  141390. * @deprecated Please use rgbOut instead.
  141391. */
  141392. get rgb(): NodeMaterialConnectionPoint;
  141393. protected _buildBlock(state: NodeMaterialBuildState): this;
  141394. }
  141395. }
  141396. declare module BABYLON {
  141397. /**
  141398. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  141399. */
  141400. export class VectorSplitterBlock extends NodeMaterialBlock {
  141401. /**
  141402. * Create a new VectorSplitterBlock
  141403. * @param name defines the block name
  141404. */
  141405. constructor(name: string);
  141406. /**
  141407. * Gets the current class name
  141408. * @returns the class name
  141409. */
  141410. getClassName(): string;
  141411. /**
  141412. * Gets the xyzw component (input)
  141413. */
  141414. get xyzw(): NodeMaterialConnectionPoint;
  141415. /**
  141416. * Gets the xyz component (input)
  141417. */
  141418. get xyzIn(): NodeMaterialConnectionPoint;
  141419. /**
  141420. * Gets the xy component (input)
  141421. */
  141422. get xyIn(): NodeMaterialConnectionPoint;
  141423. /**
  141424. * Gets the xyz component (output)
  141425. */
  141426. get xyzOut(): NodeMaterialConnectionPoint;
  141427. /**
  141428. * Gets the xy component (output)
  141429. */
  141430. get xyOut(): NodeMaterialConnectionPoint;
  141431. /**
  141432. * Gets the x component (output)
  141433. */
  141434. get x(): NodeMaterialConnectionPoint;
  141435. /**
  141436. * Gets the y component (output)
  141437. */
  141438. get y(): NodeMaterialConnectionPoint;
  141439. /**
  141440. * Gets the z component (output)
  141441. */
  141442. get z(): NodeMaterialConnectionPoint;
  141443. /**
  141444. * Gets the w component (output)
  141445. */
  141446. get w(): NodeMaterialConnectionPoint;
  141447. protected _inputRename(name: string): string;
  141448. protected _outputRename(name: string): string;
  141449. protected _buildBlock(state: NodeMaterialBuildState): this;
  141450. }
  141451. }
  141452. declare module BABYLON {
  141453. /**
  141454. * Block used to lerp between 2 values
  141455. */
  141456. export class LerpBlock extends NodeMaterialBlock {
  141457. /**
  141458. * Creates a new LerpBlock
  141459. * @param name defines the block name
  141460. */
  141461. constructor(name: string);
  141462. /**
  141463. * Gets the current class name
  141464. * @returns the class name
  141465. */
  141466. getClassName(): string;
  141467. /**
  141468. * Gets the left operand input component
  141469. */
  141470. get left(): NodeMaterialConnectionPoint;
  141471. /**
  141472. * Gets the right operand input component
  141473. */
  141474. get right(): NodeMaterialConnectionPoint;
  141475. /**
  141476. * Gets the gradient operand input component
  141477. */
  141478. get gradient(): NodeMaterialConnectionPoint;
  141479. /**
  141480. * Gets the output component
  141481. */
  141482. get output(): NodeMaterialConnectionPoint;
  141483. protected _buildBlock(state: NodeMaterialBuildState): this;
  141484. }
  141485. }
  141486. declare module BABYLON {
  141487. /**
  141488. * Block used to divide 2 vectors
  141489. */
  141490. export class DivideBlock extends NodeMaterialBlock {
  141491. /**
  141492. * Creates a new DivideBlock
  141493. * @param name defines the block name
  141494. */
  141495. constructor(name: string);
  141496. /**
  141497. * Gets the current class name
  141498. * @returns the class name
  141499. */
  141500. getClassName(): string;
  141501. /**
  141502. * Gets the left operand input component
  141503. */
  141504. get left(): NodeMaterialConnectionPoint;
  141505. /**
  141506. * Gets the right operand input component
  141507. */
  141508. get right(): NodeMaterialConnectionPoint;
  141509. /**
  141510. * Gets the output component
  141511. */
  141512. get output(): NodeMaterialConnectionPoint;
  141513. protected _buildBlock(state: NodeMaterialBuildState): this;
  141514. }
  141515. }
  141516. declare module BABYLON {
  141517. /**
  141518. * Block used to subtract 2 vectors
  141519. */
  141520. export class SubtractBlock extends NodeMaterialBlock {
  141521. /**
  141522. * Creates a new SubtractBlock
  141523. * @param name defines the block name
  141524. */
  141525. constructor(name: string);
  141526. /**
  141527. * Gets the current class name
  141528. * @returns the class name
  141529. */
  141530. getClassName(): string;
  141531. /**
  141532. * Gets the left operand input component
  141533. */
  141534. get left(): NodeMaterialConnectionPoint;
  141535. /**
  141536. * Gets the right operand input component
  141537. */
  141538. get right(): NodeMaterialConnectionPoint;
  141539. /**
  141540. * Gets the output component
  141541. */
  141542. get output(): NodeMaterialConnectionPoint;
  141543. protected _buildBlock(state: NodeMaterialBuildState): this;
  141544. }
  141545. }
  141546. declare module BABYLON {
  141547. /**
  141548. * Block used to step a value
  141549. */
  141550. export class StepBlock extends NodeMaterialBlock {
  141551. /**
  141552. * Creates a new StepBlock
  141553. * @param name defines the block name
  141554. */
  141555. constructor(name: string);
  141556. /**
  141557. * Gets the current class name
  141558. * @returns the class name
  141559. */
  141560. getClassName(): string;
  141561. /**
  141562. * Gets the value operand input component
  141563. */
  141564. get value(): NodeMaterialConnectionPoint;
  141565. /**
  141566. * Gets the edge operand input component
  141567. */
  141568. get edge(): NodeMaterialConnectionPoint;
  141569. /**
  141570. * Gets the output component
  141571. */
  141572. get output(): NodeMaterialConnectionPoint;
  141573. protected _buildBlock(state: NodeMaterialBuildState): this;
  141574. }
  141575. }
  141576. declare module BABYLON {
  141577. /**
  141578. * Block used to get the opposite (1 - x) of a value
  141579. */
  141580. export class OneMinusBlock extends NodeMaterialBlock {
  141581. /**
  141582. * Creates a new OneMinusBlock
  141583. * @param name defines the block name
  141584. */
  141585. constructor(name: string);
  141586. /**
  141587. * Gets the current class name
  141588. * @returns the class name
  141589. */
  141590. getClassName(): string;
  141591. /**
  141592. * Gets the input component
  141593. */
  141594. get input(): NodeMaterialConnectionPoint;
  141595. /**
  141596. * Gets the output component
  141597. */
  141598. get output(): NodeMaterialConnectionPoint;
  141599. protected _buildBlock(state: NodeMaterialBuildState): this;
  141600. }
  141601. }
  141602. declare module BABYLON {
  141603. /**
  141604. * Block used to get the view direction
  141605. */
  141606. export class ViewDirectionBlock extends NodeMaterialBlock {
  141607. /**
  141608. * Creates a new ViewDirectionBlock
  141609. * @param name defines the block name
  141610. */
  141611. constructor(name: string);
  141612. /**
  141613. * Gets the current class name
  141614. * @returns the class name
  141615. */
  141616. getClassName(): string;
  141617. /**
  141618. * Gets the world position component
  141619. */
  141620. get worldPosition(): NodeMaterialConnectionPoint;
  141621. /**
  141622. * Gets the camera position component
  141623. */
  141624. get cameraPosition(): NodeMaterialConnectionPoint;
  141625. /**
  141626. * Gets the output component
  141627. */
  141628. get output(): NodeMaterialConnectionPoint;
  141629. autoConfigure(material: NodeMaterial): void;
  141630. protected _buildBlock(state: NodeMaterialBuildState): this;
  141631. }
  141632. }
  141633. declare module BABYLON {
  141634. /**
  141635. * Block used to compute fresnel value
  141636. */
  141637. export class FresnelBlock extends NodeMaterialBlock {
  141638. /**
  141639. * Create a new FresnelBlock
  141640. * @param name defines the block name
  141641. */
  141642. constructor(name: string);
  141643. /**
  141644. * Gets the current class name
  141645. * @returns the class name
  141646. */
  141647. getClassName(): string;
  141648. /**
  141649. * Gets the world normal input component
  141650. */
  141651. get worldNormal(): NodeMaterialConnectionPoint;
  141652. /**
  141653. * Gets the view direction input component
  141654. */
  141655. get viewDirection(): NodeMaterialConnectionPoint;
  141656. /**
  141657. * Gets the bias input component
  141658. */
  141659. get bias(): NodeMaterialConnectionPoint;
  141660. /**
  141661. * Gets the camera (or eye) position component
  141662. */
  141663. get power(): NodeMaterialConnectionPoint;
  141664. /**
  141665. * Gets the fresnel output component
  141666. */
  141667. get fresnel(): NodeMaterialConnectionPoint;
  141668. autoConfigure(material: NodeMaterial): void;
  141669. protected _buildBlock(state: NodeMaterialBuildState): this;
  141670. }
  141671. }
  141672. declare module BABYLON {
  141673. /**
  141674. * Block used to get the max of 2 values
  141675. */
  141676. export class MaxBlock extends NodeMaterialBlock {
  141677. /**
  141678. * Creates a new MaxBlock
  141679. * @param name defines the block name
  141680. */
  141681. constructor(name: string);
  141682. /**
  141683. * Gets the current class name
  141684. * @returns the class name
  141685. */
  141686. getClassName(): string;
  141687. /**
  141688. * Gets the left operand input component
  141689. */
  141690. get left(): NodeMaterialConnectionPoint;
  141691. /**
  141692. * Gets the right operand input component
  141693. */
  141694. get right(): NodeMaterialConnectionPoint;
  141695. /**
  141696. * Gets the output component
  141697. */
  141698. get output(): NodeMaterialConnectionPoint;
  141699. protected _buildBlock(state: NodeMaterialBuildState): this;
  141700. }
  141701. }
  141702. declare module BABYLON {
  141703. /**
  141704. * Block used to get the min of 2 values
  141705. */
  141706. export class MinBlock extends NodeMaterialBlock {
  141707. /**
  141708. * Creates a new MinBlock
  141709. * @param name defines the block name
  141710. */
  141711. constructor(name: string);
  141712. /**
  141713. * Gets the current class name
  141714. * @returns the class name
  141715. */
  141716. getClassName(): string;
  141717. /**
  141718. * Gets the left operand input component
  141719. */
  141720. get left(): NodeMaterialConnectionPoint;
  141721. /**
  141722. * Gets the right operand input component
  141723. */
  141724. get right(): NodeMaterialConnectionPoint;
  141725. /**
  141726. * Gets the output component
  141727. */
  141728. get output(): NodeMaterialConnectionPoint;
  141729. protected _buildBlock(state: NodeMaterialBuildState): this;
  141730. }
  141731. }
  141732. declare module BABYLON {
  141733. /**
  141734. * Block used to get the distance between 2 values
  141735. */
  141736. export class DistanceBlock extends NodeMaterialBlock {
  141737. /**
  141738. * Creates a new DistanceBlock
  141739. * @param name defines the block name
  141740. */
  141741. constructor(name: string);
  141742. /**
  141743. * Gets the current class name
  141744. * @returns the class name
  141745. */
  141746. getClassName(): string;
  141747. /**
  141748. * Gets the left operand input component
  141749. */
  141750. get left(): NodeMaterialConnectionPoint;
  141751. /**
  141752. * Gets the right operand input component
  141753. */
  141754. get right(): NodeMaterialConnectionPoint;
  141755. /**
  141756. * Gets the output component
  141757. */
  141758. get output(): NodeMaterialConnectionPoint;
  141759. protected _buildBlock(state: NodeMaterialBuildState): this;
  141760. }
  141761. }
  141762. declare module BABYLON {
  141763. /**
  141764. * Block used to get the length of a vector
  141765. */
  141766. export class LengthBlock extends NodeMaterialBlock {
  141767. /**
  141768. * Creates a new LengthBlock
  141769. * @param name defines the block name
  141770. */
  141771. constructor(name: string);
  141772. /**
  141773. * Gets the current class name
  141774. * @returns the class name
  141775. */
  141776. getClassName(): string;
  141777. /**
  141778. * Gets the value input component
  141779. */
  141780. get value(): NodeMaterialConnectionPoint;
  141781. /**
  141782. * Gets the output component
  141783. */
  141784. get output(): NodeMaterialConnectionPoint;
  141785. protected _buildBlock(state: NodeMaterialBuildState): this;
  141786. }
  141787. }
  141788. declare module BABYLON {
  141789. /**
  141790. * Block used to get negative version of a value (i.e. x * -1)
  141791. */
  141792. export class NegateBlock extends NodeMaterialBlock {
  141793. /**
  141794. * Creates a new NegateBlock
  141795. * @param name defines the block name
  141796. */
  141797. constructor(name: string);
  141798. /**
  141799. * Gets the current class name
  141800. * @returns the class name
  141801. */
  141802. getClassName(): string;
  141803. /**
  141804. * Gets the value input component
  141805. */
  141806. get value(): NodeMaterialConnectionPoint;
  141807. /**
  141808. * Gets the output component
  141809. */
  141810. get output(): NodeMaterialConnectionPoint;
  141811. protected _buildBlock(state: NodeMaterialBuildState): this;
  141812. }
  141813. }
  141814. declare module BABYLON {
  141815. /**
  141816. * Block used to get the value of the first parameter raised to the power of the second
  141817. */
  141818. export class PowBlock extends NodeMaterialBlock {
  141819. /**
  141820. * Creates a new PowBlock
  141821. * @param name defines the block name
  141822. */
  141823. constructor(name: string);
  141824. /**
  141825. * Gets the current class name
  141826. * @returns the class name
  141827. */
  141828. getClassName(): string;
  141829. /**
  141830. * Gets the value operand input component
  141831. */
  141832. get value(): NodeMaterialConnectionPoint;
  141833. /**
  141834. * Gets the power operand input component
  141835. */
  141836. get power(): NodeMaterialConnectionPoint;
  141837. /**
  141838. * Gets the output component
  141839. */
  141840. get output(): NodeMaterialConnectionPoint;
  141841. protected _buildBlock(state: NodeMaterialBuildState): this;
  141842. }
  141843. }
  141844. declare module BABYLON {
  141845. /**
  141846. * Block used to get a random number
  141847. */
  141848. export class RandomNumberBlock extends NodeMaterialBlock {
  141849. /**
  141850. * Creates a new RandomNumberBlock
  141851. * @param name defines the block name
  141852. */
  141853. constructor(name: string);
  141854. /**
  141855. * Gets the current class name
  141856. * @returns the class name
  141857. */
  141858. getClassName(): string;
  141859. /**
  141860. * Gets the seed input component
  141861. */
  141862. get seed(): NodeMaterialConnectionPoint;
  141863. /**
  141864. * Gets the output component
  141865. */
  141866. get output(): NodeMaterialConnectionPoint;
  141867. protected _buildBlock(state: NodeMaterialBuildState): this;
  141868. }
  141869. }
  141870. declare module BABYLON {
  141871. /**
  141872. * Block used to compute arc tangent of 2 values
  141873. */
  141874. export class ArcTan2Block extends NodeMaterialBlock {
  141875. /**
  141876. * Creates a new ArcTan2Block
  141877. * @param name defines the block name
  141878. */
  141879. constructor(name: string);
  141880. /**
  141881. * Gets the current class name
  141882. * @returns the class name
  141883. */
  141884. getClassName(): string;
  141885. /**
  141886. * Gets the x operand input component
  141887. */
  141888. get x(): NodeMaterialConnectionPoint;
  141889. /**
  141890. * Gets the y operand input component
  141891. */
  141892. get y(): NodeMaterialConnectionPoint;
  141893. /**
  141894. * Gets the output component
  141895. */
  141896. get output(): NodeMaterialConnectionPoint;
  141897. protected _buildBlock(state: NodeMaterialBuildState): this;
  141898. }
  141899. }
  141900. declare module BABYLON {
  141901. /**
  141902. * Block used to smooth step a value
  141903. */
  141904. export class SmoothStepBlock extends NodeMaterialBlock {
  141905. /**
  141906. * Creates a new SmoothStepBlock
  141907. * @param name defines the block name
  141908. */
  141909. constructor(name: string);
  141910. /**
  141911. * Gets the current class name
  141912. * @returns the class name
  141913. */
  141914. getClassName(): string;
  141915. /**
  141916. * Gets the value operand input component
  141917. */
  141918. get value(): NodeMaterialConnectionPoint;
  141919. /**
  141920. * Gets the first edge operand input component
  141921. */
  141922. get edge0(): NodeMaterialConnectionPoint;
  141923. /**
  141924. * Gets the second edge operand input component
  141925. */
  141926. get edge1(): NodeMaterialConnectionPoint;
  141927. /**
  141928. * Gets the output component
  141929. */
  141930. get output(): NodeMaterialConnectionPoint;
  141931. protected _buildBlock(state: NodeMaterialBuildState): this;
  141932. }
  141933. }
  141934. declare module BABYLON {
  141935. /**
  141936. * Block used to get the reciprocal (1 / x) of a value
  141937. */
  141938. export class ReciprocalBlock extends NodeMaterialBlock {
  141939. /**
  141940. * Creates a new ReciprocalBlock
  141941. * @param name defines the block name
  141942. */
  141943. constructor(name: string);
  141944. /**
  141945. * Gets the current class name
  141946. * @returns the class name
  141947. */
  141948. getClassName(): string;
  141949. /**
  141950. * Gets the input component
  141951. */
  141952. get input(): NodeMaterialConnectionPoint;
  141953. /**
  141954. * Gets the output component
  141955. */
  141956. get output(): NodeMaterialConnectionPoint;
  141957. protected _buildBlock(state: NodeMaterialBuildState): this;
  141958. }
  141959. }
  141960. declare module BABYLON {
  141961. /**
  141962. * Block used to replace a color by another one
  141963. */
  141964. export class ReplaceColorBlock extends NodeMaterialBlock {
  141965. /**
  141966. * Creates a new ReplaceColorBlock
  141967. * @param name defines the block name
  141968. */
  141969. constructor(name: string);
  141970. /**
  141971. * Gets the current class name
  141972. * @returns the class name
  141973. */
  141974. getClassName(): string;
  141975. /**
  141976. * Gets the value input component
  141977. */
  141978. get value(): NodeMaterialConnectionPoint;
  141979. /**
  141980. * Gets the reference input component
  141981. */
  141982. get reference(): NodeMaterialConnectionPoint;
  141983. /**
  141984. * Gets the distance input component
  141985. */
  141986. get distance(): NodeMaterialConnectionPoint;
  141987. /**
  141988. * Gets the replacement input component
  141989. */
  141990. get replacement(): NodeMaterialConnectionPoint;
  141991. /**
  141992. * Gets the output component
  141993. */
  141994. get output(): NodeMaterialConnectionPoint;
  141995. protected _buildBlock(state: NodeMaterialBuildState): this;
  141996. }
  141997. }
  141998. declare module BABYLON {
  141999. /**
  142000. * Block used to posterize a value
  142001. * @see https://en.wikipedia.org/wiki/Posterization
  142002. */
  142003. export class PosterizeBlock extends NodeMaterialBlock {
  142004. /**
  142005. * Creates a new PosterizeBlock
  142006. * @param name defines the block name
  142007. */
  142008. constructor(name: string);
  142009. /**
  142010. * Gets the current class name
  142011. * @returns the class name
  142012. */
  142013. getClassName(): string;
  142014. /**
  142015. * Gets the value input component
  142016. */
  142017. get value(): NodeMaterialConnectionPoint;
  142018. /**
  142019. * Gets the steps input component
  142020. */
  142021. get steps(): NodeMaterialConnectionPoint;
  142022. /**
  142023. * Gets the output component
  142024. */
  142025. get output(): NodeMaterialConnectionPoint;
  142026. protected _buildBlock(state: NodeMaterialBuildState): this;
  142027. }
  142028. }
  142029. declare module BABYLON {
  142030. /**
  142031. * Operations supported by the Wave block
  142032. */
  142033. export enum WaveBlockKind {
  142034. /** SawTooth */
  142035. SawTooth = 0,
  142036. /** Square */
  142037. Square = 1,
  142038. /** Triangle */
  142039. Triangle = 2
  142040. }
  142041. /**
  142042. * Block used to apply wave operation to floats
  142043. */
  142044. export class WaveBlock extends NodeMaterialBlock {
  142045. /**
  142046. * Gets or sets the kibnd of wave to be applied by the block
  142047. */
  142048. kind: WaveBlockKind;
  142049. /**
  142050. * Creates a new WaveBlock
  142051. * @param name defines the block name
  142052. */
  142053. constructor(name: string);
  142054. /**
  142055. * Gets the current class name
  142056. * @returns the class name
  142057. */
  142058. getClassName(): string;
  142059. /**
  142060. * Gets the input component
  142061. */
  142062. get input(): NodeMaterialConnectionPoint;
  142063. /**
  142064. * Gets the output component
  142065. */
  142066. get output(): NodeMaterialConnectionPoint;
  142067. protected _buildBlock(state: NodeMaterialBuildState): this;
  142068. serialize(): any;
  142069. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142070. }
  142071. }
  142072. declare module BABYLON {
  142073. /**
  142074. * Class used to store a color step for the GradientBlock
  142075. */
  142076. export class GradientBlockColorStep {
  142077. /**
  142078. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  142079. */
  142080. step: number;
  142081. /**
  142082. * Gets or sets the color associated with this step
  142083. */
  142084. color: Color3;
  142085. /**
  142086. * Creates a new GradientBlockColorStep
  142087. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  142088. * @param color defines the color associated with this step
  142089. */
  142090. constructor(
  142091. /**
  142092. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  142093. */
  142094. step: number,
  142095. /**
  142096. * Gets or sets the color associated with this step
  142097. */
  142098. color: Color3);
  142099. }
  142100. /**
  142101. * Block used to return a color from a gradient based on an input value between 0 and 1
  142102. */
  142103. export class GradientBlock extends NodeMaterialBlock {
  142104. /**
  142105. * Gets or sets the list of color steps
  142106. */
  142107. colorSteps: GradientBlockColorStep[];
  142108. /**
  142109. * Creates a new GradientBlock
  142110. * @param name defines the block name
  142111. */
  142112. constructor(name: string);
  142113. /**
  142114. * Gets the current class name
  142115. * @returns the class name
  142116. */
  142117. getClassName(): string;
  142118. /**
  142119. * Gets the gradient input component
  142120. */
  142121. get gradient(): NodeMaterialConnectionPoint;
  142122. /**
  142123. * Gets the output component
  142124. */
  142125. get output(): NodeMaterialConnectionPoint;
  142126. private _writeColorConstant;
  142127. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142128. serialize(): any;
  142129. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142130. protected _dumpPropertiesCode(): string;
  142131. }
  142132. }
  142133. declare module BABYLON {
  142134. /**
  142135. * Block used to normalize lerp between 2 values
  142136. */
  142137. export class NLerpBlock extends NodeMaterialBlock {
  142138. /**
  142139. * Creates a new NLerpBlock
  142140. * @param name defines the block name
  142141. */
  142142. constructor(name: string);
  142143. /**
  142144. * Gets the current class name
  142145. * @returns the class name
  142146. */
  142147. getClassName(): string;
  142148. /**
  142149. * Gets the left operand input component
  142150. */
  142151. get left(): NodeMaterialConnectionPoint;
  142152. /**
  142153. * Gets the right operand input component
  142154. */
  142155. get right(): NodeMaterialConnectionPoint;
  142156. /**
  142157. * Gets the gradient operand input component
  142158. */
  142159. get gradient(): NodeMaterialConnectionPoint;
  142160. /**
  142161. * Gets the output component
  142162. */
  142163. get output(): NodeMaterialConnectionPoint;
  142164. protected _buildBlock(state: NodeMaterialBuildState): this;
  142165. }
  142166. }
  142167. declare module BABYLON {
  142168. /**
  142169. * block used to Generate a Worley Noise 3D Noise Pattern
  142170. */
  142171. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  142172. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  142173. manhattanDistance: boolean;
  142174. /**
  142175. * Creates a new WorleyNoise3DBlock
  142176. * @param name defines the block name
  142177. */
  142178. constructor(name: string);
  142179. /**
  142180. * Gets the current class name
  142181. * @returns the class name
  142182. */
  142183. getClassName(): string;
  142184. /**
  142185. * Gets the seed input component
  142186. */
  142187. get seed(): NodeMaterialConnectionPoint;
  142188. /**
  142189. * Gets the jitter input component
  142190. */
  142191. get jitter(): NodeMaterialConnectionPoint;
  142192. /**
  142193. * Gets the output component
  142194. */
  142195. get output(): NodeMaterialConnectionPoint;
  142196. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142197. /**
  142198. * Exposes the properties to the UI?
  142199. */
  142200. protected _dumpPropertiesCode(): string;
  142201. /**
  142202. * Exposes the properties to the Seralize?
  142203. */
  142204. serialize(): any;
  142205. /**
  142206. * Exposes the properties to the deseralize?
  142207. */
  142208. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142209. }
  142210. }
  142211. declare module BABYLON {
  142212. /**
  142213. * block used to Generate a Simplex Perlin 3d Noise Pattern
  142214. */
  142215. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  142216. /**
  142217. * Creates a new SimplexPerlin3DBlock
  142218. * @param name defines the block name
  142219. */
  142220. constructor(name: string);
  142221. /**
  142222. * Gets the current class name
  142223. * @returns the class name
  142224. */
  142225. getClassName(): string;
  142226. /**
  142227. * Gets the seed operand input component
  142228. */
  142229. get seed(): NodeMaterialConnectionPoint;
  142230. /**
  142231. * Gets the output component
  142232. */
  142233. get output(): NodeMaterialConnectionPoint;
  142234. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142235. }
  142236. }
  142237. declare module BABYLON {
  142238. /**
  142239. * Block used to blend normals
  142240. */
  142241. export class NormalBlendBlock extends NodeMaterialBlock {
  142242. /**
  142243. * Creates a new NormalBlendBlock
  142244. * @param name defines the block name
  142245. */
  142246. constructor(name: string);
  142247. /**
  142248. * Gets the current class name
  142249. * @returns the class name
  142250. */
  142251. getClassName(): string;
  142252. /**
  142253. * Gets the first input component
  142254. */
  142255. get normalMap0(): NodeMaterialConnectionPoint;
  142256. /**
  142257. * Gets the second input component
  142258. */
  142259. get normalMap1(): NodeMaterialConnectionPoint;
  142260. /**
  142261. * Gets the output component
  142262. */
  142263. get output(): NodeMaterialConnectionPoint;
  142264. protected _buildBlock(state: NodeMaterialBuildState): this;
  142265. }
  142266. }
  142267. declare module BABYLON {
  142268. /**
  142269. * Block used to rotate a 2d vector by a given angle
  142270. */
  142271. export class Rotate2dBlock extends NodeMaterialBlock {
  142272. /**
  142273. * Creates a new Rotate2dBlock
  142274. * @param name defines the block name
  142275. */
  142276. constructor(name: string);
  142277. /**
  142278. * Gets the current class name
  142279. * @returns the class name
  142280. */
  142281. getClassName(): string;
  142282. /**
  142283. * Gets the input vector
  142284. */
  142285. get input(): NodeMaterialConnectionPoint;
  142286. /**
  142287. * Gets the input angle
  142288. */
  142289. get angle(): NodeMaterialConnectionPoint;
  142290. /**
  142291. * Gets the output component
  142292. */
  142293. get output(): NodeMaterialConnectionPoint;
  142294. autoConfigure(material: NodeMaterial): void;
  142295. protected _buildBlock(state: NodeMaterialBuildState): this;
  142296. }
  142297. }
  142298. declare module BABYLON {
  142299. /**
  142300. * Block used to get the reflected vector from a direction and a normal
  142301. */
  142302. export class ReflectBlock extends NodeMaterialBlock {
  142303. /**
  142304. * Creates a new ReflectBlock
  142305. * @param name defines the block name
  142306. */
  142307. constructor(name: string);
  142308. /**
  142309. * Gets the current class name
  142310. * @returns the class name
  142311. */
  142312. getClassName(): string;
  142313. /**
  142314. * Gets the incident component
  142315. */
  142316. get incident(): NodeMaterialConnectionPoint;
  142317. /**
  142318. * Gets the normal component
  142319. */
  142320. get normal(): NodeMaterialConnectionPoint;
  142321. /**
  142322. * Gets the output component
  142323. */
  142324. get output(): NodeMaterialConnectionPoint;
  142325. protected _buildBlock(state: NodeMaterialBuildState): this;
  142326. }
  142327. }
  142328. declare module BABYLON {
  142329. /**
  142330. * Block used to get the refracted vector from a direction and a normal
  142331. */
  142332. export class RefractBlock extends NodeMaterialBlock {
  142333. /**
  142334. * Creates a new RefractBlock
  142335. * @param name defines the block name
  142336. */
  142337. constructor(name: string);
  142338. /**
  142339. * Gets the current class name
  142340. * @returns the class name
  142341. */
  142342. getClassName(): string;
  142343. /**
  142344. * Gets the incident component
  142345. */
  142346. get incident(): NodeMaterialConnectionPoint;
  142347. /**
  142348. * Gets the normal component
  142349. */
  142350. get normal(): NodeMaterialConnectionPoint;
  142351. /**
  142352. * Gets the index of refraction component
  142353. */
  142354. get ior(): NodeMaterialConnectionPoint;
  142355. /**
  142356. * Gets the output component
  142357. */
  142358. get output(): NodeMaterialConnectionPoint;
  142359. protected _buildBlock(state: NodeMaterialBuildState): this;
  142360. }
  142361. }
  142362. declare module BABYLON {
  142363. /**
  142364. * Block used to desaturate a color
  142365. */
  142366. export class DesaturateBlock extends NodeMaterialBlock {
  142367. /**
  142368. * Creates a new DesaturateBlock
  142369. * @param name defines the block name
  142370. */
  142371. constructor(name: string);
  142372. /**
  142373. * Gets the current class name
  142374. * @returns the class name
  142375. */
  142376. getClassName(): string;
  142377. /**
  142378. * Gets the color operand input component
  142379. */
  142380. get color(): NodeMaterialConnectionPoint;
  142381. /**
  142382. * Gets the level operand input component
  142383. */
  142384. get level(): NodeMaterialConnectionPoint;
  142385. /**
  142386. * Gets the output component
  142387. */
  142388. get output(): NodeMaterialConnectionPoint;
  142389. protected _buildBlock(state: NodeMaterialBuildState): this;
  142390. }
  142391. }
  142392. declare module BABYLON {
  142393. /**
  142394. * Block used to implement the ambient occlusion module of the PBR material
  142395. */
  142396. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  142397. /**
  142398. * Create a new AmbientOcclusionBlock
  142399. * @param name defines the block name
  142400. */
  142401. constructor(name: string);
  142402. /**
  142403. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  142404. */
  142405. useAmbientInGrayScale: boolean;
  142406. /**
  142407. * Initialize the block and prepare the context for build
  142408. * @param state defines the state that will be used for the build
  142409. */
  142410. initialize(state: NodeMaterialBuildState): void;
  142411. /**
  142412. * Gets the current class name
  142413. * @returns the class name
  142414. */
  142415. getClassName(): string;
  142416. /**
  142417. * Gets the texture input component
  142418. */
  142419. get texture(): NodeMaterialConnectionPoint;
  142420. /**
  142421. * Gets the texture intensity component
  142422. */
  142423. get intensity(): NodeMaterialConnectionPoint;
  142424. /**
  142425. * Gets the direct light intensity input component
  142426. */
  142427. get directLightIntensity(): NodeMaterialConnectionPoint;
  142428. /**
  142429. * Gets the ambient occlusion object output component
  142430. */
  142431. get ambientOcclusion(): NodeMaterialConnectionPoint;
  142432. /**
  142433. * Gets the main code of the block (fragment side)
  142434. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  142435. * @returns the shader code
  142436. */
  142437. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  142438. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142439. protected _buildBlock(state: NodeMaterialBuildState): this;
  142440. protected _dumpPropertiesCode(): string;
  142441. serialize(): any;
  142442. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142443. }
  142444. }
  142445. declare module BABYLON {
  142446. /**
  142447. * Block used to implement the reflection module of the PBR material
  142448. */
  142449. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  142450. /** @hidden */
  142451. _defineLODReflectionAlpha: string;
  142452. /** @hidden */
  142453. _defineLinearSpecularReflection: string;
  142454. private _vEnvironmentIrradianceName;
  142455. /** @hidden */
  142456. _vReflectionMicrosurfaceInfosName: string;
  142457. /** @hidden */
  142458. _vReflectionInfosName: string;
  142459. /** @hidden */
  142460. _vReflectionFilteringInfoName: string;
  142461. private _scene;
  142462. /**
  142463. * The three properties below are set by the main PBR block prior to calling methods of this class.
  142464. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  142465. * It's less burden on the user side in the editor part.
  142466. */
  142467. /** @hidden */
  142468. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  142469. /** @hidden */
  142470. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  142471. /** @hidden */
  142472. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  142473. /**
  142474. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  142475. * diffuse part of the IBL.
  142476. */
  142477. useSphericalHarmonics: boolean;
  142478. /**
  142479. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  142480. */
  142481. forceIrradianceInFragment: boolean;
  142482. /**
  142483. * Create a new ReflectionBlock
  142484. * @param name defines the block name
  142485. */
  142486. constructor(name: string);
  142487. /**
  142488. * Gets the current class name
  142489. * @returns the class name
  142490. */
  142491. getClassName(): string;
  142492. /**
  142493. * Gets the position input component
  142494. */
  142495. get position(): NodeMaterialConnectionPoint;
  142496. /**
  142497. * Gets the world position input component
  142498. */
  142499. get worldPosition(): NodeMaterialConnectionPoint;
  142500. /**
  142501. * Gets the world normal input component
  142502. */
  142503. get worldNormal(): NodeMaterialConnectionPoint;
  142504. /**
  142505. * Gets the world input component
  142506. */
  142507. get world(): NodeMaterialConnectionPoint;
  142508. /**
  142509. * Gets the camera (or eye) position component
  142510. */
  142511. get cameraPosition(): NodeMaterialConnectionPoint;
  142512. /**
  142513. * Gets the view input component
  142514. */
  142515. get view(): NodeMaterialConnectionPoint;
  142516. /**
  142517. * Gets the color input component
  142518. */
  142519. get color(): NodeMaterialConnectionPoint;
  142520. /**
  142521. * Gets the reflection object output component
  142522. */
  142523. get reflection(): NodeMaterialConnectionPoint;
  142524. /**
  142525. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  142526. */
  142527. get hasTexture(): boolean;
  142528. /**
  142529. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  142530. */
  142531. get reflectionColor(): string;
  142532. protected _getTexture(): Nullable<BaseTexture>;
  142533. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142534. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  142535. /**
  142536. * Gets the code to inject in the vertex shader
  142537. * @param state current state of the node material building
  142538. * @returns the shader code
  142539. */
  142540. handleVertexSide(state: NodeMaterialBuildState): string;
  142541. /**
  142542. * Gets the main code of the block (fragment side)
  142543. * @param state current state of the node material building
  142544. * @param normalVarName name of the existing variable corresponding to the normal
  142545. * @returns the shader code
  142546. */
  142547. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  142548. protected _buildBlock(state: NodeMaterialBuildState): this;
  142549. protected _dumpPropertiesCode(): string;
  142550. serialize(): any;
  142551. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142552. }
  142553. }
  142554. declare module BABYLON {
  142555. /**
  142556. * Block used to implement the sheen module of the PBR material
  142557. */
  142558. export class SheenBlock extends NodeMaterialBlock {
  142559. /**
  142560. * Create a new SheenBlock
  142561. * @param name defines the block name
  142562. */
  142563. constructor(name: string);
  142564. /**
  142565. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  142566. * It allows the strength of the sheen effect to not depend on the base color of the material,
  142567. * making it easier to setup and tweak the effect
  142568. */
  142569. albedoScaling: boolean;
  142570. /**
  142571. * Defines if the sheen is linked to the sheen color.
  142572. */
  142573. linkSheenWithAlbedo: boolean;
  142574. /**
  142575. * Initialize the block and prepare the context for build
  142576. * @param state defines the state that will be used for the build
  142577. */
  142578. initialize(state: NodeMaterialBuildState): void;
  142579. /**
  142580. * Gets the current class name
  142581. * @returns the class name
  142582. */
  142583. getClassName(): string;
  142584. /**
  142585. * Gets the intensity input component
  142586. */
  142587. get intensity(): NodeMaterialConnectionPoint;
  142588. /**
  142589. * Gets the color input component
  142590. */
  142591. get color(): NodeMaterialConnectionPoint;
  142592. /**
  142593. * Gets the roughness input component
  142594. */
  142595. get roughness(): NodeMaterialConnectionPoint;
  142596. /**
  142597. * Gets the sheen object output component
  142598. */
  142599. get sheen(): NodeMaterialConnectionPoint;
  142600. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142601. /**
  142602. * Gets the main code of the block (fragment side)
  142603. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  142604. * @returns the shader code
  142605. */
  142606. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  142607. protected _buildBlock(state: NodeMaterialBuildState): this;
  142608. protected _dumpPropertiesCode(): string;
  142609. serialize(): any;
  142610. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142611. }
  142612. }
  142613. declare module BABYLON {
  142614. /**
  142615. * Block used to implement the reflectivity module of the PBR material
  142616. */
  142617. export class ReflectivityBlock extends NodeMaterialBlock {
  142618. private _metallicReflectanceColor;
  142619. private _metallicF0Factor;
  142620. /** @hidden */
  142621. _vMetallicReflectanceFactorsName: string;
  142622. /**
  142623. * The property below is set by the main PBR block prior to calling methods of this class.
  142624. */
  142625. /** @hidden */
  142626. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  142627. /**
  142628. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  142629. */
  142630. useAmbientOcclusionFromMetallicTextureRed: boolean;
  142631. /**
  142632. * Specifies if the metallic texture contains the metallness information in its blue channel.
  142633. */
  142634. useMetallnessFromMetallicTextureBlue: boolean;
  142635. /**
  142636. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  142637. */
  142638. useRoughnessFromMetallicTextureAlpha: boolean;
  142639. /**
  142640. * Specifies if the metallic texture contains the roughness information in its green channel.
  142641. */
  142642. useRoughnessFromMetallicTextureGreen: boolean;
  142643. /**
  142644. * Create a new ReflectivityBlock
  142645. * @param name defines the block name
  142646. */
  142647. constructor(name: string);
  142648. /**
  142649. * Initialize the block and prepare the context for build
  142650. * @param state defines the state that will be used for the build
  142651. */
  142652. initialize(state: NodeMaterialBuildState): void;
  142653. /**
  142654. * Gets the current class name
  142655. * @returns the class name
  142656. */
  142657. getClassName(): string;
  142658. /**
  142659. * Gets the metallic input component
  142660. */
  142661. get metallic(): NodeMaterialConnectionPoint;
  142662. /**
  142663. * Gets the roughness input component
  142664. */
  142665. get roughness(): NodeMaterialConnectionPoint;
  142666. /**
  142667. * Gets the texture input component
  142668. */
  142669. get texture(): NodeMaterialConnectionPoint;
  142670. /**
  142671. * Gets the reflectivity object output component
  142672. */
  142673. get reflectivity(): NodeMaterialConnectionPoint;
  142674. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  142675. /**
  142676. * Gets the main code of the block (fragment side)
  142677. * @param state current state of the node material building
  142678. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  142679. * @returns the shader code
  142680. */
  142681. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  142682. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142683. protected _buildBlock(state: NodeMaterialBuildState): this;
  142684. protected _dumpPropertiesCode(): string;
  142685. serialize(): any;
  142686. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142687. }
  142688. }
  142689. declare module BABYLON {
  142690. /**
  142691. * Block used to implement the anisotropy module of the PBR material
  142692. */
  142693. export class AnisotropyBlock extends NodeMaterialBlock {
  142694. /**
  142695. * The two properties below are set by the main PBR block prior to calling methods of this class.
  142696. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  142697. * It's less burden on the user side in the editor part.
  142698. */
  142699. /** @hidden */
  142700. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  142701. /** @hidden */
  142702. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  142703. /**
  142704. * Create a new AnisotropyBlock
  142705. * @param name defines the block name
  142706. */
  142707. constructor(name: string);
  142708. /**
  142709. * Initialize the block and prepare the context for build
  142710. * @param state defines the state that will be used for the build
  142711. */
  142712. initialize(state: NodeMaterialBuildState): void;
  142713. /**
  142714. * Gets the current class name
  142715. * @returns the class name
  142716. */
  142717. getClassName(): string;
  142718. /**
  142719. * Gets the intensity input component
  142720. */
  142721. get intensity(): NodeMaterialConnectionPoint;
  142722. /**
  142723. * Gets the direction input component
  142724. */
  142725. get direction(): NodeMaterialConnectionPoint;
  142726. /**
  142727. * Gets the texture input component
  142728. */
  142729. get texture(): NodeMaterialConnectionPoint;
  142730. /**
  142731. * Gets the uv input component
  142732. */
  142733. get uv(): NodeMaterialConnectionPoint;
  142734. /**
  142735. * Gets the worldTangent input component
  142736. */
  142737. get worldTangent(): NodeMaterialConnectionPoint;
  142738. /**
  142739. * Gets the anisotropy object output component
  142740. */
  142741. get anisotropy(): NodeMaterialConnectionPoint;
  142742. private _generateTBNSpace;
  142743. /**
  142744. * Gets the main code of the block (fragment side)
  142745. * @param state current state of the node material building
  142746. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  142747. * @returns the shader code
  142748. */
  142749. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  142750. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142751. protected _buildBlock(state: NodeMaterialBuildState): this;
  142752. }
  142753. }
  142754. declare module BABYLON {
  142755. /**
  142756. * Block used to implement the clear coat module of the PBR material
  142757. */
  142758. export class ClearCoatBlock extends NodeMaterialBlock {
  142759. private _scene;
  142760. /**
  142761. * Create a new ClearCoatBlock
  142762. * @param name defines the block name
  142763. */
  142764. constructor(name: string);
  142765. /**
  142766. * Initialize the block and prepare the context for build
  142767. * @param state defines the state that will be used for the build
  142768. */
  142769. initialize(state: NodeMaterialBuildState): void;
  142770. /**
  142771. * Gets the current class name
  142772. * @returns the class name
  142773. */
  142774. getClassName(): string;
  142775. /**
  142776. * Gets the intensity input component
  142777. */
  142778. get intensity(): NodeMaterialConnectionPoint;
  142779. /**
  142780. * Gets the roughness input component
  142781. */
  142782. get roughness(): NodeMaterialConnectionPoint;
  142783. /**
  142784. * Gets the ior input component
  142785. */
  142786. get ior(): NodeMaterialConnectionPoint;
  142787. /**
  142788. * Gets the texture input component
  142789. */
  142790. get texture(): NodeMaterialConnectionPoint;
  142791. /**
  142792. * Gets the bump texture input component
  142793. */
  142794. get bumpTexture(): NodeMaterialConnectionPoint;
  142795. /**
  142796. * Gets the uv input component
  142797. */
  142798. get uv(): NodeMaterialConnectionPoint;
  142799. /**
  142800. * Gets the tint color input component
  142801. */
  142802. get tintColor(): NodeMaterialConnectionPoint;
  142803. /**
  142804. * Gets the tint "at distance" input component
  142805. */
  142806. get tintAtDistance(): NodeMaterialConnectionPoint;
  142807. /**
  142808. * Gets the tint thickness input component
  142809. */
  142810. get tintThickness(): NodeMaterialConnectionPoint;
  142811. /**
  142812. * Gets the world tangent input component
  142813. */
  142814. get worldTangent(): NodeMaterialConnectionPoint;
  142815. /**
  142816. * Gets the clear coat object output component
  142817. */
  142818. get clearcoat(): NodeMaterialConnectionPoint;
  142819. autoConfigure(material: NodeMaterial): void;
  142820. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142821. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  142822. private _generateTBNSpace;
  142823. /**
  142824. * Gets the main code of the block (fragment side)
  142825. * @param state current state of the node material building
  142826. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  142827. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  142828. * @param worldPosVarName name of the variable holding the world position
  142829. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  142830. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  142831. * @param worldNormalVarName name of the variable holding the world normal
  142832. * @returns the shader code
  142833. */
  142834. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  142835. protected _buildBlock(state: NodeMaterialBuildState): this;
  142836. }
  142837. }
  142838. declare module BABYLON {
  142839. /**
  142840. * Block used to implement the sub surface module of the PBR material
  142841. */
  142842. export class SubSurfaceBlock extends NodeMaterialBlock {
  142843. /**
  142844. * Create a new SubSurfaceBlock
  142845. * @param name defines the block name
  142846. */
  142847. constructor(name: string);
  142848. /**
  142849. * Stores the intensity of the different subsurface effects in the thickness texture.
  142850. * * the green channel is the translucency intensity.
  142851. * * the blue channel is the scattering intensity.
  142852. * * the alpha channel is the refraction intensity.
  142853. */
  142854. useMaskFromThicknessTexture: boolean;
  142855. /**
  142856. * Initialize the block and prepare the context for build
  142857. * @param state defines the state that will be used for the build
  142858. */
  142859. initialize(state: NodeMaterialBuildState): void;
  142860. /**
  142861. * Gets the current class name
  142862. * @returns the class name
  142863. */
  142864. getClassName(): string;
  142865. /**
  142866. * Gets the min thickness input component
  142867. */
  142868. get minThickness(): NodeMaterialConnectionPoint;
  142869. /**
  142870. * Gets the max thickness input component
  142871. */
  142872. get maxThickness(): NodeMaterialConnectionPoint;
  142873. /**
  142874. * Gets the thickness texture component
  142875. */
  142876. get thicknessTexture(): NodeMaterialConnectionPoint;
  142877. /**
  142878. * Gets the tint color input component
  142879. */
  142880. get tintColor(): NodeMaterialConnectionPoint;
  142881. /**
  142882. * Gets the translucency intensity input component
  142883. */
  142884. get translucencyIntensity(): NodeMaterialConnectionPoint;
  142885. /**
  142886. * Gets the translucency diffusion distance input component
  142887. */
  142888. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  142889. /**
  142890. * Gets the refraction object parameters
  142891. */
  142892. get refraction(): NodeMaterialConnectionPoint;
  142893. /**
  142894. * Gets the sub surface object output component
  142895. */
  142896. get subsurface(): NodeMaterialConnectionPoint;
  142897. autoConfigure(material: NodeMaterial): void;
  142898. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142899. /**
  142900. * Gets the main code of the block (fragment side)
  142901. * @param state current state of the node material building
  142902. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  142903. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  142904. * @param worldPosVarName name of the variable holding the world position
  142905. * @returns the shader code
  142906. */
  142907. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  142908. protected _buildBlock(state: NodeMaterialBuildState): this;
  142909. }
  142910. }
  142911. declare module BABYLON {
  142912. /**
  142913. * Block used to implement the PBR metallic/roughness model
  142914. */
  142915. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  142916. /**
  142917. * Gets or sets the light associated with this block
  142918. */
  142919. light: Nullable<Light>;
  142920. private _lightId;
  142921. private _scene;
  142922. private _environmentBRDFTexture;
  142923. private _environmentBrdfSamplerName;
  142924. private _vNormalWName;
  142925. private _invertNormalName;
  142926. /**
  142927. * Create a new ReflectionBlock
  142928. * @param name defines the block name
  142929. */
  142930. constructor(name: string);
  142931. /**
  142932. * Intensity of the direct lights e.g. the four lights available in your scene.
  142933. * This impacts both the direct diffuse and specular highlights.
  142934. */
  142935. directIntensity: number;
  142936. /**
  142937. * Intensity of the environment e.g. how much the environment will light the object
  142938. * either through harmonics for rough material or through the refelction for shiny ones.
  142939. */
  142940. environmentIntensity: number;
  142941. /**
  142942. * This is a special control allowing the reduction of the specular highlights coming from the
  142943. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  142944. */
  142945. specularIntensity: number;
  142946. /**
  142947. * Defines the falloff type used in this material.
  142948. * It by default is Physical.
  142949. */
  142950. lightFalloff: number;
  142951. /**
  142952. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  142953. */
  142954. useAlphaFromAlbedoTexture: boolean;
  142955. /**
  142956. * Specifies that alpha test should be used
  142957. */
  142958. useAlphaTest: boolean;
  142959. /**
  142960. * Defines the alpha limits in alpha test mode.
  142961. */
  142962. alphaTestCutoff: number;
  142963. /**
  142964. * Specifies that alpha blending should be used
  142965. */
  142966. useAlphaBlending: boolean;
  142967. /**
  142968. * Defines if the alpha value should be determined via the rgb values.
  142969. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  142970. */
  142971. opacityRGB: boolean;
  142972. /**
  142973. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  142974. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  142975. */
  142976. useRadianceOverAlpha: boolean;
  142977. /**
  142978. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  142979. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  142980. */
  142981. useSpecularOverAlpha: boolean;
  142982. /**
  142983. * Enables specular anti aliasing in the PBR shader.
  142984. * It will both interacts on the Geometry for analytical and IBL lighting.
  142985. * It also prefilter the roughness map based on the bump values.
  142986. */
  142987. enableSpecularAntiAliasing: boolean;
  142988. /**
  142989. * Enables realtime filtering on the texture.
  142990. */
  142991. realTimeFiltering: boolean;
  142992. /**
  142993. * Quality switch for realtime filtering
  142994. */
  142995. realTimeFilteringQuality: number;
  142996. /**
  142997. * Defines if the material uses energy conservation.
  142998. */
  142999. useEnergyConservation: boolean;
  143000. /**
  143001. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  143002. * too much the area relying on ambient texture to define their ambient occlusion.
  143003. */
  143004. useRadianceOcclusion: boolean;
  143005. /**
  143006. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  143007. * makes the reflect vector face the model (under horizon).
  143008. */
  143009. useHorizonOcclusion: boolean;
  143010. /**
  143011. * If set to true, no lighting calculations will be applied.
  143012. */
  143013. unlit: boolean;
  143014. /**
  143015. * Force normal to face away from face.
  143016. */
  143017. forceNormalForward: boolean;
  143018. /**
  143019. * Defines the material debug mode.
  143020. * It helps seeing only some components of the material while troubleshooting.
  143021. */
  143022. debugMode: number;
  143023. /**
  143024. * Specify from where on screen the debug mode should start.
  143025. * The value goes from -1 (full screen) to 1 (not visible)
  143026. * It helps with side by side comparison against the final render
  143027. * This defaults to 0
  143028. */
  143029. debugLimit: number;
  143030. /**
  143031. * As the default viewing range might not be enough (if the ambient is really small for instance)
  143032. * You can use the factor to better multiply the final value.
  143033. */
  143034. debugFactor: number;
  143035. /**
  143036. * Initialize the block and prepare the context for build
  143037. * @param state defines the state that will be used for the build
  143038. */
  143039. initialize(state: NodeMaterialBuildState): void;
  143040. /**
  143041. * Gets the current class name
  143042. * @returns the class name
  143043. */
  143044. getClassName(): string;
  143045. /**
  143046. * Gets the world position input component
  143047. */
  143048. get worldPosition(): NodeMaterialConnectionPoint;
  143049. /**
  143050. * Gets the world normal input component
  143051. */
  143052. get worldNormal(): NodeMaterialConnectionPoint;
  143053. /**
  143054. * Gets the perturbed normal input component
  143055. */
  143056. get perturbedNormal(): NodeMaterialConnectionPoint;
  143057. /**
  143058. * Gets the camera position input component
  143059. */
  143060. get cameraPosition(): NodeMaterialConnectionPoint;
  143061. /**
  143062. * Gets the base color input component
  143063. */
  143064. get baseColor(): NodeMaterialConnectionPoint;
  143065. /**
  143066. * Gets the opacity texture input component
  143067. */
  143068. get opacityTexture(): NodeMaterialConnectionPoint;
  143069. /**
  143070. * Gets the ambient color input component
  143071. */
  143072. get ambientColor(): NodeMaterialConnectionPoint;
  143073. /**
  143074. * Gets the reflectivity object parameters
  143075. */
  143076. get reflectivity(): NodeMaterialConnectionPoint;
  143077. /**
  143078. * Gets the ambient occlusion object parameters
  143079. */
  143080. get ambientOcclusion(): NodeMaterialConnectionPoint;
  143081. /**
  143082. * Gets the reflection object parameters
  143083. */
  143084. get reflection(): NodeMaterialConnectionPoint;
  143085. /**
  143086. * Gets the sheen object parameters
  143087. */
  143088. get sheen(): NodeMaterialConnectionPoint;
  143089. /**
  143090. * Gets the clear coat object parameters
  143091. */
  143092. get clearcoat(): NodeMaterialConnectionPoint;
  143093. /**
  143094. * Gets the sub surface object parameters
  143095. */
  143096. get subsurface(): NodeMaterialConnectionPoint;
  143097. /**
  143098. * Gets the anisotropy object parameters
  143099. */
  143100. get anisotropy(): NodeMaterialConnectionPoint;
  143101. /**
  143102. * Gets the ambient output component
  143103. */
  143104. get ambient(): NodeMaterialConnectionPoint;
  143105. /**
  143106. * Gets the diffuse output component
  143107. */
  143108. get diffuse(): NodeMaterialConnectionPoint;
  143109. /**
  143110. * Gets the specular output component
  143111. */
  143112. get specular(): NodeMaterialConnectionPoint;
  143113. /**
  143114. * Gets the sheen output component
  143115. */
  143116. get sheenDir(): NodeMaterialConnectionPoint;
  143117. /**
  143118. * Gets the clear coat output component
  143119. */
  143120. get clearcoatDir(): NodeMaterialConnectionPoint;
  143121. /**
  143122. * Gets the indirect diffuse output component
  143123. */
  143124. get diffuseIndirect(): NodeMaterialConnectionPoint;
  143125. /**
  143126. * Gets the indirect specular output component
  143127. */
  143128. get specularIndirect(): NodeMaterialConnectionPoint;
  143129. /**
  143130. * Gets the indirect sheen output component
  143131. */
  143132. get sheenIndirect(): NodeMaterialConnectionPoint;
  143133. /**
  143134. * Gets the indirect clear coat output component
  143135. */
  143136. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  143137. /**
  143138. * Gets the refraction output component
  143139. */
  143140. get refraction(): NodeMaterialConnectionPoint;
  143141. /**
  143142. * Gets the global lighting output component
  143143. */
  143144. get lighting(): NodeMaterialConnectionPoint;
  143145. /**
  143146. * Gets the shadow output component
  143147. */
  143148. get shadow(): NodeMaterialConnectionPoint;
  143149. /**
  143150. * Gets the alpha output component
  143151. */
  143152. get alpha(): NodeMaterialConnectionPoint;
  143153. autoConfigure(material: NodeMaterial): void;
  143154. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143155. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  143156. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143157. private _injectVertexCode;
  143158. /**
  143159. * Gets the code corresponding to the albedo/opacity module
  143160. * @returns the shader code
  143161. */
  143162. getAlbedoOpacityCode(): string;
  143163. protected _buildBlock(state: NodeMaterialBuildState): this;
  143164. protected _dumpPropertiesCode(): string;
  143165. serialize(): any;
  143166. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143167. }
  143168. }
  143169. declare module BABYLON {
  143170. /**
  143171. * Block used to compute value of one parameter modulo another
  143172. */
  143173. export class ModBlock extends NodeMaterialBlock {
  143174. /**
  143175. * Creates a new ModBlock
  143176. * @param name defines the block name
  143177. */
  143178. constructor(name: string);
  143179. /**
  143180. * Gets the current class name
  143181. * @returns the class name
  143182. */
  143183. getClassName(): string;
  143184. /**
  143185. * Gets the left operand input component
  143186. */
  143187. get left(): NodeMaterialConnectionPoint;
  143188. /**
  143189. * Gets the right operand input component
  143190. */
  143191. get right(): NodeMaterialConnectionPoint;
  143192. /**
  143193. * Gets the output component
  143194. */
  143195. get output(): NodeMaterialConnectionPoint;
  143196. protected _buildBlock(state: NodeMaterialBuildState): this;
  143197. }
  143198. }
  143199. declare module BABYLON {
  143200. /**
  143201. * Helper class to push actions to a pool of workers.
  143202. */
  143203. export class WorkerPool implements IDisposable {
  143204. private _workerInfos;
  143205. private _pendingActions;
  143206. /**
  143207. * Constructor
  143208. * @param workers Array of workers to use for actions
  143209. */
  143210. constructor(workers: Array<Worker>);
  143211. /**
  143212. * Terminates all workers and clears any pending actions.
  143213. */
  143214. dispose(): void;
  143215. /**
  143216. * Pushes an action to the worker pool. If all the workers are active, the action will be
  143217. * pended until a worker has completed its action.
  143218. * @param action The action to perform. Call onComplete when the action is complete.
  143219. */
  143220. push(action: (worker: Worker, onComplete: () => void) => void): void;
  143221. private _execute;
  143222. }
  143223. }
  143224. declare module BABYLON {
  143225. /**
  143226. * Configuration for Draco compression
  143227. */
  143228. export interface IDracoCompressionConfiguration {
  143229. /**
  143230. * Configuration for the decoder.
  143231. */
  143232. decoder: {
  143233. /**
  143234. * The url to the WebAssembly module.
  143235. */
  143236. wasmUrl?: string;
  143237. /**
  143238. * The url to the WebAssembly binary.
  143239. */
  143240. wasmBinaryUrl?: string;
  143241. /**
  143242. * The url to the fallback JavaScript module.
  143243. */
  143244. fallbackUrl?: string;
  143245. };
  143246. }
  143247. /**
  143248. * Draco compression (https://google.github.io/draco/)
  143249. *
  143250. * This class wraps the Draco module.
  143251. *
  143252. * **Encoder**
  143253. *
  143254. * The encoder is not currently implemented.
  143255. *
  143256. * **Decoder**
  143257. *
  143258. * 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.
  143259. *
  143260. * To update the configuration, use the following code:
  143261. * ```javascript
  143262. * DracoCompression.Configuration = {
  143263. * decoder: {
  143264. * wasmUrl: "<url to the WebAssembly library>",
  143265. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  143266. * fallbackUrl: "<url to the fallback JavaScript library>",
  143267. * }
  143268. * };
  143269. * ```
  143270. *
  143271. * 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.
  143272. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  143273. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  143274. *
  143275. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  143276. * ```javascript
  143277. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  143278. * ```
  143279. *
  143280. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  143281. */
  143282. export class DracoCompression implements IDisposable {
  143283. private _workerPoolPromise?;
  143284. private _decoderModulePromise?;
  143285. /**
  143286. * The configuration. Defaults to the following urls:
  143287. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  143288. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  143289. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  143290. */
  143291. static Configuration: IDracoCompressionConfiguration;
  143292. /**
  143293. * Returns true if the decoder configuration is available.
  143294. */
  143295. static get DecoderAvailable(): boolean;
  143296. /**
  143297. * Default number of workers to create when creating the draco compression object.
  143298. */
  143299. static DefaultNumWorkers: number;
  143300. private static GetDefaultNumWorkers;
  143301. private static _Default;
  143302. /**
  143303. * Default instance for the draco compression object.
  143304. */
  143305. static get Default(): DracoCompression;
  143306. /**
  143307. * Constructor
  143308. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  143309. */
  143310. constructor(numWorkers?: number);
  143311. /**
  143312. * Stop all async operations and release resources.
  143313. */
  143314. dispose(): void;
  143315. /**
  143316. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  143317. * @returns a promise that resolves when ready
  143318. */
  143319. whenReadyAsync(): Promise<void>;
  143320. /**
  143321. * Decode Draco compressed mesh data to vertex data.
  143322. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  143323. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  143324. * @returns A promise that resolves with the decoded vertex data
  143325. */
  143326. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  143327. [kind: string]: number;
  143328. }): Promise<VertexData>;
  143329. }
  143330. }
  143331. declare module BABYLON {
  143332. /**
  143333. * Class for building Constructive Solid Geometry
  143334. */
  143335. export class CSG {
  143336. private polygons;
  143337. /**
  143338. * The world matrix
  143339. */
  143340. matrix: Matrix;
  143341. /**
  143342. * Stores the position
  143343. */
  143344. position: Vector3;
  143345. /**
  143346. * Stores the rotation
  143347. */
  143348. rotation: Vector3;
  143349. /**
  143350. * Stores the rotation quaternion
  143351. */
  143352. rotationQuaternion: Nullable<Quaternion>;
  143353. /**
  143354. * Stores the scaling vector
  143355. */
  143356. scaling: Vector3;
  143357. /**
  143358. * Convert the Mesh to CSG
  143359. * @param mesh The Mesh to convert to CSG
  143360. * @returns A new CSG from the Mesh
  143361. */
  143362. static FromMesh(mesh: Mesh): CSG;
  143363. /**
  143364. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  143365. * @param polygons Polygons used to construct a CSG solid
  143366. */
  143367. private static FromPolygons;
  143368. /**
  143369. * Clones, or makes a deep copy, of the CSG
  143370. * @returns A new CSG
  143371. */
  143372. clone(): CSG;
  143373. /**
  143374. * Unions this CSG with another CSG
  143375. * @param csg The CSG to union against this CSG
  143376. * @returns The unioned CSG
  143377. */
  143378. union(csg: CSG): CSG;
  143379. /**
  143380. * Unions this CSG with another CSG in place
  143381. * @param csg The CSG to union against this CSG
  143382. */
  143383. unionInPlace(csg: CSG): void;
  143384. /**
  143385. * Subtracts this CSG with another CSG
  143386. * @param csg The CSG to subtract against this CSG
  143387. * @returns A new CSG
  143388. */
  143389. subtract(csg: CSG): CSG;
  143390. /**
  143391. * Subtracts this CSG with another CSG in place
  143392. * @param csg The CSG to subtact against this CSG
  143393. */
  143394. subtractInPlace(csg: CSG): void;
  143395. /**
  143396. * Intersect this CSG with another CSG
  143397. * @param csg The CSG to intersect against this CSG
  143398. * @returns A new CSG
  143399. */
  143400. intersect(csg: CSG): CSG;
  143401. /**
  143402. * Intersects this CSG with another CSG in place
  143403. * @param csg The CSG to intersect against this CSG
  143404. */
  143405. intersectInPlace(csg: CSG): void;
  143406. /**
  143407. * Return a new CSG solid with solid and empty space switched. This solid is
  143408. * not modified.
  143409. * @returns A new CSG solid with solid and empty space switched
  143410. */
  143411. inverse(): CSG;
  143412. /**
  143413. * Inverses the CSG in place
  143414. */
  143415. inverseInPlace(): void;
  143416. /**
  143417. * This is used to keep meshes transformations so they can be restored
  143418. * when we build back a Babylon Mesh
  143419. * NB : All CSG operations are performed in world coordinates
  143420. * @param csg The CSG to copy the transform attributes from
  143421. * @returns This CSG
  143422. */
  143423. copyTransformAttributes(csg: CSG): CSG;
  143424. /**
  143425. * Build Raw mesh from CSG
  143426. * Coordinates here are in world space
  143427. * @param name The name of the mesh geometry
  143428. * @param scene The Scene
  143429. * @param keepSubMeshes Specifies if the submeshes should be kept
  143430. * @returns A new Mesh
  143431. */
  143432. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  143433. /**
  143434. * Build Mesh from CSG taking material and transforms into account
  143435. * @param name The name of the Mesh
  143436. * @param material The material of the Mesh
  143437. * @param scene The Scene
  143438. * @param keepSubMeshes Specifies if submeshes should be kept
  143439. * @returns The new Mesh
  143440. */
  143441. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  143442. }
  143443. }
  143444. declare module BABYLON {
  143445. /**
  143446. * Class used to create a trail following a mesh
  143447. */
  143448. export class TrailMesh extends Mesh {
  143449. private _generator;
  143450. private _autoStart;
  143451. private _running;
  143452. private _diameter;
  143453. private _length;
  143454. private _sectionPolygonPointsCount;
  143455. private _sectionVectors;
  143456. private _sectionNormalVectors;
  143457. private _beforeRenderObserver;
  143458. /**
  143459. * @constructor
  143460. * @param name The value used by scene.getMeshByName() to do a lookup.
  143461. * @param generator The mesh or transform node to generate a trail.
  143462. * @param scene The scene to add this mesh to.
  143463. * @param diameter Diameter of trailing mesh. Default is 1.
  143464. * @param length Length of trailing mesh. Default is 60.
  143465. * @param autoStart Automatically start trailing mesh. Default true.
  143466. */
  143467. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  143468. /**
  143469. * "TrailMesh"
  143470. * @returns "TrailMesh"
  143471. */
  143472. getClassName(): string;
  143473. private _createMesh;
  143474. /**
  143475. * Start trailing mesh.
  143476. */
  143477. start(): void;
  143478. /**
  143479. * Stop trailing mesh.
  143480. */
  143481. stop(): void;
  143482. /**
  143483. * Update trailing mesh geometry.
  143484. */
  143485. update(): void;
  143486. /**
  143487. * Returns a new TrailMesh object.
  143488. * @param name is a string, the name given to the new mesh
  143489. * @param newGenerator use new generator object for cloned trail mesh
  143490. * @returns a new mesh
  143491. */
  143492. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  143493. /**
  143494. * Serializes this trail mesh
  143495. * @param serializationObject object to write serialization to
  143496. */
  143497. serialize(serializationObject: any): void;
  143498. /**
  143499. * Parses a serialized trail mesh
  143500. * @param parsedMesh the serialized mesh
  143501. * @param scene the scene to create the trail mesh in
  143502. * @returns the created trail mesh
  143503. */
  143504. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  143505. }
  143506. }
  143507. declare module BABYLON {
  143508. /**
  143509. * Class containing static functions to help procedurally build meshes
  143510. */
  143511. export class TiledBoxBuilder {
  143512. /**
  143513. * Creates a box mesh
  143514. * 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)
  143515. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143519. * @param name defines the name of the mesh
  143520. * @param options defines the options used to create the mesh
  143521. * @param scene defines the hosting scene
  143522. * @returns the box mesh
  143523. */
  143524. static CreateTiledBox(name: string, options: {
  143525. pattern?: number;
  143526. width?: number;
  143527. height?: number;
  143528. depth?: number;
  143529. tileSize?: number;
  143530. tileWidth?: number;
  143531. tileHeight?: number;
  143532. alignHorizontal?: number;
  143533. alignVertical?: number;
  143534. faceUV?: Vector4[];
  143535. faceColors?: Color4[];
  143536. sideOrientation?: number;
  143537. updatable?: boolean;
  143538. }, scene?: Nullable<Scene>): Mesh;
  143539. }
  143540. }
  143541. declare module BABYLON {
  143542. /**
  143543. * Class containing static functions to help procedurally build meshes
  143544. */
  143545. export class TorusKnotBuilder {
  143546. /**
  143547. * Creates a torus knot mesh
  143548. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  143549. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  143550. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  143551. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  143552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143555. * @param name defines the name of the mesh
  143556. * @param options defines the options used to create the mesh
  143557. * @param scene defines the hosting scene
  143558. * @returns the torus knot mesh
  143559. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  143560. */
  143561. static CreateTorusKnot(name: string, options: {
  143562. radius?: number;
  143563. tube?: number;
  143564. radialSegments?: number;
  143565. tubularSegments?: number;
  143566. p?: number;
  143567. q?: number;
  143568. updatable?: boolean;
  143569. sideOrientation?: number;
  143570. frontUVs?: Vector4;
  143571. backUVs?: Vector4;
  143572. }, scene: any): Mesh;
  143573. }
  143574. }
  143575. declare module BABYLON {
  143576. /**
  143577. * Polygon
  143578. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  143579. */
  143580. export class Polygon {
  143581. /**
  143582. * Creates a rectangle
  143583. * @param xmin bottom X coord
  143584. * @param ymin bottom Y coord
  143585. * @param xmax top X coord
  143586. * @param ymax top Y coord
  143587. * @returns points that make the resulting rectation
  143588. */
  143589. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  143590. /**
  143591. * Creates a circle
  143592. * @param radius radius of circle
  143593. * @param cx scale in x
  143594. * @param cy scale in y
  143595. * @param numberOfSides number of sides that make up the circle
  143596. * @returns points that make the resulting circle
  143597. */
  143598. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  143599. /**
  143600. * Creates a polygon from input string
  143601. * @param input Input polygon data
  143602. * @returns the parsed points
  143603. */
  143604. static Parse(input: string): Vector2[];
  143605. /**
  143606. * Starts building a polygon from x and y coordinates
  143607. * @param x x coordinate
  143608. * @param y y coordinate
  143609. * @returns the started path2
  143610. */
  143611. static StartingAt(x: number, y: number): Path2;
  143612. }
  143613. /**
  143614. * Builds a polygon
  143615. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  143616. */
  143617. export class PolygonMeshBuilder {
  143618. private _points;
  143619. private _outlinepoints;
  143620. private _holes;
  143621. private _name;
  143622. private _scene;
  143623. private _epoints;
  143624. private _eholes;
  143625. private _addToepoint;
  143626. /**
  143627. * Babylon reference to the earcut plugin.
  143628. */
  143629. bjsEarcut: any;
  143630. /**
  143631. * Creates a PolygonMeshBuilder
  143632. * @param name name of the builder
  143633. * @param contours Path of the polygon
  143634. * @param scene scene to add to when creating the mesh
  143635. * @param earcutInjection can be used to inject your own earcut reference
  143636. */
  143637. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  143638. /**
  143639. * Adds a whole within the polygon
  143640. * @param hole Array of points defining the hole
  143641. * @returns this
  143642. */
  143643. addHole(hole: Vector2[]): PolygonMeshBuilder;
  143644. /**
  143645. * Creates the polygon
  143646. * @param updatable If the mesh should be updatable
  143647. * @param depth The depth of the mesh created
  143648. * @returns the created mesh
  143649. */
  143650. build(updatable?: boolean, depth?: number): Mesh;
  143651. /**
  143652. * Creates the polygon
  143653. * @param depth The depth of the mesh created
  143654. * @returns the created VertexData
  143655. */
  143656. buildVertexData(depth?: number): VertexData;
  143657. /**
  143658. * Adds a side to the polygon
  143659. * @param positions points that make the polygon
  143660. * @param normals normals of the polygon
  143661. * @param uvs uvs of the polygon
  143662. * @param indices indices of the polygon
  143663. * @param bounds bounds of the polygon
  143664. * @param points points of the polygon
  143665. * @param depth depth of the polygon
  143666. * @param flip flip of the polygon
  143667. */
  143668. private addSide;
  143669. }
  143670. }
  143671. declare module BABYLON {
  143672. /**
  143673. * Class containing static functions to help procedurally build meshes
  143674. */
  143675. export class PolygonBuilder {
  143676. /**
  143677. * Creates a polygon mesh
  143678. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  143679. * * 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
  143680. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  143681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  143683. * * Remember you can only change the shape positions, not their number when updating a polygon
  143684. * @param name defines the name of the mesh
  143685. * @param options defines the options used to create the mesh
  143686. * @param scene defines the hosting scene
  143687. * @param earcutInjection can be used to inject your own earcut reference
  143688. * @returns the polygon mesh
  143689. */
  143690. static CreatePolygon(name: string, options: {
  143691. shape: Vector3[];
  143692. holes?: Vector3[][];
  143693. depth?: number;
  143694. faceUV?: Vector4[];
  143695. faceColors?: Color4[];
  143696. updatable?: boolean;
  143697. sideOrientation?: number;
  143698. frontUVs?: Vector4;
  143699. backUVs?: Vector4;
  143700. wrap?: boolean;
  143701. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143702. /**
  143703. * Creates an extruded polygon mesh, with depth in the Y direction.
  143704. * * 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)
  143705. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143706. * @param name defines the name of the mesh
  143707. * @param options defines the options used to create the mesh
  143708. * @param scene defines the hosting scene
  143709. * @param earcutInjection can be used to inject your own earcut reference
  143710. * @returns the polygon mesh
  143711. */
  143712. static ExtrudePolygon(name: string, options: {
  143713. shape: Vector3[];
  143714. holes?: Vector3[][];
  143715. depth?: number;
  143716. faceUV?: Vector4[];
  143717. faceColors?: Color4[];
  143718. updatable?: boolean;
  143719. sideOrientation?: number;
  143720. frontUVs?: Vector4;
  143721. backUVs?: Vector4;
  143722. wrap?: boolean;
  143723. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143724. }
  143725. }
  143726. declare module BABYLON {
  143727. /**
  143728. * Class containing static functions to help procedurally build meshes
  143729. */
  143730. export class LatheBuilder {
  143731. /**
  143732. * Creates lathe mesh.
  143733. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  143734. * * 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
  143735. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  143736. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  143737. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  143738. * * 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
  143739. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  143740. * * 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
  143741. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143742. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143743. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143745. * @param name defines the name of the mesh
  143746. * @param options defines the options used to create the mesh
  143747. * @param scene defines the hosting scene
  143748. * @returns the lathe mesh
  143749. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  143750. */
  143751. static CreateLathe(name: string, options: {
  143752. shape: Vector3[];
  143753. radius?: number;
  143754. tessellation?: number;
  143755. clip?: number;
  143756. arc?: number;
  143757. closed?: boolean;
  143758. updatable?: boolean;
  143759. sideOrientation?: number;
  143760. frontUVs?: Vector4;
  143761. backUVs?: Vector4;
  143762. cap?: number;
  143763. invertUV?: boolean;
  143764. }, scene?: Nullable<Scene>): Mesh;
  143765. }
  143766. }
  143767. declare module BABYLON {
  143768. /**
  143769. * Class containing static functions to help procedurally build meshes
  143770. */
  143771. export class TiledPlaneBuilder {
  143772. /**
  143773. * Creates a tiled plane mesh
  143774. * * The parameter `pattern` will, depending on value, do nothing or
  143775. * * * flip (reflect about central vertical) alternate tiles across and up
  143776. * * * flip every tile on alternate rows
  143777. * * * rotate (180 degs) alternate tiles across and up
  143778. * * * rotate every tile on alternate rows
  143779. * * * flip and rotate alternate tiles across and up
  143780. * * * flip and rotate every tile on alternate rows
  143781. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  143782. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  143783. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143784. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  143785. * * 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)
  143786. * * 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)
  143787. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  143788. * @param name defines the name of the mesh
  143789. * @param options defines the options used to create the mesh
  143790. * @param scene defines the hosting scene
  143791. * @returns the box mesh
  143792. */
  143793. static CreateTiledPlane(name: string, options: {
  143794. pattern?: number;
  143795. tileSize?: number;
  143796. tileWidth?: number;
  143797. tileHeight?: number;
  143798. size?: number;
  143799. width?: number;
  143800. height?: number;
  143801. alignHorizontal?: number;
  143802. alignVertical?: number;
  143803. sideOrientation?: number;
  143804. frontUVs?: Vector4;
  143805. backUVs?: Vector4;
  143806. updatable?: boolean;
  143807. }, scene?: Nullable<Scene>): Mesh;
  143808. }
  143809. }
  143810. declare module BABYLON {
  143811. /**
  143812. * Class containing static functions to help procedurally build meshes
  143813. */
  143814. export class TubeBuilder {
  143815. /**
  143816. * Creates a tube mesh.
  143817. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143818. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  143819. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  143820. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  143821. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  143822. * * 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)
  143823. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  143824. * * 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
  143825. * * 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
  143826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143827. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143828. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143830. * @param name defines the name of the mesh
  143831. * @param options defines the options used to create the mesh
  143832. * @param scene defines the hosting scene
  143833. * @returns the tube mesh
  143834. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143835. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  143836. */
  143837. static CreateTube(name: string, options: {
  143838. path: Vector3[];
  143839. radius?: number;
  143840. tessellation?: number;
  143841. radiusFunction?: {
  143842. (i: number, distance: number): number;
  143843. };
  143844. cap?: number;
  143845. arc?: number;
  143846. updatable?: boolean;
  143847. sideOrientation?: number;
  143848. frontUVs?: Vector4;
  143849. backUVs?: Vector4;
  143850. instance?: Mesh;
  143851. invertUV?: boolean;
  143852. }, scene?: Nullable<Scene>): Mesh;
  143853. }
  143854. }
  143855. declare module BABYLON {
  143856. /**
  143857. * Class containing static functions to help procedurally build meshes
  143858. */
  143859. export class IcoSphereBuilder {
  143860. /**
  143861. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  143862. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  143863. * * 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`)
  143864. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  143865. * * 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
  143866. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143867. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143869. * @param name defines the name of the mesh
  143870. * @param options defines the options used to create the mesh
  143871. * @param scene defines the hosting scene
  143872. * @returns the icosahedron mesh
  143873. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  143874. */
  143875. static CreateIcoSphere(name: string, options: {
  143876. radius?: number;
  143877. radiusX?: number;
  143878. radiusY?: number;
  143879. radiusZ?: number;
  143880. flat?: boolean;
  143881. subdivisions?: number;
  143882. sideOrientation?: number;
  143883. frontUVs?: Vector4;
  143884. backUVs?: Vector4;
  143885. updatable?: boolean;
  143886. }, scene?: Nullable<Scene>): Mesh;
  143887. }
  143888. }
  143889. declare module BABYLON {
  143890. /**
  143891. * Class containing static functions to help procedurally build meshes
  143892. */
  143893. export class DecalBuilder {
  143894. /**
  143895. * Creates a decal mesh.
  143896. * 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
  143897. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  143898. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  143899. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  143900. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  143901. * @param name defines the name of the mesh
  143902. * @param sourceMesh defines the mesh where the decal must be applied
  143903. * @param options defines the options used to create the mesh
  143904. * @param scene defines the hosting scene
  143905. * @returns the decal mesh
  143906. * @see https://doc.babylonjs.com/how_to/decals
  143907. */
  143908. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  143909. position?: Vector3;
  143910. normal?: Vector3;
  143911. size?: Vector3;
  143912. angle?: number;
  143913. }): Mesh;
  143914. }
  143915. }
  143916. declare module BABYLON {
  143917. /**
  143918. * Class containing static functions to help procedurally build meshes
  143919. */
  143920. export class MeshBuilder {
  143921. /**
  143922. * Creates a box mesh
  143923. * * The parameter `size` sets the size (float) of each box side (default 1)
  143924. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  143925. * * 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)
  143926. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143928. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143930. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  143931. * @param name defines the name of the mesh
  143932. * @param options defines the options used to create the mesh
  143933. * @param scene defines the hosting scene
  143934. * @returns the box mesh
  143935. */
  143936. static CreateBox(name: string, options: {
  143937. size?: number;
  143938. width?: number;
  143939. height?: number;
  143940. depth?: number;
  143941. faceUV?: Vector4[];
  143942. faceColors?: Color4[];
  143943. sideOrientation?: number;
  143944. frontUVs?: Vector4;
  143945. backUVs?: Vector4;
  143946. wrap?: boolean;
  143947. topBaseAt?: number;
  143948. bottomBaseAt?: number;
  143949. updatable?: boolean;
  143950. }, scene?: Nullable<Scene>): Mesh;
  143951. /**
  143952. * Creates a tiled box mesh
  143953. * * faceTiles sets the pattern, tile size and number of tiles for a face
  143954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143955. * @param name defines the name of the mesh
  143956. * @param options defines the options used to create the mesh
  143957. * @param scene defines the hosting scene
  143958. * @returns the tiled box mesh
  143959. */
  143960. static CreateTiledBox(name: string, options: {
  143961. pattern?: number;
  143962. size?: number;
  143963. width?: number;
  143964. height?: number;
  143965. depth: number;
  143966. tileSize?: number;
  143967. tileWidth?: number;
  143968. tileHeight?: number;
  143969. faceUV?: Vector4[];
  143970. faceColors?: Color4[];
  143971. alignHorizontal?: number;
  143972. alignVertical?: number;
  143973. sideOrientation?: number;
  143974. updatable?: boolean;
  143975. }, scene?: Nullable<Scene>): Mesh;
  143976. /**
  143977. * Creates a sphere mesh
  143978. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  143979. * * 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`)
  143980. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  143981. * * 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
  143982. * * 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)
  143983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143984. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143986. * @param name defines the name of the mesh
  143987. * @param options defines the options used to create the mesh
  143988. * @param scene defines the hosting scene
  143989. * @returns the sphere mesh
  143990. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  143991. */
  143992. static CreateSphere(name: string, options: {
  143993. segments?: number;
  143994. diameter?: number;
  143995. diameterX?: number;
  143996. diameterY?: number;
  143997. diameterZ?: number;
  143998. arc?: number;
  143999. slice?: number;
  144000. sideOrientation?: number;
  144001. frontUVs?: Vector4;
  144002. backUVs?: Vector4;
  144003. updatable?: boolean;
  144004. }, scene?: Nullable<Scene>): Mesh;
  144005. /**
  144006. * Creates a plane polygonal mesh. By default, this is a disc
  144007. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  144008. * * 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
  144009. * * 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
  144010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144011. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144013. * @param name defines the name of the mesh
  144014. * @param options defines the options used to create the mesh
  144015. * @param scene defines the hosting scene
  144016. * @returns the plane polygonal mesh
  144017. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  144018. */
  144019. static CreateDisc(name: string, options: {
  144020. radius?: number;
  144021. tessellation?: number;
  144022. arc?: number;
  144023. updatable?: boolean;
  144024. sideOrientation?: number;
  144025. frontUVs?: Vector4;
  144026. backUVs?: Vector4;
  144027. }, scene?: Nullable<Scene>): Mesh;
  144028. /**
  144029. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  144030. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  144031. * * 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`)
  144032. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  144033. * * 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
  144034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144037. * @param name defines the name of the mesh
  144038. * @param options defines the options used to create the mesh
  144039. * @param scene defines the hosting scene
  144040. * @returns the icosahedron mesh
  144041. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  144042. */
  144043. static CreateIcoSphere(name: string, options: {
  144044. radius?: number;
  144045. radiusX?: number;
  144046. radiusY?: number;
  144047. radiusZ?: number;
  144048. flat?: boolean;
  144049. subdivisions?: number;
  144050. sideOrientation?: number;
  144051. frontUVs?: Vector4;
  144052. backUVs?: Vector4;
  144053. updatable?: boolean;
  144054. }, scene?: Nullable<Scene>): Mesh;
  144055. /**
  144056. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144057. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  144058. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  144059. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  144060. * * 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
  144061. * * 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
  144062. * * 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
  144063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144065. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144066. * * 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
  144067. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  144068. * * 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
  144069. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  144070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144071. * @param name defines the name of the mesh
  144072. * @param options defines the options used to create the mesh
  144073. * @param scene defines the hosting scene
  144074. * @returns the ribbon mesh
  144075. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  144076. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144077. */
  144078. static CreateRibbon(name: string, options: {
  144079. pathArray: Vector3[][];
  144080. closeArray?: boolean;
  144081. closePath?: boolean;
  144082. offset?: number;
  144083. updatable?: boolean;
  144084. sideOrientation?: number;
  144085. frontUVs?: Vector4;
  144086. backUVs?: Vector4;
  144087. instance?: Mesh;
  144088. invertUV?: boolean;
  144089. uvs?: Vector2[];
  144090. colors?: Color4[];
  144091. }, scene?: Nullable<Scene>): Mesh;
  144092. /**
  144093. * Creates a cylinder or a cone mesh
  144094. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  144095. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  144096. * * 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.
  144097. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  144098. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  144099. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  144100. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  144101. * * 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).
  144102. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  144103. * * 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).
  144104. * * 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
  144105. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  144106. * * 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
  144107. * * 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.
  144108. * * If `enclose` is false, a ring surface is one element.
  144109. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  144110. * * 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
  144111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144112. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144114. * @param name defines the name of the mesh
  144115. * @param options defines the options used to create the mesh
  144116. * @param scene defines the hosting scene
  144117. * @returns the cylinder mesh
  144118. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  144119. */
  144120. static CreateCylinder(name: string, options: {
  144121. height?: number;
  144122. diameterTop?: number;
  144123. diameterBottom?: number;
  144124. diameter?: number;
  144125. tessellation?: number;
  144126. subdivisions?: number;
  144127. arc?: number;
  144128. faceColors?: Color4[];
  144129. faceUV?: Vector4[];
  144130. updatable?: boolean;
  144131. hasRings?: boolean;
  144132. enclose?: boolean;
  144133. cap?: number;
  144134. sideOrientation?: number;
  144135. frontUVs?: Vector4;
  144136. backUVs?: Vector4;
  144137. }, scene?: Nullable<Scene>): Mesh;
  144138. /**
  144139. * Creates a torus mesh
  144140. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  144141. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  144142. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  144143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144144. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144146. * @param name defines the name of the mesh
  144147. * @param options defines the options used to create the mesh
  144148. * @param scene defines the hosting scene
  144149. * @returns the torus mesh
  144150. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  144151. */
  144152. static CreateTorus(name: string, options: {
  144153. diameter?: number;
  144154. thickness?: number;
  144155. tessellation?: number;
  144156. updatable?: boolean;
  144157. sideOrientation?: number;
  144158. frontUVs?: Vector4;
  144159. backUVs?: Vector4;
  144160. }, scene?: Nullable<Scene>): Mesh;
  144161. /**
  144162. * Creates a torus knot mesh
  144163. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  144164. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  144165. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  144166. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  144167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144168. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144170. * @param name defines the name of the mesh
  144171. * @param options defines the options used to create the mesh
  144172. * @param scene defines the hosting scene
  144173. * @returns the torus knot mesh
  144174. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  144175. */
  144176. static CreateTorusKnot(name: string, options: {
  144177. radius?: number;
  144178. tube?: number;
  144179. radialSegments?: number;
  144180. tubularSegments?: number;
  144181. p?: number;
  144182. q?: number;
  144183. updatable?: boolean;
  144184. sideOrientation?: number;
  144185. frontUVs?: Vector4;
  144186. backUVs?: Vector4;
  144187. }, scene?: Nullable<Scene>): Mesh;
  144188. /**
  144189. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  144190. * * 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
  144191. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  144192. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  144193. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  144194. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  144195. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  144196. * * 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
  144197. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  144198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144199. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  144200. * @param name defines the name of the new line system
  144201. * @param options defines the options used to create the line system
  144202. * @param scene defines the hosting scene
  144203. * @returns a new line system mesh
  144204. */
  144205. static CreateLineSystem(name: string, options: {
  144206. lines: Vector3[][];
  144207. updatable?: boolean;
  144208. instance?: Nullable<LinesMesh>;
  144209. colors?: Nullable<Color4[][]>;
  144210. useVertexAlpha?: boolean;
  144211. }, scene: Nullable<Scene>): LinesMesh;
  144212. /**
  144213. * Creates a line mesh
  144214. * 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
  144215. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  144216. * * The parameter `points` is an array successive Vector3
  144217. * * 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
  144218. * * The optional parameter `colors` is an array of successive Color4, one per line point
  144219. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  144220. * * When updating an instance, remember that only point positions can change, not the number of points
  144221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144222. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  144223. * @param name defines the name of the new line system
  144224. * @param options defines the options used to create the line system
  144225. * @param scene defines the hosting scene
  144226. * @returns a new line mesh
  144227. */
  144228. static CreateLines(name: string, options: {
  144229. points: Vector3[];
  144230. updatable?: boolean;
  144231. instance?: Nullable<LinesMesh>;
  144232. colors?: Color4[];
  144233. useVertexAlpha?: boolean;
  144234. }, scene?: Nullable<Scene>): LinesMesh;
  144235. /**
  144236. * Creates a dashed line mesh
  144237. * * 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
  144238. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  144239. * * The parameter `points` is an array successive Vector3
  144240. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  144241. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  144242. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  144243. * * 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
  144244. * * When updating an instance, remember that only point positions can change, not the number of points
  144245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144246. * @param name defines the name of the mesh
  144247. * @param options defines the options used to create the mesh
  144248. * @param scene defines the hosting scene
  144249. * @returns the dashed line mesh
  144250. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  144251. */
  144252. static CreateDashedLines(name: string, options: {
  144253. points: Vector3[];
  144254. dashSize?: number;
  144255. gapSize?: number;
  144256. dashNb?: number;
  144257. updatable?: boolean;
  144258. instance?: LinesMesh;
  144259. }, scene?: Nullable<Scene>): LinesMesh;
  144260. /**
  144261. * 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.
  144262. * * 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.
  144263. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  144264. * * 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.
  144265. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  144266. * * 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
  144267. * * 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
  144268. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  144269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144270. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144271. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  144272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144273. * @param name defines the name of the mesh
  144274. * @param options defines the options used to create the mesh
  144275. * @param scene defines the hosting scene
  144276. * @returns the extruded shape mesh
  144277. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  144279. */
  144280. static ExtrudeShape(name: string, options: {
  144281. shape: Vector3[];
  144282. path: Vector3[];
  144283. scale?: number;
  144284. rotation?: number;
  144285. cap?: number;
  144286. updatable?: boolean;
  144287. sideOrientation?: number;
  144288. frontUVs?: Vector4;
  144289. backUVs?: Vector4;
  144290. instance?: Mesh;
  144291. invertUV?: boolean;
  144292. }, scene?: Nullable<Scene>): Mesh;
  144293. /**
  144294. * Creates an custom extruded shape mesh.
  144295. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  144296. * * 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.
  144297. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  144298. * * 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
  144299. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  144300. * * 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
  144301. * * It must returns a float value that will be the scale value applied to the shape on each path point
  144302. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  144303. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  144304. * * 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
  144305. * * 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
  144306. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  144307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144308. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144309. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144311. * @param name defines the name of the mesh
  144312. * @param options defines the options used to create the mesh
  144313. * @param scene defines the hosting scene
  144314. * @returns the custom extruded shape mesh
  144315. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  144316. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144317. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  144318. */
  144319. static ExtrudeShapeCustom(name: string, options: {
  144320. shape: Vector3[];
  144321. path: Vector3[];
  144322. scaleFunction?: any;
  144323. rotationFunction?: any;
  144324. ribbonCloseArray?: boolean;
  144325. ribbonClosePath?: boolean;
  144326. cap?: number;
  144327. updatable?: boolean;
  144328. sideOrientation?: number;
  144329. frontUVs?: Vector4;
  144330. backUVs?: Vector4;
  144331. instance?: Mesh;
  144332. invertUV?: boolean;
  144333. }, scene?: Nullable<Scene>): Mesh;
  144334. /**
  144335. * Creates lathe mesh.
  144336. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  144337. * * 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
  144338. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  144339. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  144340. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  144341. * * 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
  144342. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  144343. * * 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
  144344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144345. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144346. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144348. * @param name defines the name of the mesh
  144349. * @param options defines the options used to create the mesh
  144350. * @param scene defines the hosting scene
  144351. * @returns the lathe mesh
  144352. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  144353. */
  144354. static CreateLathe(name: string, options: {
  144355. shape: Vector3[];
  144356. radius?: number;
  144357. tessellation?: number;
  144358. clip?: number;
  144359. arc?: number;
  144360. closed?: boolean;
  144361. updatable?: boolean;
  144362. sideOrientation?: number;
  144363. frontUVs?: Vector4;
  144364. backUVs?: Vector4;
  144365. cap?: number;
  144366. invertUV?: boolean;
  144367. }, scene?: Nullable<Scene>): Mesh;
  144368. /**
  144369. * Creates a tiled plane mesh
  144370. * * You can set a limited pattern arrangement with the tiles
  144371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144372. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144374. * @param name defines the name of the mesh
  144375. * @param options defines the options used to create the mesh
  144376. * @param scene defines the hosting scene
  144377. * @returns the plane mesh
  144378. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  144379. */
  144380. static CreateTiledPlane(name: string, options: {
  144381. pattern?: number;
  144382. tileSize?: number;
  144383. tileWidth?: number;
  144384. tileHeight?: number;
  144385. size?: number;
  144386. width?: number;
  144387. height?: number;
  144388. alignHorizontal?: number;
  144389. alignVertical?: number;
  144390. sideOrientation?: number;
  144391. frontUVs?: Vector4;
  144392. backUVs?: Vector4;
  144393. updatable?: boolean;
  144394. }, scene?: Nullable<Scene>): Mesh;
  144395. /**
  144396. * Creates a plane mesh
  144397. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  144398. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  144399. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  144400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144401. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144403. * @param name defines the name of the mesh
  144404. * @param options defines the options used to create the mesh
  144405. * @param scene defines the hosting scene
  144406. * @returns the plane mesh
  144407. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  144408. */
  144409. static CreatePlane(name: string, options: {
  144410. size?: number;
  144411. width?: number;
  144412. height?: number;
  144413. sideOrientation?: number;
  144414. frontUVs?: Vector4;
  144415. backUVs?: Vector4;
  144416. updatable?: boolean;
  144417. sourcePlane?: Plane;
  144418. }, scene?: Nullable<Scene>): Mesh;
  144419. /**
  144420. * Creates a ground mesh
  144421. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  144422. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  144423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144424. * @param name defines the name of the mesh
  144425. * @param options defines the options used to create the mesh
  144426. * @param scene defines the hosting scene
  144427. * @returns the ground mesh
  144428. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  144429. */
  144430. static CreateGround(name: string, options: {
  144431. width?: number;
  144432. height?: number;
  144433. subdivisions?: number;
  144434. subdivisionsX?: number;
  144435. subdivisionsY?: number;
  144436. updatable?: boolean;
  144437. }, scene?: Nullable<Scene>): Mesh;
  144438. /**
  144439. * Creates a tiled ground mesh
  144440. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  144441. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  144442. * * 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
  144443. * * 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
  144444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144445. * @param name defines the name of the mesh
  144446. * @param options defines the options used to create the mesh
  144447. * @param scene defines the hosting scene
  144448. * @returns the tiled ground mesh
  144449. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  144450. */
  144451. static CreateTiledGround(name: string, options: {
  144452. xmin: number;
  144453. zmin: number;
  144454. xmax: number;
  144455. zmax: number;
  144456. subdivisions?: {
  144457. w: number;
  144458. h: number;
  144459. };
  144460. precision?: {
  144461. w: number;
  144462. h: number;
  144463. };
  144464. updatable?: boolean;
  144465. }, scene?: Nullable<Scene>): Mesh;
  144466. /**
  144467. * Creates a ground mesh from a height map
  144468. * * The parameter `url` sets the URL of the height map image resource.
  144469. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  144470. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  144471. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  144472. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  144473. * * 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.
  144474. * * 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).
  144475. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  144476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144477. * @param name defines the name of the mesh
  144478. * @param url defines the url to the height map
  144479. * @param options defines the options used to create the mesh
  144480. * @param scene defines the hosting scene
  144481. * @returns the ground mesh
  144482. * @see https://doc.babylonjs.com/babylon101/height_map
  144483. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  144484. */
  144485. static CreateGroundFromHeightMap(name: string, url: string, options: {
  144486. width?: number;
  144487. height?: number;
  144488. subdivisions?: number;
  144489. minHeight?: number;
  144490. maxHeight?: number;
  144491. colorFilter?: Color3;
  144492. alphaFilter?: number;
  144493. updatable?: boolean;
  144494. onReady?: (mesh: GroundMesh) => void;
  144495. }, scene?: Nullable<Scene>): GroundMesh;
  144496. /**
  144497. * Creates a polygon mesh
  144498. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  144499. * * 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
  144500. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  144503. * * Remember you can only change the shape positions, not their number when updating a polygon
  144504. * @param name defines the name of the mesh
  144505. * @param options defines the options used to create the mesh
  144506. * @param scene defines the hosting scene
  144507. * @param earcutInjection can be used to inject your own earcut reference
  144508. * @returns the polygon mesh
  144509. */
  144510. static CreatePolygon(name: string, options: {
  144511. shape: Vector3[];
  144512. holes?: Vector3[][];
  144513. depth?: number;
  144514. faceUV?: Vector4[];
  144515. faceColors?: Color4[];
  144516. updatable?: boolean;
  144517. sideOrientation?: number;
  144518. frontUVs?: Vector4;
  144519. backUVs?: Vector4;
  144520. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144521. /**
  144522. * Creates an extruded polygon mesh, with depth in the Y direction.
  144523. * * 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)
  144524. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144525. * @param name defines the name of the mesh
  144526. * @param options defines the options used to create the mesh
  144527. * @param scene defines the hosting scene
  144528. * @param earcutInjection can be used to inject your own earcut reference
  144529. * @returns the polygon mesh
  144530. */
  144531. static ExtrudePolygon(name: string, options: {
  144532. shape: Vector3[];
  144533. holes?: Vector3[][];
  144534. depth?: number;
  144535. faceUV?: Vector4[];
  144536. faceColors?: Color4[];
  144537. updatable?: boolean;
  144538. sideOrientation?: number;
  144539. frontUVs?: Vector4;
  144540. backUVs?: Vector4;
  144541. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144542. /**
  144543. * Creates a tube mesh.
  144544. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144545. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  144546. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  144547. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  144548. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  144549. * * 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)
  144550. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  144551. * * 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
  144552. * * 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
  144553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144554. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144555. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144557. * @param name defines the name of the mesh
  144558. * @param options defines the options used to create the mesh
  144559. * @param scene defines the hosting scene
  144560. * @returns the tube mesh
  144561. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144562. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  144563. */
  144564. static CreateTube(name: string, options: {
  144565. path: Vector3[];
  144566. radius?: number;
  144567. tessellation?: number;
  144568. radiusFunction?: {
  144569. (i: number, distance: number): number;
  144570. };
  144571. cap?: number;
  144572. arc?: number;
  144573. updatable?: boolean;
  144574. sideOrientation?: number;
  144575. frontUVs?: Vector4;
  144576. backUVs?: Vector4;
  144577. instance?: Mesh;
  144578. invertUV?: boolean;
  144579. }, scene?: Nullable<Scene>): Mesh;
  144580. /**
  144581. * Creates a polyhedron mesh
  144582. * * 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
  144583. * * The parameter `size` (positive float, default 1) sets the polygon size
  144584. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  144585. * * 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`
  144586. * * 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
  144587. * * 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)`)
  144588. * * 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
  144589. * * 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
  144590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144593. * @param name defines the name of the mesh
  144594. * @param options defines the options used to create the mesh
  144595. * @param scene defines the hosting scene
  144596. * @returns the polyhedron mesh
  144597. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  144598. */
  144599. static CreatePolyhedron(name: string, options: {
  144600. type?: number;
  144601. size?: number;
  144602. sizeX?: number;
  144603. sizeY?: number;
  144604. sizeZ?: number;
  144605. custom?: any;
  144606. faceUV?: Vector4[];
  144607. faceColors?: Color4[];
  144608. flat?: boolean;
  144609. updatable?: boolean;
  144610. sideOrientation?: number;
  144611. frontUVs?: Vector4;
  144612. backUVs?: Vector4;
  144613. }, scene?: Nullable<Scene>): Mesh;
  144614. /**
  144615. * Creates a decal mesh.
  144616. * 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
  144617. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  144618. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  144619. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  144620. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  144621. * @param name defines the name of the mesh
  144622. * @param sourceMesh defines the mesh where the decal must be applied
  144623. * @param options defines the options used to create the mesh
  144624. * @param scene defines the hosting scene
  144625. * @returns the decal mesh
  144626. * @see https://doc.babylonjs.com/how_to/decals
  144627. */
  144628. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  144629. position?: Vector3;
  144630. normal?: Vector3;
  144631. size?: Vector3;
  144632. angle?: number;
  144633. }): Mesh;
  144634. }
  144635. }
  144636. declare module BABYLON {
  144637. /**
  144638. * A simplifier interface for future simplification implementations
  144639. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144640. */
  144641. export interface ISimplifier {
  144642. /**
  144643. * Simplification of a given mesh according to the given settings.
  144644. * Since this requires computation, it is assumed that the function runs async.
  144645. * @param settings The settings of the simplification, including quality and distance
  144646. * @param successCallback A callback that will be called after the mesh was simplified.
  144647. * @param errorCallback in case of an error, this callback will be called. optional.
  144648. */
  144649. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  144650. }
  144651. /**
  144652. * Expected simplification settings.
  144653. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  144654. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144655. */
  144656. export interface ISimplificationSettings {
  144657. /**
  144658. * Gets or sets the expected quality
  144659. */
  144660. quality: number;
  144661. /**
  144662. * Gets or sets the distance when this optimized version should be used
  144663. */
  144664. distance: number;
  144665. /**
  144666. * Gets an already optimized mesh
  144667. */
  144668. optimizeMesh?: boolean;
  144669. }
  144670. /**
  144671. * Class used to specify simplification options
  144672. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144673. */
  144674. export class SimplificationSettings implements ISimplificationSettings {
  144675. /** expected quality */
  144676. quality: number;
  144677. /** distance when this optimized version should be used */
  144678. distance: number;
  144679. /** already optimized mesh */
  144680. optimizeMesh?: boolean | undefined;
  144681. /**
  144682. * Creates a SimplificationSettings
  144683. * @param quality expected quality
  144684. * @param distance distance when this optimized version should be used
  144685. * @param optimizeMesh already optimized mesh
  144686. */
  144687. constructor(
  144688. /** expected quality */
  144689. quality: number,
  144690. /** distance when this optimized version should be used */
  144691. distance: number,
  144692. /** already optimized mesh */
  144693. optimizeMesh?: boolean | undefined);
  144694. }
  144695. /**
  144696. * Interface used to define a simplification task
  144697. */
  144698. export interface ISimplificationTask {
  144699. /**
  144700. * Array of settings
  144701. */
  144702. settings: Array<ISimplificationSettings>;
  144703. /**
  144704. * Simplification type
  144705. */
  144706. simplificationType: SimplificationType;
  144707. /**
  144708. * Mesh to simplify
  144709. */
  144710. mesh: Mesh;
  144711. /**
  144712. * Callback called on success
  144713. */
  144714. successCallback?: () => void;
  144715. /**
  144716. * Defines if parallel processing can be used
  144717. */
  144718. parallelProcessing: boolean;
  144719. }
  144720. /**
  144721. * Queue used to order the simplification tasks
  144722. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144723. */
  144724. export class SimplificationQueue {
  144725. private _simplificationArray;
  144726. /**
  144727. * Gets a boolean indicating that the process is still running
  144728. */
  144729. running: boolean;
  144730. /**
  144731. * Creates a new queue
  144732. */
  144733. constructor();
  144734. /**
  144735. * Adds a new simplification task
  144736. * @param task defines a task to add
  144737. */
  144738. addTask(task: ISimplificationTask): void;
  144739. /**
  144740. * Execute next task
  144741. */
  144742. executeNext(): void;
  144743. /**
  144744. * Execute a simplification task
  144745. * @param task defines the task to run
  144746. */
  144747. runSimplification(task: ISimplificationTask): void;
  144748. private getSimplifier;
  144749. }
  144750. /**
  144751. * The implemented types of simplification
  144752. * At the moment only Quadratic Error Decimation is implemented
  144753. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144754. */
  144755. export enum SimplificationType {
  144756. /** Quadratic error decimation */
  144757. QUADRATIC = 0
  144758. }
  144759. /**
  144760. * An implementation of the Quadratic Error simplification algorithm.
  144761. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  144762. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  144763. * @author RaananW
  144764. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144765. */
  144766. export class QuadraticErrorSimplification implements ISimplifier {
  144767. private _mesh;
  144768. private triangles;
  144769. private vertices;
  144770. private references;
  144771. private _reconstructedMesh;
  144772. /** Gets or sets the number pf sync interations */
  144773. syncIterations: number;
  144774. /** Gets or sets the aggressiveness of the simplifier */
  144775. aggressiveness: number;
  144776. /** Gets or sets the number of allowed iterations for decimation */
  144777. decimationIterations: number;
  144778. /** Gets or sets the espilon to use for bounding box computation */
  144779. boundingBoxEpsilon: number;
  144780. /**
  144781. * Creates a new QuadraticErrorSimplification
  144782. * @param _mesh defines the target mesh
  144783. */
  144784. constructor(_mesh: Mesh);
  144785. /**
  144786. * Simplification of a given mesh according to the given settings.
  144787. * Since this requires computation, it is assumed that the function runs async.
  144788. * @param settings The settings of the simplification, including quality and distance
  144789. * @param successCallback A callback that will be called after the mesh was simplified.
  144790. */
  144791. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  144792. private runDecimation;
  144793. private initWithMesh;
  144794. private init;
  144795. private reconstructMesh;
  144796. private initDecimatedMesh;
  144797. private isFlipped;
  144798. private updateTriangles;
  144799. private identifyBorder;
  144800. private updateMesh;
  144801. private vertexError;
  144802. private calculateError;
  144803. }
  144804. }
  144805. declare module BABYLON {
  144806. interface Scene {
  144807. /** @hidden (Backing field) */
  144808. _simplificationQueue: SimplificationQueue;
  144809. /**
  144810. * Gets or sets the simplification queue attached to the scene
  144811. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144812. */
  144813. simplificationQueue: SimplificationQueue;
  144814. }
  144815. interface Mesh {
  144816. /**
  144817. * Simplify the mesh according to the given array of settings.
  144818. * Function will return immediately and will simplify async
  144819. * @param settings a collection of simplification settings
  144820. * @param parallelProcessing should all levels calculate parallel or one after the other
  144821. * @param simplificationType the type of simplification to run
  144822. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  144823. * @returns the current mesh
  144824. */
  144825. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  144826. }
  144827. /**
  144828. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  144829. * created in a scene
  144830. */
  144831. export class SimplicationQueueSceneComponent implements ISceneComponent {
  144832. /**
  144833. * The component name helpfull to identify the component in the list of scene components.
  144834. */
  144835. readonly name: string;
  144836. /**
  144837. * The scene the component belongs to.
  144838. */
  144839. scene: Scene;
  144840. /**
  144841. * Creates a new instance of the component for the given scene
  144842. * @param scene Defines the scene to register the component in
  144843. */
  144844. constructor(scene: Scene);
  144845. /**
  144846. * Registers the component in a given scene
  144847. */
  144848. register(): void;
  144849. /**
  144850. * Rebuilds the elements related to this component in case of
  144851. * context lost for instance.
  144852. */
  144853. rebuild(): void;
  144854. /**
  144855. * Disposes the component and the associated ressources
  144856. */
  144857. dispose(): void;
  144858. private _beforeCameraUpdate;
  144859. }
  144860. }
  144861. declare module BABYLON {
  144862. interface Mesh {
  144863. /**
  144864. * Creates a new thin instance
  144865. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  144866. * @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
  144867. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  144868. */
  144869. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  144870. /**
  144871. * Adds the transformation (matrix) of the current mesh as a thin instance
  144872. * @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
  144873. * @returns the thin instance index number
  144874. */
  144875. thinInstanceAddSelf(refresh: boolean): number;
  144876. /**
  144877. * Registers a custom attribute to be used with thin instances
  144878. * @param kind name of the attribute
  144879. * @param stride size in floats of the attribute
  144880. */
  144881. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  144882. /**
  144883. * Sets the matrix of a thin instance
  144884. * @param index index of the thin instance
  144885. * @param matrix matrix to set
  144886. * @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
  144887. */
  144888. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  144889. /**
  144890. * Sets the value of a custom attribute for a thin instance
  144891. * @param kind name of the attribute
  144892. * @param index index of the thin instance
  144893. * @param value value to set
  144894. * @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
  144895. */
  144896. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  144897. /**
  144898. * 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.
  144899. */
  144900. thinInstanceCount: number;
  144901. /**
  144902. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  144903. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  144904. * @param buffer buffer to set
  144905. * @param stride size in floats of each value of the buffer
  144906. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  144907. */
  144908. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  144909. /**
  144910. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  144911. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  144912. */
  144913. thinInstanceBufferUpdated(kind: string): void;
  144914. /**
  144915. * Refreshes the bounding info, taking into account all the thin instances defined
  144916. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  144917. */
  144918. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  144919. /** @hidden */
  144920. _thinInstanceInitializeUserStorage(): void;
  144921. /** @hidden */
  144922. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  144923. /** @hidden */
  144924. _userThinInstanceBuffersStorage: {
  144925. data: {
  144926. [key: string]: Float32Array;
  144927. };
  144928. sizes: {
  144929. [key: string]: number;
  144930. };
  144931. vertexBuffers: {
  144932. [key: string]: Nullable<VertexBuffer>;
  144933. };
  144934. strides: {
  144935. [key: string]: number;
  144936. };
  144937. };
  144938. }
  144939. }
  144940. declare module BABYLON {
  144941. /**
  144942. * Navigation plugin interface to add navigation constrained by a navigation mesh
  144943. */
  144944. export interface INavigationEnginePlugin {
  144945. /**
  144946. * plugin name
  144947. */
  144948. name: string;
  144949. /**
  144950. * Creates a navigation mesh
  144951. * @param meshes array of all the geometry used to compute the navigatio mesh
  144952. * @param parameters bunch of parameters used to filter geometry
  144953. */
  144954. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  144955. /**
  144956. * Create a navigation mesh debug mesh
  144957. * @param scene is where the mesh will be added
  144958. * @returns debug display mesh
  144959. */
  144960. createDebugNavMesh(scene: Scene): Mesh;
  144961. /**
  144962. * Get a navigation mesh constrained position, closest to the parameter position
  144963. * @param position world position
  144964. * @returns the closest point to position constrained by the navigation mesh
  144965. */
  144966. getClosestPoint(position: Vector3): Vector3;
  144967. /**
  144968. * Get a navigation mesh constrained position, closest to the parameter position
  144969. * @param position world position
  144970. * @param result output the closest point to position constrained by the navigation mesh
  144971. */
  144972. getClosestPointToRef(position: Vector3, result: Vector3): void;
  144973. /**
  144974. * Get a navigation mesh constrained position, within a particular radius
  144975. * @param position world position
  144976. * @param maxRadius the maximum distance to the constrained world position
  144977. * @returns the closest point to position constrained by the navigation mesh
  144978. */
  144979. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  144980. /**
  144981. * Get a navigation mesh constrained position, within a particular radius
  144982. * @param position world position
  144983. * @param maxRadius the maximum distance to the constrained world position
  144984. * @param result output the closest point to position constrained by the navigation mesh
  144985. */
  144986. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  144987. /**
  144988. * Compute the final position from a segment made of destination-position
  144989. * @param position world position
  144990. * @param destination world position
  144991. * @returns the resulting point along the navmesh
  144992. */
  144993. moveAlong(position: Vector3, destination: Vector3): Vector3;
  144994. /**
  144995. * Compute the final position from a segment made of destination-position
  144996. * @param position world position
  144997. * @param destination world position
  144998. * @param result output the resulting point along the navmesh
  144999. */
  145000. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  145001. /**
  145002. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  145003. * @param start world position
  145004. * @param end world position
  145005. * @returns array containing world position composing the path
  145006. */
  145007. computePath(start: Vector3, end: Vector3): Vector3[];
  145008. /**
  145009. * If this plugin is supported
  145010. * @returns true if plugin is supported
  145011. */
  145012. isSupported(): boolean;
  145013. /**
  145014. * Create a new Crowd so you can add agents
  145015. * @param maxAgents the maximum agent count in the crowd
  145016. * @param maxAgentRadius the maximum radius an agent can have
  145017. * @param scene to attach the crowd to
  145018. * @returns the crowd you can add agents to
  145019. */
  145020. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  145021. /**
  145022. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145023. * The queries will try to find a solution within those bounds
  145024. * default is (1,1,1)
  145025. * @param extent x,y,z value that define the extent around the queries point of reference
  145026. */
  145027. setDefaultQueryExtent(extent: Vector3): void;
  145028. /**
  145029. * Get the Bounding box extent specified by setDefaultQueryExtent
  145030. * @returns the box extent values
  145031. */
  145032. getDefaultQueryExtent(): Vector3;
  145033. /**
  145034. * build the navmesh from a previously saved state using getNavmeshData
  145035. * @param data the Uint8Array returned by getNavmeshData
  145036. */
  145037. buildFromNavmeshData(data: Uint8Array): void;
  145038. /**
  145039. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  145040. * @returns data the Uint8Array that can be saved and reused
  145041. */
  145042. getNavmeshData(): Uint8Array;
  145043. /**
  145044. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145045. * @param result output the box extent values
  145046. */
  145047. getDefaultQueryExtentToRef(result: Vector3): void;
  145048. /**
  145049. * Release all resources
  145050. */
  145051. dispose(): void;
  145052. }
  145053. /**
  145054. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  145055. */
  145056. export interface ICrowd {
  145057. /**
  145058. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  145059. * You can attach anything to that node. The node position is updated in the scene update tick.
  145060. * @param pos world position that will be constrained by the navigation mesh
  145061. * @param parameters agent parameters
  145062. * @param transform hooked to the agent that will be update by the scene
  145063. * @returns agent index
  145064. */
  145065. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  145066. /**
  145067. * Returns the agent position in world space
  145068. * @param index agent index returned by addAgent
  145069. * @returns world space position
  145070. */
  145071. getAgentPosition(index: number): Vector3;
  145072. /**
  145073. * Gets the agent position result in world space
  145074. * @param index agent index returned by addAgent
  145075. * @param result output world space position
  145076. */
  145077. getAgentPositionToRef(index: number, result: Vector3): void;
  145078. /**
  145079. * Gets the agent velocity in world space
  145080. * @param index agent index returned by addAgent
  145081. * @returns world space velocity
  145082. */
  145083. getAgentVelocity(index: number): Vector3;
  145084. /**
  145085. * Gets the agent velocity result in world space
  145086. * @param index agent index returned by addAgent
  145087. * @param result output world space velocity
  145088. */
  145089. getAgentVelocityToRef(index: number, result: Vector3): void;
  145090. /**
  145091. * remove a particular agent previously created
  145092. * @param index agent index returned by addAgent
  145093. */
  145094. removeAgent(index: number): void;
  145095. /**
  145096. * get the list of all agents attached to this crowd
  145097. * @returns list of agent indices
  145098. */
  145099. getAgents(): number[];
  145100. /**
  145101. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  145102. * @param deltaTime in seconds
  145103. */
  145104. update(deltaTime: number): void;
  145105. /**
  145106. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  145107. * @param index agent index returned by addAgent
  145108. * @param destination targeted world position
  145109. */
  145110. agentGoto(index: number, destination: Vector3): void;
  145111. /**
  145112. * Teleport the agent to a new position
  145113. * @param index agent index returned by addAgent
  145114. * @param destination targeted world position
  145115. */
  145116. agentTeleport(index: number, destination: Vector3): void;
  145117. /**
  145118. * Update agent parameters
  145119. * @param index agent index returned by addAgent
  145120. * @param parameters agent parameters
  145121. */
  145122. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  145123. /**
  145124. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145125. * The queries will try to find a solution within those bounds
  145126. * default is (1,1,1)
  145127. * @param extent x,y,z value that define the extent around the queries point of reference
  145128. */
  145129. setDefaultQueryExtent(extent: Vector3): void;
  145130. /**
  145131. * Get the Bounding box extent specified by setDefaultQueryExtent
  145132. * @returns the box extent values
  145133. */
  145134. getDefaultQueryExtent(): Vector3;
  145135. /**
  145136. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145137. * @param result output the box extent values
  145138. */
  145139. getDefaultQueryExtentToRef(result: Vector3): void;
  145140. /**
  145141. * Release all resources
  145142. */
  145143. dispose(): void;
  145144. }
  145145. /**
  145146. * Configures an agent
  145147. */
  145148. export interface IAgentParameters {
  145149. /**
  145150. * Agent radius. [Limit: >= 0]
  145151. */
  145152. radius: number;
  145153. /**
  145154. * Agent height. [Limit: > 0]
  145155. */
  145156. height: number;
  145157. /**
  145158. * Maximum allowed acceleration. [Limit: >= 0]
  145159. */
  145160. maxAcceleration: number;
  145161. /**
  145162. * Maximum allowed speed. [Limit: >= 0]
  145163. */
  145164. maxSpeed: number;
  145165. /**
  145166. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  145167. */
  145168. collisionQueryRange: number;
  145169. /**
  145170. * The path visibility optimization range. [Limit: > 0]
  145171. */
  145172. pathOptimizationRange: number;
  145173. /**
  145174. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  145175. */
  145176. separationWeight: number;
  145177. }
  145178. /**
  145179. * Configures the navigation mesh creation
  145180. */
  145181. export interface INavMeshParameters {
  145182. /**
  145183. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  145184. */
  145185. cs: number;
  145186. /**
  145187. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  145188. */
  145189. ch: number;
  145190. /**
  145191. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  145192. */
  145193. walkableSlopeAngle: number;
  145194. /**
  145195. * Minimum floor to 'ceiling' height that will still allow the floor area to
  145196. * be considered walkable. [Limit: >= 3] [Units: vx]
  145197. */
  145198. walkableHeight: number;
  145199. /**
  145200. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  145201. */
  145202. walkableClimb: number;
  145203. /**
  145204. * The distance to erode/shrink the walkable area of the heightfield away from
  145205. * obstructions. [Limit: >=0] [Units: vx]
  145206. */
  145207. walkableRadius: number;
  145208. /**
  145209. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  145210. */
  145211. maxEdgeLen: number;
  145212. /**
  145213. * The maximum distance a simplfied contour's border edges should deviate
  145214. * the original raw contour. [Limit: >=0] [Units: vx]
  145215. */
  145216. maxSimplificationError: number;
  145217. /**
  145218. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  145219. */
  145220. minRegionArea: number;
  145221. /**
  145222. * Any regions with a span count smaller than this value will, if possible,
  145223. * be merged with larger regions. [Limit: >=0] [Units: vx]
  145224. */
  145225. mergeRegionArea: number;
  145226. /**
  145227. * The maximum number of vertices allowed for polygons generated during the
  145228. * contour to polygon conversion process. [Limit: >= 3]
  145229. */
  145230. maxVertsPerPoly: number;
  145231. /**
  145232. * Sets the sampling distance to use when generating the detail mesh.
  145233. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  145234. */
  145235. detailSampleDist: number;
  145236. /**
  145237. * The maximum distance the detail mesh surface should deviate from heightfield
  145238. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  145239. */
  145240. detailSampleMaxError: number;
  145241. }
  145242. }
  145243. declare module BABYLON {
  145244. /**
  145245. * RecastJS navigation plugin
  145246. */
  145247. export class RecastJSPlugin implements INavigationEnginePlugin {
  145248. /**
  145249. * Reference to the Recast library
  145250. */
  145251. bjsRECAST: any;
  145252. /**
  145253. * plugin name
  145254. */
  145255. name: string;
  145256. /**
  145257. * the first navmesh created. We might extend this to support multiple navmeshes
  145258. */
  145259. navMesh: any;
  145260. /**
  145261. * Initializes the recastJS plugin
  145262. * @param recastInjection can be used to inject your own recast reference
  145263. */
  145264. constructor(recastInjection?: any);
  145265. /**
  145266. * Creates a navigation mesh
  145267. * @param meshes array of all the geometry used to compute the navigatio mesh
  145268. * @param parameters bunch of parameters used to filter geometry
  145269. */
  145270. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  145271. /**
  145272. * Create a navigation mesh debug mesh
  145273. * @param scene is where the mesh will be added
  145274. * @returns debug display mesh
  145275. */
  145276. createDebugNavMesh(scene: Scene): Mesh;
  145277. /**
  145278. * Get a navigation mesh constrained position, closest to the parameter position
  145279. * @param position world position
  145280. * @returns the closest point to position constrained by the navigation mesh
  145281. */
  145282. getClosestPoint(position: Vector3): Vector3;
  145283. /**
  145284. * Get a navigation mesh constrained position, closest to the parameter position
  145285. * @param position world position
  145286. * @param result output the closest point to position constrained by the navigation mesh
  145287. */
  145288. getClosestPointToRef(position: Vector3, result: Vector3): void;
  145289. /**
  145290. * Get a navigation mesh constrained position, within a particular radius
  145291. * @param position world position
  145292. * @param maxRadius the maximum distance to the constrained world position
  145293. * @returns the closest point to position constrained by the navigation mesh
  145294. */
  145295. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  145296. /**
  145297. * Get a navigation mesh constrained position, within a particular radius
  145298. * @param position world position
  145299. * @param maxRadius the maximum distance to the constrained world position
  145300. * @param result output the closest point to position constrained by the navigation mesh
  145301. */
  145302. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  145303. /**
  145304. * Compute the final position from a segment made of destination-position
  145305. * @param position world position
  145306. * @param destination world position
  145307. * @returns the resulting point along the navmesh
  145308. */
  145309. moveAlong(position: Vector3, destination: Vector3): Vector3;
  145310. /**
  145311. * Compute the final position from a segment made of destination-position
  145312. * @param position world position
  145313. * @param destination world position
  145314. * @param result output the resulting point along the navmesh
  145315. */
  145316. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  145317. /**
  145318. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  145319. * @param start world position
  145320. * @param end world position
  145321. * @returns array containing world position composing the path
  145322. */
  145323. computePath(start: Vector3, end: Vector3): Vector3[];
  145324. /**
  145325. * Create a new Crowd so you can add agents
  145326. * @param maxAgents the maximum agent count in the crowd
  145327. * @param maxAgentRadius the maximum radius an agent can have
  145328. * @param scene to attach the crowd to
  145329. * @returns the crowd you can add agents to
  145330. */
  145331. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  145332. /**
  145333. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145334. * The queries will try to find a solution within those bounds
  145335. * default is (1,1,1)
  145336. * @param extent x,y,z value that define the extent around the queries point of reference
  145337. */
  145338. setDefaultQueryExtent(extent: Vector3): void;
  145339. /**
  145340. * Get the Bounding box extent specified by setDefaultQueryExtent
  145341. * @returns the box extent values
  145342. */
  145343. getDefaultQueryExtent(): Vector3;
  145344. /**
  145345. * build the navmesh from a previously saved state using getNavmeshData
  145346. * @param data the Uint8Array returned by getNavmeshData
  145347. */
  145348. buildFromNavmeshData(data: Uint8Array): void;
  145349. /**
  145350. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  145351. * @returns data the Uint8Array that can be saved and reused
  145352. */
  145353. getNavmeshData(): Uint8Array;
  145354. /**
  145355. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145356. * @param result output the box extent values
  145357. */
  145358. getDefaultQueryExtentToRef(result: Vector3): void;
  145359. /**
  145360. * Disposes
  145361. */
  145362. dispose(): void;
  145363. /**
  145364. * If this plugin is supported
  145365. * @returns true if plugin is supported
  145366. */
  145367. isSupported(): boolean;
  145368. }
  145369. /**
  145370. * Recast detour crowd implementation
  145371. */
  145372. export class RecastJSCrowd implements ICrowd {
  145373. /**
  145374. * Recast/detour plugin
  145375. */
  145376. bjsRECASTPlugin: RecastJSPlugin;
  145377. /**
  145378. * Link to the detour crowd
  145379. */
  145380. recastCrowd: any;
  145381. /**
  145382. * One transform per agent
  145383. */
  145384. transforms: TransformNode[];
  145385. /**
  145386. * All agents created
  145387. */
  145388. agents: number[];
  145389. /**
  145390. * Link to the scene is kept to unregister the crowd from the scene
  145391. */
  145392. private _scene;
  145393. /**
  145394. * Observer for crowd updates
  145395. */
  145396. private _onBeforeAnimationsObserver;
  145397. /**
  145398. * Constructor
  145399. * @param plugin recastJS plugin
  145400. * @param maxAgents the maximum agent count in the crowd
  145401. * @param maxAgentRadius the maximum radius an agent can have
  145402. * @param scene to attach the crowd to
  145403. * @returns the crowd you can add agents to
  145404. */
  145405. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  145406. /**
  145407. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  145408. * You can attach anything to that node. The node position is updated in the scene update tick.
  145409. * @param pos world position that will be constrained by the navigation mesh
  145410. * @param parameters agent parameters
  145411. * @param transform hooked to the agent that will be update by the scene
  145412. * @returns agent index
  145413. */
  145414. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  145415. /**
  145416. * Returns the agent position in world space
  145417. * @param index agent index returned by addAgent
  145418. * @returns world space position
  145419. */
  145420. getAgentPosition(index: number): Vector3;
  145421. /**
  145422. * Returns the agent position result in world space
  145423. * @param index agent index returned by addAgent
  145424. * @param result output world space position
  145425. */
  145426. getAgentPositionToRef(index: number, result: Vector3): void;
  145427. /**
  145428. * Returns the agent velocity in world space
  145429. * @param index agent index returned by addAgent
  145430. * @returns world space velocity
  145431. */
  145432. getAgentVelocity(index: number): Vector3;
  145433. /**
  145434. * Returns the agent velocity result in world space
  145435. * @param index agent index returned by addAgent
  145436. * @param result output world space velocity
  145437. */
  145438. getAgentVelocityToRef(index: number, result: Vector3): void;
  145439. /**
  145440. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  145441. * @param index agent index returned by addAgent
  145442. * @param destination targeted world position
  145443. */
  145444. agentGoto(index: number, destination: Vector3): void;
  145445. /**
  145446. * Teleport the agent to a new position
  145447. * @param index agent index returned by addAgent
  145448. * @param destination targeted world position
  145449. */
  145450. agentTeleport(index: number, destination: Vector3): void;
  145451. /**
  145452. * Update agent parameters
  145453. * @param index agent index returned by addAgent
  145454. * @param parameters agent parameters
  145455. */
  145456. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  145457. /**
  145458. * remove a particular agent previously created
  145459. * @param index agent index returned by addAgent
  145460. */
  145461. removeAgent(index: number): void;
  145462. /**
  145463. * get the list of all agents attached to this crowd
  145464. * @returns list of agent indices
  145465. */
  145466. getAgents(): number[];
  145467. /**
  145468. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  145469. * @param deltaTime in seconds
  145470. */
  145471. update(deltaTime: number): void;
  145472. /**
  145473. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145474. * The queries will try to find a solution within those bounds
  145475. * default is (1,1,1)
  145476. * @param extent x,y,z value that define the extent around the queries point of reference
  145477. */
  145478. setDefaultQueryExtent(extent: Vector3): void;
  145479. /**
  145480. * Get the Bounding box extent specified by setDefaultQueryExtent
  145481. * @returns the box extent values
  145482. */
  145483. getDefaultQueryExtent(): Vector3;
  145484. /**
  145485. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145486. * @param result output the box extent values
  145487. */
  145488. getDefaultQueryExtentToRef(result: Vector3): void;
  145489. /**
  145490. * Release all resources
  145491. */
  145492. dispose(): void;
  145493. }
  145494. }
  145495. declare module BABYLON {
  145496. /**
  145497. * Class used to enable access to IndexedDB
  145498. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  145499. */
  145500. export class Database implements IOfflineProvider {
  145501. private _callbackManifestChecked;
  145502. private _currentSceneUrl;
  145503. private _db;
  145504. private _enableSceneOffline;
  145505. private _enableTexturesOffline;
  145506. private _manifestVersionFound;
  145507. private _mustUpdateRessources;
  145508. private _hasReachedQuota;
  145509. private _isSupported;
  145510. private _idbFactory;
  145511. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  145512. private static IsUASupportingBlobStorage;
  145513. /**
  145514. * Gets a boolean indicating if Database storate is enabled (off by default)
  145515. */
  145516. static IDBStorageEnabled: boolean;
  145517. /**
  145518. * Gets a boolean indicating if scene must be saved in the database
  145519. */
  145520. get enableSceneOffline(): boolean;
  145521. /**
  145522. * Gets a boolean indicating if textures must be saved in the database
  145523. */
  145524. get enableTexturesOffline(): boolean;
  145525. /**
  145526. * Creates a new Database
  145527. * @param urlToScene defines the url to load the scene
  145528. * @param callbackManifestChecked defines the callback to use when manifest is checked
  145529. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  145530. */
  145531. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  145532. private static _ParseURL;
  145533. private static _ReturnFullUrlLocation;
  145534. private _checkManifestFile;
  145535. /**
  145536. * Open the database and make it available
  145537. * @param successCallback defines the callback to call on success
  145538. * @param errorCallback defines the callback to call on error
  145539. */
  145540. open(successCallback: () => void, errorCallback: () => void): void;
  145541. /**
  145542. * Loads an image from the database
  145543. * @param url defines the url to load from
  145544. * @param image defines the target DOM image
  145545. */
  145546. loadImage(url: string, image: HTMLImageElement): void;
  145547. private _loadImageFromDBAsync;
  145548. private _saveImageIntoDBAsync;
  145549. private _checkVersionFromDB;
  145550. private _loadVersionFromDBAsync;
  145551. private _saveVersionIntoDBAsync;
  145552. /**
  145553. * Loads a file from database
  145554. * @param url defines the URL to load from
  145555. * @param sceneLoaded defines a callback to call on success
  145556. * @param progressCallBack defines a callback to call when progress changed
  145557. * @param errorCallback defines a callback to call on error
  145558. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  145559. */
  145560. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  145561. private _loadFileAsync;
  145562. private _saveFileAsync;
  145563. /**
  145564. * Validates if xhr data is correct
  145565. * @param xhr defines the request to validate
  145566. * @param dataType defines the expected data type
  145567. * @returns true if data is correct
  145568. */
  145569. private static _ValidateXHRData;
  145570. }
  145571. }
  145572. declare module BABYLON {
  145573. /** @hidden */
  145574. export var gpuUpdateParticlesPixelShader: {
  145575. name: string;
  145576. shader: string;
  145577. };
  145578. }
  145579. declare module BABYLON {
  145580. /** @hidden */
  145581. export var gpuUpdateParticlesVertexShader: {
  145582. name: string;
  145583. shader: string;
  145584. };
  145585. }
  145586. declare module BABYLON {
  145587. /** @hidden */
  145588. export var clipPlaneFragmentDeclaration2: {
  145589. name: string;
  145590. shader: string;
  145591. };
  145592. }
  145593. declare module BABYLON {
  145594. /** @hidden */
  145595. export var gpuRenderParticlesPixelShader: {
  145596. name: string;
  145597. shader: string;
  145598. };
  145599. }
  145600. declare module BABYLON {
  145601. /** @hidden */
  145602. export var clipPlaneVertexDeclaration2: {
  145603. name: string;
  145604. shader: string;
  145605. };
  145606. }
  145607. declare module BABYLON {
  145608. /** @hidden */
  145609. export var gpuRenderParticlesVertexShader: {
  145610. name: string;
  145611. shader: string;
  145612. };
  145613. }
  145614. declare module BABYLON {
  145615. /**
  145616. * This represents a GPU particle system in Babylon
  145617. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  145618. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  145619. */
  145620. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  145621. /**
  145622. * The layer mask we are rendering the particles through.
  145623. */
  145624. layerMask: number;
  145625. private _capacity;
  145626. private _activeCount;
  145627. private _currentActiveCount;
  145628. private _accumulatedCount;
  145629. private _renderEffect;
  145630. private _updateEffect;
  145631. private _buffer0;
  145632. private _buffer1;
  145633. private _spriteBuffer;
  145634. private _updateVAO;
  145635. private _renderVAO;
  145636. private _targetIndex;
  145637. private _sourceBuffer;
  145638. private _targetBuffer;
  145639. private _engine;
  145640. private _currentRenderId;
  145641. private _started;
  145642. private _stopped;
  145643. private _timeDelta;
  145644. private _randomTexture;
  145645. private _randomTexture2;
  145646. private _attributesStrideSize;
  145647. private _updateEffectOptions;
  145648. private _randomTextureSize;
  145649. private _actualFrame;
  145650. private _customEffect;
  145651. private readonly _rawTextureWidth;
  145652. /**
  145653. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  145654. */
  145655. static get IsSupported(): boolean;
  145656. /**
  145657. * An event triggered when the system is disposed.
  145658. */
  145659. onDisposeObservable: Observable<IParticleSystem>;
  145660. /**
  145661. * Gets the maximum number of particles active at the same time.
  145662. * @returns The max number of active particles.
  145663. */
  145664. getCapacity(): number;
  145665. /**
  145666. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  145667. * to override the particles.
  145668. */
  145669. forceDepthWrite: boolean;
  145670. /**
  145671. * Gets or set the number of active particles
  145672. */
  145673. get activeParticleCount(): number;
  145674. set activeParticleCount(value: number);
  145675. private _preWarmDone;
  145676. /**
  145677. * Specifies if the particles are updated in emitter local space or world space.
  145678. */
  145679. isLocal: boolean;
  145680. /**
  145681. * Is this system ready to be used/rendered
  145682. * @return true if the system is ready
  145683. */
  145684. isReady(): boolean;
  145685. /**
  145686. * Gets if the system has been started. (Note: this will still be true after stop is called)
  145687. * @returns True if it has been started, otherwise false.
  145688. */
  145689. isStarted(): boolean;
  145690. /**
  145691. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  145692. * @returns True if it has been stopped, otherwise false.
  145693. */
  145694. isStopped(): boolean;
  145695. /**
  145696. * Gets a boolean indicating that the system is stopping
  145697. * @returns true if the system is currently stopping
  145698. */
  145699. isStopping(): boolean;
  145700. /**
  145701. * Gets the number of particles active at the same time.
  145702. * @returns The number of active particles.
  145703. */
  145704. getActiveCount(): number;
  145705. /**
  145706. * Starts the particle system and begins to emit
  145707. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  145708. */
  145709. start(delay?: number): void;
  145710. /**
  145711. * Stops the particle system.
  145712. */
  145713. stop(): void;
  145714. /**
  145715. * Remove all active particles
  145716. */
  145717. reset(): void;
  145718. /**
  145719. * Returns the string "GPUParticleSystem"
  145720. * @returns a string containing the class name
  145721. */
  145722. getClassName(): string;
  145723. /**
  145724. * Gets the custom effect used to render the particles
  145725. * @param blendMode Blend mode for which the effect should be retrieved
  145726. * @returns The effect
  145727. */
  145728. getCustomEffect(blendMode?: number): Nullable<Effect>;
  145729. /**
  145730. * Sets the custom effect used to render the particles
  145731. * @param effect The effect to set
  145732. * @param blendMode Blend mode for which the effect should be set
  145733. */
  145734. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  145735. /** @hidden */
  145736. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  145737. /**
  145738. * Observable that will be called just before the particles are drawn
  145739. */
  145740. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  145741. /**
  145742. * Gets the name of the particle vertex shader
  145743. */
  145744. get vertexShaderName(): string;
  145745. private _colorGradientsTexture;
  145746. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  145747. /**
  145748. * Adds a new color gradient
  145749. * @param gradient defines the gradient to use (between 0 and 1)
  145750. * @param color1 defines the color to affect to the specified gradient
  145751. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  145752. * @returns the current particle system
  145753. */
  145754. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  145755. private _refreshColorGradient;
  145756. /** Force the system to rebuild all gradients that need to be resync */
  145757. forceRefreshGradients(): void;
  145758. /**
  145759. * Remove a specific color gradient
  145760. * @param gradient defines the gradient to remove
  145761. * @returns the current particle system
  145762. */
  145763. removeColorGradient(gradient: number): GPUParticleSystem;
  145764. private _angularSpeedGradientsTexture;
  145765. private _sizeGradientsTexture;
  145766. private _velocityGradientsTexture;
  145767. private _limitVelocityGradientsTexture;
  145768. private _dragGradientsTexture;
  145769. private _addFactorGradient;
  145770. /**
  145771. * Adds a new size gradient
  145772. * @param gradient defines the gradient to use (between 0 and 1)
  145773. * @param factor defines the size factor to affect to the specified gradient
  145774. * @returns the current particle system
  145775. */
  145776. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  145777. /**
  145778. * Remove a specific size gradient
  145779. * @param gradient defines the gradient to remove
  145780. * @returns the current particle system
  145781. */
  145782. removeSizeGradient(gradient: number): GPUParticleSystem;
  145783. private _refreshFactorGradient;
  145784. /**
  145785. * Adds a new angular speed gradient
  145786. * @param gradient defines the gradient to use (between 0 and 1)
  145787. * @param factor defines the angular speed to affect to the specified gradient
  145788. * @returns the current particle system
  145789. */
  145790. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  145791. /**
  145792. * Remove a specific angular speed gradient
  145793. * @param gradient defines the gradient to remove
  145794. * @returns the current particle system
  145795. */
  145796. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  145797. /**
  145798. * Adds a new velocity gradient
  145799. * @param gradient defines the gradient to use (between 0 and 1)
  145800. * @param factor defines the velocity to affect to the specified gradient
  145801. * @returns the current particle system
  145802. */
  145803. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  145804. /**
  145805. * Remove a specific velocity gradient
  145806. * @param gradient defines the gradient to remove
  145807. * @returns the current particle system
  145808. */
  145809. removeVelocityGradient(gradient: number): GPUParticleSystem;
  145810. /**
  145811. * Adds a new limit velocity gradient
  145812. * @param gradient defines the gradient to use (between 0 and 1)
  145813. * @param factor defines the limit velocity value to affect to the specified gradient
  145814. * @returns the current particle system
  145815. */
  145816. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  145817. /**
  145818. * Remove a specific limit velocity gradient
  145819. * @param gradient defines the gradient to remove
  145820. * @returns the current particle system
  145821. */
  145822. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  145823. /**
  145824. * Adds a new drag gradient
  145825. * @param gradient defines the gradient to use (between 0 and 1)
  145826. * @param factor defines the drag value to affect to the specified gradient
  145827. * @returns the current particle system
  145828. */
  145829. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  145830. /**
  145831. * Remove a specific drag gradient
  145832. * @param gradient defines the gradient to remove
  145833. * @returns the current particle system
  145834. */
  145835. removeDragGradient(gradient: number): GPUParticleSystem;
  145836. /**
  145837. * Not supported by GPUParticleSystem
  145838. * @param gradient defines the gradient to use (between 0 and 1)
  145839. * @param factor defines the emit rate value to affect to the specified gradient
  145840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  145841. * @returns the current particle system
  145842. */
  145843. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  145844. /**
  145845. * Not supported by GPUParticleSystem
  145846. * @param gradient defines the gradient to remove
  145847. * @returns the current particle system
  145848. */
  145849. removeEmitRateGradient(gradient: number): IParticleSystem;
  145850. /**
  145851. * Not supported by GPUParticleSystem
  145852. * @param gradient defines the gradient to use (between 0 and 1)
  145853. * @param factor defines the start size value to affect to the specified gradient
  145854. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  145855. * @returns the current particle system
  145856. */
  145857. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  145858. /**
  145859. * Not supported by GPUParticleSystem
  145860. * @param gradient defines the gradient to remove
  145861. * @returns the current particle system
  145862. */
  145863. removeStartSizeGradient(gradient: number): IParticleSystem;
  145864. /**
  145865. * Not supported by GPUParticleSystem
  145866. * @param gradient defines the gradient to use (between 0 and 1)
  145867. * @param min defines the color remap minimal range
  145868. * @param max defines the color remap maximal range
  145869. * @returns the current particle system
  145870. */
  145871. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  145872. /**
  145873. * Not supported by GPUParticleSystem
  145874. * @param gradient defines the gradient to remove
  145875. * @returns the current particle system
  145876. */
  145877. removeColorRemapGradient(): IParticleSystem;
  145878. /**
  145879. * Not supported by GPUParticleSystem
  145880. * @param gradient defines the gradient to use (between 0 and 1)
  145881. * @param min defines the alpha remap minimal range
  145882. * @param max defines the alpha remap maximal range
  145883. * @returns the current particle system
  145884. */
  145885. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  145886. /**
  145887. * Not supported by GPUParticleSystem
  145888. * @param gradient defines the gradient to remove
  145889. * @returns the current particle system
  145890. */
  145891. removeAlphaRemapGradient(): IParticleSystem;
  145892. /**
  145893. * Not supported by GPUParticleSystem
  145894. * @param gradient defines the gradient to use (between 0 and 1)
  145895. * @param color defines the color to affect to the specified gradient
  145896. * @returns the current particle system
  145897. */
  145898. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  145899. /**
  145900. * Not supported by GPUParticleSystem
  145901. * @param gradient defines the gradient to remove
  145902. * @returns the current particle system
  145903. */
  145904. removeRampGradient(): IParticleSystem;
  145905. /**
  145906. * Not supported by GPUParticleSystem
  145907. * @returns the list of ramp gradients
  145908. */
  145909. getRampGradients(): Nullable<Array<Color3Gradient>>;
  145910. /**
  145911. * Not supported by GPUParticleSystem
  145912. * Gets or sets a boolean indicating that ramp gradients must be used
  145913. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  145914. */
  145915. get useRampGradients(): boolean;
  145916. set useRampGradients(value: boolean);
  145917. /**
  145918. * Not supported by GPUParticleSystem
  145919. * @param gradient defines the gradient to use (between 0 and 1)
  145920. * @param factor defines the life time factor to affect to the specified gradient
  145921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  145922. * @returns the current particle system
  145923. */
  145924. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  145925. /**
  145926. * Not supported by GPUParticleSystem
  145927. * @param gradient defines the gradient to remove
  145928. * @returns the current particle system
  145929. */
  145930. removeLifeTimeGradient(gradient: number): IParticleSystem;
  145931. /**
  145932. * Instantiates a GPU particle system.
  145933. * 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.
  145934. * @param name The name of the particle system
  145935. * @param options The options used to create the system
  145936. * @param scene The scene the particle system belongs to
  145937. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  145938. * @param customEffect a custom effect used to change the way particles are rendered by default
  145939. */
  145940. constructor(name: string, options: Partial<{
  145941. capacity: number;
  145942. randomTextureSize: number;
  145943. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  145944. protected _reset(): void;
  145945. private _createUpdateVAO;
  145946. private _createRenderVAO;
  145947. private _initialize;
  145948. /** @hidden */
  145949. _recreateUpdateEffect(): void;
  145950. private _getEffect;
  145951. /**
  145952. * Fill the defines array according to the current settings of the particle system
  145953. * @param defines Array to be updated
  145954. * @param blendMode blend mode to take into account when updating the array
  145955. */
  145956. fillDefines(defines: Array<string>, blendMode?: number): void;
  145957. /**
  145958. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  145959. * @param uniforms Uniforms array to fill
  145960. * @param attributes Attributes array to fill
  145961. * @param samplers Samplers array to fill
  145962. */
  145963. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  145964. /** @hidden */
  145965. _recreateRenderEffect(): Effect;
  145966. /**
  145967. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  145968. * @param preWarm defines if we are in the pre-warmimg phase
  145969. */
  145970. animate(preWarm?: boolean): void;
  145971. private _createFactorGradientTexture;
  145972. private _createSizeGradientTexture;
  145973. private _createAngularSpeedGradientTexture;
  145974. private _createVelocityGradientTexture;
  145975. private _createLimitVelocityGradientTexture;
  145976. private _createDragGradientTexture;
  145977. private _createColorGradientTexture;
  145978. /**
  145979. * Renders the particle system in its current state
  145980. * @param preWarm defines if the system should only update the particles but not render them
  145981. * @returns the current number of particles
  145982. */
  145983. render(preWarm?: boolean): number;
  145984. /**
  145985. * Rebuilds the particle system
  145986. */
  145987. rebuild(): void;
  145988. private _releaseBuffers;
  145989. private _releaseVAOs;
  145990. /**
  145991. * Disposes the particle system and free the associated resources
  145992. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  145993. */
  145994. dispose(disposeTexture?: boolean): void;
  145995. /**
  145996. * Clones the particle system.
  145997. * @param name The name of the cloned object
  145998. * @param newEmitter The new emitter to use
  145999. * @returns the cloned particle system
  146000. */
  146001. clone(name: string, newEmitter: any): GPUParticleSystem;
  146002. /**
  146003. * Serializes the particle system to a JSON object
  146004. * @param serializeTexture defines if the texture must be serialized as well
  146005. * @returns the JSON object
  146006. */
  146007. serialize(serializeTexture?: boolean): any;
  146008. /**
  146009. * Parses a JSON object to create a GPU particle system.
  146010. * @param parsedParticleSystem The JSON object to parse
  146011. * @param scene The scene to create the particle system in
  146012. * @param rootUrl The root url to use to load external dependencies like texture
  146013. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  146014. * @returns the parsed GPU particle system
  146015. */
  146016. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  146017. }
  146018. }
  146019. declare module BABYLON {
  146020. /**
  146021. * Represents a set of particle systems working together to create a specific effect
  146022. */
  146023. export class ParticleSystemSet implements IDisposable {
  146024. /**
  146025. * Gets or sets base Assets URL
  146026. */
  146027. static BaseAssetsUrl: string;
  146028. private _emitterCreationOptions;
  146029. private _emitterNode;
  146030. /**
  146031. * Gets the particle system list
  146032. */
  146033. systems: IParticleSystem[];
  146034. /**
  146035. * Gets the emitter node used with this set
  146036. */
  146037. get emitterNode(): Nullable<TransformNode>;
  146038. /**
  146039. * Creates a new emitter mesh as a sphere
  146040. * @param options defines the options used to create the sphere
  146041. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  146042. * @param scene defines the hosting scene
  146043. */
  146044. setEmitterAsSphere(options: {
  146045. diameter: number;
  146046. segments: number;
  146047. color: Color3;
  146048. }, renderingGroupId: number, scene: Scene): void;
  146049. /**
  146050. * Starts all particle systems of the set
  146051. * @param emitter defines an optional mesh to use as emitter for the particle systems
  146052. */
  146053. start(emitter?: AbstractMesh): void;
  146054. /**
  146055. * Release all associated resources
  146056. */
  146057. dispose(): void;
  146058. /**
  146059. * Serialize the set into a JSON compatible object
  146060. * @param serializeTexture defines if the texture must be serialized as well
  146061. * @returns a JSON compatible representation of the set
  146062. */
  146063. serialize(serializeTexture?: boolean): any;
  146064. /**
  146065. * Parse a new ParticleSystemSet from a serialized source
  146066. * @param data defines a JSON compatible representation of the set
  146067. * @param scene defines the hosting scene
  146068. * @param gpu defines if we want GPU particles or CPU particles
  146069. * @returns a new ParticleSystemSet
  146070. */
  146071. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  146072. }
  146073. }
  146074. declare module BABYLON {
  146075. /**
  146076. * This class is made for on one-liner static method to help creating particle system set.
  146077. */
  146078. export class ParticleHelper {
  146079. /**
  146080. * Gets or sets base Assets URL
  146081. */
  146082. static BaseAssetsUrl: string;
  146083. /** Define the Url to load snippets */
  146084. static SnippetUrl: string;
  146085. /**
  146086. * Create a default particle system that you can tweak
  146087. * @param emitter defines the emitter to use
  146088. * @param capacity defines the system capacity (default is 500 particles)
  146089. * @param scene defines the hosting scene
  146090. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  146091. * @returns the new Particle system
  146092. */
  146093. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  146094. /**
  146095. * This is the main static method (one-liner) of this helper to create different particle systems
  146096. * @param type This string represents the type to the particle system to create
  146097. * @param scene The scene where the particle system should live
  146098. * @param gpu If the system will use gpu
  146099. * @returns the ParticleSystemSet created
  146100. */
  146101. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  146102. /**
  146103. * Static function used to export a particle system to a ParticleSystemSet variable.
  146104. * Please note that the emitter shape is not exported
  146105. * @param systems defines the particle systems to export
  146106. * @returns the created particle system set
  146107. */
  146108. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  146109. /**
  146110. * Creates a particle system from a snippet saved in a remote file
  146111. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  146112. * @param url defines the url to load from
  146113. * @param scene defines the hosting scene
  146114. * @param gpu If the system will use gpu
  146115. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  146116. * @returns a promise that will resolve to the new particle system
  146117. */
  146118. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  146119. /**
  146120. * Creates a particle system from a snippet saved by the particle system editor
  146121. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  146122. * @param scene defines the hosting scene
  146123. * @param gpu If the system will use gpu
  146124. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  146125. * @returns a promise that will resolve to the new particle system
  146126. */
  146127. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  146128. }
  146129. }
  146130. declare module BABYLON {
  146131. interface Engine {
  146132. /**
  146133. * Create an effect to use with particle systems.
  146134. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  146135. * the particle system for which you want to create a custom effect in the last parameter
  146136. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  146137. * @param uniformsNames defines a list of attribute names
  146138. * @param samplers defines an array of string used to represent textures
  146139. * @param defines defines the string containing the defines to use to compile the shaders
  146140. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  146141. * @param onCompiled defines a function to call when the effect creation is successful
  146142. * @param onError defines a function to call when the effect creation has failed
  146143. * @param particleSystem the particle system you want to create the effect for
  146144. * @returns the new Effect
  146145. */
  146146. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  146147. }
  146148. interface Mesh {
  146149. /**
  146150. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  146151. * @returns an array of IParticleSystem
  146152. */
  146153. getEmittedParticleSystems(): IParticleSystem[];
  146154. /**
  146155. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  146156. * @returns an array of IParticleSystem
  146157. */
  146158. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  146159. }
  146160. }
  146161. declare module BABYLON {
  146162. /** Defines the 4 color options */
  146163. export enum PointColor {
  146164. /** color value */
  146165. Color = 2,
  146166. /** uv value */
  146167. UV = 1,
  146168. /** random value */
  146169. Random = 0,
  146170. /** stated value */
  146171. Stated = 3
  146172. }
  146173. /**
  146174. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  146175. * 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.
  146176. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  146177. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  146178. *
  146179. * Full documentation here : TO BE ENTERED
  146180. */
  146181. export class PointsCloudSystem implements IDisposable {
  146182. /**
  146183. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  146184. * Example : var p = SPS.particles[i];
  146185. */
  146186. particles: CloudPoint[];
  146187. /**
  146188. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  146189. */
  146190. nbParticles: number;
  146191. /**
  146192. * This a counter for your own usage. It's not set by any SPS functions.
  146193. */
  146194. counter: number;
  146195. /**
  146196. * The PCS name. This name is also given to the underlying mesh.
  146197. */
  146198. name: string;
  146199. /**
  146200. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  146201. */
  146202. mesh: Mesh;
  146203. /**
  146204. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  146205. * Please read :
  146206. */
  146207. vars: any;
  146208. /**
  146209. * @hidden
  146210. */
  146211. _size: number;
  146212. private _scene;
  146213. private _promises;
  146214. private _positions;
  146215. private _indices;
  146216. private _normals;
  146217. private _colors;
  146218. private _uvs;
  146219. private _indices32;
  146220. private _positions32;
  146221. private _colors32;
  146222. private _uvs32;
  146223. private _updatable;
  146224. private _isVisibilityBoxLocked;
  146225. private _alwaysVisible;
  146226. private _groups;
  146227. private _groupCounter;
  146228. private _computeParticleColor;
  146229. private _computeParticleTexture;
  146230. private _computeParticleRotation;
  146231. private _computeBoundingBox;
  146232. private _isReady;
  146233. /**
  146234. * Creates a PCS (Points Cloud System) object
  146235. * @param name (String) is the PCS name, this will be the underlying mesh name
  146236. * @param pointSize (number) is the size for each point
  146237. * @param scene (Scene) is the scene in which the PCS is added
  146238. * @param options defines the options of the PCS e.g.
  146239. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  146240. */
  146241. constructor(name: string, pointSize: number, scene: Scene, options?: {
  146242. updatable?: boolean;
  146243. });
  146244. /**
  146245. * Builds the PCS underlying mesh. Returns a standard Mesh.
  146246. * If no points were added to the PCS, the returned mesh is just a single point.
  146247. * @returns a promise for the created mesh
  146248. */
  146249. buildMeshAsync(): Promise<Mesh>;
  146250. /**
  146251. * @hidden
  146252. */
  146253. private _buildMesh;
  146254. private _addParticle;
  146255. private _randomUnitVector;
  146256. private _getColorIndicesForCoord;
  146257. private _setPointsColorOrUV;
  146258. private _colorFromTexture;
  146259. private _calculateDensity;
  146260. /**
  146261. * Adds points to the PCS in random positions within a unit sphere
  146262. * @param nb (positive integer) the number of particles to be created from this model
  146263. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  146264. * @returns the number of groups in the system
  146265. */
  146266. addPoints(nb: number, pointFunction?: any): number;
  146267. /**
  146268. * Adds points to the PCS from the surface of the model shape
  146269. * @param mesh is any Mesh object that will be used as a surface model for the points
  146270. * @param nb (positive integer) the number of particles to be created from this model
  146271. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  146272. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  146273. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  146274. * @returns the number of groups in the system
  146275. */
  146276. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  146277. /**
  146278. * Adds points to the PCS inside the model shape
  146279. * @param mesh is any Mesh object that will be used as a surface model for the points
  146280. * @param nb (positive integer) the number of particles to be created from this model
  146281. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  146282. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  146283. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  146284. * @returns the number of groups in the system
  146285. */
  146286. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  146287. /**
  146288. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  146289. * This method calls `updateParticle()` for each particle of the SPS.
  146290. * For an animated SPS, it is usually called within the render loop.
  146291. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  146292. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  146293. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  146294. * @returns the PCS.
  146295. */
  146296. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  146297. /**
  146298. * Disposes the PCS.
  146299. */
  146300. dispose(): void;
  146301. /**
  146302. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  146303. * doc :
  146304. * @returns the PCS.
  146305. */
  146306. refreshVisibleSize(): PointsCloudSystem;
  146307. /**
  146308. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  146309. * @param size the size (float) of the visibility box
  146310. * note : this doesn't lock the PCS mesh bounding box.
  146311. * doc :
  146312. */
  146313. setVisibilityBox(size: number): void;
  146314. /**
  146315. * Gets whether the PCS is always visible or not
  146316. * doc :
  146317. */
  146318. get isAlwaysVisible(): boolean;
  146319. /**
  146320. * Sets the PCS as always visible or not
  146321. * doc :
  146322. */
  146323. set isAlwaysVisible(val: boolean);
  146324. /**
  146325. * Tells to `setParticles()` to compute the particle rotations or not
  146326. * Default value : false. The PCS is faster when it's set to false
  146327. * Note : particle rotations are only applied to parent particles
  146328. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  146329. */
  146330. set computeParticleRotation(val: boolean);
  146331. /**
  146332. * Tells to `setParticles()` to compute the particle colors or not.
  146333. * Default value : true. The PCS is faster when it's set to false.
  146334. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  146335. */
  146336. set computeParticleColor(val: boolean);
  146337. set computeParticleTexture(val: boolean);
  146338. /**
  146339. * Gets if `setParticles()` computes the particle colors or not.
  146340. * Default value : false. The PCS is faster when it's set to false.
  146341. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  146342. */
  146343. get computeParticleColor(): boolean;
  146344. /**
  146345. * Gets if `setParticles()` computes the particle textures or not.
  146346. * Default value : false. The PCS is faster when it's set to false.
  146347. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  146348. */
  146349. get computeParticleTexture(): boolean;
  146350. /**
  146351. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  146352. */
  146353. set computeBoundingBox(val: boolean);
  146354. /**
  146355. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  146356. */
  146357. get computeBoundingBox(): boolean;
  146358. /**
  146359. * This function does nothing. It may be overwritten to set all the particle first values.
  146360. * The PCS doesn't call this function, you may have to call it by your own.
  146361. * doc :
  146362. */
  146363. initParticles(): void;
  146364. /**
  146365. * This function does nothing. It may be overwritten to recycle a particle
  146366. * The PCS doesn't call this function, you can to call it
  146367. * doc :
  146368. * @param particle The particle to recycle
  146369. * @returns the recycled particle
  146370. */
  146371. recycleParticle(particle: CloudPoint): CloudPoint;
  146372. /**
  146373. * Updates a particle : this function should be overwritten by the user.
  146374. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  146375. * doc :
  146376. * @example : just set a particle position or velocity and recycle conditions
  146377. * @param particle The particle to update
  146378. * @returns the updated particle
  146379. */
  146380. updateParticle(particle: CloudPoint): CloudPoint;
  146381. /**
  146382. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  146383. * This does nothing and may be overwritten by the user.
  146384. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  146385. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  146386. * @param update the boolean update value actually passed to setParticles()
  146387. */
  146388. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  146389. /**
  146390. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  146391. * This will be passed three parameters.
  146392. * This does nothing and may be overwritten by the user.
  146393. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  146394. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  146395. * @param update the boolean update value actually passed to setParticles()
  146396. */
  146397. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  146398. }
  146399. }
  146400. declare module BABYLON {
  146401. /**
  146402. * Represents one particle of a points cloud system.
  146403. */
  146404. export class CloudPoint {
  146405. /**
  146406. * particle global index
  146407. */
  146408. idx: number;
  146409. /**
  146410. * The color of the particle
  146411. */
  146412. color: Nullable<Color4>;
  146413. /**
  146414. * The world space position of the particle.
  146415. */
  146416. position: Vector3;
  146417. /**
  146418. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  146419. */
  146420. rotation: Vector3;
  146421. /**
  146422. * The world space rotation quaternion of the particle.
  146423. */
  146424. rotationQuaternion: Nullable<Quaternion>;
  146425. /**
  146426. * The uv of the particle.
  146427. */
  146428. uv: Nullable<Vector2>;
  146429. /**
  146430. * The current speed of the particle.
  146431. */
  146432. velocity: Vector3;
  146433. /**
  146434. * The pivot point in the particle local space.
  146435. */
  146436. pivot: Vector3;
  146437. /**
  146438. * Must the particle be translated from its pivot point in its local space ?
  146439. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  146440. * Default : false
  146441. */
  146442. translateFromPivot: boolean;
  146443. /**
  146444. * Index of this particle in the global "positions" array (Internal use)
  146445. * @hidden
  146446. */
  146447. _pos: number;
  146448. /**
  146449. * @hidden Index of this particle in the global "indices" array (Internal use)
  146450. */
  146451. _ind: number;
  146452. /**
  146453. * Group this particle belongs to
  146454. */
  146455. _group: PointsGroup;
  146456. /**
  146457. * Group id of this particle
  146458. */
  146459. groupId: number;
  146460. /**
  146461. * Index of the particle in its group id (Internal use)
  146462. */
  146463. idxInGroup: number;
  146464. /**
  146465. * @hidden Particle BoundingInfo object (Internal use)
  146466. */
  146467. _boundingInfo: BoundingInfo;
  146468. /**
  146469. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  146470. */
  146471. _pcs: PointsCloudSystem;
  146472. /**
  146473. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  146474. */
  146475. _stillInvisible: boolean;
  146476. /**
  146477. * @hidden Last computed particle rotation matrix
  146478. */
  146479. _rotationMatrix: number[];
  146480. /**
  146481. * Parent particle Id, if any.
  146482. * Default null.
  146483. */
  146484. parentId: Nullable<number>;
  146485. /**
  146486. * @hidden Internal global position in the PCS.
  146487. */
  146488. _globalPosition: Vector3;
  146489. /**
  146490. * Creates a Point Cloud object.
  146491. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  146492. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  146493. * @param group (PointsGroup) is the group the particle belongs to
  146494. * @param groupId (integer) is the group identifier in the PCS.
  146495. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  146496. * @param pcs defines the PCS it is associated to
  146497. */
  146498. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  146499. /**
  146500. * get point size
  146501. */
  146502. get size(): Vector3;
  146503. /**
  146504. * Set point size
  146505. */
  146506. set size(scale: Vector3);
  146507. /**
  146508. * Legacy support, changed quaternion to rotationQuaternion
  146509. */
  146510. get quaternion(): Nullable<Quaternion>;
  146511. /**
  146512. * Legacy support, changed quaternion to rotationQuaternion
  146513. */
  146514. set quaternion(q: Nullable<Quaternion>);
  146515. /**
  146516. * Returns a boolean. True if the particle intersects a mesh, else false
  146517. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  146518. * @param target is the object (point or mesh) what the intersection is computed against
  146519. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  146520. * @returns true if it intersects
  146521. */
  146522. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  146523. /**
  146524. * get the rotation matrix of the particle
  146525. * @hidden
  146526. */
  146527. getRotationMatrix(m: Matrix): void;
  146528. }
  146529. /**
  146530. * Represents a group of points in a points cloud system
  146531. * * PCS internal tool, don't use it manually.
  146532. */
  146533. export class PointsGroup {
  146534. /**
  146535. * The group id
  146536. * @hidden
  146537. */
  146538. groupID: number;
  146539. /**
  146540. * image data for group (internal use)
  146541. * @hidden
  146542. */
  146543. _groupImageData: Nullable<ArrayBufferView>;
  146544. /**
  146545. * Image Width (internal use)
  146546. * @hidden
  146547. */
  146548. _groupImgWidth: number;
  146549. /**
  146550. * Image Height (internal use)
  146551. * @hidden
  146552. */
  146553. _groupImgHeight: number;
  146554. /**
  146555. * Custom position function (internal use)
  146556. * @hidden
  146557. */
  146558. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  146559. /**
  146560. * density per facet for surface points
  146561. * @hidden
  146562. */
  146563. _groupDensity: number[];
  146564. /**
  146565. * Only when points are colored by texture carries pointer to texture list array
  146566. * @hidden
  146567. */
  146568. _textureNb: number;
  146569. /**
  146570. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  146571. * PCS internal tool, don't use it manually.
  146572. * @hidden
  146573. */
  146574. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  146575. }
  146576. }
  146577. declare module BABYLON {
  146578. interface Scene {
  146579. /** @hidden (Backing field) */
  146580. _physicsEngine: Nullable<IPhysicsEngine>;
  146581. /** @hidden */
  146582. _physicsTimeAccumulator: number;
  146583. /**
  146584. * Gets the current physics engine
  146585. * @returns a IPhysicsEngine or null if none attached
  146586. */
  146587. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  146588. /**
  146589. * Enables physics to the current scene
  146590. * @param gravity defines the scene's gravity for the physics engine
  146591. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  146592. * @return a boolean indicating if the physics engine was initialized
  146593. */
  146594. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  146595. /**
  146596. * Disables and disposes the physics engine associated with the scene
  146597. */
  146598. disablePhysicsEngine(): void;
  146599. /**
  146600. * Gets a boolean indicating if there is an active physics engine
  146601. * @returns a boolean indicating if there is an active physics engine
  146602. */
  146603. isPhysicsEnabled(): boolean;
  146604. /**
  146605. * Deletes a physics compound impostor
  146606. * @param compound defines the compound to delete
  146607. */
  146608. deleteCompoundImpostor(compound: any): void;
  146609. /**
  146610. * An event triggered when physic simulation is about to be run
  146611. */
  146612. onBeforePhysicsObservable: Observable<Scene>;
  146613. /**
  146614. * An event triggered when physic simulation has been done
  146615. */
  146616. onAfterPhysicsObservable: Observable<Scene>;
  146617. }
  146618. interface AbstractMesh {
  146619. /** @hidden */
  146620. _physicsImpostor: Nullable<PhysicsImpostor>;
  146621. /**
  146622. * Gets or sets impostor used for physic simulation
  146623. * @see https://doc.babylonjs.com/features/physics_engine
  146624. */
  146625. physicsImpostor: Nullable<PhysicsImpostor>;
  146626. /**
  146627. * Gets the current physics impostor
  146628. * @see https://doc.babylonjs.com/features/physics_engine
  146629. * @returns a physics impostor or null
  146630. */
  146631. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  146632. /** Apply a physic impulse to the mesh
  146633. * @param force defines the force to apply
  146634. * @param contactPoint defines where to apply the force
  146635. * @returns the current mesh
  146636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  146637. */
  146638. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  146639. /**
  146640. * Creates a physic joint between two meshes
  146641. * @param otherMesh defines the other mesh to use
  146642. * @param pivot1 defines the pivot to use on this mesh
  146643. * @param pivot2 defines the pivot to use on the other mesh
  146644. * @param options defines additional options (can be plugin dependent)
  146645. * @returns the current mesh
  146646. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  146647. */
  146648. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  146649. /** @hidden */
  146650. _disposePhysicsObserver: Nullable<Observer<Node>>;
  146651. }
  146652. /**
  146653. * Defines the physics engine scene component responsible to manage a physics engine
  146654. */
  146655. export class PhysicsEngineSceneComponent implements ISceneComponent {
  146656. /**
  146657. * The component name helpful to identify the component in the list of scene components.
  146658. */
  146659. readonly name: string;
  146660. /**
  146661. * The scene the component belongs to.
  146662. */
  146663. scene: Scene;
  146664. /**
  146665. * Creates a new instance of the component for the given scene
  146666. * @param scene Defines the scene to register the component in
  146667. */
  146668. constructor(scene: Scene);
  146669. /**
  146670. * Registers the component in a given scene
  146671. */
  146672. register(): void;
  146673. /**
  146674. * Rebuilds the elements related to this component in case of
  146675. * context lost for instance.
  146676. */
  146677. rebuild(): void;
  146678. /**
  146679. * Disposes the component and the associated ressources
  146680. */
  146681. dispose(): void;
  146682. }
  146683. }
  146684. declare module BABYLON {
  146685. /**
  146686. * A helper for physics simulations
  146687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146688. */
  146689. export class PhysicsHelper {
  146690. private _scene;
  146691. private _physicsEngine;
  146692. /**
  146693. * Initializes the Physics helper
  146694. * @param scene Babylon.js scene
  146695. */
  146696. constructor(scene: Scene);
  146697. /**
  146698. * Applies a radial explosion impulse
  146699. * @param origin the origin of the explosion
  146700. * @param radiusOrEventOptions the radius or the options of radial explosion
  146701. * @param strength the explosion strength
  146702. * @param falloff possible options: Constant & Linear. Defaults to Constant
  146703. * @returns A physics radial explosion event, or null
  146704. */
  146705. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  146706. /**
  146707. * Applies a radial explosion force
  146708. * @param origin the origin of the explosion
  146709. * @param radiusOrEventOptions the radius or the options of radial explosion
  146710. * @param strength the explosion strength
  146711. * @param falloff possible options: Constant & Linear. Defaults to Constant
  146712. * @returns A physics radial explosion event, or null
  146713. */
  146714. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  146715. /**
  146716. * Creates a gravitational field
  146717. * @param origin the origin of the explosion
  146718. * @param radiusOrEventOptions the radius or the options of radial explosion
  146719. * @param strength the explosion strength
  146720. * @param falloff possible options: Constant & Linear. Defaults to Constant
  146721. * @returns A physics gravitational field event, or null
  146722. */
  146723. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  146724. /**
  146725. * Creates a physics updraft event
  146726. * @param origin the origin of the updraft
  146727. * @param radiusOrEventOptions the radius or the options of the updraft
  146728. * @param strength the strength of the updraft
  146729. * @param height the height of the updraft
  146730. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  146731. * @returns A physics updraft event, or null
  146732. */
  146733. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  146734. /**
  146735. * Creates a physics vortex event
  146736. * @param origin the of the vortex
  146737. * @param radiusOrEventOptions the radius or the options of the vortex
  146738. * @param strength the strength of the vortex
  146739. * @param height the height of the vortex
  146740. * @returns a Physics vortex event, or null
  146741. * A physics vortex event or null
  146742. */
  146743. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  146744. }
  146745. /**
  146746. * Represents a physics radial explosion event
  146747. */
  146748. class PhysicsRadialExplosionEvent {
  146749. private _scene;
  146750. private _options;
  146751. private _sphere;
  146752. private _dataFetched;
  146753. /**
  146754. * Initializes a radial explosioin event
  146755. * @param _scene BabylonJS scene
  146756. * @param _options The options for the vortex event
  146757. */
  146758. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  146759. /**
  146760. * Returns the data related to the radial explosion event (sphere).
  146761. * @returns The radial explosion event data
  146762. */
  146763. getData(): PhysicsRadialExplosionEventData;
  146764. /**
  146765. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  146766. * @param impostor A physics imposter
  146767. * @param origin the origin of the explosion
  146768. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  146769. */
  146770. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  146771. /**
  146772. * Triggers affecterd impostors callbacks
  146773. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  146774. */
  146775. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  146776. /**
  146777. * Disposes the sphere.
  146778. * @param force Specifies if the sphere should be disposed by force
  146779. */
  146780. dispose(force?: boolean): void;
  146781. /*** Helpers ***/
  146782. private _prepareSphere;
  146783. private _intersectsWithSphere;
  146784. }
  146785. /**
  146786. * Represents a gravitational field event
  146787. */
  146788. class PhysicsGravitationalFieldEvent {
  146789. private _physicsHelper;
  146790. private _scene;
  146791. private _origin;
  146792. private _options;
  146793. private _tickCallback;
  146794. private _sphere;
  146795. private _dataFetched;
  146796. /**
  146797. * Initializes the physics gravitational field event
  146798. * @param _physicsHelper A physics helper
  146799. * @param _scene BabylonJS scene
  146800. * @param _origin The origin position of the gravitational field event
  146801. * @param _options The options for the vortex event
  146802. */
  146803. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  146804. /**
  146805. * Returns the data related to the gravitational field event (sphere).
  146806. * @returns A gravitational field event
  146807. */
  146808. getData(): PhysicsGravitationalFieldEventData;
  146809. /**
  146810. * Enables the gravitational field.
  146811. */
  146812. enable(): void;
  146813. /**
  146814. * Disables the gravitational field.
  146815. */
  146816. disable(): void;
  146817. /**
  146818. * Disposes the sphere.
  146819. * @param force The force to dispose from the gravitational field event
  146820. */
  146821. dispose(force?: boolean): void;
  146822. private _tick;
  146823. }
  146824. /**
  146825. * Represents a physics updraft event
  146826. */
  146827. class PhysicsUpdraftEvent {
  146828. private _scene;
  146829. private _origin;
  146830. private _options;
  146831. private _physicsEngine;
  146832. private _originTop;
  146833. private _originDirection;
  146834. private _tickCallback;
  146835. private _cylinder;
  146836. private _cylinderPosition;
  146837. private _dataFetched;
  146838. /**
  146839. * Initializes the physics updraft event
  146840. * @param _scene BabylonJS scene
  146841. * @param _origin The origin position of the updraft
  146842. * @param _options The options for the updraft event
  146843. */
  146844. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  146845. /**
  146846. * Returns the data related to the updraft event (cylinder).
  146847. * @returns A physics updraft event
  146848. */
  146849. getData(): PhysicsUpdraftEventData;
  146850. /**
  146851. * Enables the updraft.
  146852. */
  146853. enable(): void;
  146854. /**
  146855. * Disables the updraft.
  146856. */
  146857. disable(): void;
  146858. /**
  146859. * Disposes the cylinder.
  146860. * @param force Specifies if the updraft should be disposed by force
  146861. */
  146862. dispose(force?: boolean): void;
  146863. private getImpostorHitData;
  146864. private _tick;
  146865. /*** Helpers ***/
  146866. private _prepareCylinder;
  146867. private _intersectsWithCylinder;
  146868. }
  146869. /**
  146870. * Represents a physics vortex event
  146871. */
  146872. class PhysicsVortexEvent {
  146873. private _scene;
  146874. private _origin;
  146875. private _options;
  146876. private _physicsEngine;
  146877. private _originTop;
  146878. private _tickCallback;
  146879. private _cylinder;
  146880. private _cylinderPosition;
  146881. private _dataFetched;
  146882. /**
  146883. * Initializes the physics vortex event
  146884. * @param _scene The BabylonJS scene
  146885. * @param _origin The origin position of the vortex
  146886. * @param _options The options for the vortex event
  146887. */
  146888. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  146889. /**
  146890. * Returns the data related to the vortex event (cylinder).
  146891. * @returns The physics vortex event data
  146892. */
  146893. getData(): PhysicsVortexEventData;
  146894. /**
  146895. * Enables the vortex.
  146896. */
  146897. enable(): void;
  146898. /**
  146899. * Disables the cortex.
  146900. */
  146901. disable(): void;
  146902. /**
  146903. * Disposes the sphere.
  146904. * @param force
  146905. */
  146906. dispose(force?: boolean): void;
  146907. private getImpostorHitData;
  146908. private _tick;
  146909. /*** Helpers ***/
  146910. private _prepareCylinder;
  146911. private _intersectsWithCylinder;
  146912. }
  146913. /**
  146914. * Options fot the radial explosion event
  146915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146916. */
  146917. export class PhysicsRadialExplosionEventOptions {
  146918. /**
  146919. * The radius of the sphere for the radial explosion.
  146920. */
  146921. radius: number;
  146922. /**
  146923. * The strenth of the explosion.
  146924. */
  146925. strength: number;
  146926. /**
  146927. * The strenght of the force in correspondence to the distance of the affected object
  146928. */
  146929. falloff: PhysicsRadialImpulseFalloff;
  146930. /**
  146931. * Sphere options for the radial explosion.
  146932. */
  146933. sphere: {
  146934. segments: number;
  146935. diameter: number;
  146936. };
  146937. /**
  146938. * Sphere options for the radial explosion.
  146939. */
  146940. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  146941. }
  146942. /**
  146943. * Options fot the updraft event
  146944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146945. */
  146946. export class PhysicsUpdraftEventOptions {
  146947. /**
  146948. * The radius of the cylinder for the vortex
  146949. */
  146950. radius: number;
  146951. /**
  146952. * The strenth of the updraft.
  146953. */
  146954. strength: number;
  146955. /**
  146956. * The height of the cylinder for the updraft.
  146957. */
  146958. height: number;
  146959. /**
  146960. * The mode for the the updraft.
  146961. */
  146962. updraftMode: PhysicsUpdraftMode;
  146963. }
  146964. /**
  146965. * Options fot the vortex event
  146966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146967. */
  146968. export class PhysicsVortexEventOptions {
  146969. /**
  146970. * The radius of the cylinder for the vortex
  146971. */
  146972. radius: number;
  146973. /**
  146974. * The strenth of the vortex.
  146975. */
  146976. strength: number;
  146977. /**
  146978. * The height of the cylinder for the vortex.
  146979. */
  146980. height: number;
  146981. /**
  146982. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  146983. */
  146984. centripetalForceThreshold: number;
  146985. /**
  146986. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  146987. */
  146988. centripetalForceMultiplier: number;
  146989. /**
  146990. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  146991. */
  146992. centrifugalForceMultiplier: number;
  146993. /**
  146994. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  146995. */
  146996. updraftForceMultiplier: number;
  146997. }
  146998. /**
  146999. * The strenght of the force in correspondence to the distance of the affected object
  147000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147001. */
  147002. export enum PhysicsRadialImpulseFalloff {
  147003. /** Defines that impulse is constant in strength across it's whole radius */
  147004. Constant = 0,
  147005. /** Defines that impulse gets weaker if it's further from the origin */
  147006. Linear = 1
  147007. }
  147008. /**
  147009. * The strength of the force in correspondence to the distance of the affected object
  147010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147011. */
  147012. export enum PhysicsUpdraftMode {
  147013. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  147014. Center = 0,
  147015. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  147016. Perpendicular = 1
  147017. }
  147018. /**
  147019. * Interface for a physics hit data
  147020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147021. */
  147022. export interface PhysicsHitData {
  147023. /**
  147024. * The force applied at the contact point
  147025. */
  147026. force: Vector3;
  147027. /**
  147028. * The contact point
  147029. */
  147030. contactPoint: Vector3;
  147031. /**
  147032. * The distance from the origin to the contact point
  147033. */
  147034. distanceFromOrigin: number;
  147035. }
  147036. /**
  147037. * Interface for radial explosion event data
  147038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147039. */
  147040. export interface PhysicsRadialExplosionEventData {
  147041. /**
  147042. * A sphere used for the radial explosion event
  147043. */
  147044. sphere: Mesh;
  147045. }
  147046. /**
  147047. * Interface for gravitational field event data
  147048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147049. */
  147050. export interface PhysicsGravitationalFieldEventData {
  147051. /**
  147052. * A sphere mesh used for the gravitational field event
  147053. */
  147054. sphere: Mesh;
  147055. }
  147056. /**
  147057. * Interface for updraft event data
  147058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147059. */
  147060. export interface PhysicsUpdraftEventData {
  147061. /**
  147062. * A cylinder used for the updraft event
  147063. */
  147064. cylinder: Mesh;
  147065. }
  147066. /**
  147067. * Interface for vortex event data
  147068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147069. */
  147070. export interface PhysicsVortexEventData {
  147071. /**
  147072. * A cylinder used for the vortex event
  147073. */
  147074. cylinder: Mesh;
  147075. }
  147076. /**
  147077. * Interface for an affected physics impostor
  147078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147079. */
  147080. export interface PhysicsAffectedImpostorWithData {
  147081. /**
  147082. * The impostor affected by the effect
  147083. */
  147084. impostor: PhysicsImpostor;
  147085. /**
  147086. * The data about the hit/horce from the explosion
  147087. */
  147088. hitData: PhysicsHitData;
  147089. }
  147090. }
  147091. declare module BABYLON {
  147092. /** @hidden */
  147093. export var blackAndWhitePixelShader: {
  147094. name: string;
  147095. shader: string;
  147096. };
  147097. }
  147098. declare module BABYLON {
  147099. /**
  147100. * Post process used to render in black and white
  147101. */
  147102. export class BlackAndWhitePostProcess extends PostProcess {
  147103. /**
  147104. * Linear about to convert he result to black and white (default: 1)
  147105. */
  147106. degree: number;
  147107. /**
  147108. * Creates a black and white post process
  147109. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  147110. * @param name The name of the effect.
  147111. * @param options The required width/height ratio to downsize to before computing the render pass.
  147112. * @param camera The camera to apply the render pass to.
  147113. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147114. * @param engine The engine which the post process will be applied. (default: current engine)
  147115. * @param reusable If the post process can be reused on the same frame. (default: false)
  147116. */
  147117. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147118. }
  147119. }
  147120. declare module BABYLON {
  147121. /**
  147122. * This represents a set of one or more post processes in Babylon.
  147123. * A post process can be used to apply a shader to a texture after it is rendered.
  147124. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147125. */
  147126. export class PostProcessRenderEffect {
  147127. private _postProcesses;
  147128. private _getPostProcesses;
  147129. private _singleInstance;
  147130. private _cameras;
  147131. private _indicesForCamera;
  147132. /**
  147133. * Name of the effect
  147134. * @hidden
  147135. */
  147136. _name: string;
  147137. /**
  147138. * Instantiates a post process render effect.
  147139. * A post process can be used to apply a shader to a texture after it is rendered.
  147140. * @param engine The engine the effect is tied to
  147141. * @param name The name of the effect
  147142. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  147143. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  147144. */
  147145. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  147146. /**
  147147. * Checks if all the post processes in the effect are supported.
  147148. */
  147149. get isSupported(): boolean;
  147150. /**
  147151. * Updates the current state of the effect
  147152. * @hidden
  147153. */
  147154. _update(): void;
  147155. /**
  147156. * Attaches the effect on cameras
  147157. * @param cameras The camera to attach to.
  147158. * @hidden
  147159. */
  147160. _attachCameras(cameras: Camera): void;
  147161. /**
  147162. * Attaches the effect on cameras
  147163. * @param cameras The camera to attach to.
  147164. * @hidden
  147165. */
  147166. _attachCameras(cameras: Camera[]): void;
  147167. /**
  147168. * Detaches the effect on cameras
  147169. * @param cameras The camera to detatch from.
  147170. * @hidden
  147171. */
  147172. _detachCameras(cameras: Camera): void;
  147173. /**
  147174. * Detatches the effect on cameras
  147175. * @param cameras The camera to detatch from.
  147176. * @hidden
  147177. */
  147178. _detachCameras(cameras: Camera[]): void;
  147179. /**
  147180. * Enables the effect on given cameras
  147181. * @param cameras The camera to enable.
  147182. * @hidden
  147183. */
  147184. _enable(cameras: Camera): void;
  147185. /**
  147186. * Enables the effect on given cameras
  147187. * @param cameras The camera to enable.
  147188. * @hidden
  147189. */
  147190. _enable(cameras: Nullable<Camera[]>): void;
  147191. /**
  147192. * Disables the effect on the given cameras
  147193. * @param cameras The camera to disable.
  147194. * @hidden
  147195. */
  147196. _disable(cameras: Camera): void;
  147197. /**
  147198. * Disables the effect on the given cameras
  147199. * @param cameras The camera to disable.
  147200. * @hidden
  147201. */
  147202. _disable(cameras: Nullable<Camera[]>): void;
  147203. /**
  147204. * Gets a list of the post processes contained in the effect.
  147205. * @param camera The camera to get the post processes on.
  147206. * @returns The list of the post processes in the effect.
  147207. */
  147208. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  147209. }
  147210. }
  147211. declare module BABYLON {
  147212. /** @hidden */
  147213. export var extractHighlightsPixelShader: {
  147214. name: string;
  147215. shader: string;
  147216. };
  147217. }
  147218. declare module BABYLON {
  147219. /**
  147220. * 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.
  147221. */
  147222. export class ExtractHighlightsPostProcess extends PostProcess {
  147223. /**
  147224. * The luminance threshold, pixels below this value will be set to black.
  147225. */
  147226. threshold: number;
  147227. /** @hidden */
  147228. _exposure: number;
  147229. /**
  147230. * Post process which has the input texture to be used when performing highlight extraction
  147231. * @hidden
  147232. */
  147233. _inputPostProcess: Nullable<PostProcess>;
  147234. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147235. }
  147236. }
  147237. declare module BABYLON {
  147238. /** @hidden */
  147239. export var bloomMergePixelShader: {
  147240. name: string;
  147241. shader: string;
  147242. };
  147243. }
  147244. declare module BABYLON {
  147245. /**
  147246. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  147247. */
  147248. export class BloomMergePostProcess extends PostProcess {
  147249. /** Weight of the bloom to be added to the original input. */
  147250. weight: number;
  147251. /**
  147252. * Creates a new instance of @see BloomMergePostProcess
  147253. * @param name The name of the effect.
  147254. * @param originalFromInput Post process which's input will be used for the merge.
  147255. * @param blurred Blurred highlights post process which's output will be used.
  147256. * @param weight Weight of the bloom to be added to the original input.
  147257. * @param options The required width/height ratio to downsize to before computing the render pass.
  147258. * @param camera The camera to apply the render pass to.
  147259. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147260. * @param engine The engine which the post process will be applied. (default: current engine)
  147261. * @param reusable If the post process can be reused on the same frame. (default: false)
  147262. * @param textureType Type of textures used when performing the post process. (default: 0)
  147263. * @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)
  147264. */
  147265. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  147266. /** Weight of the bloom to be added to the original input. */
  147267. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147268. }
  147269. }
  147270. declare module BABYLON {
  147271. /**
  147272. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  147273. */
  147274. export class BloomEffect extends PostProcessRenderEffect {
  147275. private bloomScale;
  147276. /**
  147277. * @hidden Internal
  147278. */
  147279. _effects: Array<PostProcess>;
  147280. /**
  147281. * @hidden Internal
  147282. */
  147283. _downscale: ExtractHighlightsPostProcess;
  147284. private _blurX;
  147285. private _blurY;
  147286. private _merge;
  147287. /**
  147288. * The luminance threshold to find bright areas of the image to bloom.
  147289. */
  147290. get threshold(): number;
  147291. set threshold(value: number);
  147292. /**
  147293. * The strength of the bloom.
  147294. */
  147295. get weight(): number;
  147296. set weight(value: number);
  147297. /**
  147298. * Specifies the size of the bloom blur kernel, relative to the final output size
  147299. */
  147300. get kernel(): number;
  147301. set kernel(value: number);
  147302. /**
  147303. * Creates a new instance of @see BloomEffect
  147304. * @param scene The scene the effect belongs to.
  147305. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  147306. * @param bloomKernel The size of the kernel to be used when applying the blur.
  147307. * @param bloomWeight The the strength of bloom.
  147308. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  147309. * @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)
  147310. */
  147311. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  147312. /**
  147313. * Disposes each of the internal effects for a given camera.
  147314. * @param camera The camera to dispose the effect on.
  147315. */
  147316. disposeEffects(camera: Camera): void;
  147317. /**
  147318. * @hidden Internal
  147319. */
  147320. _updateEffects(): void;
  147321. /**
  147322. * Internal
  147323. * @returns if all the contained post processes are ready.
  147324. * @hidden
  147325. */
  147326. _isReady(): boolean;
  147327. }
  147328. }
  147329. declare module BABYLON {
  147330. /** @hidden */
  147331. export var chromaticAberrationPixelShader: {
  147332. name: string;
  147333. shader: string;
  147334. };
  147335. }
  147336. declare module BABYLON {
  147337. /**
  147338. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  147339. */
  147340. export class ChromaticAberrationPostProcess extends PostProcess {
  147341. /**
  147342. * The amount of seperation of rgb channels (default: 30)
  147343. */
  147344. aberrationAmount: number;
  147345. /**
  147346. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  147347. */
  147348. radialIntensity: number;
  147349. /**
  147350. * 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))
  147351. */
  147352. direction: Vector2;
  147353. /**
  147354. * 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))
  147355. */
  147356. centerPosition: Vector2;
  147357. /**
  147358. * Creates a new instance ChromaticAberrationPostProcess
  147359. * @param name The name of the effect.
  147360. * @param screenWidth The width of the screen to apply the effect on.
  147361. * @param screenHeight The height of the screen to apply the effect on.
  147362. * @param options The required width/height ratio to downsize to before computing the render pass.
  147363. * @param camera The camera to apply the render pass to.
  147364. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147365. * @param engine The engine which the post process will be applied. (default: current engine)
  147366. * @param reusable If the post process can be reused on the same frame. (default: false)
  147367. * @param textureType Type of textures used when performing the post process. (default: 0)
  147368. * @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)
  147369. */
  147370. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147371. }
  147372. }
  147373. declare module BABYLON {
  147374. /** @hidden */
  147375. export var circleOfConfusionPixelShader: {
  147376. name: string;
  147377. shader: string;
  147378. };
  147379. }
  147380. declare module BABYLON {
  147381. /**
  147382. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  147383. */
  147384. export class CircleOfConfusionPostProcess extends PostProcess {
  147385. /**
  147386. * 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.
  147387. */
  147388. lensSize: number;
  147389. /**
  147390. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  147391. */
  147392. fStop: number;
  147393. /**
  147394. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  147395. */
  147396. focusDistance: number;
  147397. /**
  147398. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  147399. */
  147400. focalLength: number;
  147401. private _depthTexture;
  147402. /**
  147403. * Creates a new instance CircleOfConfusionPostProcess
  147404. * @param name The name of the effect.
  147405. * @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.
  147406. * @param options The required width/height ratio to downsize to before computing the render pass.
  147407. * @param camera The camera to apply the render pass to.
  147408. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147409. * @param engine The engine which the post process will be applied. (default: current engine)
  147410. * @param reusable If the post process can be reused on the same frame. (default: false)
  147411. * @param textureType Type of textures used when performing the post process. (default: 0)
  147412. * @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)
  147413. */
  147414. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147415. /**
  147416. * 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.
  147417. */
  147418. set depthTexture(value: RenderTargetTexture);
  147419. }
  147420. }
  147421. declare module BABYLON {
  147422. /** @hidden */
  147423. export var colorCorrectionPixelShader: {
  147424. name: string;
  147425. shader: string;
  147426. };
  147427. }
  147428. declare module BABYLON {
  147429. /**
  147430. *
  147431. * This post-process allows the modification of rendered colors by using
  147432. * a 'look-up table' (LUT). This effect is also called Color Grading.
  147433. *
  147434. * The object needs to be provided an url to a texture containing the color
  147435. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  147436. * Use an image editing software to tweak the LUT to match your needs.
  147437. *
  147438. * For an example of a color LUT, see here:
  147439. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  147440. * For explanations on color grading, see here:
  147441. * @see http://udn.epicgames.com/Three/ColorGrading.html
  147442. *
  147443. */
  147444. export class ColorCorrectionPostProcess extends PostProcess {
  147445. private _colorTableTexture;
  147446. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147447. }
  147448. }
  147449. declare module BABYLON {
  147450. /** @hidden */
  147451. export var convolutionPixelShader: {
  147452. name: string;
  147453. shader: string;
  147454. };
  147455. }
  147456. declare module BABYLON {
  147457. /**
  147458. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  147459. * input texture to perform effects such as edge detection or sharpening
  147460. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  147461. */
  147462. export class ConvolutionPostProcess extends PostProcess {
  147463. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  147464. kernel: number[];
  147465. /**
  147466. * Creates a new instance ConvolutionPostProcess
  147467. * @param name The name of the effect.
  147468. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  147469. * @param options The required width/height ratio to downsize to before computing the render pass.
  147470. * @param camera The camera to apply the render pass to.
  147471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147472. * @param engine The engine which the post process will be applied. (default: current engine)
  147473. * @param reusable If the post process can be reused on the same frame. (default: false)
  147474. * @param textureType Type of textures used when performing the post process. (default: 0)
  147475. */
  147476. constructor(name: string,
  147477. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  147478. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  147479. /**
  147480. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147481. */
  147482. static EdgeDetect0Kernel: number[];
  147483. /**
  147484. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147485. */
  147486. static EdgeDetect1Kernel: number[];
  147487. /**
  147488. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147489. */
  147490. static EdgeDetect2Kernel: number[];
  147491. /**
  147492. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147493. */
  147494. static SharpenKernel: number[];
  147495. /**
  147496. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147497. */
  147498. static EmbossKernel: number[];
  147499. /**
  147500. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147501. */
  147502. static GaussianKernel: number[];
  147503. }
  147504. }
  147505. declare module BABYLON {
  147506. /**
  147507. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  147508. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  147509. * based on samples that have a large difference in distance than the center pixel.
  147510. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  147511. */
  147512. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  147513. direction: Vector2;
  147514. /**
  147515. * Creates a new instance CircleOfConfusionPostProcess
  147516. * @param name The name of the effect.
  147517. * @param scene The scene the effect belongs to.
  147518. * @param direction The direction the blur should be applied.
  147519. * @param kernel The size of the kernel used to blur.
  147520. * @param options The required width/height ratio to downsize to before computing the render pass.
  147521. * @param camera The camera to apply the render pass to.
  147522. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  147523. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  147524. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147525. * @param engine The engine which the post process will be applied. (default: current engine)
  147526. * @param reusable If the post process can be reused on the same frame. (default: false)
  147527. * @param textureType Type of textures used when performing the post process. (default: 0)
  147528. * @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)
  147529. */
  147530. 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);
  147531. }
  147532. }
  147533. declare module BABYLON {
  147534. /** @hidden */
  147535. export var depthOfFieldMergePixelShader: {
  147536. name: string;
  147537. shader: string;
  147538. };
  147539. }
  147540. declare module BABYLON {
  147541. /**
  147542. * Options to be set when merging outputs from the default pipeline.
  147543. */
  147544. export class DepthOfFieldMergePostProcessOptions {
  147545. /**
  147546. * The original image to merge on top of
  147547. */
  147548. originalFromInput: PostProcess;
  147549. /**
  147550. * Parameters to perform the merge of the depth of field effect
  147551. */
  147552. depthOfField?: {
  147553. circleOfConfusion: PostProcess;
  147554. blurSteps: Array<PostProcess>;
  147555. };
  147556. /**
  147557. * Parameters to perform the merge of bloom effect
  147558. */
  147559. bloom?: {
  147560. blurred: PostProcess;
  147561. weight: number;
  147562. };
  147563. }
  147564. /**
  147565. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  147566. */
  147567. export class DepthOfFieldMergePostProcess extends PostProcess {
  147568. private blurSteps;
  147569. /**
  147570. * Creates a new instance of DepthOfFieldMergePostProcess
  147571. * @param name The name of the effect.
  147572. * @param originalFromInput Post process which's input will be used for the merge.
  147573. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  147574. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  147575. * @param options The required width/height ratio to downsize to before computing the render pass.
  147576. * @param camera The camera to apply the render pass to.
  147577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147578. * @param engine The engine which the post process will be applied. (default: current engine)
  147579. * @param reusable If the post process can be reused on the same frame. (default: false)
  147580. * @param textureType Type of textures used when performing the post process. (default: 0)
  147581. * @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)
  147582. */
  147583. 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);
  147584. /**
  147585. * Updates the effect with the current post process compile time values and recompiles the shader.
  147586. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  147587. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  147588. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  147589. * @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
  147590. * @param onCompiled Called when the shader has been compiled.
  147591. * @param onError Called if there is an error when compiling a shader.
  147592. */
  147593. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  147594. }
  147595. }
  147596. declare module BABYLON {
  147597. /**
  147598. * Specifies the level of max blur that should be applied when using the depth of field effect
  147599. */
  147600. export enum DepthOfFieldEffectBlurLevel {
  147601. /**
  147602. * Subtle blur
  147603. */
  147604. Low = 0,
  147605. /**
  147606. * Medium blur
  147607. */
  147608. Medium = 1,
  147609. /**
  147610. * Large blur
  147611. */
  147612. High = 2
  147613. }
  147614. /**
  147615. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  147616. */
  147617. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  147618. private _circleOfConfusion;
  147619. /**
  147620. * @hidden Internal, blurs from high to low
  147621. */
  147622. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  147623. private _depthOfFieldBlurY;
  147624. private _dofMerge;
  147625. /**
  147626. * @hidden Internal post processes in depth of field effect
  147627. */
  147628. _effects: Array<PostProcess>;
  147629. /**
  147630. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  147631. */
  147632. set focalLength(value: number);
  147633. get focalLength(): number;
  147634. /**
  147635. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  147636. */
  147637. set fStop(value: number);
  147638. get fStop(): number;
  147639. /**
  147640. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  147641. */
  147642. set focusDistance(value: number);
  147643. get focusDistance(): number;
  147644. /**
  147645. * 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.
  147646. */
  147647. set lensSize(value: number);
  147648. get lensSize(): number;
  147649. /**
  147650. * Creates a new instance DepthOfFieldEffect
  147651. * @param scene The scene the effect belongs to.
  147652. * @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.
  147653. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  147654. * @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)
  147655. */
  147656. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  147657. /**
  147658. * Get the current class name of the current effet
  147659. * @returns "DepthOfFieldEffect"
  147660. */
  147661. getClassName(): string;
  147662. /**
  147663. * 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.
  147664. */
  147665. set depthTexture(value: RenderTargetTexture);
  147666. /**
  147667. * Disposes each of the internal effects for a given camera.
  147668. * @param camera The camera to dispose the effect on.
  147669. */
  147670. disposeEffects(camera: Camera): void;
  147671. /**
  147672. * @hidden Internal
  147673. */
  147674. _updateEffects(): void;
  147675. /**
  147676. * Internal
  147677. * @returns if all the contained post processes are ready.
  147678. * @hidden
  147679. */
  147680. _isReady(): boolean;
  147681. }
  147682. }
  147683. declare module BABYLON {
  147684. /** @hidden */
  147685. export var displayPassPixelShader: {
  147686. name: string;
  147687. shader: string;
  147688. };
  147689. }
  147690. declare module BABYLON {
  147691. /**
  147692. * DisplayPassPostProcess which produces an output the same as it's input
  147693. */
  147694. export class DisplayPassPostProcess extends PostProcess {
  147695. /**
  147696. * Creates the DisplayPassPostProcess
  147697. * @param name The name of the effect.
  147698. * @param options The required width/height ratio to downsize to before computing the render pass.
  147699. * @param camera The camera to apply the render pass to.
  147700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147701. * @param engine The engine which the post process will be applied. (default: current engine)
  147702. * @param reusable If the post process can be reused on the same frame. (default: false)
  147703. */
  147704. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147705. }
  147706. }
  147707. declare module BABYLON {
  147708. /** @hidden */
  147709. export var filterPixelShader: {
  147710. name: string;
  147711. shader: string;
  147712. };
  147713. }
  147714. declare module BABYLON {
  147715. /**
  147716. * Applies a kernel filter to the image
  147717. */
  147718. export class FilterPostProcess extends PostProcess {
  147719. /** The matrix to be applied to the image */
  147720. kernelMatrix: Matrix;
  147721. /**
  147722. *
  147723. * @param name The name of the effect.
  147724. * @param kernelMatrix The matrix to be applied to the image
  147725. * @param options The required width/height ratio to downsize to before computing the render pass.
  147726. * @param camera The camera to apply the render pass to.
  147727. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147728. * @param engine The engine which the post process will be applied. (default: current engine)
  147729. * @param reusable If the post process can be reused on the same frame. (default: false)
  147730. */
  147731. constructor(name: string,
  147732. /** The matrix to be applied to the image */
  147733. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147734. }
  147735. }
  147736. declare module BABYLON {
  147737. /** @hidden */
  147738. export var fxaaPixelShader: {
  147739. name: string;
  147740. shader: string;
  147741. };
  147742. }
  147743. declare module BABYLON {
  147744. /** @hidden */
  147745. export var fxaaVertexShader: {
  147746. name: string;
  147747. shader: string;
  147748. };
  147749. }
  147750. declare module BABYLON {
  147751. /**
  147752. * Fxaa post process
  147753. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  147754. */
  147755. export class FxaaPostProcess extends PostProcess {
  147756. /** @hidden */
  147757. texelWidth: number;
  147758. /** @hidden */
  147759. texelHeight: number;
  147760. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  147761. private _getDefines;
  147762. }
  147763. }
  147764. declare module BABYLON {
  147765. /** @hidden */
  147766. export var grainPixelShader: {
  147767. name: string;
  147768. shader: string;
  147769. };
  147770. }
  147771. declare module BABYLON {
  147772. /**
  147773. * The GrainPostProcess adds noise to the image at mid luminance levels
  147774. */
  147775. export class GrainPostProcess extends PostProcess {
  147776. /**
  147777. * The intensity of the grain added (default: 30)
  147778. */
  147779. intensity: number;
  147780. /**
  147781. * If the grain should be randomized on every frame
  147782. */
  147783. animated: boolean;
  147784. /**
  147785. * Creates a new instance of @see GrainPostProcess
  147786. * @param name The name of the effect.
  147787. * @param options The required width/height ratio to downsize to before computing the render pass.
  147788. * @param camera The camera to apply the render pass to.
  147789. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147790. * @param engine The engine which the post process will be applied. (default: current engine)
  147791. * @param reusable If the post process can be reused on the same frame. (default: false)
  147792. * @param textureType Type of textures used when performing the post process. (default: 0)
  147793. * @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)
  147794. */
  147795. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147796. }
  147797. }
  147798. declare module BABYLON {
  147799. /** @hidden */
  147800. export var highlightsPixelShader: {
  147801. name: string;
  147802. shader: string;
  147803. };
  147804. }
  147805. declare module BABYLON {
  147806. /**
  147807. * Extracts highlights from the image
  147808. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  147809. */
  147810. export class HighlightsPostProcess extends PostProcess {
  147811. /**
  147812. * Extracts highlights from the image
  147813. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  147814. * @param name The name of the effect.
  147815. * @param options The required width/height ratio to downsize to before computing the render pass.
  147816. * @param camera The camera to apply the render pass to.
  147817. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147818. * @param engine The engine which the post process will be applied. (default: current engine)
  147819. * @param reusable If the post process can be reused on the same frame. (default: false)
  147820. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  147821. */
  147822. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  147823. }
  147824. }
  147825. declare module BABYLON {
  147826. /** @hidden */
  147827. export var mrtFragmentDeclaration: {
  147828. name: string;
  147829. shader: string;
  147830. };
  147831. }
  147832. declare module BABYLON {
  147833. /** @hidden */
  147834. export var geometryPixelShader: {
  147835. name: string;
  147836. shader: string;
  147837. };
  147838. }
  147839. declare module BABYLON {
  147840. /** @hidden */
  147841. export var geometryVertexShader: {
  147842. name: string;
  147843. shader: string;
  147844. };
  147845. }
  147846. declare module BABYLON {
  147847. /** @hidden */
  147848. interface ISavedTransformationMatrix {
  147849. world: Matrix;
  147850. viewProjection: Matrix;
  147851. }
  147852. /**
  147853. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  147854. */
  147855. export class GeometryBufferRenderer {
  147856. /**
  147857. * Constant used to retrieve the position texture index in the G-Buffer textures array
  147858. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  147859. */
  147860. static readonly POSITION_TEXTURE_TYPE: number;
  147861. /**
  147862. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  147863. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  147864. */
  147865. static readonly VELOCITY_TEXTURE_TYPE: number;
  147866. /**
  147867. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  147868. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  147869. */
  147870. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  147871. /**
  147872. * Dictionary used to store the previous transformation matrices of each rendered mesh
  147873. * in order to compute objects velocities when enableVelocity is set to "true"
  147874. * @hidden
  147875. */
  147876. _previousTransformationMatrices: {
  147877. [index: number]: ISavedTransformationMatrix;
  147878. };
  147879. /**
  147880. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  147881. * in order to compute objects velocities when enableVelocity is set to "true"
  147882. * @hidden
  147883. */
  147884. _previousBonesTransformationMatrices: {
  147885. [index: number]: Float32Array;
  147886. };
  147887. /**
  147888. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  147889. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  147890. */
  147891. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  147892. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  147893. renderTransparentMeshes: boolean;
  147894. private _scene;
  147895. private _resizeObserver;
  147896. private _multiRenderTarget;
  147897. private _ratio;
  147898. private _enablePosition;
  147899. private _enableVelocity;
  147900. private _enableReflectivity;
  147901. private _positionIndex;
  147902. private _velocityIndex;
  147903. private _reflectivityIndex;
  147904. protected _effect: Effect;
  147905. protected _cachedDefines: string;
  147906. /**
  147907. * Set the render list (meshes to be rendered) used in the G buffer.
  147908. */
  147909. set renderList(meshes: Mesh[]);
  147910. /**
  147911. * Gets wether or not G buffer are supported by the running hardware.
  147912. * This requires draw buffer supports
  147913. */
  147914. get isSupported(): boolean;
  147915. /**
  147916. * Returns the index of the given texture type in the G-Buffer textures array
  147917. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  147918. * @returns the index of the given texture type in the G-Buffer textures array
  147919. */
  147920. getTextureIndex(textureType: number): number;
  147921. /**
  147922. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  147923. */
  147924. get enablePosition(): boolean;
  147925. /**
  147926. * Sets whether or not objects positions are enabled for the G buffer.
  147927. */
  147928. set enablePosition(enable: boolean);
  147929. /**
  147930. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  147931. */
  147932. get enableVelocity(): boolean;
  147933. /**
  147934. * Sets wether or not objects velocities are enabled for the G buffer.
  147935. */
  147936. set enableVelocity(enable: boolean);
  147937. /**
  147938. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  147939. */
  147940. get enableReflectivity(): boolean;
  147941. /**
  147942. * Sets wether or not objects roughness are enabled for the G buffer.
  147943. */
  147944. set enableReflectivity(enable: boolean);
  147945. /**
  147946. * Gets the scene associated with the buffer.
  147947. */
  147948. get scene(): Scene;
  147949. /**
  147950. * Gets the ratio used by the buffer during its creation.
  147951. * How big is the buffer related to the main canvas.
  147952. */
  147953. get ratio(): number;
  147954. /** @hidden */
  147955. static _SceneComponentInitialization: (scene: Scene) => void;
  147956. /**
  147957. * Creates a new G Buffer for the scene
  147958. * @param scene The scene the buffer belongs to
  147959. * @param ratio How big is the buffer related to the main canvas.
  147960. */
  147961. constructor(scene: Scene, ratio?: number);
  147962. /**
  147963. * Checks wether everything is ready to render a submesh to the G buffer.
  147964. * @param subMesh the submesh to check readiness for
  147965. * @param useInstances is the mesh drawn using instance or not
  147966. * @returns true if ready otherwise false
  147967. */
  147968. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  147969. /**
  147970. * Gets the current underlying G Buffer.
  147971. * @returns the buffer
  147972. */
  147973. getGBuffer(): MultiRenderTarget;
  147974. /**
  147975. * Gets the number of samples used to render the buffer (anti aliasing).
  147976. */
  147977. get samples(): number;
  147978. /**
  147979. * Sets the number of samples used to render the buffer (anti aliasing).
  147980. */
  147981. set samples(value: number);
  147982. /**
  147983. * Disposes the renderer and frees up associated resources.
  147984. */
  147985. dispose(): void;
  147986. protected _createRenderTargets(): void;
  147987. private _copyBonesTransformationMatrices;
  147988. }
  147989. }
  147990. declare module BABYLON {
  147991. interface Scene {
  147992. /** @hidden (Backing field) */
  147993. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  147994. /**
  147995. * Gets or Sets the current geometry buffer associated to the scene.
  147996. */
  147997. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  147998. /**
  147999. * Enables a GeometryBufferRender and associates it with the scene
  148000. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  148001. * @returns the GeometryBufferRenderer
  148002. */
  148003. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  148004. /**
  148005. * Disables the GeometryBufferRender associated with the scene
  148006. */
  148007. disableGeometryBufferRenderer(): void;
  148008. }
  148009. /**
  148010. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  148011. * in several rendering techniques.
  148012. */
  148013. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  148014. /**
  148015. * The component name helpful to identify the component in the list of scene components.
  148016. */
  148017. readonly name: string;
  148018. /**
  148019. * The scene the component belongs to.
  148020. */
  148021. scene: Scene;
  148022. /**
  148023. * Creates a new instance of the component for the given scene
  148024. * @param scene Defines the scene to register the component in
  148025. */
  148026. constructor(scene: Scene);
  148027. /**
  148028. * Registers the component in a given scene
  148029. */
  148030. register(): void;
  148031. /**
  148032. * Rebuilds the elements related to this component in case of
  148033. * context lost for instance.
  148034. */
  148035. rebuild(): void;
  148036. /**
  148037. * Disposes the component and the associated ressources
  148038. */
  148039. dispose(): void;
  148040. private _gatherRenderTargets;
  148041. }
  148042. }
  148043. declare module BABYLON {
  148044. /** @hidden */
  148045. export var motionBlurPixelShader: {
  148046. name: string;
  148047. shader: string;
  148048. };
  148049. }
  148050. declare module BABYLON {
  148051. /**
  148052. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  148053. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  148054. * As an example, all you have to do is to create the post-process:
  148055. * var mb = new BABYLON.MotionBlurPostProcess(
  148056. * 'mb', // The name of the effect.
  148057. * scene, // The scene containing the objects to blur according to their velocity.
  148058. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  148059. * camera // The camera to apply the render pass to.
  148060. * );
  148061. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  148062. */
  148063. export class MotionBlurPostProcess extends PostProcess {
  148064. /**
  148065. * Defines how much the image is blurred by the movement. Default value is equal to 1
  148066. */
  148067. motionStrength: number;
  148068. /**
  148069. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  148070. */
  148071. get motionBlurSamples(): number;
  148072. /**
  148073. * Sets the number of iterations to be used for motion blur quality
  148074. */
  148075. set motionBlurSamples(samples: number);
  148076. private _motionBlurSamples;
  148077. private _geometryBufferRenderer;
  148078. /**
  148079. * Creates a new instance MotionBlurPostProcess
  148080. * @param name The name of the effect.
  148081. * @param scene The scene containing the objects to blur according to their velocity.
  148082. * @param options The required width/height ratio to downsize to before computing the render pass.
  148083. * @param camera The camera to apply the render pass to.
  148084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148085. * @param engine The engine which the post process will be applied. (default: current engine)
  148086. * @param reusable If the post process can be reused on the same frame. (default: false)
  148087. * @param textureType Type of textures used when performing the post process. (default: 0)
  148088. * @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)
  148089. */
  148090. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148091. /**
  148092. * Excludes the given skinned mesh from computing bones velocities.
  148093. * 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.
  148094. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  148095. */
  148096. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  148097. /**
  148098. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  148099. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  148100. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  148101. */
  148102. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  148103. /**
  148104. * Disposes the post process.
  148105. * @param camera The camera to dispose the post process on.
  148106. */
  148107. dispose(camera?: Camera): void;
  148108. }
  148109. }
  148110. declare module BABYLON {
  148111. /** @hidden */
  148112. export var refractionPixelShader: {
  148113. name: string;
  148114. shader: string;
  148115. };
  148116. }
  148117. declare module BABYLON {
  148118. /**
  148119. * Post process which applies a refractin texture
  148120. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  148121. */
  148122. export class RefractionPostProcess extends PostProcess {
  148123. /** the base color of the refraction (used to taint the rendering) */
  148124. color: Color3;
  148125. /** simulated refraction depth */
  148126. depth: number;
  148127. /** the coefficient of the base color (0 to remove base color tainting) */
  148128. colorLevel: number;
  148129. private _refTexture;
  148130. private _ownRefractionTexture;
  148131. /**
  148132. * Gets or sets the refraction texture
  148133. * Please note that you are responsible for disposing the texture if you set it manually
  148134. */
  148135. get refractionTexture(): Texture;
  148136. set refractionTexture(value: Texture);
  148137. /**
  148138. * Initializes the RefractionPostProcess
  148139. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  148140. * @param name The name of the effect.
  148141. * @param refractionTextureUrl Url of the refraction texture to use
  148142. * @param color the base color of the refraction (used to taint the rendering)
  148143. * @param depth simulated refraction depth
  148144. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  148145. * @param camera The camera to apply the render pass to.
  148146. * @param options The required width/height ratio to downsize to before computing the render pass.
  148147. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148148. * @param engine The engine which the post process will be applied. (default: current engine)
  148149. * @param reusable If the post process can be reused on the same frame. (default: false)
  148150. */
  148151. constructor(name: string, refractionTextureUrl: string,
  148152. /** the base color of the refraction (used to taint the rendering) */
  148153. color: Color3,
  148154. /** simulated refraction depth */
  148155. depth: number,
  148156. /** the coefficient of the base color (0 to remove base color tainting) */
  148157. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148158. /**
  148159. * Disposes of the post process
  148160. * @param camera Camera to dispose post process on
  148161. */
  148162. dispose(camera: Camera): void;
  148163. }
  148164. }
  148165. declare module BABYLON {
  148166. /** @hidden */
  148167. export var sharpenPixelShader: {
  148168. name: string;
  148169. shader: string;
  148170. };
  148171. }
  148172. declare module BABYLON {
  148173. /**
  148174. * The SharpenPostProcess applies a sharpen kernel to every pixel
  148175. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  148176. */
  148177. export class SharpenPostProcess extends PostProcess {
  148178. /**
  148179. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  148180. */
  148181. colorAmount: number;
  148182. /**
  148183. * How much sharpness should be applied (default: 0.3)
  148184. */
  148185. edgeAmount: number;
  148186. /**
  148187. * Creates a new instance ConvolutionPostProcess
  148188. * @param name The name of the effect.
  148189. * @param options The required width/height ratio to downsize to before computing the render pass.
  148190. * @param camera The camera to apply the render pass to.
  148191. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148192. * @param engine The engine which the post process will be applied. (default: current engine)
  148193. * @param reusable If the post process can be reused on the same frame. (default: false)
  148194. * @param textureType Type of textures used when performing the post process. (default: 0)
  148195. * @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)
  148196. */
  148197. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148198. }
  148199. }
  148200. declare module BABYLON {
  148201. /**
  148202. * PostProcessRenderPipeline
  148203. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148204. */
  148205. export class PostProcessRenderPipeline {
  148206. private engine;
  148207. private _renderEffects;
  148208. private _renderEffectsForIsolatedPass;
  148209. /**
  148210. * List of inspectable custom properties (used by the Inspector)
  148211. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  148212. */
  148213. inspectableCustomProperties: IInspectable[];
  148214. /**
  148215. * @hidden
  148216. */
  148217. protected _cameras: Camera[];
  148218. /** @hidden */
  148219. _name: string;
  148220. /**
  148221. * Gets pipeline name
  148222. */
  148223. get name(): string;
  148224. /** Gets the list of attached cameras */
  148225. get cameras(): Camera[];
  148226. /**
  148227. * Initializes a PostProcessRenderPipeline
  148228. * @param engine engine to add the pipeline to
  148229. * @param name name of the pipeline
  148230. */
  148231. constructor(engine: Engine, name: string);
  148232. /**
  148233. * Gets the class name
  148234. * @returns "PostProcessRenderPipeline"
  148235. */
  148236. getClassName(): string;
  148237. /**
  148238. * If all the render effects in the pipeline are supported
  148239. */
  148240. get isSupported(): boolean;
  148241. /**
  148242. * Adds an effect to the pipeline
  148243. * @param renderEffect the effect to add
  148244. */
  148245. addEffect(renderEffect: PostProcessRenderEffect): void;
  148246. /** @hidden */
  148247. _rebuild(): void;
  148248. /** @hidden */
  148249. _enableEffect(renderEffectName: string, cameras: Camera): void;
  148250. /** @hidden */
  148251. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  148252. /** @hidden */
  148253. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  148254. /** @hidden */
  148255. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  148256. /** @hidden */
  148257. _attachCameras(cameras: Camera, unique: boolean): void;
  148258. /** @hidden */
  148259. _attachCameras(cameras: Camera[], unique: boolean): void;
  148260. /** @hidden */
  148261. _detachCameras(cameras: Camera): void;
  148262. /** @hidden */
  148263. _detachCameras(cameras: Nullable<Camera[]>): void;
  148264. /** @hidden */
  148265. _update(): void;
  148266. /** @hidden */
  148267. _reset(): void;
  148268. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  148269. /**
  148270. * Sets the required values to the prepass renderer.
  148271. * @param prePassRenderer defines the prepass renderer to setup.
  148272. * @returns true if the pre pass is needed.
  148273. */
  148274. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  148275. /**
  148276. * Disposes of the pipeline
  148277. */
  148278. dispose(): void;
  148279. }
  148280. }
  148281. declare module BABYLON {
  148282. /**
  148283. * PostProcessRenderPipelineManager class
  148284. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148285. */
  148286. export class PostProcessRenderPipelineManager {
  148287. private _renderPipelines;
  148288. /**
  148289. * Initializes a PostProcessRenderPipelineManager
  148290. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148291. */
  148292. constructor();
  148293. /**
  148294. * Gets the list of supported render pipelines
  148295. */
  148296. get supportedPipelines(): PostProcessRenderPipeline[];
  148297. /**
  148298. * Adds a pipeline to the manager
  148299. * @param renderPipeline The pipeline to add
  148300. */
  148301. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  148302. /**
  148303. * Attaches a camera to the pipeline
  148304. * @param renderPipelineName The name of the pipeline to attach to
  148305. * @param cameras the camera to attach
  148306. * @param unique if the camera can be attached multiple times to the pipeline
  148307. */
  148308. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  148309. /**
  148310. * Detaches a camera from the pipeline
  148311. * @param renderPipelineName The name of the pipeline to detach from
  148312. * @param cameras the camera to detach
  148313. */
  148314. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  148315. /**
  148316. * Enables an effect by name on a pipeline
  148317. * @param renderPipelineName the name of the pipeline to enable the effect in
  148318. * @param renderEffectName the name of the effect to enable
  148319. * @param cameras the cameras that the effect should be enabled on
  148320. */
  148321. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  148322. /**
  148323. * Disables an effect by name on a pipeline
  148324. * @param renderPipelineName the name of the pipeline to disable the effect in
  148325. * @param renderEffectName the name of the effect to disable
  148326. * @param cameras the cameras that the effect should be disabled on
  148327. */
  148328. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  148329. /**
  148330. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  148331. */
  148332. update(): void;
  148333. /** @hidden */
  148334. _rebuild(): void;
  148335. /**
  148336. * Disposes of the manager and pipelines
  148337. */
  148338. dispose(): void;
  148339. }
  148340. }
  148341. declare module BABYLON {
  148342. interface Scene {
  148343. /** @hidden (Backing field) */
  148344. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  148345. /**
  148346. * Gets the postprocess render pipeline manager
  148347. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148348. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  148349. */
  148350. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  148351. }
  148352. /**
  148353. * Defines the Render Pipeline scene component responsible to rendering pipelines
  148354. */
  148355. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  148356. /**
  148357. * The component name helpfull to identify the component in the list of scene components.
  148358. */
  148359. readonly name: string;
  148360. /**
  148361. * The scene the component belongs to.
  148362. */
  148363. scene: Scene;
  148364. /**
  148365. * Creates a new instance of the component for the given scene
  148366. * @param scene Defines the scene to register the component in
  148367. */
  148368. constructor(scene: Scene);
  148369. /**
  148370. * Registers the component in a given scene
  148371. */
  148372. register(): void;
  148373. /**
  148374. * Rebuilds the elements related to this component in case of
  148375. * context lost for instance.
  148376. */
  148377. rebuild(): void;
  148378. /**
  148379. * Disposes the component and the associated ressources
  148380. */
  148381. dispose(): void;
  148382. private _gatherRenderTargets;
  148383. }
  148384. }
  148385. declare module BABYLON {
  148386. /**
  148387. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  148388. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  148389. */
  148390. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  148391. private _scene;
  148392. private _camerasToBeAttached;
  148393. /**
  148394. * ID of the sharpen post process,
  148395. */
  148396. private readonly SharpenPostProcessId;
  148397. /**
  148398. * @ignore
  148399. * ID of the image processing post process;
  148400. */
  148401. readonly ImageProcessingPostProcessId: string;
  148402. /**
  148403. * @ignore
  148404. * ID of the Fast Approximate Anti-Aliasing post process;
  148405. */
  148406. readonly FxaaPostProcessId: string;
  148407. /**
  148408. * ID of the chromatic aberration post process,
  148409. */
  148410. private readonly ChromaticAberrationPostProcessId;
  148411. /**
  148412. * ID of the grain post process
  148413. */
  148414. private readonly GrainPostProcessId;
  148415. /**
  148416. * Sharpen post process which will apply a sharpen convolution to enhance edges
  148417. */
  148418. sharpen: SharpenPostProcess;
  148419. private _sharpenEffect;
  148420. private bloom;
  148421. /**
  148422. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  148423. */
  148424. depthOfField: DepthOfFieldEffect;
  148425. /**
  148426. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  148427. */
  148428. fxaa: FxaaPostProcess;
  148429. /**
  148430. * Image post processing pass used to perform operations such as tone mapping or color grading.
  148431. */
  148432. imageProcessing: ImageProcessingPostProcess;
  148433. /**
  148434. * Chromatic aberration post process which will shift rgb colors in the image
  148435. */
  148436. chromaticAberration: ChromaticAberrationPostProcess;
  148437. private _chromaticAberrationEffect;
  148438. /**
  148439. * Grain post process which add noise to the image
  148440. */
  148441. grain: GrainPostProcess;
  148442. private _grainEffect;
  148443. /**
  148444. * Glow post process which adds a glow to emissive areas of the image
  148445. */
  148446. private _glowLayer;
  148447. /**
  148448. * Animations which can be used to tweak settings over a period of time
  148449. */
  148450. animations: Animation[];
  148451. private _imageProcessingConfigurationObserver;
  148452. private _sharpenEnabled;
  148453. private _bloomEnabled;
  148454. private _depthOfFieldEnabled;
  148455. private _depthOfFieldBlurLevel;
  148456. private _fxaaEnabled;
  148457. private _imageProcessingEnabled;
  148458. private _defaultPipelineTextureType;
  148459. private _bloomScale;
  148460. private _chromaticAberrationEnabled;
  148461. private _grainEnabled;
  148462. private _buildAllowed;
  148463. /**
  148464. * Gets active scene
  148465. */
  148466. get scene(): Scene;
  148467. /**
  148468. * Enable or disable the sharpen process from the pipeline
  148469. */
  148470. set sharpenEnabled(enabled: boolean);
  148471. get sharpenEnabled(): boolean;
  148472. private _resizeObserver;
  148473. private _hardwareScaleLevel;
  148474. private _bloomKernel;
  148475. /**
  148476. * Specifies the size of the bloom blur kernel, relative to the final output size
  148477. */
  148478. get bloomKernel(): number;
  148479. set bloomKernel(value: number);
  148480. /**
  148481. * Specifies the weight of the bloom in the final rendering
  148482. */
  148483. private _bloomWeight;
  148484. /**
  148485. * Specifies the luma threshold for the area that will be blurred by the bloom
  148486. */
  148487. private _bloomThreshold;
  148488. private _hdr;
  148489. /**
  148490. * The strength of the bloom.
  148491. */
  148492. set bloomWeight(value: number);
  148493. get bloomWeight(): number;
  148494. /**
  148495. * The strength of the bloom.
  148496. */
  148497. set bloomThreshold(value: number);
  148498. get bloomThreshold(): number;
  148499. /**
  148500. * The scale of the bloom, lower value will provide better performance.
  148501. */
  148502. set bloomScale(value: number);
  148503. get bloomScale(): number;
  148504. /**
  148505. * Enable or disable the bloom from the pipeline
  148506. */
  148507. set bloomEnabled(enabled: boolean);
  148508. get bloomEnabled(): boolean;
  148509. private _rebuildBloom;
  148510. /**
  148511. * If the depth of field is enabled.
  148512. */
  148513. get depthOfFieldEnabled(): boolean;
  148514. set depthOfFieldEnabled(enabled: boolean);
  148515. /**
  148516. * Blur level of the depth of field effect. (Higher blur will effect performance)
  148517. */
  148518. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  148519. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  148520. /**
  148521. * If the anti aliasing is enabled.
  148522. */
  148523. set fxaaEnabled(enabled: boolean);
  148524. get fxaaEnabled(): boolean;
  148525. private _samples;
  148526. /**
  148527. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  148528. */
  148529. set samples(sampleCount: number);
  148530. get samples(): number;
  148531. /**
  148532. * If image processing is enabled.
  148533. */
  148534. set imageProcessingEnabled(enabled: boolean);
  148535. get imageProcessingEnabled(): boolean;
  148536. /**
  148537. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  148538. */
  148539. set glowLayerEnabled(enabled: boolean);
  148540. get glowLayerEnabled(): boolean;
  148541. /**
  148542. * Gets the glow layer (or null if not defined)
  148543. */
  148544. get glowLayer(): Nullable<GlowLayer>;
  148545. /**
  148546. * Enable or disable the chromaticAberration process from the pipeline
  148547. */
  148548. set chromaticAberrationEnabled(enabled: boolean);
  148549. get chromaticAberrationEnabled(): boolean;
  148550. /**
  148551. * Enable or disable the grain process from the pipeline
  148552. */
  148553. set grainEnabled(enabled: boolean);
  148554. get grainEnabled(): boolean;
  148555. /**
  148556. * @constructor
  148557. * @param name - The rendering pipeline name (default: "")
  148558. * @param hdr - If high dynamic range textures should be used (default: true)
  148559. * @param scene - The scene linked to this pipeline (default: the last created scene)
  148560. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  148561. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  148562. */
  148563. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  148564. /**
  148565. * Get the class name
  148566. * @returns "DefaultRenderingPipeline"
  148567. */
  148568. getClassName(): string;
  148569. /**
  148570. * Force the compilation of the entire pipeline.
  148571. */
  148572. prepare(): void;
  148573. private _hasCleared;
  148574. private _prevPostProcess;
  148575. private _prevPrevPostProcess;
  148576. private _setAutoClearAndTextureSharing;
  148577. private _depthOfFieldSceneObserver;
  148578. private _buildPipeline;
  148579. private _disposePostProcesses;
  148580. /**
  148581. * Adds a camera to the pipeline
  148582. * @param camera the camera to be added
  148583. */
  148584. addCamera(camera: Camera): void;
  148585. /**
  148586. * Removes a camera from the pipeline
  148587. * @param camera the camera to remove
  148588. */
  148589. removeCamera(camera: Camera): void;
  148590. /**
  148591. * Dispose of the pipeline and stop all post processes
  148592. */
  148593. dispose(): void;
  148594. /**
  148595. * Serialize the rendering pipeline (Used when exporting)
  148596. * @returns the serialized object
  148597. */
  148598. serialize(): any;
  148599. /**
  148600. * Parse the serialized pipeline
  148601. * @param source Source pipeline.
  148602. * @param scene The scene to load the pipeline to.
  148603. * @param rootUrl The URL of the serialized pipeline.
  148604. * @returns An instantiated pipeline from the serialized object.
  148605. */
  148606. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  148607. }
  148608. }
  148609. declare module BABYLON {
  148610. /** @hidden */
  148611. export var lensHighlightsPixelShader: {
  148612. name: string;
  148613. shader: string;
  148614. };
  148615. }
  148616. declare module BABYLON {
  148617. /** @hidden */
  148618. export var depthOfFieldPixelShader: {
  148619. name: string;
  148620. shader: string;
  148621. };
  148622. }
  148623. declare module BABYLON {
  148624. /**
  148625. * BABYLON.JS Chromatic Aberration GLSL Shader
  148626. * Author: Olivier Guyot
  148627. * Separates very slightly R, G and B colors on the edges of the screen
  148628. * Inspired by Francois Tarlier & Martins Upitis
  148629. */
  148630. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  148631. /**
  148632. * @ignore
  148633. * The chromatic aberration PostProcess id in the pipeline
  148634. */
  148635. LensChromaticAberrationEffect: string;
  148636. /**
  148637. * @ignore
  148638. * The highlights enhancing PostProcess id in the pipeline
  148639. */
  148640. HighlightsEnhancingEffect: string;
  148641. /**
  148642. * @ignore
  148643. * The depth-of-field PostProcess id in the pipeline
  148644. */
  148645. LensDepthOfFieldEffect: string;
  148646. private _scene;
  148647. private _depthTexture;
  148648. private _grainTexture;
  148649. private _chromaticAberrationPostProcess;
  148650. private _highlightsPostProcess;
  148651. private _depthOfFieldPostProcess;
  148652. private _edgeBlur;
  148653. private _grainAmount;
  148654. private _chromaticAberration;
  148655. private _distortion;
  148656. private _highlightsGain;
  148657. private _highlightsThreshold;
  148658. private _dofDistance;
  148659. private _dofAperture;
  148660. private _dofDarken;
  148661. private _dofPentagon;
  148662. private _blurNoise;
  148663. /**
  148664. * @constructor
  148665. *
  148666. * Effect parameters are as follow:
  148667. * {
  148668. * chromatic_aberration: number; // from 0 to x (1 for realism)
  148669. * edge_blur: number; // from 0 to x (1 for realism)
  148670. * distortion: number; // from 0 to x (1 for realism)
  148671. * grain_amount: number; // from 0 to 1
  148672. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  148673. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  148674. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  148675. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  148676. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  148677. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  148678. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  148679. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  148680. * }
  148681. * Note: if an effect parameter is unset, effect is disabled
  148682. *
  148683. * @param name The rendering pipeline name
  148684. * @param parameters - An object containing all parameters (see above)
  148685. * @param scene The scene linked to this pipeline
  148686. * @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)
  148687. * @param cameras The array of cameras that the rendering pipeline will be attached to
  148688. */
  148689. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  148690. /**
  148691. * Get the class name
  148692. * @returns "LensRenderingPipeline"
  148693. */
  148694. getClassName(): string;
  148695. /**
  148696. * Gets associated scene
  148697. */
  148698. get scene(): Scene;
  148699. /**
  148700. * Gets or sets the edge blur
  148701. */
  148702. get edgeBlur(): number;
  148703. set edgeBlur(value: number);
  148704. /**
  148705. * Gets or sets the grain amount
  148706. */
  148707. get grainAmount(): number;
  148708. set grainAmount(value: number);
  148709. /**
  148710. * Gets or sets the chromatic aberration amount
  148711. */
  148712. get chromaticAberration(): number;
  148713. set chromaticAberration(value: number);
  148714. /**
  148715. * Gets or sets the depth of field aperture
  148716. */
  148717. get dofAperture(): number;
  148718. set dofAperture(value: number);
  148719. /**
  148720. * Gets or sets the edge distortion
  148721. */
  148722. get edgeDistortion(): number;
  148723. set edgeDistortion(value: number);
  148724. /**
  148725. * Gets or sets the depth of field distortion
  148726. */
  148727. get dofDistortion(): number;
  148728. set dofDistortion(value: number);
  148729. /**
  148730. * Gets or sets the darken out of focus amount
  148731. */
  148732. get darkenOutOfFocus(): number;
  148733. set darkenOutOfFocus(value: number);
  148734. /**
  148735. * Gets or sets a boolean indicating if blur noise is enabled
  148736. */
  148737. get blurNoise(): boolean;
  148738. set blurNoise(value: boolean);
  148739. /**
  148740. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  148741. */
  148742. get pentagonBokeh(): boolean;
  148743. set pentagonBokeh(value: boolean);
  148744. /**
  148745. * Gets or sets the highlight grain amount
  148746. */
  148747. get highlightsGain(): number;
  148748. set highlightsGain(value: number);
  148749. /**
  148750. * Gets or sets the highlight threshold
  148751. */
  148752. get highlightsThreshold(): number;
  148753. set highlightsThreshold(value: number);
  148754. /**
  148755. * Sets the amount of blur at the edges
  148756. * @param amount blur amount
  148757. */
  148758. setEdgeBlur(amount: number): void;
  148759. /**
  148760. * Sets edge blur to 0
  148761. */
  148762. disableEdgeBlur(): void;
  148763. /**
  148764. * Sets the amout of grain
  148765. * @param amount Amount of grain
  148766. */
  148767. setGrainAmount(amount: number): void;
  148768. /**
  148769. * Set grain amount to 0
  148770. */
  148771. disableGrain(): void;
  148772. /**
  148773. * Sets the chromatic aberration amount
  148774. * @param amount amount of chromatic aberration
  148775. */
  148776. setChromaticAberration(amount: number): void;
  148777. /**
  148778. * Sets chromatic aberration amount to 0
  148779. */
  148780. disableChromaticAberration(): void;
  148781. /**
  148782. * Sets the EdgeDistortion amount
  148783. * @param amount amount of EdgeDistortion
  148784. */
  148785. setEdgeDistortion(amount: number): void;
  148786. /**
  148787. * Sets edge distortion to 0
  148788. */
  148789. disableEdgeDistortion(): void;
  148790. /**
  148791. * Sets the FocusDistance amount
  148792. * @param amount amount of FocusDistance
  148793. */
  148794. setFocusDistance(amount: number): void;
  148795. /**
  148796. * Disables depth of field
  148797. */
  148798. disableDepthOfField(): void;
  148799. /**
  148800. * Sets the Aperture amount
  148801. * @param amount amount of Aperture
  148802. */
  148803. setAperture(amount: number): void;
  148804. /**
  148805. * Sets the DarkenOutOfFocus amount
  148806. * @param amount amount of DarkenOutOfFocus
  148807. */
  148808. setDarkenOutOfFocus(amount: number): void;
  148809. private _pentagonBokehIsEnabled;
  148810. /**
  148811. * Creates a pentagon bokeh effect
  148812. */
  148813. enablePentagonBokeh(): void;
  148814. /**
  148815. * Disables the pentagon bokeh effect
  148816. */
  148817. disablePentagonBokeh(): void;
  148818. /**
  148819. * Enables noise blur
  148820. */
  148821. enableNoiseBlur(): void;
  148822. /**
  148823. * Disables noise blur
  148824. */
  148825. disableNoiseBlur(): void;
  148826. /**
  148827. * Sets the HighlightsGain amount
  148828. * @param amount amount of HighlightsGain
  148829. */
  148830. setHighlightsGain(amount: number): void;
  148831. /**
  148832. * Sets the HighlightsThreshold amount
  148833. * @param amount amount of HighlightsThreshold
  148834. */
  148835. setHighlightsThreshold(amount: number): void;
  148836. /**
  148837. * Disables highlights
  148838. */
  148839. disableHighlights(): void;
  148840. /**
  148841. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  148842. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  148843. */
  148844. dispose(disableDepthRender?: boolean): void;
  148845. private _createChromaticAberrationPostProcess;
  148846. private _createHighlightsPostProcess;
  148847. private _createDepthOfFieldPostProcess;
  148848. private _createGrainTexture;
  148849. }
  148850. }
  148851. declare module BABYLON {
  148852. /** @hidden */
  148853. export var ssao2PixelShader: {
  148854. name: string;
  148855. shader: string;
  148856. };
  148857. }
  148858. declare module BABYLON {
  148859. /** @hidden */
  148860. export var ssaoCombinePixelShader: {
  148861. name: string;
  148862. shader: string;
  148863. };
  148864. }
  148865. declare module BABYLON {
  148866. /**
  148867. * Render pipeline to produce ssao effect
  148868. */
  148869. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  148870. /**
  148871. * @ignore
  148872. * The PassPostProcess id in the pipeline that contains the original scene color
  148873. */
  148874. SSAOOriginalSceneColorEffect: string;
  148875. /**
  148876. * @ignore
  148877. * The SSAO PostProcess id in the pipeline
  148878. */
  148879. SSAORenderEffect: string;
  148880. /**
  148881. * @ignore
  148882. * The horizontal blur PostProcess id in the pipeline
  148883. */
  148884. SSAOBlurHRenderEffect: string;
  148885. /**
  148886. * @ignore
  148887. * The vertical blur PostProcess id in the pipeline
  148888. */
  148889. SSAOBlurVRenderEffect: string;
  148890. /**
  148891. * @ignore
  148892. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  148893. */
  148894. SSAOCombineRenderEffect: string;
  148895. /**
  148896. * The output strength of the SSAO post-process. Default value is 1.0.
  148897. */
  148898. totalStrength: number;
  148899. /**
  148900. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  148901. */
  148902. maxZ: number;
  148903. /**
  148904. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  148905. */
  148906. minZAspect: number;
  148907. private _samples;
  148908. /**
  148909. * Number of samples used for the SSAO calculations. Default value is 8
  148910. */
  148911. set samples(n: number);
  148912. get samples(): number;
  148913. private _textureSamples;
  148914. /**
  148915. * Number of samples to use for antialiasing
  148916. */
  148917. set textureSamples(n: number);
  148918. get textureSamples(): number;
  148919. /**
  148920. * Force rendering the geometry through geometry buffer
  148921. */
  148922. private _forceGeometryBuffer;
  148923. /**
  148924. * Ratio object used for SSAO ratio and blur ratio
  148925. */
  148926. private _ratio;
  148927. /**
  148928. * Dynamically generated sphere sampler.
  148929. */
  148930. private _sampleSphere;
  148931. /**
  148932. * Blur filter offsets
  148933. */
  148934. private _samplerOffsets;
  148935. private _expensiveBlur;
  148936. /**
  148937. * If bilateral blur should be used
  148938. */
  148939. set expensiveBlur(b: boolean);
  148940. get expensiveBlur(): boolean;
  148941. /**
  148942. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  148943. */
  148944. radius: number;
  148945. /**
  148946. * The base color of the SSAO post-process
  148947. * The final result is "base + ssao" between [0, 1]
  148948. */
  148949. base: number;
  148950. /**
  148951. * Support test.
  148952. */
  148953. static get IsSupported(): boolean;
  148954. private _scene;
  148955. private _randomTexture;
  148956. private _originalColorPostProcess;
  148957. private _ssaoPostProcess;
  148958. private _blurHPostProcess;
  148959. private _blurVPostProcess;
  148960. private _ssaoCombinePostProcess;
  148961. private _prePassRenderer;
  148962. /**
  148963. * Gets active scene
  148964. */
  148965. get scene(): Scene;
  148966. /**
  148967. * @constructor
  148968. * @param name The rendering pipeline name
  148969. * @param scene The scene linked to this pipeline
  148970. * @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 }
  148971. * @param cameras The array of cameras that the rendering pipeline will be attached to
  148972. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  148973. */
  148974. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  148975. /**
  148976. * Get the class name
  148977. * @returns "SSAO2RenderingPipeline"
  148978. */
  148979. getClassName(): string;
  148980. /**
  148981. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  148982. */
  148983. dispose(disableGeometryBufferRenderer?: boolean): void;
  148984. private _createBlurPostProcess;
  148985. /** @hidden */
  148986. _rebuild(): void;
  148987. private _bits;
  148988. private _radicalInverse_VdC;
  148989. private _hammersley;
  148990. private _hemisphereSample_uniform;
  148991. private _generateHemisphere;
  148992. private _getDefinesForSSAO;
  148993. private _createSSAOPostProcess;
  148994. private _createSSAOCombinePostProcess;
  148995. private _createRandomTexture;
  148996. /**
  148997. * Serialize the rendering pipeline (Used when exporting)
  148998. * @returns the serialized object
  148999. */
  149000. serialize(): any;
  149001. /**
  149002. * Parse the serialized pipeline
  149003. * @param source Source pipeline.
  149004. * @param scene The scene to load the pipeline to.
  149005. * @param rootUrl The URL of the serialized pipeline.
  149006. * @returns An instantiated pipeline from the serialized object.
  149007. */
  149008. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  149009. /**
  149010. * Sets the required values to the prepass renderer.
  149011. * @param prePassRenderer defines the prepass renderer to setup
  149012. * @returns true if the pre pass is needed.
  149013. */
  149014. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  149015. }
  149016. }
  149017. declare module BABYLON {
  149018. /** @hidden */
  149019. export var ssaoPixelShader: {
  149020. name: string;
  149021. shader: string;
  149022. };
  149023. }
  149024. declare module BABYLON {
  149025. /**
  149026. * Render pipeline to produce ssao effect
  149027. */
  149028. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  149029. /**
  149030. * @ignore
  149031. * The PassPostProcess id in the pipeline that contains the original scene color
  149032. */
  149033. SSAOOriginalSceneColorEffect: string;
  149034. /**
  149035. * @ignore
  149036. * The SSAO PostProcess id in the pipeline
  149037. */
  149038. SSAORenderEffect: string;
  149039. /**
  149040. * @ignore
  149041. * The horizontal blur PostProcess id in the pipeline
  149042. */
  149043. SSAOBlurHRenderEffect: string;
  149044. /**
  149045. * @ignore
  149046. * The vertical blur PostProcess id in the pipeline
  149047. */
  149048. SSAOBlurVRenderEffect: string;
  149049. /**
  149050. * @ignore
  149051. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  149052. */
  149053. SSAOCombineRenderEffect: string;
  149054. /**
  149055. * The output strength of the SSAO post-process. Default value is 1.0.
  149056. */
  149057. totalStrength: number;
  149058. /**
  149059. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  149060. */
  149061. radius: number;
  149062. /**
  149063. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  149064. * Must not be equal to fallOff and superior to fallOff.
  149065. * Default value is 0.0075
  149066. */
  149067. area: number;
  149068. /**
  149069. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  149070. * Must not be equal to area and inferior to area.
  149071. * Default value is 0.000001
  149072. */
  149073. fallOff: number;
  149074. /**
  149075. * The base color of the SSAO post-process
  149076. * The final result is "base + ssao" between [0, 1]
  149077. */
  149078. base: number;
  149079. private _scene;
  149080. private _depthTexture;
  149081. private _randomTexture;
  149082. private _originalColorPostProcess;
  149083. private _ssaoPostProcess;
  149084. private _blurHPostProcess;
  149085. private _blurVPostProcess;
  149086. private _ssaoCombinePostProcess;
  149087. private _firstUpdate;
  149088. /**
  149089. * Gets active scene
  149090. */
  149091. get scene(): Scene;
  149092. /**
  149093. * @constructor
  149094. * @param name - The rendering pipeline name
  149095. * @param scene - The scene linked to this pipeline
  149096. * @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 }
  149097. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  149098. */
  149099. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  149100. /**
  149101. * Get the class name
  149102. * @returns "SSAORenderingPipeline"
  149103. */
  149104. getClassName(): string;
  149105. /**
  149106. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  149107. */
  149108. dispose(disableDepthRender?: boolean): void;
  149109. private _createBlurPostProcess;
  149110. /** @hidden */
  149111. _rebuild(): void;
  149112. private _createSSAOPostProcess;
  149113. private _createSSAOCombinePostProcess;
  149114. private _createRandomTexture;
  149115. }
  149116. }
  149117. declare module BABYLON {
  149118. /** @hidden */
  149119. export var screenSpaceReflectionPixelShader: {
  149120. name: string;
  149121. shader: string;
  149122. };
  149123. }
  149124. declare module BABYLON {
  149125. /**
  149126. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  149127. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  149128. */
  149129. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  149130. /**
  149131. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  149132. */
  149133. threshold: number;
  149134. /**
  149135. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  149136. */
  149137. strength: number;
  149138. /**
  149139. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  149140. */
  149141. reflectionSpecularFalloffExponent: number;
  149142. /**
  149143. * 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]
  149144. */
  149145. step: number;
  149146. /**
  149147. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  149148. */
  149149. roughnessFactor: number;
  149150. private _geometryBufferRenderer;
  149151. private _enableSmoothReflections;
  149152. private _reflectionSamples;
  149153. private _smoothSteps;
  149154. /**
  149155. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  149156. * @param name The name of the effect.
  149157. * @param scene The scene containing the objects to calculate reflections.
  149158. * @param options The required width/height ratio to downsize to before computing the render pass.
  149159. * @param camera The camera to apply the render pass to.
  149160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149161. * @param engine The engine which the post process will be applied. (default: current engine)
  149162. * @param reusable If the post process can be reused on the same frame. (default: false)
  149163. * @param textureType Type of textures used when performing the post process. (default: 0)
  149164. * @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)
  149165. */
  149166. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149167. /**
  149168. * Gets wether or not smoothing reflections is enabled.
  149169. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  149170. */
  149171. get enableSmoothReflections(): boolean;
  149172. /**
  149173. * Sets wether or not smoothing reflections is enabled.
  149174. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  149175. */
  149176. set enableSmoothReflections(enabled: boolean);
  149177. /**
  149178. * Gets the number of samples taken while computing reflections. More samples count is high,
  149179. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  149180. */
  149181. get reflectionSamples(): number;
  149182. /**
  149183. * Sets the number of samples taken while computing reflections. More samples count is high,
  149184. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  149185. */
  149186. set reflectionSamples(samples: number);
  149187. /**
  149188. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  149189. * more the post-process will require GPU power and can generate a drop in FPS.
  149190. * Default value (5.0) work pretty well in all cases but can be adjusted.
  149191. */
  149192. get smoothSteps(): number;
  149193. set smoothSteps(steps: number);
  149194. private _updateEffectDefines;
  149195. }
  149196. }
  149197. declare module BABYLON {
  149198. /** @hidden */
  149199. export var standardPixelShader: {
  149200. name: string;
  149201. shader: string;
  149202. };
  149203. }
  149204. declare module BABYLON {
  149205. /**
  149206. * Standard rendering pipeline
  149207. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  149208. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  149209. */
  149210. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  149211. /**
  149212. * Public members
  149213. */
  149214. /**
  149215. * Post-process which contains the original scene color before the pipeline applies all the effects
  149216. */
  149217. originalPostProcess: Nullable<PostProcess>;
  149218. /**
  149219. * Post-process used to down scale an image x4
  149220. */
  149221. downSampleX4PostProcess: Nullable<PostProcess>;
  149222. /**
  149223. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  149224. */
  149225. brightPassPostProcess: Nullable<PostProcess>;
  149226. /**
  149227. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  149228. */
  149229. blurHPostProcesses: PostProcess[];
  149230. /**
  149231. * Post-process array storing all the vertical blur post-processes used by the pipeline
  149232. */
  149233. blurVPostProcesses: PostProcess[];
  149234. /**
  149235. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  149236. */
  149237. textureAdderPostProcess: Nullable<PostProcess>;
  149238. /**
  149239. * Post-process used to create volumetric lighting effect
  149240. */
  149241. volumetricLightPostProcess: Nullable<PostProcess>;
  149242. /**
  149243. * Post-process used to smooth the previous volumetric light post-process on the X axis
  149244. */
  149245. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  149246. /**
  149247. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  149248. */
  149249. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  149250. /**
  149251. * Post-process used to merge the volumetric light effect and the real scene color
  149252. */
  149253. volumetricLightMergePostProces: Nullable<PostProcess>;
  149254. /**
  149255. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  149256. */
  149257. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  149258. /**
  149259. * Base post-process used to calculate the average luminance of the final image for HDR
  149260. */
  149261. luminancePostProcess: Nullable<PostProcess>;
  149262. /**
  149263. * Post-processes used to create down sample post-processes in order to get
  149264. * the average luminance of the final image for HDR
  149265. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  149266. */
  149267. luminanceDownSamplePostProcesses: PostProcess[];
  149268. /**
  149269. * Post-process used to create a HDR effect (light adaptation)
  149270. */
  149271. hdrPostProcess: Nullable<PostProcess>;
  149272. /**
  149273. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  149274. */
  149275. textureAdderFinalPostProcess: Nullable<PostProcess>;
  149276. /**
  149277. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  149278. */
  149279. lensFlareFinalPostProcess: Nullable<PostProcess>;
  149280. /**
  149281. * Post-process used to merge the final HDR post-process and the real scene color
  149282. */
  149283. hdrFinalPostProcess: Nullable<PostProcess>;
  149284. /**
  149285. * Post-process used to create a lens flare effect
  149286. */
  149287. lensFlarePostProcess: Nullable<PostProcess>;
  149288. /**
  149289. * Post-process that merges the result of the lens flare post-process and the real scene color
  149290. */
  149291. lensFlareComposePostProcess: Nullable<PostProcess>;
  149292. /**
  149293. * Post-process used to create a motion blur effect
  149294. */
  149295. motionBlurPostProcess: Nullable<PostProcess>;
  149296. /**
  149297. * Post-process used to create a depth of field effect
  149298. */
  149299. depthOfFieldPostProcess: Nullable<PostProcess>;
  149300. /**
  149301. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  149302. */
  149303. fxaaPostProcess: Nullable<FxaaPostProcess>;
  149304. /**
  149305. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  149306. */
  149307. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  149308. /**
  149309. * Represents the brightness threshold in order to configure the illuminated surfaces
  149310. */
  149311. brightThreshold: number;
  149312. /**
  149313. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  149314. */
  149315. blurWidth: number;
  149316. /**
  149317. * Sets if the blur for highlighted surfaces must be only horizontal
  149318. */
  149319. horizontalBlur: boolean;
  149320. /**
  149321. * Gets the overall exposure used by the pipeline
  149322. */
  149323. get exposure(): number;
  149324. /**
  149325. * Sets the overall exposure used by the pipeline
  149326. */
  149327. set exposure(value: number);
  149328. /**
  149329. * Texture used typically to simulate "dirty" on camera lens
  149330. */
  149331. lensTexture: Nullable<Texture>;
  149332. /**
  149333. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  149334. */
  149335. volumetricLightCoefficient: number;
  149336. /**
  149337. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  149338. */
  149339. volumetricLightPower: number;
  149340. /**
  149341. * Used the set the blur intensity to smooth the volumetric lights
  149342. */
  149343. volumetricLightBlurScale: number;
  149344. /**
  149345. * Light (spot or directional) used to generate the volumetric lights rays
  149346. * The source light must have a shadow generate so the pipeline can get its
  149347. * depth map
  149348. */
  149349. sourceLight: Nullable<SpotLight | DirectionalLight>;
  149350. /**
  149351. * For eye adaptation, represents the minimum luminance the eye can see
  149352. */
  149353. hdrMinimumLuminance: number;
  149354. /**
  149355. * For eye adaptation, represents the decrease luminance speed
  149356. */
  149357. hdrDecreaseRate: number;
  149358. /**
  149359. * For eye adaptation, represents the increase luminance speed
  149360. */
  149361. hdrIncreaseRate: number;
  149362. /**
  149363. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  149364. */
  149365. get hdrAutoExposure(): boolean;
  149366. /**
  149367. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  149368. */
  149369. set hdrAutoExposure(value: boolean);
  149370. /**
  149371. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  149372. */
  149373. lensColorTexture: Nullable<Texture>;
  149374. /**
  149375. * The overall strengh for the lens flare effect
  149376. */
  149377. lensFlareStrength: number;
  149378. /**
  149379. * Dispersion coefficient for lens flare ghosts
  149380. */
  149381. lensFlareGhostDispersal: number;
  149382. /**
  149383. * Main lens flare halo width
  149384. */
  149385. lensFlareHaloWidth: number;
  149386. /**
  149387. * Based on the lens distortion effect, defines how much the lens flare result
  149388. * is distorted
  149389. */
  149390. lensFlareDistortionStrength: number;
  149391. /**
  149392. * Configures the blur intensity used for for lens flare (halo)
  149393. */
  149394. lensFlareBlurWidth: number;
  149395. /**
  149396. * Lens star texture must be used to simulate rays on the flares and is available
  149397. * in the documentation
  149398. */
  149399. lensStarTexture: Nullable<Texture>;
  149400. /**
  149401. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  149402. * flare effect by taking account of the dirt texture
  149403. */
  149404. lensFlareDirtTexture: Nullable<Texture>;
  149405. /**
  149406. * Represents the focal length for the depth of field effect
  149407. */
  149408. depthOfFieldDistance: number;
  149409. /**
  149410. * Represents the blur intensity for the blurred part of the depth of field effect
  149411. */
  149412. depthOfFieldBlurWidth: number;
  149413. /**
  149414. * Gets how much the image is blurred by the movement while using the motion blur post-process
  149415. */
  149416. get motionStrength(): number;
  149417. /**
  149418. * Sets how much the image is blurred by the movement while using the motion blur post-process
  149419. */
  149420. set motionStrength(strength: number);
  149421. /**
  149422. * Gets wether or not the motion blur post-process is object based or screen based.
  149423. */
  149424. get objectBasedMotionBlur(): boolean;
  149425. /**
  149426. * Sets wether or not the motion blur post-process should be object based or screen based
  149427. */
  149428. set objectBasedMotionBlur(value: boolean);
  149429. /**
  149430. * List of animations for the pipeline (IAnimatable implementation)
  149431. */
  149432. animations: Animation[];
  149433. /**
  149434. * Private members
  149435. */
  149436. private _scene;
  149437. private _currentDepthOfFieldSource;
  149438. private _basePostProcess;
  149439. private _fixedExposure;
  149440. private _currentExposure;
  149441. private _hdrAutoExposure;
  149442. private _hdrCurrentLuminance;
  149443. private _motionStrength;
  149444. private _isObjectBasedMotionBlur;
  149445. private _floatTextureType;
  149446. private _camerasToBeAttached;
  149447. private _ratio;
  149448. private _bloomEnabled;
  149449. private _depthOfFieldEnabled;
  149450. private _vlsEnabled;
  149451. private _lensFlareEnabled;
  149452. private _hdrEnabled;
  149453. private _motionBlurEnabled;
  149454. private _fxaaEnabled;
  149455. private _screenSpaceReflectionsEnabled;
  149456. private _motionBlurSamples;
  149457. private _volumetricLightStepsCount;
  149458. private _samples;
  149459. /**
  149460. * @ignore
  149461. * Specifies if the bloom pipeline is enabled
  149462. */
  149463. get BloomEnabled(): boolean;
  149464. set BloomEnabled(enabled: boolean);
  149465. /**
  149466. * @ignore
  149467. * Specifies if the depth of field pipeline is enabed
  149468. */
  149469. get DepthOfFieldEnabled(): boolean;
  149470. set DepthOfFieldEnabled(enabled: boolean);
  149471. /**
  149472. * @ignore
  149473. * Specifies if the lens flare pipeline is enabed
  149474. */
  149475. get LensFlareEnabled(): boolean;
  149476. set LensFlareEnabled(enabled: boolean);
  149477. /**
  149478. * @ignore
  149479. * Specifies if the HDR pipeline is enabled
  149480. */
  149481. get HDREnabled(): boolean;
  149482. set HDREnabled(enabled: boolean);
  149483. /**
  149484. * @ignore
  149485. * Specifies if the volumetric lights scattering effect is enabled
  149486. */
  149487. get VLSEnabled(): boolean;
  149488. set VLSEnabled(enabled: boolean);
  149489. /**
  149490. * @ignore
  149491. * Specifies if the motion blur effect is enabled
  149492. */
  149493. get MotionBlurEnabled(): boolean;
  149494. set MotionBlurEnabled(enabled: boolean);
  149495. /**
  149496. * Specifies if anti-aliasing is enabled
  149497. */
  149498. get fxaaEnabled(): boolean;
  149499. set fxaaEnabled(enabled: boolean);
  149500. /**
  149501. * Specifies if screen space reflections are enabled.
  149502. */
  149503. get screenSpaceReflectionsEnabled(): boolean;
  149504. set screenSpaceReflectionsEnabled(enabled: boolean);
  149505. /**
  149506. * Specifies the number of steps used to calculate the volumetric lights
  149507. * Typically in interval [50, 200]
  149508. */
  149509. get volumetricLightStepsCount(): number;
  149510. set volumetricLightStepsCount(count: number);
  149511. /**
  149512. * Specifies the number of samples used for the motion blur effect
  149513. * Typically in interval [16, 64]
  149514. */
  149515. get motionBlurSamples(): number;
  149516. set motionBlurSamples(samples: number);
  149517. /**
  149518. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  149519. */
  149520. get samples(): number;
  149521. set samples(sampleCount: number);
  149522. /**
  149523. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  149524. * @constructor
  149525. * @param name The rendering pipeline name
  149526. * @param scene The scene linked to this pipeline
  149527. * @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)
  149528. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  149529. * @param cameras The array of cameras that the rendering pipeline will be attached to
  149530. */
  149531. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  149532. private _buildPipeline;
  149533. private _createDownSampleX4PostProcess;
  149534. private _createBrightPassPostProcess;
  149535. private _createBlurPostProcesses;
  149536. private _createTextureAdderPostProcess;
  149537. private _createVolumetricLightPostProcess;
  149538. private _createLuminancePostProcesses;
  149539. private _createHdrPostProcess;
  149540. private _createLensFlarePostProcess;
  149541. private _createDepthOfFieldPostProcess;
  149542. private _createMotionBlurPostProcess;
  149543. private _getDepthTexture;
  149544. private _disposePostProcesses;
  149545. /**
  149546. * Dispose of the pipeline and stop all post processes
  149547. */
  149548. dispose(): void;
  149549. /**
  149550. * Serialize the rendering pipeline (Used when exporting)
  149551. * @returns the serialized object
  149552. */
  149553. serialize(): any;
  149554. /**
  149555. * Parse the serialized pipeline
  149556. * @param source Source pipeline.
  149557. * @param scene The scene to load the pipeline to.
  149558. * @param rootUrl The URL of the serialized pipeline.
  149559. * @returns An instantiated pipeline from the serialized object.
  149560. */
  149561. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  149562. /**
  149563. * Luminance steps
  149564. */
  149565. static LuminanceSteps: number;
  149566. }
  149567. }
  149568. declare module BABYLON {
  149569. /** @hidden */
  149570. export var stereoscopicInterlacePixelShader: {
  149571. name: string;
  149572. shader: string;
  149573. };
  149574. }
  149575. declare module BABYLON {
  149576. /**
  149577. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  149578. */
  149579. export class StereoscopicInterlacePostProcessI extends PostProcess {
  149580. private _stepSize;
  149581. private _passedProcess;
  149582. /**
  149583. * Initializes a StereoscopicInterlacePostProcessI
  149584. * @param name The name of the effect.
  149585. * @param rigCameras The rig cameras to be appled to the post process
  149586. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  149587. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  149588. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149589. * @param engine The engine which the post process will be applied. (default: current engine)
  149590. * @param reusable If the post process can be reused on the same frame. (default: false)
  149591. */
  149592. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149593. }
  149594. /**
  149595. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  149596. */
  149597. export class StereoscopicInterlacePostProcess extends PostProcess {
  149598. private _stepSize;
  149599. private _passedProcess;
  149600. /**
  149601. * Initializes a StereoscopicInterlacePostProcess
  149602. * @param name The name of the effect.
  149603. * @param rigCameras The rig cameras to be appled to the post process
  149604. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  149605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149606. * @param engine The engine which the post process will be applied. (default: current engine)
  149607. * @param reusable If the post process can be reused on the same frame. (default: false)
  149608. */
  149609. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149610. }
  149611. }
  149612. declare module BABYLON {
  149613. /** @hidden */
  149614. export var tonemapPixelShader: {
  149615. name: string;
  149616. shader: string;
  149617. };
  149618. }
  149619. declare module BABYLON {
  149620. /** Defines operator used for tonemapping */
  149621. export enum TonemappingOperator {
  149622. /** Hable */
  149623. Hable = 0,
  149624. /** Reinhard */
  149625. Reinhard = 1,
  149626. /** HejiDawson */
  149627. HejiDawson = 2,
  149628. /** Photographic */
  149629. Photographic = 3
  149630. }
  149631. /**
  149632. * Defines a post process to apply tone mapping
  149633. */
  149634. export class TonemapPostProcess extends PostProcess {
  149635. private _operator;
  149636. /** Defines the required exposure adjustement */
  149637. exposureAdjustment: number;
  149638. /**
  149639. * Creates a new TonemapPostProcess
  149640. * @param name defines the name of the postprocess
  149641. * @param _operator defines the operator to use
  149642. * @param exposureAdjustment defines the required exposure adjustement
  149643. * @param camera defines the camera to use (can be null)
  149644. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  149645. * @param engine defines the hosting engine (can be ignore if camera is set)
  149646. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  149647. */
  149648. constructor(name: string, _operator: TonemappingOperator,
  149649. /** Defines the required exposure adjustement */
  149650. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  149651. }
  149652. }
  149653. declare module BABYLON {
  149654. /** @hidden */
  149655. export var volumetricLightScatteringPixelShader: {
  149656. name: string;
  149657. shader: string;
  149658. };
  149659. }
  149660. declare module BABYLON {
  149661. /** @hidden */
  149662. export var volumetricLightScatteringPassVertexShader: {
  149663. name: string;
  149664. shader: string;
  149665. };
  149666. }
  149667. declare module BABYLON {
  149668. /** @hidden */
  149669. export var volumetricLightScatteringPassPixelShader: {
  149670. name: string;
  149671. shader: string;
  149672. };
  149673. }
  149674. declare module BABYLON {
  149675. /**
  149676. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  149677. */
  149678. export class VolumetricLightScatteringPostProcess extends PostProcess {
  149679. private _volumetricLightScatteringPass;
  149680. private _volumetricLightScatteringRTT;
  149681. private _viewPort;
  149682. private _screenCoordinates;
  149683. private _cachedDefines;
  149684. /**
  149685. * If not undefined, the mesh position is computed from the attached node position
  149686. */
  149687. attachedNode: {
  149688. position: Vector3;
  149689. };
  149690. /**
  149691. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  149692. */
  149693. customMeshPosition: Vector3;
  149694. /**
  149695. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  149696. */
  149697. useCustomMeshPosition: boolean;
  149698. /**
  149699. * If the post-process should inverse the light scattering direction
  149700. */
  149701. invert: boolean;
  149702. /**
  149703. * The internal mesh used by the post-process
  149704. */
  149705. mesh: Mesh;
  149706. /**
  149707. * @hidden
  149708. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  149709. */
  149710. get useDiffuseColor(): boolean;
  149711. set useDiffuseColor(useDiffuseColor: boolean);
  149712. /**
  149713. * Array containing the excluded meshes not rendered in the internal pass
  149714. */
  149715. excludedMeshes: AbstractMesh[];
  149716. /**
  149717. * Controls the overall intensity of the post-process
  149718. */
  149719. exposure: number;
  149720. /**
  149721. * Dissipates each sample's contribution in range [0, 1]
  149722. */
  149723. decay: number;
  149724. /**
  149725. * Controls the overall intensity of each sample
  149726. */
  149727. weight: number;
  149728. /**
  149729. * Controls the density of each sample
  149730. */
  149731. density: number;
  149732. /**
  149733. * @constructor
  149734. * @param name The post-process name
  149735. * @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)
  149736. * @param camera The camera that the post-process will be attached to
  149737. * @param mesh The mesh used to create the light scattering
  149738. * @param samples The post-process quality, default 100
  149739. * @param samplingModeThe post-process filtering mode
  149740. * @param engine The babylon engine
  149741. * @param reusable If the post-process is reusable
  149742. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  149743. */
  149744. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  149745. /**
  149746. * Returns the string "VolumetricLightScatteringPostProcess"
  149747. * @returns "VolumetricLightScatteringPostProcess"
  149748. */
  149749. getClassName(): string;
  149750. private _isReady;
  149751. /**
  149752. * Sets the new light position for light scattering effect
  149753. * @param position The new custom light position
  149754. */
  149755. setCustomMeshPosition(position: Vector3): void;
  149756. /**
  149757. * Returns the light position for light scattering effect
  149758. * @return Vector3 The custom light position
  149759. */
  149760. getCustomMeshPosition(): Vector3;
  149761. /**
  149762. * Disposes the internal assets and detaches the post-process from the camera
  149763. */
  149764. dispose(camera: Camera): void;
  149765. /**
  149766. * Returns the render target texture used by the post-process
  149767. * @return the render target texture used by the post-process
  149768. */
  149769. getPass(): RenderTargetTexture;
  149770. private _meshExcluded;
  149771. private _createPass;
  149772. private _updateMeshScreenCoordinates;
  149773. /**
  149774. * Creates a default mesh for the Volumeric Light Scattering post-process
  149775. * @param name The mesh name
  149776. * @param scene The scene where to create the mesh
  149777. * @return the default mesh
  149778. */
  149779. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  149780. }
  149781. }
  149782. declare module BABYLON {
  149783. /** @hidden */
  149784. export var screenSpaceCurvaturePixelShader: {
  149785. name: string;
  149786. shader: string;
  149787. };
  149788. }
  149789. declare module BABYLON {
  149790. /**
  149791. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  149792. */
  149793. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  149794. /**
  149795. * Defines how much ridge the curvature effect displays.
  149796. */
  149797. ridge: number;
  149798. /**
  149799. * Defines how much valley the curvature effect displays.
  149800. */
  149801. valley: number;
  149802. private _geometryBufferRenderer;
  149803. /**
  149804. * Creates a new instance ScreenSpaceCurvaturePostProcess
  149805. * @param name The name of the effect.
  149806. * @param scene The scene containing the objects to blur according to their velocity.
  149807. * @param options The required width/height ratio to downsize to before computing the render pass.
  149808. * @param camera The camera to apply the render pass to.
  149809. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149810. * @param engine The engine which the post process will be applied. (default: current engine)
  149811. * @param reusable If the post process can be reused on the same frame. (default: false)
  149812. * @param textureType Type of textures used when performing the post process. (default: 0)
  149813. * @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)
  149814. */
  149815. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149816. /**
  149817. * Support test.
  149818. */
  149819. static get IsSupported(): boolean;
  149820. }
  149821. }
  149822. declare module BABYLON {
  149823. interface Scene {
  149824. /** @hidden (Backing field) */
  149825. _boundingBoxRenderer: BoundingBoxRenderer;
  149826. /** @hidden (Backing field) */
  149827. _forceShowBoundingBoxes: boolean;
  149828. /**
  149829. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  149830. */
  149831. forceShowBoundingBoxes: boolean;
  149832. /**
  149833. * Gets the bounding box renderer associated with the scene
  149834. * @returns a BoundingBoxRenderer
  149835. */
  149836. getBoundingBoxRenderer(): BoundingBoxRenderer;
  149837. }
  149838. interface AbstractMesh {
  149839. /** @hidden (Backing field) */
  149840. _showBoundingBox: boolean;
  149841. /**
  149842. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  149843. */
  149844. showBoundingBox: boolean;
  149845. }
  149846. /**
  149847. * Component responsible of rendering the bounding box of the meshes in a scene.
  149848. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  149849. */
  149850. export class BoundingBoxRenderer implements ISceneComponent {
  149851. /**
  149852. * The component name helpfull to identify the component in the list of scene components.
  149853. */
  149854. readonly name: string;
  149855. /**
  149856. * The scene the component belongs to.
  149857. */
  149858. scene: Scene;
  149859. /**
  149860. * Color of the bounding box lines placed in front of an object
  149861. */
  149862. frontColor: Color3;
  149863. /**
  149864. * Color of the bounding box lines placed behind an object
  149865. */
  149866. backColor: Color3;
  149867. /**
  149868. * Defines if the renderer should show the back lines or not
  149869. */
  149870. showBackLines: boolean;
  149871. /**
  149872. * Observable raised before rendering a bounding box
  149873. */
  149874. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  149875. /**
  149876. * Observable raised after rendering a bounding box
  149877. */
  149878. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  149879. /**
  149880. * @hidden
  149881. */
  149882. renderList: SmartArray<BoundingBox>;
  149883. private _colorShader;
  149884. private _vertexBuffers;
  149885. private _indexBuffer;
  149886. private _fillIndexBuffer;
  149887. private _fillIndexData;
  149888. /**
  149889. * Instantiates a new bounding box renderer in a scene.
  149890. * @param scene the scene the renderer renders in
  149891. */
  149892. constructor(scene: Scene);
  149893. /**
  149894. * Registers the component in a given scene
  149895. */
  149896. register(): void;
  149897. private _evaluateSubMesh;
  149898. private _activeMesh;
  149899. private _prepareRessources;
  149900. private _createIndexBuffer;
  149901. /**
  149902. * Rebuilds the elements related to this component in case of
  149903. * context lost for instance.
  149904. */
  149905. rebuild(): void;
  149906. /**
  149907. * @hidden
  149908. */
  149909. reset(): void;
  149910. /**
  149911. * Render the bounding boxes of a specific rendering group
  149912. * @param renderingGroupId defines the rendering group to render
  149913. */
  149914. render(renderingGroupId: number): void;
  149915. /**
  149916. * In case of occlusion queries, we can render the occlusion bounding box through this method
  149917. * @param mesh Define the mesh to render the occlusion bounding box for
  149918. */
  149919. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  149920. /**
  149921. * Dispose and release the resources attached to this renderer.
  149922. */
  149923. dispose(): void;
  149924. }
  149925. }
  149926. declare module BABYLON {
  149927. interface Scene {
  149928. /** @hidden (Backing field) */
  149929. _depthRenderer: {
  149930. [id: string]: DepthRenderer;
  149931. };
  149932. /**
  149933. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  149934. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  149935. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  149936. * @returns the created depth renderer
  149937. */
  149938. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  149939. /**
  149940. * Disables a depth renderer for a given camera
  149941. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  149942. */
  149943. disableDepthRenderer(camera?: Nullable<Camera>): void;
  149944. }
  149945. /**
  149946. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  149947. * in several rendering techniques.
  149948. */
  149949. export class DepthRendererSceneComponent implements ISceneComponent {
  149950. /**
  149951. * The component name helpfull to identify the component in the list of scene components.
  149952. */
  149953. readonly name: string;
  149954. /**
  149955. * The scene the component belongs to.
  149956. */
  149957. scene: Scene;
  149958. /**
  149959. * Creates a new instance of the component for the given scene
  149960. * @param scene Defines the scene to register the component in
  149961. */
  149962. constructor(scene: Scene);
  149963. /**
  149964. * Registers the component in a given scene
  149965. */
  149966. register(): void;
  149967. /**
  149968. * Rebuilds the elements related to this component in case of
  149969. * context lost for instance.
  149970. */
  149971. rebuild(): void;
  149972. /**
  149973. * Disposes the component and the associated ressources
  149974. */
  149975. dispose(): void;
  149976. private _gatherRenderTargets;
  149977. private _gatherActiveCameraRenderTargets;
  149978. }
  149979. }
  149980. declare module BABYLON {
  149981. interface AbstractScene {
  149982. /** @hidden (Backing field) */
  149983. _prePassRenderer: Nullable<PrePassRenderer>;
  149984. /**
  149985. * Gets or Sets the current prepass renderer associated to the scene.
  149986. */
  149987. prePassRenderer: Nullable<PrePassRenderer>;
  149988. /**
  149989. * Enables the prepass and associates it with the scene
  149990. * @returns the PrePassRenderer
  149991. */
  149992. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  149993. /**
  149994. * Disables the prepass associated with the scene
  149995. */
  149996. disablePrePassRenderer(): void;
  149997. }
  149998. /**
  149999. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  150000. * in several rendering techniques.
  150001. */
  150002. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  150003. /**
  150004. * The component name helpful to identify the component in the list of scene components.
  150005. */
  150006. readonly name: string;
  150007. /**
  150008. * The scene the component belongs to.
  150009. */
  150010. scene: Scene;
  150011. /**
  150012. * Creates a new instance of the component for the given scene
  150013. * @param scene Defines the scene to register the component in
  150014. */
  150015. constructor(scene: Scene);
  150016. /**
  150017. * Registers the component in a given scene
  150018. */
  150019. register(): void;
  150020. private _beforeCameraDraw;
  150021. private _afterCameraDraw;
  150022. private _beforeClearStage;
  150023. /**
  150024. * Serializes the component data to the specified json object
  150025. * @param serializationObject The object to serialize to
  150026. */
  150027. serialize(serializationObject: any): void;
  150028. /**
  150029. * Adds all the elements from the container to the scene
  150030. * @param container the container holding the elements
  150031. */
  150032. addFromContainer(container: AbstractScene): void;
  150033. /**
  150034. * Removes all the elements in the container from the scene
  150035. * @param container contains the elements to remove
  150036. * @param dispose if the removed element should be disposed (default: false)
  150037. */
  150038. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  150039. /**
  150040. * Rebuilds the elements related to this component in case of
  150041. * context lost for instance.
  150042. */
  150043. rebuild(): void;
  150044. /**
  150045. * Disposes the component and the associated ressources
  150046. */
  150047. dispose(): void;
  150048. }
  150049. }
  150050. declare module BABYLON {
  150051. /** @hidden */
  150052. export var outlinePixelShader: {
  150053. name: string;
  150054. shader: string;
  150055. };
  150056. }
  150057. declare module BABYLON {
  150058. /** @hidden */
  150059. export var outlineVertexShader: {
  150060. name: string;
  150061. shader: string;
  150062. };
  150063. }
  150064. declare module BABYLON {
  150065. interface Scene {
  150066. /** @hidden */
  150067. _outlineRenderer: OutlineRenderer;
  150068. /**
  150069. * Gets the outline renderer associated with the scene
  150070. * @returns a OutlineRenderer
  150071. */
  150072. getOutlineRenderer(): OutlineRenderer;
  150073. }
  150074. interface AbstractMesh {
  150075. /** @hidden (Backing field) */
  150076. _renderOutline: boolean;
  150077. /**
  150078. * Gets or sets a boolean indicating if the outline must be rendered as well
  150079. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  150080. */
  150081. renderOutline: boolean;
  150082. /** @hidden (Backing field) */
  150083. _renderOverlay: boolean;
  150084. /**
  150085. * Gets or sets a boolean indicating if the overlay must be rendered as well
  150086. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  150087. */
  150088. renderOverlay: boolean;
  150089. }
  150090. /**
  150091. * This class is responsible to draw bothe outline/overlay of meshes.
  150092. * It should not be used directly but through the available method on mesh.
  150093. */
  150094. export class OutlineRenderer implements ISceneComponent {
  150095. /**
  150096. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  150097. */
  150098. private static _StencilReference;
  150099. /**
  150100. * The name of the component. Each component must have a unique name.
  150101. */
  150102. name: string;
  150103. /**
  150104. * The scene the component belongs to.
  150105. */
  150106. scene: Scene;
  150107. /**
  150108. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  150109. */
  150110. zOffset: number;
  150111. private _engine;
  150112. private _effect;
  150113. private _cachedDefines;
  150114. private _savedDepthWrite;
  150115. /**
  150116. * Instantiates a new outline renderer. (There could be only one per scene).
  150117. * @param scene Defines the scene it belongs to
  150118. */
  150119. constructor(scene: Scene);
  150120. /**
  150121. * Register the component to one instance of a scene.
  150122. */
  150123. register(): void;
  150124. /**
  150125. * Rebuilds the elements related to this component in case of
  150126. * context lost for instance.
  150127. */
  150128. rebuild(): void;
  150129. /**
  150130. * Disposes the component and the associated ressources.
  150131. */
  150132. dispose(): void;
  150133. /**
  150134. * Renders the outline in the canvas.
  150135. * @param subMesh Defines the sumesh to render
  150136. * @param batch Defines the batch of meshes in case of instances
  150137. * @param useOverlay Defines if the rendering is for the overlay or the outline
  150138. */
  150139. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  150140. /**
  150141. * Returns whether or not the outline renderer is ready for a given submesh.
  150142. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  150143. * @param subMesh Defines the submesh to check readyness for
  150144. * @param useInstances Defines wheter wee are trying to render instances or not
  150145. * @returns true if ready otherwise false
  150146. */
  150147. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  150148. private _beforeRenderingMesh;
  150149. private _afterRenderingMesh;
  150150. }
  150151. }
  150152. declare module BABYLON {
  150153. /**
  150154. * Defines the basic options interface of a Sprite Frame Source Size.
  150155. */
  150156. export interface ISpriteJSONSpriteSourceSize {
  150157. /**
  150158. * number of the original width of the Frame
  150159. */
  150160. w: number;
  150161. /**
  150162. * number of the original height of the Frame
  150163. */
  150164. h: number;
  150165. }
  150166. /**
  150167. * Defines the basic options interface of a Sprite Frame Data.
  150168. */
  150169. export interface ISpriteJSONSpriteFrameData {
  150170. /**
  150171. * number of the x offset of the Frame
  150172. */
  150173. x: number;
  150174. /**
  150175. * number of the y offset of the Frame
  150176. */
  150177. y: number;
  150178. /**
  150179. * number of the width of the Frame
  150180. */
  150181. w: number;
  150182. /**
  150183. * number of the height of the Frame
  150184. */
  150185. h: number;
  150186. }
  150187. /**
  150188. * Defines the basic options interface of a JSON Sprite.
  150189. */
  150190. export interface ISpriteJSONSprite {
  150191. /**
  150192. * string name of the Frame
  150193. */
  150194. filename: string;
  150195. /**
  150196. * ISpriteJSONSpriteFrame basic object of the frame data
  150197. */
  150198. frame: ISpriteJSONSpriteFrameData;
  150199. /**
  150200. * boolean to flag is the frame was rotated.
  150201. */
  150202. rotated: boolean;
  150203. /**
  150204. * boolean to flag is the frame was trimmed.
  150205. */
  150206. trimmed: boolean;
  150207. /**
  150208. * ISpriteJSONSpriteFrame basic object of the source data
  150209. */
  150210. spriteSourceSize: ISpriteJSONSpriteFrameData;
  150211. /**
  150212. * ISpriteJSONSpriteFrame basic object of the source data
  150213. */
  150214. sourceSize: ISpriteJSONSpriteSourceSize;
  150215. }
  150216. /**
  150217. * Defines the basic options interface of a JSON atlas.
  150218. */
  150219. export interface ISpriteJSONAtlas {
  150220. /**
  150221. * Array of objects that contain the frame data.
  150222. */
  150223. frames: Array<ISpriteJSONSprite>;
  150224. /**
  150225. * object basic object containing the sprite meta data.
  150226. */
  150227. meta?: object;
  150228. }
  150229. }
  150230. declare module BABYLON {
  150231. /** @hidden */
  150232. export var spriteMapPixelShader: {
  150233. name: string;
  150234. shader: string;
  150235. };
  150236. }
  150237. declare module BABYLON {
  150238. /** @hidden */
  150239. export var spriteMapVertexShader: {
  150240. name: string;
  150241. shader: string;
  150242. };
  150243. }
  150244. declare module BABYLON {
  150245. /**
  150246. * Defines the basic options interface of a SpriteMap
  150247. */
  150248. export interface ISpriteMapOptions {
  150249. /**
  150250. * Vector2 of the number of cells in the grid.
  150251. */
  150252. stageSize?: Vector2;
  150253. /**
  150254. * Vector2 of the size of the output plane in World Units.
  150255. */
  150256. outputSize?: Vector2;
  150257. /**
  150258. * Vector3 of the position of the output plane in World Units.
  150259. */
  150260. outputPosition?: Vector3;
  150261. /**
  150262. * Vector3 of the rotation of the output plane.
  150263. */
  150264. outputRotation?: Vector3;
  150265. /**
  150266. * number of layers that the system will reserve in resources.
  150267. */
  150268. layerCount?: number;
  150269. /**
  150270. * number of max animation frames a single cell will reserve in resources.
  150271. */
  150272. maxAnimationFrames?: number;
  150273. /**
  150274. * number cell index of the base tile when the system compiles.
  150275. */
  150276. baseTile?: number;
  150277. /**
  150278. * boolean flip the sprite after its been repositioned by the framing data.
  150279. */
  150280. flipU?: boolean;
  150281. /**
  150282. * Vector3 scalar of the global RGB values of the SpriteMap.
  150283. */
  150284. colorMultiply?: Vector3;
  150285. }
  150286. /**
  150287. * Defines the IDisposable interface in order to be cleanable from resources.
  150288. */
  150289. export interface ISpriteMap extends IDisposable {
  150290. /**
  150291. * String name of the SpriteMap.
  150292. */
  150293. name: string;
  150294. /**
  150295. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  150296. */
  150297. atlasJSON: ISpriteJSONAtlas;
  150298. /**
  150299. * Texture of the SpriteMap.
  150300. */
  150301. spriteSheet: Texture;
  150302. /**
  150303. * The parameters to initialize the SpriteMap with.
  150304. */
  150305. options: ISpriteMapOptions;
  150306. }
  150307. /**
  150308. * Class used to manage a grid restricted sprite deployment on an Output plane.
  150309. */
  150310. export class SpriteMap implements ISpriteMap {
  150311. /** The Name of the spriteMap */
  150312. name: string;
  150313. /** The JSON file with the frame and meta data */
  150314. atlasJSON: ISpriteJSONAtlas;
  150315. /** The systems Sprite Sheet Texture */
  150316. spriteSheet: Texture;
  150317. /** Arguments passed with the Constructor */
  150318. options: ISpriteMapOptions;
  150319. /** Public Sprite Storage array, parsed from atlasJSON */
  150320. sprites: Array<ISpriteJSONSprite>;
  150321. /** Returns the Number of Sprites in the System */
  150322. get spriteCount(): number;
  150323. /** Returns the Position of Output Plane*/
  150324. get position(): Vector3;
  150325. /** Returns the Position of Output Plane*/
  150326. set position(v: Vector3);
  150327. /** Returns the Rotation of Output Plane*/
  150328. get rotation(): Vector3;
  150329. /** Returns the Rotation of Output Plane*/
  150330. set rotation(v: Vector3);
  150331. /** Sets the AnimationMap*/
  150332. get animationMap(): RawTexture;
  150333. /** Sets the AnimationMap*/
  150334. set animationMap(v: RawTexture);
  150335. /** Scene that the SpriteMap was created in */
  150336. private _scene;
  150337. /** Texture Buffer of Float32 that holds tile frame data*/
  150338. private _frameMap;
  150339. /** Texture Buffers of Float32 that holds tileMap data*/
  150340. private _tileMaps;
  150341. /** Texture Buffer of Float32 that holds Animation Data*/
  150342. private _animationMap;
  150343. /** Custom ShaderMaterial Central to the System*/
  150344. private _material;
  150345. /** Custom ShaderMaterial Central to the System*/
  150346. private _output;
  150347. /** Systems Time Ticker*/
  150348. private _time;
  150349. /**
  150350. * Creates a new SpriteMap
  150351. * @param name defines the SpriteMaps Name
  150352. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  150353. * @param spriteSheet is the Texture that the Sprites are on.
  150354. * @param options a basic deployment configuration
  150355. * @param scene The Scene that the map is deployed on
  150356. */
  150357. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  150358. /**
  150359. * Returns tileID location
  150360. * @returns Vector2 the cell position ID
  150361. */
  150362. getTileID(): Vector2;
  150363. /**
  150364. * Gets the UV location of the mouse over the SpriteMap.
  150365. * @returns Vector2 the UV position of the mouse interaction
  150366. */
  150367. getMousePosition(): Vector2;
  150368. /**
  150369. * Creates the "frame" texture Buffer
  150370. * -------------------------------------
  150371. * Structure of frames
  150372. * "filename": "Falling-Water-2.png",
  150373. * "frame": {"x":69,"y":103,"w":24,"h":32},
  150374. * "rotated": true,
  150375. * "trimmed": true,
  150376. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  150377. * "sourceSize": {"w":32,"h":32}
  150378. * @returns RawTexture of the frameMap
  150379. */
  150380. private _createFrameBuffer;
  150381. /**
  150382. * Creates the tileMap texture Buffer
  150383. * @param buffer normally and array of numbers, or a false to generate from scratch
  150384. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  150385. * @returns RawTexture of the tileMap
  150386. */
  150387. private _createTileBuffer;
  150388. /**
  150389. * Modifies the data of the tileMaps
  150390. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  150391. * @param pos is the iVector2 Coordinates of the Tile
  150392. * @param tile The SpriteIndex of the new Tile
  150393. */
  150394. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  150395. /**
  150396. * Creates the animationMap texture Buffer
  150397. * @param buffer normally and array of numbers, or a false to generate from scratch
  150398. * @returns RawTexture of the animationMap
  150399. */
  150400. private _createTileAnimationBuffer;
  150401. /**
  150402. * Modifies the data of the animationMap
  150403. * @param cellID is the Index of the Sprite
  150404. * @param _frame is the target Animation frame
  150405. * @param toCell is the Target Index of the next frame of the animation
  150406. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  150407. * @param speed is a global scalar of the time variable on the map.
  150408. */
  150409. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  150410. /**
  150411. * Exports the .tilemaps file
  150412. */
  150413. saveTileMaps(): void;
  150414. /**
  150415. * Imports the .tilemaps file
  150416. * @param url of the .tilemaps file
  150417. */
  150418. loadTileMaps(url: string): void;
  150419. /**
  150420. * Release associated resources
  150421. */
  150422. dispose(): void;
  150423. }
  150424. }
  150425. declare module BABYLON {
  150426. /**
  150427. * Class used to manage multiple sprites of different sizes on the same spritesheet
  150428. * @see https://doc.babylonjs.com/babylon101/sprites
  150429. */
  150430. export class SpritePackedManager extends SpriteManager {
  150431. /** defines the packed manager's name */
  150432. name: string;
  150433. /**
  150434. * Creates a new sprite manager from a packed sprite sheet
  150435. * @param name defines the manager's name
  150436. * @param imgUrl defines the sprite sheet url
  150437. * @param capacity defines the maximum allowed number of sprites
  150438. * @param scene defines the hosting scene
  150439. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  150440. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  150441. * @param samplingMode defines the smapling mode to use with spritesheet
  150442. * @param fromPacked set to true; do not alter
  150443. */
  150444. constructor(
  150445. /** defines the packed manager's name */
  150446. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  150447. }
  150448. }
  150449. declare module BABYLON {
  150450. /**
  150451. * Defines the list of states available for a task inside a AssetsManager
  150452. */
  150453. export enum AssetTaskState {
  150454. /**
  150455. * Initialization
  150456. */
  150457. INIT = 0,
  150458. /**
  150459. * Running
  150460. */
  150461. RUNNING = 1,
  150462. /**
  150463. * Done
  150464. */
  150465. DONE = 2,
  150466. /**
  150467. * Error
  150468. */
  150469. ERROR = 3
  150470. }
  150471. /**
  150472. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  150473. */
  150474. export abstract class AbstractAssetTask {
  150475. /**
  150476. * Task name
  150477. */ name: string;
  150478. /**
  150479. * Callback called when the task is successful
  150480. */
  150481. onSuccess: (task: any) => void;
  150482. /**
  150483. * Callback called when the task is not successful
  150484. */
  150485. onError: (task: any, message?: string, exception?: any) => void;
  150486. /**
  150487. * Creates a new AssetsManager
  150488. * @param name defines the name of the task
  150489. */
  150490. constructor(
  150491. /**
  150492. * Task name
  150493. */ name: string);
  150494. private _isCompleted;
  150495. private _taskState;
  150496. private _errorObject;
  150497. /**
  150498. * Get if the task is completed
  150499. */
  150500. get isCompleted(): boolean;
  150501. /**
  150502. * Gets the current state of the task
  150503. */
  150504. get taskState(): AssetTaskState;
  150505. /**
  150506. * Gets the current error object (if task is in error)
  150507. */
  150508. get errorObject(): {
  150509. message?: string;
  150510. exception?: any;
  150511. };
  150512. /**
  150513. * Internal only
  150514. * @hidden
  150515. */
  150516. _setErrorObject(message?: string, exception?: any): void;
  150517. /**
  150518. * Execute the current task
  150519. * @param scene defines the scene where you want your assets to be loaded
  150520. * @param onSuccess is a callback called when the task is successfully executed
  150521. * @param onError is a callback called if an error occurs
  150522. */
  150523. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150524. /**
  150525. * Execute the current task
  150526. * @param scene defines the scene where you want your assets to be loaded
  150527. * @param onSuccess is a callback called when the task is successfully executed
  150528. * @param onError is a callback called if an error occurs
  150529. */
  150530. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150531. /**
  150532. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  150533. * This can be used with failed tasks that have the reason for failure fixed.
  150534. */
  150535. reset(): void;
  150536. private onErrorCallback;
  150537. private onDoneCallback;
  150538. }
  150539. /**
  150540. * Define the interface used by progress events raised during assets loading
  150541. */
  150542. export interface IAssetsProgressEvent {
  150543. /**
  150544. * Defines the number of remaining tasks to process
  150545. */
  150546. remainingCount: number;
  150547. /**
  150548. * Defines the total number of tasks
  150549. */
  150550. totalCount: number;
  150551. /**
  150552. * Defines the task that was just processed
  150553. */
  150554. task: AbstractAssetTask;
  150555. }
  150556. /**
  150557. * Class used to share progress information about assets loading
  150558. */
  150559. export class AssetsProgressEvent implements IAssetsProgressEvent {
  150560. /**
  150561. * Defines the number of remaining tasks to process
  150562. */
  150563. remainingCount: number;
  150564. /**
  150565. * Defines the total number of tasks
  150566. */
  150567. totalCount: number;
  150568. /**
  150569. * Defines the task that was just processed
  150570. */
  150571. task: AbstractAssetTask;
  150572. /**
  150573. * Creates a AssetsProgressEvent
  150574. * @param remainingCount defines the number of remaining tasks to process
  150575. * @param totalCount defines the total number of tasks
  150576. * @param task defines the task that was just processed
  150577. */
  150578. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  150579. }
  150580. /**
  150581. * Define a task used by AssetsManager to load meshes
  150582. */
  150583. export class MeshAssetTask extends AbstractAssetTask {
  150584. /**
  150585. * Defines the name of the task
  150586. */
  150587. name: string;
  150588. /**
  150589. * Defines the list of mesh's names you want to load
  150590. */
  150591. meshesNames: any;
  150592. /**
  150593. * Defines the root url to use as a base to load your meshes and associated resources
  150594. */
  150595. rootUrl: string;
  150596. /**
  150597. * Defines the filename or File of the scene to load from
  150598. */
  150599. sceneFilename: string | File;
  150600. /**
  150601. * Gets the list of loaded meshes
  150602. */
  150603. loadedMeshes: Array<AbstractMesh>;
  150604. /**
  150605. * Gets the list of loaded particle systems
  150606. */
  150607. loadedParticleSystems: Array<IParticleSystem>;
  150608. /**
  150609. * Gets the list of loaded skeletons
  150610. */
  150611. loadedSkeletons: Array<Skeleton>;
  150612. /**
  150613. * Gets the list of loaded animation groups
  150614. */
  150615. loadedAnimationGroups: Array<AnimationGroup>;
  150616. /**
  150617. * Callback called when the task is successful
  150618. */
  150619. onSuccess: (task: MeshAssetTask) => void;
  150620. /**
  150621. * Callback called when the task is successful
  150622. */
  150623. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  150624. /**
  150625. * Creates a new MeshAssetTask
  150626. * @param name defines the name of the task
  150627. * @param meshesNames defines the list of mesh's names you want to load
  150628. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  150629. * @param sceneFilename defines the filename or File of the scene to load from
  150630. */
  150631. constructor(
  150632. /**
  150633. * Defines the name of the task
  150634. */
  150635. name: string,
  150636. /**
  150637. * Defines the list of mesh's names you want to load
  150638. */
  150639. meshesNames: any,
  150640. /**
  150641. * Defines the root url to use as a base to load your meshes and associated resources
  150642. */
  150643. rootUrl: string,
  150644. /**
  150645. * Defines the filename or File of the scene to load from
  150646. */
  150647. sceneFilename: string | File);
  150648. /**
  150649. * Execute the current task
  150650. * @param scene defines the scene where you want your assets to be loaded
  150651. * @param onSuccess is a callback called when the task is successfully executed
  150652. * @param onError is a callback called if an error occurs
  150653. */
  150654. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150655. }
  150656. /**
  150657. * Define a task used by AssetsManager to load text content
  150658. */
  150659. export class TextFileAssetTask extends AbstractAssetTask {
  150660. /**
  150661. * Defines the name of the task
  150662. */
  150663. name: string;
  150664. /**
  150665. * Defines the location of the file to load
  150666. */
  150667. url: string;
  150668. /**
  150669. * Gets the loaded text string
  150670. */
  150671. text: string;
  150672. /**
  150673. * Callback called when the task is successful
  150674. */
  150675. onSuccess: (task: TextFileAssetTask) => void;
  150676. /**
  150677. * Callback called when the task is successful
  150678. */
  150679. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  150680. /**
  150681. * Creates a new TextFileAssetTask object
  150682. * @param name defines the name of the task
  150683. * @param url defines the location of the file to load
  150684. */
  150685. constructor(
  150686. /**
  150687. * Defines the name of the task
  150688. */
  150689. name: string,
  150690. /**
  150691. * Defines the location of the file to load
  150692. */
  150693. url: string);
  150694. /**
  150695. * Execute the current task
  150696. * @param scene defines the scene where you want your assets to be loaded
  150697. * @param onSuccess is a callback called when the task is successfully executed
  150698. * @param onError is a callback called if an error occurs
  150699. */
  150700. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150701. }
  150702. /**
  150703. * Define a task used by AssetsManager to load binary data
  150704. */
  150705. export class BinaryFileAssetTask extends AbstractAssetTask {
  150706. /**
  150707. * Defines the name of the task
  150708. */
  150709. name: string;
  150710. /**
  150711. * Defines the location of the file to load
  150712. */
  150713. url: string;
  150714. /**
  150715. * Gets the lodaded data (as an array buffer)
  150716. */
  150717. data: ArrayBuffer;
  150718. /**
  150719. * Callback called when the task is successful
  150720. */
  150721. onSuccess: (task: BinaryFileAssetTask) => void;
  150722. /**
  150723. * Callback called when the task is successful
  150724. */
  150725. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  150726. /**
  150727. * Creates a new BinaryFileAssetTask object
  150728. * @param name defines the name of the new task
  150729. * @param url defines the location of the file to load
  150730. */
  150731. constructor(
  150732. /**
  150733. * Defines the name of the task
  150734. */
  150735. name: string,
  150736. /**
  150737. * Defines the location of the file to load
  150738. */
  150739. url: string);
  150740. /**
  150741. * Execute the current task
  150742. * @param scene defines the scene where you want your assets to be loaded
  150743. * @param onSuccess is a callback called when the task is successfully executed
  150744. * @param onError is a callback called if an error occurs
  150745. */
  150746. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150747. }
  150748. /**
  150749. * Define a task used by AssetsManager to load images
  150750. */
  150751. export class ImageAssetTask extends AbstractAssetTask {
  150752. /**
  150753. * Defines the name of the task
  150754. */
  150755. name: string;
  150756. /**
  150757. * Defines the location of the image to load
  150758. */
  150759. url: string;
  150760. /**
  150761. * Gets the loaded images
  150762. */
  150763. image: HTMLImageElement;
  150764. /**
  150765. * Callback called when the task is successful
  150766. */
  150767. onSuccess: (task: ImageAssetTask) => void;
  150768. /**
  150769. * Callback called when the task is successful
  150770. */
  150771. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  150772. /**
  150773. * Creates a new ImageAssetTask
  150774. * @param name defines the name of the task
  150775. * @param url defines the location of the image to load
  150776. */
  150777. constructor(
  150778. /**
  150779. * Defines the name of the task
  150780. */
  150781. name: string,
  150782. /**
  150783. * Defines the location of the image to load
  150784. */
  150785. url: string);
  150786. /**
  150787. * Execute the current task
  150788. * @param scene defines the scene where you want your assets to be loaded
  150789. * @param onSuccess is a callback called when the task is successfully executed
  150790. * @param onError is a callback called if an error occurs
  150791. */
  150792. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150793. }
  150794. /**
  150795. * Defines the interface used by texture loading tasks
  150796. */
  150797. export interface ITextureAssetTask<TEX extends BaseTexture> {
  150798. /**
  150799. * Gets the loaded texture
  150800. */
  150801. texture: TEX;
  150802. }
  150803. /**
  150804. * Define a task used by AssetsManager to load 2D textures
  150805. */
  150806. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  150807. /**
  150808. * Defines the name of the task
  150809. */
  150810. name: string;
  150811. /**
  150812. * Defines the location of the file to load
  150813. */
  150814. url: string;
  150815. /**
  150816. * Defines if mipmap should not be generated (default is false)
  150817. */
  150818. noMipmap?: boolean | undefined;
  150819. /**
  150820. * Defines if texture must be inverted on Y axis (default is true)
  150821. */
  150822. invertY: boolean;
  150823. /**
  150824. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150825. */
  150826. samplingMode: number;
  150827. /**
  150828. * Gets the loaded texture
  150829. */
  150830. texture: Texture;
  150831. /**
  150832. * Callback called when the task is successful
  150833. */
  150834. onSuccess: (task: TextureAssetTask) => void;
  150835. /**
  150836. * Callback called when the task is successful
  150837. */
  150838. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  150839. /**
  150840. * Creates a new TextureAssetTask object
  150841. * @param name defines the name of the task
  150842. * @param url defines the location of the file to load
  150843. * @param noMipmap defines if mipmap should not be generated (default is false)
  150844. * @param invertY defines if texture must be inverted on Y axis (default is true)
  150845. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150846. */
  150847. constructor(
  150848. /**
  150849. * Defines the name of the task
  150850. */
  150851. name: string,
  150852. /**
  150853. * Defines the location of the file to load
  150854. */
  150855. url: string,
  150856. /**
  150857. * Defines if mipmap should not be generated (default is false)
  150858. */
  150859. noMipmap?: boolean | undefined,
  150860. /**
  150861. * Defines if texture must be inverted on Y axis (default is true)
  150862. */
  150863. invertY?: boolean,
  150864. /**
  150865. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150866. */
  150867. samplingMode?: number);
  150868. /**
  150869. * Execute the current task
  150870. * @param scene defines the scene where you want your assets to be loaded
  150871. * @param onSuccess is a callback called when the task is successfully executed
  150872. * @param onError is a callback called if an error occurs
  150873. */
  150874. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150875. }
  150876. /**
  150877. * Define a task used by AssetsManager to load cube textures
  150878. */
  150879. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  150880. /**
  150881. * Defines the name of the task
  150882. */
  150883. name: string;
  150884. /**
  150885. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150886. */
  150887. url: string;
  150888. /**
  150889. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150890. */
  150891. extensions?: string[] | undefined;
  150892. /**
  150893. * Defines if mipmaps should not be generated (default is false)
  150894. */
  150895. noMipmap?: boolean | undefined;
  150896. /**
  150897. * Defines the explicit list of files (undefined by default)
  150898. */
  150899. files?: string[] | undefined;
  150900. /**
  150901. * Gets the loaded texture
  150902. */
  150903. texture: CubeTexture;
  150904. /**
  150905. * Callback called when the task is successful
  150906. */
  150907. onSuccess: (task: CubeTextureAssetTask) => void;
  150908. /**
  150909. * Callback called when the task is successful
  150910. */
  150911. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  150912. /**
  150913. * Creates a new CubeTextureAssetTask
  150914. * @param name defines the name of the task
  150915. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150916. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150917. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150918. * @param files defines the explicit list of files (undefined by default)
  150919. */
  150920. constructor(
  150921. /**
  150922. * Defines the name of the task
  150923. */
  150924. name: string,
  150925. /**
  150926. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150927. */
  150928. url: string,
  150929. /**
  150930. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150931. */
  150932. extensions?: string[] | undefined,
  150933. /**
  150934. * Defines if mipmaps should not be generated (default is false)
  150935. */
  150936. noMipmap?: boolean | undefined,
  150937. /**
  150938. * Defines the explicit list of files (undefined by default)
  150939. */
  150940. files?: string[] | undefined);
  150941. /**
  150942. * Execute the current task
  150943. * @param scene defines the scene where you want your assets to be loaded
  150944. * @param onSuccess is a callback called when the task is successfully executed
  150945. * @param onError is a callback called if an error occurs
  150946. */
  150947. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150948. }
  150949. /**
  150950. * Define a task used by AssetsManager to load HDR cube textures
  150951. */
  150952. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  150953. /**
  150954. * Defines the name of the task
  150955. */
  150956. name: string;
  150957. /**
  150958. * Defines the location of the file to load
  150959. */
  150960. url: string;
  150961. /**
  150962. * Defines the desired size (the more it increases the longer the generation will be)
  150963. */
  150964. size: number;
  150965. /**
  150966. * Defines if mipmaps should not be generated (default is false)
  150967. */
  150968. noMipmap: boolean;
  150969. /**
  150970. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150971. */
  150972. generateHarmonics: boolean;
  150973. /**
  150974. * 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)
  150975. */
  150976. gammaSpace: boolean;
  150977. /**
  150978. * Internal Use Only
  150979. */
  150980. reserved: boolean;
  150981. /**
  150982. * Gets the loaded texture
  150983. */
  150984. texture: HDRCubeTexture;
  150985. /**
  150986. * Callback called when the task is successful
  150987. */
  150988. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  150989. /**
  150990. * Callback called when the task is successful
  150991. */
  150992. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  150993. /**
  150994. * Creates a new HDRCubeTextureAssetTask object
  150995. * @param name defines the name of the task
  150996. * @param url defines the location of the file to load
  150997. * @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.
  150998. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150999. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151000. * @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)
  151001. * @param reserved Internal use only
  151002. */
  151003. constructor(
  151004. /**
  151005. * Defines the name of the task
  151006. */
  151007. name: string,
  151008. /**
  151009. * Defines the location of the file to load
  151010. */
  151011. url: string,
  151012. /**
  151013. * Defines the desired size (the more it increases the longer the generation will be)
  151014. */
  151015. size: number,
  151016. /**
  151017. * Defines if mipmaps should not be generated (default is false)
  151018. */
  151019. noMipmap?: boolean,
  151020. /**
  151021. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151022. */
  151023. generateHarmonics?: boolean,
  151024. /**
  151025. * 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)
  151026. */
  151027. gammaSpace?: boolean,
  151028. /**
  151029. * Internal Use Only
  151030. */
  151031. reserved?: boolean);
  151032. /**
  151033. * Execute the current task
  151034. * @param scene defines the scene where you want your assets to be loaded
  151035. * @param onSuccess is a callback called when the task is successfully executed
  151036. * @param onError is a callback called if an error occurs
  151037. */
  151038. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151039. }
  151040. /**
  151041. * Define a task used by AssetsManager to load Equirectangular cube textures
  151042. */
  151043. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  151044. /**
  151045. * Defines the name of the task
  151046. */
  151047. name: string;
  151048. /**
  151049. * Defines the location of the file to load
  151050. */
  151051. url: string;
  151052. /**
  151053. * Defines the desired size (the more it increases the longer the generation will be)
  151054. */
  151055. size: number;
  151056. /**
  151057. * Defines if mipmaps should not be generated (default is false)
  151058. */
  151059. noMipmap: boolean;
  151060. /**
  151061. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  151062. * but the standard material would require them in Gamma space) (default is true)
  151063. */
  151064. gammaSpace: boolean;
  151065. /**
  151066. * Gets the loaded texture
  151067. */
  151068. texture: EquiRectangularCubeTexture;
  151069. /**
  151070. * Callback called when the task is successful
  151071. */
  151072. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  151073. /**
  151074. * Callback called when the task is successful
  151075. */
  151076. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  151077. /**
  151078. * Creates a new EquiRectangularCubeTextureAssetTask object
  151079. * @param name defines the name of the task
  151080. * @param url defines the location of the file to load
  151081. * @param size defines the desired size (the more it increases the longer the generation will be)
  151082. * If the size is omitted this implies you are using a preprocessed cubemap.
  151083. * @param noMipmap defines if mipmaps should not be generated (default is false)
  151084. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  151085. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  151086. * (default is true)
  151087. */
  151088. constructor(
  151089. /**
  151090. * Defines the name of the task
  151091. */
  151092. name: string,
  151093. /**
  151094. * Defines the location of the file to load
  151095. */
  151096. url: string,
  151097. /**
  151098. * Defines the desired size (the more it increases the longer the generation will be)
  151099. */
  151100. size: number,
  151101. /**
  151102. * Defines if mipmaps should not be generated (default is false)
  151103. */
  151104. noMipmap?: boolean,
  151105. /**
  151106. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  151107. * but the standard material would require them in Gamma space) (default is true)
  151108. */
  151109. gammaSpace?: boolean);
  151110. /**
  151111. * Execute the current task
  151112. * @param scene defines the scene where you want your assets to be loaded
  151113. * @param onSuccess is a callback called when the task is successfully executed
  151114. * @param onError is a callback called if an error occurs
  151115. */
  151116. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151117. }
  151118. /**
  151119. * This class can be used to easily import assets into a scene
  151120. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  151121. */
  151122. export class AssetsManager {
  151123. private _scene;
  151124. private _isLoading;
  151125. protected _tasks: AbstractAssetTask[];
  151126. protected _waitingTasksCount: number;
  151127. protected _totalTasksCount: number;
  151128. /**
  151129. * Callback called when all tasks are processed
  151130. */
  151131. onFinish: (tasks: AbstractAssetTask[]) => void;
  151132. /**
  151133. * Callback called when a task is successful
  151134. */
  151135. onTaskSuccess: (task: AbstractAssetTask) => void;
  151136. /**
  151137. * Callback called when a task had an error
  151138. */
  151139. onTaskError: (task: AbstractAssetTask) => void;
  151140. /**
  151141. * Callback called when a task is done (whatever the result is)
  151142. */
  151143. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  151144. /**
  151145. * Observable called when all tasks are processed
  151146. */
  151147. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  151148. /**
  151149. * Observable called when a task had an error
  151150. */
  151151. onTaskErrorObservable: Observable<AbstractAssetTask>;
  151152. /**
  151153. * Observable called when all tasks were executed
  151154. */
  151155. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  151156. /**
  151157. * Observable called when a task is done (whatever the result is)
  151158. */
  151159. onProgressObservable: Observable<IAssetsProgressEvent>;
  151160. /**
  151161. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  151162. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  151163. */
  151164. useDefaultLoadingScreen: boolean;
  151165. /**
  151166. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  151167. * when all assets have been downloaded.
  151168. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  151169. */
  151170. autoHideLoadingUI: boolean;
  151171. /**
  151172. * Creates a new AssetsManager
  151173. * @param scene defines the scene to work on
  151174. */
  151175. constructor(scene: Scene);
  151176. /**
  151177. * Add a MeshAssetTask to the list of active tasks
  151178. * @param taskName defines the name of the new task
  151179. * @param meshesNames defines the name of meshes to load
  151180. * @param rootUrl defines the root url to use to locate files
  151181. * @param sceneFilename defines the filename of the scene file
  151182. * @returns a new MeshAssetTask object
  151183. */
  151184. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  151185. /**
  151186. * Add a TextFileAssetTask to the list of active tasks
  151187. * @param taskName defines the name of the new task
  151188. * @param url defines the url of the file to load
  151189. * @returns a new TextFileAssetTask object
  151190. */
  151191. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  151192. /**
  151193. * Add a BinaryFileAssetTask to the list of active tasks
  151194. * @param taskName defines the name of the new task
  151195. * @param url defines the url of the file to load
  151196. * @returns a new BinaryFileAssetTask object
  151197. */
  151198. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  151199. /**
  151200. * Add a ImageAssetTask to the list of active tasks
  151201. * @param taskName defines the name of the new task
  151202. * @param url defines the url of the file to load
  151203. * @returns a new ImageAssetTask object
  151204. */
  151205. addImageTask(taskName: string, url: string): ImageAssetTask;
  151206. /**
  151207. * Add a TextureAssetTask to the list of active tasks
  151208. * @param taskName defines the name of the new task
  151209. * @param url defines the url of the file to load
  151210. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151211. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  151212. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  151213. * @returns a new TextureAssetTask object
  151214. */
  151215. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  151216. /**
  151217. * Add a CubeTextureAssetTask to the list of active tasks
  151218. * @param taskName defines the name of the new task
  151219. * @param url defines the url of the file to load
  151220. * @param extensions defines the extension to use to load the cube map (can be null)
  151221. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151222. * @param files defines the list of files to load (can be null)
  151223. * @returns a new CubeTextureAssetTask object
  151224. */
  151225. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  151226. /**
  151227. *
  151228. * Add a HDRCubeTextureAssetTask to the list of active tasks
  151229. * @param taskName defines the name of the new task
  151230. * @param url defines the url of the file to load
  151231. * @param size defines the size you want for the cubemap (can be null)
  151232. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151233. * @param generateHarmonics defines if you want to automatically generate (true by default)
  151234. * @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)
  151235. * @param reserved Internal use only
  151236. * @returns a new HDRCubeTextureAssetTask object
  151237. */
  151238. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  151239. /**
  151240. *
  151241. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  151242. * @param taskName defines the name of the new task
  151243. * @param url defines the url of the file to load
  151244. * @param size defines the size you want for the cubemap (can be null)
  151245. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151246. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  151247. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  151248. * @returns a new EquiRectangularCubeTextureAssetTask object
  151249. */
  151250. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  151251. /**
  151252. * Remove a task from the assets manager.
  151253. * @param task the task to remove
  151254. */
  151255. removeTask(task: AbstractAssetTask): void;
  151256. private _decreaseWaitingTasksCount;
  151257. private _runTask;
  151258. /**
  151259. * Reset the AssetsManager and remove all tasks
  151260. * @return the current instance of the AssetsManager
  151261. */
  151262. reset(): AssetsManager;
  151263. /**
  151264. * Start the loading process
  151265. * @return the current instance of the AssetsManager
  151266. */
  151267. load(): AssetsManager;
  151268. /**
  151269. * Start the loading process as an async operation
  151270. * @return a promise returning the list of failed tasks
  151271. */
  151272. loadAsync(): Promise<void>;
  151273. }
  151274. }
  151275. declare module BABYLON {
  151276. /**
  151277. * Wrapper class for promise with external resolve and reject.
  151278. */
  151279. export class Deferred<T> {
  151280. /**
  151281. * The promise associated with this deferred object.
  151282. */
  151283. readonly promise: Promise<T>;
  151284. private _resolve;
  151285. private _reject;
  151286. /**
  151287. * The resolve method of the promise associated with this deferred object.
  151288. */
  151289. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  151290. /**
  151291. * The reject method of the promise associated with this deferred object.
  151292. */
  151293. get reject(): (reason?: any) => void;
  151294. /**
  151295. * Constructor for this deferred object.
  151296. */
  151297. constructor();
  151298. }
  151299. }
  151300. declare module BABYLON {
  151301. /**
  151302. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  151303. */
  151304. export class MeshExploder {
  151305. private _centerMesh;
  151306. private _meshes;
  151307. private _meshesOrigins;
  151308. private _toCenterVectors;
  151309. private _scaledDirection;
  151310. private _newPosition;
  151311. private _centerPosition;
  151312. /**
  151313. * Explodes meshes from a center mesh.
  151314. * @param meshes The meshes to explode.
  151315. * @param centerMesh The mesh to be center of explosion.
  151316. */
  151317. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  151318. private _setCenterMesh;
  151319. /**
  151320. * Get class name
  151321. * @returns "MeshExploder"
  151322. */
  151323. getClassName(): string;
  151324. /**
  151325. * "Exploded meshes"
  151326. * @returns Array of meshes with the centerMesh at index 0.
  151327. */
  151328. getMeshes(): Array<Mesh>;
  151329. /**
  151330. * Explodes meshes giving a specific direction
  151331. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  151332. */
  151333. explode(direction?: number): void;
  151334. }
  151335. }
  151336. declare module BABYLON {
  151337. /**
  151338. * Class used to help managing file picking and drag'n'drop
  151339. */
  151340. export class FilesInput {
  151341. /**
  151342. * List of files ready to be loaded
  151343. */
  151344. static get FilesToLoad(): {
  151345. [key: string]: File;
  151346. };
  151347. /**
  151348. * Callback called when a file is processed
  151349. */
  151350. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  151351. private _engine;
  151352. private _currentScene;
  151353. private _sceneLoadedCallback;
  151354. private _progressCallback;
  151355. private _additionalRenderLoopLogicCallback;
  151356. private _textureLoadingCallback;
  151357. private _startingProcessingFilesCallback;
  151358. private _onReloadCallback;
  151359. private _errorCallback;
  151360. private _elementToMonitor;
  151361. private _sceneFileToLoad;
  151362. private _filesToLoad;
  151363. /**
  151364. * Creates a new FilesInput
  151365. * @param engine defines the rendering engine
  151366. * @param scene defines the hosting scene
  151367. * @param sceneLoadedCallback callback called when scene is loaded
  151368. * @param progressCallback callback called to track progress
  151369. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  151370. * @param textureLoadingCallback callback called when a texture is loading
  151371. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  151372. * @param onReloadCallback callback called when a reload is requested
  151373. * @param errorCallback callback call if an error occurs
  151374. */
  151375. 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>);
  151376. private _dragEnterHandler;
  151377. private _dragOverHandler;
  151378. private _dropHandler;
  151379. /**
  151380. * Calls this function to listen to drag'n'drop events on a specific DOM element
  151381. * @param elementToMonitor defines the DOM element to track
  151382. */
  151383. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  151384. /** Gets the current list of files to load */
  151385. get filesToLoad(): File[];
  151386. /**
  151387. * Release all associated resources
  151388. */
  151389. dispose(): void;
  151390. private renderFunction;
  151391. private drag;
  151392. private drop;
  151393. private _traverseFolder;
  151394. private _processFiles;
  151395. /**
  151396. * Load files from a drop event
  151397. * @param event defines the drop event to use as source
  151398. */
  151399. loadFiles(event: any): void;
  151400. private _processReload;
  151401. /**
  151402. * Reload the current scene from the loaded files
  151403. */
  151404. reload(): void;
  151405. }
  151406. }
  151407. declare module BABYLON {
  151408. /**
  151409. * Defines the root class used to create scene optimization to use with SceneOptimizer
  151410. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151411. */
  151412. export class SceneOptimization {
  151413. /**
  151414. * Defines the priority of this optimization (0 by default which means first in the list)
  151415. */
  151416. priority: number;
  151417. /**
  151418. * Gets a string describing the action executed by the current optimization
  151419. * @returns description string
  151420. */
  151421. getDescription(): string;
  151422. /**
  151423. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151424. * @param scene defines the current scene where to apply this optimization
  151425. * @param optimizer defines the current optimizer
  151426. * @returns true if everything that can be done was applied
  151427. */
  151428. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151429. /**
  151430. * Creates the SceneOptimization object
  151431. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151432. * @param desc defines the description associated with the optimization
  151433. */
  151434. constructor(
  151435. /**
  151436. * Defines the priority of this optimization (0 by default which means first in the list)
  151437. */
  151438. priority?: number);
  151439. }
  151440. /**
  151441. * Defines an optimization used to reduce the size of render target textures
  151442. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151443. */
  151444. export class TextureOptimization extends SceneOptimization {
  151445. /**
  151446. * Defines the priority of this optimization (0 by default which means first in the list)
  151447. */
  151448. priority: number;
  151449. /**
  151450. * 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
  151451. */
  151452. maximumSize: number;
  151453. /**
  151454. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151455. */
  151456. step: number;
  151457. /**
  151458. * Gets a string describing the action executed by the current optimization
  151459. * @returns description string
  151460. */
  151461. getDescription(): string;
  151462. /**
  151463. * Creates the TextureOptimization object
  151464. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151465. * @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
  151466. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151467. */
  151468. constructor(
  151469. /**
  151470. * Defines the priority of this optimization (0 by default which means first in the list)
  151471. */
  151472. priority?: number,
  151473. /**
  151474. * 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
  151475. */
  151476. maximumSize?: number,
  151477. /**
  151478. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151479. */
  151480. step?: number);
  151481. /**
  151482. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151483. * @param scene defines the current scene where to apply this optimization
  151484. * @param optimizer defines the current optimizer
  151485. * @returns true if everything that can be done was applied
  151486. */
  151487. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151488. }
  151489. /**
  151490. * Defines an optimization used to increase or decrease the rendering resolution
  151491. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151492. */
  151493. export class HardwareScalingOptimization extends SceneOptimization {
  151494. /**
  151495. * Defines the priority of this optimization (0 by default which means first in the list)
  151496. */
  151497. priority: number;
  151498. /**
  151499. * Defines the maximum scale to use (2 by default)
  151500. */
  151501. maximumScale: number;
  151502. /**
  151503. * Defines the step to use between two passes (0.5 by default)
  151504. */
  151505. step: number;
  151506. private _currentScale;
  151507. private _directionOffset;
  151508. /**
  151509. * Gets a string describing the action executed by the current optimization
  151510. * @return description string
  151511. */
  151512. getDescription(): string;
  151513. /**
  151514. * Creates the HardwareScalingOptimization object
  151515. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151516. * @param maximumScale defines the maximum scale to use (2 by default)
  151517. * @param step defines the step to use between two passes (0.5 by default)
  151518. */
  151519. constructor(
  151520. /**
  151521. * Defines the priority of this optimization (0 by default which means first in the list)
  151522. */
  151523. priority?: number,
  151524. /**
  151525. * Defines the maximum scale to use (2 by default)
  151526. */
  151527. maximumScale?: number,
  151528. /**
  151529. * Defines the step to use between two passes (0.5 by default)
  151530. */
  151531. step?: number);
  151532. /**
  151533. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151534. * @param scene defines the current scene where to apply this optimization
  151535. * @param optimizer defines the current optimizer
  151536. * @returns true if everything that can be done was applied
  151537. */
  151538. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151539. }
  151540. /**
  151541. * Defines an optimization used to remove shadows
  151542. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151543. */
  151544. export class ShadowsOptimization extends SceneOptimization {
  151545. /**
  151546. * Gets a string describing the action executed by the current optimization
  151547. * @return description string
  151548. */
  151549. getDescription(): string;
  151550. /**
  151551. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151552. * @param scene defines the current scene where to apply this optimization
  151553. * @param optimizer defines the current optimizer
  151554. * @returns true if everything that can be done was applied
  151555. */
  151556. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151557. }
  151558. /**
  151559. * Defines an optimization used to turn post-processes off
  151560. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151561. */
  151562. export class PostProcessesOptimization extends SceneOptimization {
  151563. /**
  151564. * Gets a string describing the action executed by the current optimization
  151565. * @return description string
  151566. */
  151567. getDescription(): string;
  151568. /**
  151569. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151570. * @param scene defines the current scene where to apply this optimization
  151571. * @param optimizer defines the current optimizer
  151572. * @returns true if everything that can be done was applied
  151573. */
  151574. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151575. }
  151576. /**
  151577. * Defines an optimization used to turn lens flares off
  151578. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151579. */
  151580. export class LensFlaresOptimization extends SceneOptimization {
  151581. /**
  151582. * Gets a string describing the action executed by the current optimization
  151583. * @return description string
  151584. */
  151585. getDescription(): string;
  151586. /**
  151587. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151588. * @param scene defines the current scene where to apply this optimization
  151589. * @param optimizer defines the current optimizer
  151590. * @returns true if everything that can be done was applied
  151591. */
  151592. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151593. }
  151594. /**
  151595. * Defines an optimization based on user defined callback.
  151596. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151597. */
  151598. export class CustomOptimization extends SceneOptimization {
  151599. /**
  151600. * Callback called to apply the custom optimization.
  151601. */
  151602. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  151603. /**
  151604. * Callback called to get custom description
  151605. */
  151606. onGetDescription: () => string;
  151607. /**
  151608. * Gets a string describing the action executed by the current optimization
  151609. * @returns description string
  151610. */
  151611. getDescription(): string;
  151612. /**
  151613. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151614. * @param scene defines the current scene where to apply this optimization
  151615. * @param optimizer defines the current optimizer
  151616. * @returns true if everything that can be done was applied
  151617. */
  151618. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151619. }
  151620. /**
  151621. * Defines an optimization used to turn particles off
  151622. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151623. */
  151624. export class ParticlesOptimization extends SceneOptimization {
  151625. /**
  151626. * Gets a string describing the action executed by the current optimization
  151627. * @return description string
  151628. */
  151629. getDescription(): string;
  151630. /**
  151631. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151632. * @param scene defines the current scene where to apply this optimization
  151633. * @param optimizer defines the current optimizer
  151634. * @returns true if everything that can be done was applied
  151635. */
  151636. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151637. }
  151638. /**
  151639. * Defines an optimization used to turn render targets off
  151640. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151641. */
  151642. export class RenderTargetsOptimization extends SceneOptimization {
  151643. /**
  151644. * Gets a string describing the action executed by the current optimization
  151645. * @return description string
  151646. */
  151647. getDescription(): string;
  151648. /**
  151649. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151650. * @param scene defines the current scene where to apply this optimization
  151651. * @param optimizer defines the current optimizer
  151652. * @returns true if everything that can be done was applied
  151653. */
  151654. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151655. }
  151656. /**
  151657. * Defines an optimization used to merge meshes with compatible materials
  151658. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151659. */
  151660. export class MergeMeshesOptimization extends SceneOptimization {
  151661. private static _UpdateSelectionTree;
  151662. /**
  151663. * Gets or sets a boolean which defines if optimization octree has to be updated
  151664. */
  151665. static get UpdateSelectionTree(): boolean;
  151666. /**
  151667. * Gets or sets a boolean which defines if optimization octree has to be updated
  151668. */
  151669. static set UpdateSelectionTree(value: boolean);
  151670. /**
  151671. * Gets a string describing the action executed by the current optimization
  151672. * @return description string
  151673. */
  151674. getDescription(): string;
  151675. private _canBeMerged;
  151676. /**
  151677. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151678. * @param scene defines the current scene where to apply this optimization
  151679. * @param optimizer defines the current optimizer
  151680. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  151681. * @returns true if everything that can be done was applied
  151682. */
  151683. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  151684. }
  151685. /**
  151686. * Defines a list of options used by SceneOptimizer
  151687. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151688. */
  151689. export class SceneOptimizerOptions {
  151690. /**
  151691. * Defines the target frame rate to reach (60 by default)
  151692. */
  151693. targetFrameRate: number;
  151694. /**
  151695. * Defines the interval between two checkes (2000ms by default)
  151696. */
  151697. trackerDuration: number;
  151698. /**
  151699. * Gets the list of optimizations to apply
  151700. */
  151701. optimizations: SceneOptimization[];
  151702. /**
  151703. * Creates a new list of options used by SceneOptimizer
  151704. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  151705. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  151706. */
  151707. constructor(
  151708. /**
  151709. * Defines the target frame rate to reach (60 by default)
  151710. */
  151711. targetFrameRate?: number,
  151712. /**
  151713. * Defines the interval between two checkes (2000ms by default)
  151714. */
  151715. trackerDuration?: number);
  151716. /**
  151717. * Add a new optimization
  151718. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  151719. * @returns the current SceneOptimizerOptions
  151720. */
  151721. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  151722. /**
  151723. * Add a new custom optimization
  151724. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  151725. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  151726. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151727. * @returns the current SceneOptimizerOptions
  151728. */
  151729. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  151730. /**
  151731. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  151732. * @param targetFrameRate defines the target frame rate (60 by default)
  151733. * @returns a SceneOptimizerOptions object
  151734. */
  151735. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  151736. /**
  151737. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  151738. * @param targetFrameRate defines the target frame rate (60 by default)
  151739. * @returns a SceneOptimizerOptions object
  151740. */
  151741. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  151742. /**
  151743. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  151744. * @param targetFrameRate defines the target frame rate (60 by default)
  151745. * @returns a SceneOptimizerOptions object
  151746. */
  151747. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  151748. }
  151749. /**
  151750. * Class used to run optimizations in order to reach a target frame rate
  151751. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151752. */
  151753. export class SceneOptimizer implements IDisposable {
  151754. private _isRunning;
  151755. private _options;
  151756. private _scene;
  151757. private _currentPriorityLevel;
  151758. private _targetFrameRate;
  151759. private _trackerDuration;
  151760. private _currentFrameRate;
  151761. private _sceneDisposeObserver;
  151762. private _improvementMode;
  151763. /**
  151764. * Defines an observable called when the optimizer reaches the target frame rate
  151765. */
  151766. onSuccessObservable: Observable<SceneOptimizer>;
  151767. /**
  151768. * Defines an observable called when the optimizer enables an optimization
  151769. */
  151770. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  151771. /**
  151772. * Defines an observable called when the optimizer is not able to reach the target frame rate
  151773. */
  151774. onFailureObservable: Observable<SceneOptimizer>;
  151775. /**
  151776. * Gets a boolean indicating if the optimizer is in improvement mode
  151777. */
  151778. get isInImprovementMode(): boolean;
  151779. /**
  151780. * Gets the current priority level (0 at start)
  151781. */
  151782. get currentPriorityLevel(): number;
  151783. /**
  151784. * Gets the current frame rate checked by the SceneOptimizer
  151785. */
  151786. get currentFrameRate(): number;
  151787. /**
  151788. * Gets or sets the current target frame rate (60 by default)
  151789. */
  151790. get targetFrameRate(): number;
  151791. /**
  151792. * Gets or sets the current target frame rate (60 by default)
  151793. */
  151794. set targetFrameRate(value: number);
  151795. /**
  151796. * Gets or sets the current interval between two checks (every 2000ms by default)
  151797. */
  151798. get trackerDuration(): number;
  151799. /**
  151800. * Gets or sets the current interval between two checks (every 2000ms by default)
  151801. */
  151802. set trackerDuration(value: number);
  151803. /**
  151804. * Gets the list of active optimizations
  151805. */
  151806. get optimizations(): SceneOptimization[];
  151807. /**
  151808. * Creates a new SceneOptimizer
  151809. * @param scene defines the scene to work on
  151810. * @param options defines the options to use with the SceneOptimizer
  151811. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  151812. * @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)
  151813. */
  151814. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  151815. /**
  151816. * Stops the current optimizer
  151817. */
  151818. stop(): void;
  151819. /**
  151820. * Reset the optimizer to initial step (current priority level = 0)
  151821. */
  151822. reset(): void;
  151823. /**
  151824. * Start the optimizer. By default it will try to reach a specific framerate
  151825. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  151826. */
  151827. start(): void;
  151828. private _checkCurrentState;
  151829. /**
  151830. * Release all resources
  151831. */
  151832. dispose(): void;
  151833. /**
  151834. * Helper function to create a SceneOptimizer with one single line of code
  151835. * @param scene defines the scene to work on
  151836. * @param options defines the options to use with the SceneOptimizer
  151837. * @param onSuccess defines a callback to call on success
  151838. * @param onFailure defines a callback to call on failure
  151839. * @returns the new SceneOptimizer object
  151840. */
  151841. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  151842. }
  151843. }
  151844. declare module BABYLON {
  151845. /**
  151846. * Class used to serialize a scene into a string
  151847. */
  151848. export class SceneSerializer {
  151849. /**
  151850. * Clear cache used by a previous serialization
  151851. */
  151852. static ClearCache(): void;
  151853. /**
  151854. * Serialize a scene into a JSON compatible object
  151855. * @param scene defines the scene to serialize
  151856. * @returns a JSON compatible object
  151857. */
  151858. static Serialize(scene: Scene): any;
  151859. /**
  151860. * Serialize a mesh into a JSON compatible object
  151861. * @param toSerialize defines the mesh to serialize
  151862. * @param withParents defines if parents must be serialized as well
  151863. * @param withChildren defines if children must be serialized as well
  151864. * @returns a JSON compatible object
  151865. */
  151866. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  151867. }
  151868. }
  151869. declare module BABYLON {
  151870. /**
  151871. * Class used to host texture specific utilities
  151872. */
  151873. export class TextureTools {
  151874. /**
  151875. * Uses the GPU to create a copy texture rescaled at a given size
  151876. * @param texture Texture to copy from
  151877. * @param width defines the desired width
  151878. * @param height defines the desired height
  151879. * @param useBilinearMode defines if bilinear mode has to be used
  151880. * @return the generated texture
  151881. */
  151882. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  151883. }
  151884. }
  151885. declare module BABYLON {
  151886. /**
  151887. * This represents the different options available for the video capture.
  151888. */
  151889. export interface VideoRecorderOptions {
  151890. /** Defines the mime type of the video. */
  151891. mimeType: string;
  151892. /** Defines the FPS the video should be recorded at. */
  151893. fps: number;
  151894. /** Defines the chunk size for the recording data. */
  151895. recordChunckSize: number;
  151896. /** The audio tracks to attach to the recording. */
  151897. audioTracks?: MediaStreamTrack[];
  151898. }
  151899. /**
  151900. * This can help with recording videos from BabylonJS.
  151901. * This is based on the available WebRTC functionalities of the browser.
  151902. *
  151903. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  151904. */
  151905. export class VideoRecorder {
  151906. private static readonly _defaultOptions;
  151907. /**
  151908. * Returns whether or not the VideoRecorder is available in your browser.
  151909. * @param engine Defines the Babylon Engine.
  151910. * @returns true if supported otherwise false.
  151911. */
  151912. static IsSupported(engine: Engine): boolean;
  151913. private readonly _options;
  151914. private _canvas;
  151915. private _mediaRecorder;
  151916. private _recordedChunks;
  151917. private _fileName;
  151918. private _resolve;
  151919. private _reject;
  151920. /**
  151921. * True when a recording is already in progress.
  151922. */
  151923. get isRecording(): boolean;
  151924. /**
  151925. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  151926. * @param engine Defines the BabylonJS Engine you wish to record.
  151927. * @param options Defines options that can be used to customize the capture.
  151928. */
  151929. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  151930. /**
  151931. * Stops the current recording before the default capture timeout passed in the startRecording function.
  151932. */
  151933. stopRecording(): void;
  151934. /**
  151935. * Starts recording the canvas for a max duration specified in parameters.
  151936. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  151937. * If null no automatic download will start and you can rely on the promise to get the data back.
  151938. * @param maxDuration Defines the maximum recording time in seconds.
  151939. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  151940. * @return A promise callback at the end of the recording with the video data in Blob.
  151941. */
  151942. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  151943. /**
  151944. * Releases internal resources used during the recording.
  151945. */
  151946. dispose(): void;
  151947. private _handleDataAvailable;
  151948. private _handleError;
  151949. private _handleStop;
  151950. }
  151951. }
  151952. declare module BABYLON {
  151953. /**
  151954. * Class containing a set of static utilities functions for screenshots
  151955. */
  151956. export class ScreenshotTools {
  151957. /**
  151958. * Captures a screenshot of the current rendering
  151959. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151960. * @param engine defines the rendering engine
  151961. * @param camera defines the source camera
  151962. * @param size This parameter can be set to a single number or to an object with the
  151963. * following (optional) properties: precision, width, height. If a single number is passed,
  151964. * it will be used for both width and height. If an object is passed, the screenshot size
  151965. * will be derived from the parameters. The precision property is a multiplier allowing
  151966. * rendering at a higher or lower resolution
  151967. * @param successCallback defines the callback receives a single parameter which contains the
  151968. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  151969. * src parameter of an <img> to display it
  151970. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  151971. * Check your browser for supported MIME types
  151972. */
  151973. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  151974. /**
  151975. * Captures a screenshot of the current rendering
  151976. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151977. * @param engine defines the rendering engine
  151978. * @param camera defines the source camera
  151979. * @param size This parameter can be set to a single number or to an object with the
  151980. * following (optional) properties: precision, width, height. If a single number is passed,
  151981. * it will be used for both width and height. If an object is passed, the screenshot size
  151982. * will be derived from the parameters. The precision property is a multiplier allowing
  151983. * rendering at a higher or lower resolution
  151984. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  151985. * Check your browser for supported MIME types
  151986. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  151987. * to the src parameter of an <img> to display it
  151988. */
  151989. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  151990. /**
  151991. * Generates an image screenshot from the specified camera.
  151992. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151993. * @param engine The engine to use for rendering
  151994. * @param camera The camera to use for rendering
  151995. * @param size This parameter can be set to a single number or to an object with the
  151996. * following (optional) properties: precision, width, height. If a single number is passed,
  151997. * it will be used for both width and height. If an object is passed, the screenshot size
  151998. * will be derived from the parameters. The precision property is a multiplier allowing
  151999. * rendering at a higher or lower resolution
  152000. * @param successCallback The callback receives a single parameter which contains the
  152001. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  152002. * src parameter of an <img> to display it
  152003. * @param mimeType The MIME type of the screenshot image (default: image/png).
  152004. * Check your browser for supported MIME types
  152005. * @param samples Texture samples (default: 1)
  152006. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  152007. * @param fileName A name for for the downloaded file.
  152008. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  152009. */
  152010. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  152011. /**
  152012. * Generates an image screenshot from the specified camera.
  152013. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152014. * @param engine The engine to use for rendering
  152015. * @param camera The camera to use for rendering
  152016. * @param size This parameter can be set to a single number or to an object with the
  152017. * following (optional) properties: precision, width, height. If a single number is passed,
  152018. * it will be used for both width and height. If an object is passed, the screenshot size
  152019. * will be derived from the parameters. The precision property is a multiplier allowing
  152020. * rendering at a higher or lower resolution
  152021. * @param mimeType The MIME type of the screenshot image (default: image/png).
  152022. * Check your browser for supported MIME types
  152023. * @param samples Texture samples (default: 1)
  152024. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  152025. * @param fileName A name for for the downloaded file.
  152026. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  152027. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  152028. * to the src parameter of an <img> to display it
  152029. */
  152030. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  152031. /**
  152032. * Gets height and width for screenshot size
  152033. * @private
  152034. */
  152035. private static _getScreenshotSize;
  152036. }
  152037. }
  152038. declare module BABYLON {
  152039. /**
  152040. * Interface for a data buffer
  152041. */
  152042. export interface IDataBuffer {
  152043. /**
  152044. * Reads bytes from the data buffer.
  152045. * @param byteOffset The byte offset to read
  152046. * @param byteLength The byte length to read
  152047. * @returns A promise that resolves when the bytes are read
  152048. */
  152049. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  152050. /**
  152051. * The byte length of the buffer.
  152052. */
  152053. readonly byteLength: number;
  152054. }
  152055. /**
  152056. * Utility class for reading from a data buffer
  152057. */
  152058. export class DataReader {
  152059. /**
  152060. * The data buffer associated with this data reader.
  152061. */
  152062. readonly buffer: IDataBuffer;
  152063. /**
  152064. * The current byte offset from the beginning of the data buffer.
  152065. */
  152066. byteOffset: number;
  152067. private _dataView;
  152068. private _dataByteOffset;
  152069. /**
  152070. * Constructor
  152071. * @param buffer The buffer to read
  152072. */
  152073. constructor(buffer: IDataBuffer);
  152074. /**
  152075. * Loads the given byte length.
  152076. * @param byteLength The byte length to load
  152077. * @returns A promise that resolves when the load is complete
  152078. */
  152079. loadAsync(byteLength: number): Promise<void>;
  152080. /**
  152081. * Read a unsigned 32-bit integer from the currently loaded data range.
  152082. * @returns The 32-bit integer read
  152083. */
  152084. readUint32(): number;
  152085. /**
  152086. * Read a byte array from the currently loaded data range.
  152087. * @param byteLength The byte length to read
  152088. * @returns The byte array read
  152089. */
  152090. readUint8Array(byteLength: number): Uint8Array;
  152091. /**
  152092. * Read a string from the currently loaded data range.
  152093. * @param byteLength The byte length to read
  152094. * @returns The string read
  152095. */
  152096. readString(byteLength: number): string;
  152097. /**
  152098. * Skips the given byte length the currently loaded data range.
  152099. * @param byteLength The byte length to skip
  152100. */
  152101. skipBytes(byteLength: number): void;
  152102. }
  152103. }
  152104. declare module BABYLON {
  152105. /**
  152106. * Class for storing data to local storage if available or in-memory storage otherwise
  152107. */
  152108. export class DataStorage {
  152109. private static _Storage;
  152110. private static _GetStorage;
  152111. /**
  152112. * Reads a string from the data storage
  152113. * @param key The key to read
  152114. * @param defaultValue The value if the key doesn't exist
  152115. * @returns The string value
  152116. */
  152117. static ReadString(key: string, defaultValue: string): string;
  152118. /**
  152119. * Writes a string to the data storage
  152120. * @param key The key to write
  152121. * @param value The value to write
  152122. */
  152123. static WriteString(key: string, value: string): void;
  152124. /**
  152125. * Reads a boolean from the data storage
  152126. * @param key The key to read
  152127. * @param defaultValue The value if the key doesn't exist
  152128. * @returns The boolean value
  152129. */
  152130. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  152131. /**
  152132. * Writes a boolean to the data storage
  152133. * @param key The key to write
  152134. * @param value The value to write
  152135. */
  152136. static WriteBoolean(key: string, value: boolean): void;
  152137. /**
  152138. * Reads a number from the data storage
  152139. * @param key The key to read
  152140. * @param defaultValue The value if the key doesn't exist
  152141. * @returns The number value
  152142. */
  152143. static ReadNumber(key: string, defaultValue: number): number;
  152144. /**
  152145. * Writes a number to the data storage
  152146. * @param key The key to write
  152147. * @param value The value to write
  152148. */
  152149. static WriteNumber(key: string, value: number): void;
  152150. }
  152151. }
  152152. declare module BABYLON {
  152153. /**
  152154. * Class used to record delta files between 2 scene states
  152155. */
  152156. export class SceneRecorder {
  152157. private _trackedScene;
  152158. private _savedJSON;
  152159. /**
  152160. * Track a given scene. This means the current scene state will be considered the original state
  152161. * @param scene defines the scene to track
  152162. */
  152163. track(scene: Scene): void;
  152164. /**
  152165. * Get the delta between current state and original state
  152166. * @returns a string containing the delta
  152167. */
  152168. getDelta(): any;
  152169. private _compareArray;
  152170. private _compareObjects;
  152171. private _compareCollections;
  152172. /**
  152173. * Apply a given delta to a given scene
  152174. * @param deltaJSON defines the JSON containing the delta
  152175. * @param scene defines the scene to apply the delta to
  152176. */
  152177. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  152178. private static _ApplyPropertiesToEntity;
  152179. private static _ApplyDeltaForEntity;
  152180. }
  152181. }
  152182. declare module BABYLON {
  152183. /**
  152184. * An interface for all Hit test features
  152185. */
  152186. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  152187. /**
  152188. * Triggered when new babylon (transformed) hit test results are available
  152189. */
  152190. onHitTestResultObservable: Observable<T[]>;
  152191. }
  152192. /**
  152193. * Options used for hit testing
  152194. */
  152195. export interface IWebXRLegacyHitTestOptions {
  152196. /**
  152197. * Only test when user interacted with the scene. Default - hit test every frame
  152198. */
  152199. testOnPointerDownOnly?: boolean;
  152200. /**
  152201. * The node to use to transform the local results to world coordinates
  152202. */
  152203. worldParentNode?: TransformNode;
  152204. }
  152205. /**
  152206. * Interface defining the babylon result of raycasting/hit-test
  152207. */
  152208. export interface IWebXRLegacyHitResult {
  152209. /**
  152210. * Transformation matrix that can be applied to a node that will put it in the hit point location
  152211. */
  152212. transformationMatrix: Matrix;
  152213. /**
  152214. * The native hit test result
  152215. */
  152216. xrHitResult: XRHitResult | XRHitTestResult;
  152217. }
  152218. /**
  152219. * The currently-working hit-test module.
  152220. * Hit test (or Ray-casting) is used to interact with the real world.
  152221. * For further information read here - https://github.com/immersive-web/hit-test
  152222. */
  152223. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  152224. /**
  152225. * options to use when constructing this feature
  152226. */
  152227. readonly options: IWebXRLegacyHitTestOptions;
  152228. private _direction;
  152229. private _mat;
  152230. private _onSelectEnabled;
  152231. private _origin;
  152232. /**
  152233. * The module's name
  152234. */
  152235. static readonly Name: string;
  152236. /**
  152237. * The (Babylon) version of this module.
  152238. * This is an integer representing the implementation version.
  152239. * This number does not correspond to the WebXR specs version
  152240. */
  152241. static readonly Version: number;
  152242. /**
  152243. * Populated with the last native XR Hit Results
  152244. */
  152245. lastNativeXRHitResults: XRHitResult[];
  152246. /**
  152247. * Triggered when new babylon (transformed) hit test results are available
  152248. */
  152249. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  152250. /**
  152251. * Creates a new instance of the (legacy version) hit test feature
  152252. * @param _xrSessionManager an instance of WebXRSessionManager
  152253. * @param options options to use when constructing this feature
  152254. */
  152255. constructor(_xrSessionManager: WebXRSessionManager,
  152256. /**
  152257. * options to use when constructing this feature
  152258. */
  152259. options?: IWebXRLegacyHitTestOptions);
  152260. /**
  152261. * execute a hit test with an XR Ray
  152262. *
  152263. * @param xrSession a native xrSession that will execute this hit test
  152264. * @param xrRay the ray (position and direction) to use for ray-casting
  152265. * @param referenceSpace native XR reference space to use for the hit-test
  152266. * @param filter filter function that will filter the results
  152267. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  152268. */
  152269. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  152270. /**
  152271. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  152272. * @param event the (select) event to use to select with
  152273. * @param referenceSpace the reference space to use for this hit test
  152274. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  152275. */
  152276. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  152277. /**
  152278. * attach this feature
  152279. * Will usually be called by the features manager
  152280. *
  152281. * @returns true if successful.
  152282. */
  152283. attach(): boolean;
  152284. /**
  152285. * detach this feature.
  152286. * Will usually be called by the features manager
  152287. *
  152288. * @returns true if successful.
  152289. */
  152290. detach(): boolean;
  152291. /**
  152292. * Dispose this feature and all of the resources attached
  152293. */
  152294. dispose(): void;
  152295. protected _onXRFrame(frame: XRFrame): void;
  152296. private _onHitTestResults;
  152297. private _onSelect;
  152298. }
  152299. }
  152300. declare module BABYLON {
  152301. /**
  152302. * Options used for hit testing (version 2)
  152303. */
  152304. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  152305. /**
  152306. * Do not create a permanent hit test. Will usually be used when only
  152307. * transient inputs are needed.
  152308. */
  152309. disablePermanentHitTest?: boolean;
  152310. /**
  152311. * Enable transient (for example touch-based) hit test inspections
  152312. */
  152313. enableTransientHitTest?: boolean;
  152314. /**
  152315. * Offset ray for the permanent hit test
  152316. */
  152317. offsetRay?: Vector3;
  152318. /**
  152319. * Offset ray for the transient hit test
  152320. */
  152321. transientOffsetRay?: Vector3;
  152322. /**
  152323. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  152324. */
  152325. useReferenceSpace?: boolean;
  152326. }
  152327. /**
  152328. * Interface defining the babylon result of hit-test
  152329. */
  152330. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  152331. /**
  152332. * The input source that generated this hit test (if transient)
  152333. */
  152334. inputSource?: XRInputSource;
  152335. /**
  152336. * Is this a transient hit test
  152337. */
  152338. isTransient?: boolean;
  152339. /**
  152340. * Position of the hit test result
  152341. */
  152342. position: Vector3;
  152343. /**
  152344. * Rotation of the hit test result
  152345. */
  152346. rotationQuaternion: Quaternion;
  152347. /**
  152348. * The native hit test result
  152349. */
  152350. xrHitResult: XRHitTestResult;
  152351. }
  152352. /**
  152353. * The currently-working hit-test module.
  152354. * Hit test (or Ray-casting) is used to interact with the real world.
  152355. * For further information read here - https://github.com/immersive-web/hit-test
  152356. *
  152357. * Tested on chrome (mobile) 80.
  152358. */
  152359. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  152360. /**
  152361. * options to use when constructing this feature
  152362. */
  152363. readonly options: IWebXRHitTestOptions;
  152364. private _tmpMat;
  152365. private _tmpPos;
  152366. private _tmpQuat;
  152367. private _transientXrHitTestSource;
  152368. private _xrHitTestSource;
  152369. private initHitTestSource;
  152370. /**
  152371. * The module's name
  152372. */
  152373. static readonly Name: string;
  152374. /**
  152375. * The (Babylon) version of this module.
  152376. * This is an integer representing the implementation version.
  152377. * This number does not correspond to the WebXR specs version
  152378. */
  152379. static readonly Version: number;
  152380. /**
  152381. * When set to true, each hit test will have its own position/rotation objects
  152382. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  152383. * the developers will clone them or copy them as they see fit.
  152384. */
  152385. autoCloneTransformation: boolean;
  152386. /**
  152387. * Triggered when new babylon (transformed) hit test results are available
  152388. */
  152389. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  152390. /**
  152391. * Use this to temporarily pause hit test checks.
  152392. */
  152393. paused: boolean;
  152394. /**
  152395. * Creates a new instance of the hit test feature
  152396. * @param _xrSessionManager an instance of WebXRSessionManager
  152397. * @param options options to use when constructing this feature
  152398. */
  152399. constructor(_xrSessionManager: WebXRSessionManager,
  152400. /**
  152401. * options to use when constructing this feature
  152402. */
  152403. options?: IWebXRHitTestOptions);
  152404. /**
  152405. * attach this feature
  152406. * Will usually be called by the features manager
  152407. *
  152408. * @returns true if successful.
  152409. */
  152410. attach(): boolean;
  152411. /**
  152412. * detach this feature.
  152413. * Will usually be called by the features manager
  152414. *
  152415. * @returns true if successful.
  152416. */
  152417. detach(): boolean;
  152418. /**
  152419. * Dispose this feature and all of the resources attached
  152420. */
  152421. dispose(): void;
  152422. protected _onXRFrame(frame: XRFrame): void;
  152423. private _processWebXRHitTestResult;
  152424. }
  152425. }
  152426. declare module BABYLON {
  152427. /**
  152428. * Configuration options of the anchor system
  152429. */
  152430. export interface IWebXRAnchorSystemOptions {
  152431. /**
  152432. * a node that will be used to convert local to world coordinates
  152433. */
  152434. worldParentNode?: TransformNode;
  152435. /**
  152436. * If set to true a reference of the created anchors will be kept until the next session starts
  152437. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  152438. */
  152439. doNotRemoveAnchorsOnSessionEnded?: boolean;
  152440. }
  152441. /**
  152442. * A babylon container for an XR Anchor
  152443. */
  152444. export interface IWebXRAnchor {
  152445. /**
  152446. * A babylon-assigned ID for this anchor
  152447. */
  152448. id: number;
  152449. /**
  152450. * Transformation matrix to apply to an object attached to this anchor
  152451. */
  152452. transformationMatrix: Matrix;
  152453. /**
  152454. * The native anchor object
  152455. */
  152456. xrAnchor: XRAnchor;
  152457. /**
  152458. * if defined, this object will be constantly updated by the anchor's position and rotation
  152459. */
  152460. attachedNode?: TransformNode;
  152461. }
  152462. /**
  152463. * An implementation of the anchor system for WebXR.
  152464. * For further information see https://github.com/immersive-web/anchors/
  152465. */
  152466. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  152467. private _options;
  152468. private _lastFrameDetected;
  152469. private _trackedAnchors;
  152470. private _referenceSpaceForFrameAnchors;
  152471. private _futureAnchors;
  152472. /**
  152473. * The module's name
  152474. */
  152475. static readonly Name: string;
  152476. /**
  152477. * The (Babylon) version of this module.
  152478. * This is an integer representing the implementation version.
  152479. * This number does not correspond to the WebXR specs version
  152480. */
  152481. static readonly Version: number;
  152482. /**
  152483. * Observers registered here will be executed when a new anchor was added to the session
  152484. */
  152485. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  152486. /**
  152487. * Observers registered here will be executed when an anchor was removed from the session
  152488. */
  152489. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  152490. /**
  152491. * Observers registered here will be executed when an existing anchor updates
  152492. * This can execute N times every frame
  152493. */
  152494. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  152495. /**
  152496. * Set the reference space to use for anchor creation, when not using a hit test.
  152497. * Will default to the session's reference space if not defined
  152498. */
  152499. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  152500. /**
  152501. * constructs a new anchor system
  152502. * @param _xrSessionManager an instance of WebXRSessionManager
  152503. * @param _options configuration object for this feature
  152504. */
  152505. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  152506. private _tmpVector;
  152507. private _tmpQuaternion;
  152508. private _populateTmpTransformation;
  152509. /**
  152510. * Create a new anchor point using a hit test result at a specific point in the scene
  152511. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  152512. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  152513. *
  152514. * @param hitTestResult The hit test result to use for this anchor creation
  152515. * @param position an optional position offset for this anchor
  152516. * @param rotationQuaternion an optional rotation offset for this anchor
  152517. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  152518. */
  152519. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  152520. /**
  152521. * Add a new anchor at a specific position and rotation
  152522. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  152523. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  152524. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  152525. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  152526. *
  152527. * @param position the position in which to add an anchor
  152528. * @param rotationQuaternion an optional rotation for the anchor transformation
  152529. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  152530. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  152531. */
  152532. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  152533. /**
  152534. * detach this feature.
  152535. * Will usually be called by the features manager
  152536. *
  152537. * @returns true if successful.
  152538. */
  152539. detach(): boolean;
  152540. /**
  152541. * Dispose this feature and all of the resources attached
  152542. */
  152543. dispose(): void;
  152544. protected _onXRFrame(frame: XRFrame): void;
  152545. /**
  152546. * avoiding using Array.find for global support.
  152547. * @param xrAnchor the plane to find in the array
  152548. */
  152549. private _findIndexInAnchorArray;
  152550. private _updateAnchorWithXRFrame;
  152551. private _createAnchorAtTransformation;
  152552. }
  152553. }
  152554. declare module BABYLON {
  152555. /**
  152556. * Options used in the plane detector module
  152557. */
  152558. export interface IWebXRPlaneDetectorOptions {
  152559. /**
  152560. * The node to use to transform the local results to world coordinates
  152561. */
  152562. worldParentNode?: TransformNode;
  152563. /**
  152564. * If set to true a reference of the created planes will be kept until the next session starts
  152565. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  152566. */
  152567. doNotRemovePlanesOnSessionEnded?: boolean;
  152568. }
  152569. /**
  152570. * A babylon interface for a WebXR plane.
  152571. * A Plane is actually a polygon, built from N points in space
  152572. *
  152573. * Supported in chrome 79, not supported in canary 81 ATM
  152574. */
  152575. export interface IWebXRPlane {
  152576. /**
  152577. * a babylon-assigned ID for this polygon
  152578. */
  152579. id: number;
  152580. /**
  152581. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  152582. */
  152583. polygonDefinition: Array<Vector3>;
  152584. /**
  152585. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  152586. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  152587. */
  152588. transformationMatrix: Matrix;
  152589. /**
  152590. * the native xr-plane object
  152591. */
  152592. xrPlane: XRPlane;
  152593. }
  152594. /**
  152595. * The plane detector is used to detect planes in the real world when in AR
  152596. * For more information see https://github.com/immersive-web/real-world-geometry/
  152597. */
  152598. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  152599. private _options;
  152600. private _detectedPlanes;
  152601. private _enabled;
  152602. private _lastFrameDetected;
  152603. /**
  152604. * The module's name
  152605. */
  152606. static readonly Name: string;
  152607. /**
  152608. * The (Babylon) version of this module.
  152609. * This is an integer representing the implementation version.
  152610. * This number does not correspond to the WebXR specs version
  152611. */
  152612. static readonly Version: number;
  152613. /**
  152614. * Observers registered here will be executed when a new plane was added to the session
  152615. */
  152616. onPlaneAddedObservable: Observable<IWebXRPlane>;
  152617. /**
  152618. * Observers registered here will be executed when a plane is no longer detected in the session
  152619. */
  152620. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  152621. /**
  152622. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  152623. * This can execute N times every frame
  152624. */
  152625. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  152626. /**
  152627. * construct a new Plane Detector
  152628. * @param _xrSessionManager an instance of xr Session manager
  152629. * @param _options configuration to use when constructing this feature
  152630. */
  152631. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  152632. /**
  152633. * detach this feature.
  152634. * Will usually be called by the features manager
  152635. *
  152636. * @returns true if successful.
  152637. */
  152638. detach(): boolean;
  152639. /**
  152640. * Dispose this feature and all of the resources attached
  152641. */
  152642. dispose(): void;
  152643. protected _onXRFrame(frame: XRFrame): void;
  152644. private _init;
  152645. private _updatePlaneWithXRPlane;
  152646. /**
  152647. * avoiding using Array.find for global support.
  152648. * @param xrPlane the plane to find in the array
  152649. */
  152650. private findIndexInPlaneArray;
  152651. }
  152652. }
  152653. declare module BABYLON {
  152654. /**
  152655. * Options interface for the background remover plugin
  152656. */
  152657. export interface IWebXRBackgroundRemoverOptions {
  152658. /**
  152659. * Further background meshes to disable when entering AR
  152660. */
  152661. backgroundMeshes?: AbstractMesh[];
  152662. /**
  152663. * flags to configure the removal of the environment helper.
  152664. * If not set, the entire background will be removed. If set, flags should be set as well.
  152665. */
  152666. environmentHelperRemovalFlags?: {
  152667. /**
  152668. * Should the skybox be removed (default false)
  152669. */
  152670. skyBox?: boolean;
  152671. /**
  152672. * Should the ground be removed (default false)
  152673. */
  152674. ground?: boolean;
  152675. };
  152676. /**
  152677. * don't disable the environment helper
  152678. */
  152679. ignoreEnvironmentHelper?: boolean;
  152680. }
  152681. /**
  152682. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  152683. */
  152684. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  152685. /**
  152686. * read-only options to be used in this module
  152687. */
  152688. readonly options: IWebXRBackgroundRemoverOptions;
  152689. /**
  152690. * The module's name
  152691. */
  152692. static readonly Name: string;
  152693. /**
  152694. * The (Babylon) version of this module.
  152695. * This is an integer representing the implementation version.
  152696. * This number does not correspond to the WebXR specs version
  152697. */
  152698. static readonly Version: number;
  152699. /**
  152700. * registered observers will be triggered when the background state changes
  152701. */
  152702. onBackgroundStateChangedObservable: Observable<boolean>;
  152703. /**
  152704. * constructs a new background remover module
  152705. * @param _xrSessionManager the session manager for this module
  152706. * @param options read-only options to be used in this module
  152707. */
  152708. constructor(_xrSessionManager: WebXRSessionManager,
  152709. /**
  152710. * read-only options to be used in this module
  152711. */
  152712. options?: IWebXRBackgroundRemoverOptions);
  152713. /**
  152714. * attach this feature
  152715. * Will usually be called by the features manager
  152716. *
  152717. * @returns true if successful.
  152718. */
  152719. attach(): boolean;
  152720. /**
  152721. * detach this feature.
  152722. * Will usually be called by the features manager
  152723. *
  152724. * @returns true if successful.
  152725. */
  152726. detach(): boolean;
  152727. /**
  152728. * Dispose this feature and all of the resources attached
  152729. */
  152730. dispose(): void;
  152731. protected _onXRFrame(_xrFrame: XRFrame): void;
  152732. private _setBackgroundState;
  152733. }
  152734. }
  152735. declare module BABYLON {
  152736. /**
  152737. * Options for the controller physics feature
  152738. */
  152739. export class IWebXRControllerPhysicsOptions {
  152740. /**
  152741. * Should the headset get its own impostor
  152742. */
  152743. enableHeadsetImpostor?: boolean;
  152744. /**
  152745. * Optional parameters for the headset impostor
  152746. */
  152747. headsetImpostorParams?: {
  152748. /**
  152749. * The type of impostor to create. Default is sphere
  152750. */
  152751. impostorType: number;
  152752. /**
  152753. * the size of the impostor. Defaults to 10cm
  152754. */
  152755. impostorSize?: number | {
  152756. width: number;
  152757. height: number;
  152758. depth: number;
  152759. };
  152760. /**
  152761. * Friction definitions
  152762. */
  152763. friction?: number;
  152764. /**
  152765. * Restitution
  152766. */
  152767. restitution?: number;
  152768. };
  152769. /**
  152770. * The physics properties of the future impostors
  152771. */
  152772. physicsProperties?: {
  152773. /**
  152774. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  152775. * Note that this requires a physics engine that supports mesh impostors!
  152776. */
  152777. useControllerMesh?: boolean;
  152778. /**
  152779. * The type of impostor to create. Default is sphere
  152780. */
  152781. impostorType?: number;
  152782. /**
  152783. * the size of the impostor. Defaults to 10cm
  152784. */
  152785. impostorSize?: number | {
  152786. width: number;
  152787. height: number;
  152788. depth: number;
  152789. };
  152790. /**
  152791. * Friction definitions
  152792. */
  152793. friction?: number;
  152794. /**
  152795. * Restitution
  152796. */
  152797. restitution?: number;
  152798. };
  152799. /**
  152800. * the xr input to use with this pointer selection
  152801. */
  152802. xrInput: WebXRInput;
  152803. }
  152804. /**
  152805. * Add physics impostor to your webxr controllers,
  152806. * including naive calculation of their linear and angular velocity
  152807. */
  152808. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  152809. private readonly _options;
  152810. private _attachController;
  152811. private _controllers;
  152812. private _debugMode;
  152813. private _delta;
  152814. private _headsetImpostor?;
  152815. private _headsetMesh?;
  152816. private _lastTimestamp;
  152817. private _tmpQuaternion;
  152818. private _tmpVector;
  152819. /**
  152820. * The module's name
  152821. */
  152822. static readonly Name: string;
  152823. /**
  152824. * The (Babylon) version of this module.
  152825. * This is an integer representing the implementation version.
  152826. * This number does not correspond to the webxr specs version
  152827. */
  152828. static readonly Version: number;
  152829. /**
  152830. * Construct a new Controller Physics Feature
  152831. * @param _xrSessionManager the corresponding xr session manager
  152832. * @param _options options to create this feature with
  152833. */
  152834. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  152835. /**
  152836. * @hidden
  152837. * enable debugging - will show console outputs and the impostor mesh
  152838. */
  152839. _enablePhysicsDebug(): void;
  152840. /**
  152841. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  152842. * @param xrController the controller to add
  152843. */
  152844. addController(xrController: WebXRInputSource): void;
  152845. /**
  152846. * attach this feature
  152847. * Will usually be called by the features manager
  152848. *
  152849. * @returns true if successful.
  152850. */
  152851. attach(): boolean;
  152852. /**
  152853. * detach this feature.
  152854. * Will usually be called by the features manager
  152855. *
  152856. * @returns true if successful.
  152857. */
  152858. detach(): boolean;
  152859. /**
  152860. * Get the headset impostor, if enabled
  152861. * @returns the impostor
  152862. */
  152863. getHeadsetImpostor(): PhysicsImpostor | undefined;
  152864. /**
  152865. * Get the physics impostor of a specific controller.
  152866. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  152867. * @param controller the controller or the controller id of which to get the impostor
  152868. * @returns the impostor or null
  152869. */
  152870. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  152871. /**
  152872. * Update the physics properties provided in the constructor
  152873. * @param newProperties the new properties object
  152874. */
  152875. setPhysicsProperties(newProperties: {
  152876. impostorType?: number;
  152877. impostorSize?: number | {
  152878. width: number;
  152879. height: number;
  152880. depth: number;
  152881. };
  152882. friction?: number;
  152883. restitution?: number;
  152884. }): void;
  152885. protected _onXRFrame(_xrFrame: any): void;
  152886. private _detachController;
  152887. }
  152888. }
  152889. declare module BABYLON {
  152890. /**
  152891. * The motion controller class for all microsoft mixed reality controllers
  152892. */
  152893. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  152894. protected readonly _mapping: {
  152895. defaultButton: {
  152896. valueNodeName: string;
  152897. unpressedNodeName: string;
  152898. pressedNodeName: string;
  152899. };
  152900. defaultAxis: {
  152901. valueNodeName: string;
  152902. minNodeName: string;
  152903. maxNodeName: string;
  152904. };
  152905. buttons: {
  152906. "xr-standard-trigger": {
  152907. rootNodeName: string;
  152908. componentProperty: string;
  152909. states: string[];
  152910. };
  152911. "xr-standard-squeeze": {
  152912. rootNodeName: string;
  152913. componentProperty: string;
  152914. states: string[];
  152915. };
  152916. "xr-standard-touchpad": {
  152917. rootNodeName: string;
  152918. labelAnchorNodeName: string;
  152919. touchPointNodeName: string;
  152920. };
  152921. "xr-standard-thumbstick": {
  152922. rootNodeName: string;
  152923. componentProperty: string;
  152924. states: string[];
  152925. };
  152926. };
  152927. axes: {
  152928. "xr-standard-touchpad": {
  152929. "x-axis": {
  152930. rootNodeName: string;
  152931. };
  152932. "y-axis": {
  152933. rootNodeName: string;
  152934. };
  152935. };
  152936. "xr-standard-thumbstick": {
  152937. "x-axis": {
  152938. rootNodeName: string;
  152939. };
  152940. "y-axis": {
  152941. rootNodeName: string;
  152942. };
  152943. };
  152944. };
  152945. };
  152946. /**
  152947. * The base url used to load the left and right controller models
  152948. */
  152949. static MODEL_BASE_URL: string;
  152950. /**
  152951. * The name of the left controller model file
  152952. */
  152953. static MODEL_LEFT_FILENAME: string;
  152954. /**
  152955. * The name of the right controller model file
  152956. */
  152957. static MODEL_RIGHT_FILENAME: string;
  152958. profileId: string;
  152959. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  152960. protected _getFilenameAndPath(): {
  152961. filename: string;
  152962. path: string;
  152963. };
  152964. protected _getModelLoadingConstraints(): boolean;
  152965. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152966. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152967. protected _updateModel(): void;
  152968. }
  152969. }
  152970. declare module BABYLON {
  152971. /**
  152972. * The motion controller class for oculus touch (quest, rift).
  152973. * This class supports legacy mapping as well the standard xr mapping
  152974. */
  152975. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  152976. private _forceLegacyControllers;
  152977. private _modelRootNode;
  152978. /**
  152979. * The base url used to load the left and right controller models
  152980. */
  152981. static MODEL_BASE_URL: string;
  152982. /**
  152983. * The name of the left controller model file
  152984. */
  152985. static MODEL_LEFT_FILENAME: string;
  152986. /**
  152987. * The name of the right controller model file
  152988. */
  152989. static MODEL_RIGHT_FILENAME: string;
  152990. /**
  152991. * Base Url for the Quest controller model.
  152992. */
  152993. static QUEST_MODEL_BASE_URL: string;
  152994. profileId: string;
  152995. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  152996. protected _getFilenameAndPath(): {
  152997. filename: string;
  152998. path: string;
  152999. };
  153000. protected _getModelLoadingConstraints(): boolean;
  153001. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153002. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153003. protected _updateModel(): void;
  153004. /**
  153005. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  153006. * between the touch and touch 2.
  153007. */
  153008. private _isQuest;
  153009. }
  153010. }
  153011. declare module BABYLON {
  153012. /**
  153013. * The motion controller class for the standard HTC-Vive controllers
  153014. */
  153015. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  153016. private _modelRootNode;
  153017. /**
  153018. * The base url used to load the left and right controller models
  153019. */
  153020. static MODEL_BASE_URL: string;
  153021. /**
  153022. * File name for the controller model.
  153023. */
  153024. static MODEL_FILENAME: string;
  153025. profileId: string;
  153026. /**
  153027. * Create a new Vive motion controller object
  153028. * @param scene the scene to use to create this controller
  153029. * @param gamepadObject the corresponding gamepad object
  153030. * @param handedness the handedness of the controller
  153031. */
  153032. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  153033. protected _getFilenameAndPath(): {
  153034. filename: string;
  153035. path: string;
  153036. };
  153037. protected _getModelLoadingConstraints(): boolean;
  153038. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153039. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153040. protected _updateModel(): void;
  153041. }
  153042. }
  153043. declare module BABYLON {
  153044. /**
  153045. * A cursor which tracks a point on a path
  153046. */
  153047. export class PathCursor {
  153048. private path;
  153049. /**
  153050. * Stores path cursor callbacks for when an onchange event is triggered
  153051. */
  153052. private _onchange;
  153053. /**
  153054. * The value of the path cursor
  153055. */
  153056. value: number;
  153057. /**
  153058. * The animation array of the path cursor
  153059. */
  153060. animations: Animation[];
  153061. /**
  153062. * Initializes the path cursor
  153063. * @param path The path to track
  153064. */
  153065. constructor(path: Path2);
  153066. /**
  153067. * Gets the cursor point on the path
  153068. * @returns A point on the path cursor at the cursor location
  153069. */
  153070. getPoint(): Vector3;
  153071. /**
  153072. * Moves the cursor ahead by the step amount
  153073. * @param step The amount to move the cursor forward
  153074. * @returns This path cursor
  153075. */
  153076. moveAhead(step?: number): PathCursor;
  153077. /**
  153078. * Moves the cursor behind by the step amount
  153079. * @param step The amount to move the cursor back
  153080. * @returns This path cursor
  153081. */
  153082. moveBack(step?: number): PathCursor;
  153083. /**
  153084. * Moves the cursor by the step amount
  153085. * If the step amount is greater than one, an exception is thrown
  153086. * @param step The amount to move the cursor
  153087. * @returns This path cursor
  153088. */
  153089. move(step: number): PathCursor;
  153090. /**
  153091. * Ensures that the value is limited between zero and one
  153092. * @returns This path cursor
  153093. */
  153094. private ensureLimits;
  153095. /**
  153096. * Runs onchange callbacks on change (used by the animation engine)
  153097. * @returns This path cursor
  153098. */
  153099. private raiseOnChange;
  153100. /**
  153101. * Executes a function on change
  153102. * @param f A path cursor onchange callback
  153103. * @returns This path cursor
  153104. */
  153105. onchange(f: (cursor: PathCursor) => void): PathCursor;
  153106. }
  153107. }
  153108. declare module BABYLON {
  153109. /** @hidden */
  153110. export var blurPixelShader: {
  153111. name: string;
  153112. shader: string;
  153113. };
  153114. }
  153115. declare module BABYLON {
  153116. /** @hidden */
  153117. export var pointCloudVertexDeclaration: {
  153118. name: string;
  153119. shader: string;
  153120. };
  153121. }
  153122. // Mixins
  153123. interface Window {
  153124. mozIndexedDB: IDBFactory;
  153125. webkitIndexedDB: IDBFactory;
  153126. msIndexedDB: IDBFactory;
  153127. webkitURL: typeof URL;
  153128. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  153129. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  153130. WebGLRenderingContext: WebGLRenderingContext;
  153131. MSGesture: MSGesture;
  153132. CANNON: any;
  153133. AudioContext: AudioContext;
  153134. webkitAudioContext: AudioContext;
  153135. PointerEvent: any;
  153136. Math: Math;
  153137. Uint8Array: Uint8ArrayConstructor;
  153138. Float32Array: Float32ArrayConstructor;
  153139. mozURL: typeof URL;
  153140. msURL: typeof URL;
  153141. VRFrameData: any; // WebVR, from specs 1.1
  153142. DracoDecoderModule: any;
  153143. setImmediate(handler: (...args: any[]) => void): number;
  153144. }
  153145. interface HTMLCanvasElement {
  153146. requestPointerLock(): void;
  153147. msRequestPointerLock?(): void;
  153148. mozRequestPointerLock?(): void;
  153149. webkitRequestPointerLock?(): void;
  153150. /** Track wether a record is in progress */
  153151. isRecording: boolean;
  153152. /** Capture Stream method defined by some browsers */
  153153. captureStream(fps?: number): MediaStream;
  153154. }
  153155. interface CanvasRenderingContext2D {
  153156. msImageSmoothingEnabled: boolean;
  153157. }
  153158. interface MouseEvent {
  153159. mozMovementX: number;
  153160. mozMovementY: number;
  153161. webkitMovementX: number;
  153162. webkitMovementY: number;
  153163. msMovementX: number;
  153164. msMovementY: number;
  153165. }
  153166. interface Navigator {
  153167. mozGetVRDevices: (any: any) => any;
  153168. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153169. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153170. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153171. webkitGetGamepads(): Gamepad[];
  153172. msGetGamepads(): Gamepad[];
  153173. webkitGamepads(): Gamepad[];
  153174. }
  153175. interface HTMLVideoElement {
  153176. mozSrcObject: any;
  153177. }
  153178. interface Math {
  153179. fround(x: number): number;
  153180. imul(a: number, b: number): number;
  153181. }
  153182. interface WebGLRenderingContext {
  153183. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  153184. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  153185. vertexAttribDivisor(index: number, divisor: number): void;
  153186. createVertexArray(): any;
  153187. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  153188. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  153189. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  153190. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  153191. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  153192. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  153193. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  153194. // Queries
  153195. createQuery(): WebGLQuery;
  153196. deleteQuery(query: WebGLQuery): void;
  153197. beginQuery(target: number, query: WebGLQuery): void;
  153198. endQuery(target: number): void;
  153199. getQueryParameter(query: WebGLQuery, pname: number): any;
  153200. getQuery(target: number, pname: number): any;
  153201. MAX_SAMPLES: number;
  153202. RGBA8: number;
  153203. READ_FRAMEBUFFER: number;
  153204. DRAW_FRAMEBUFFER: number;
  153205. UNIFORM_BUFFER: number;
  153206. HALF_FLOAT_OES: number;
  153207. RGBA16F: number;
  153208. RGBA32F: number;
  153209. R32F: number;
  153210. RG32F: number;
  153211. RGB32F: number;
  153212. R16F: number;
  153213. RG16F: number;
  153214. RGB16F: number;
  153215. RED: number;
  153216. RG: number;
  153217. R8: number;
  153218. RG8: number;
  153219. UNSIGNED_INT_24_8: number;
  153220. DEPTH24_STENCIL8: number;
  153221. MIN: number;
  153222. MAX: number;
  153223. /* Multiple Render Targets */
  153224. drawBuffers(buffers: number[]): void;
  153225. readBuffer(src: number): void;
  153226. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  153227. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  153228. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  153229. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  153230. // Occlusion Query
  153231. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  153232. ANY_SAMPLES_PASSED: number;
  153233. QUERY_RESULT_AVAILABLE: number;
  153234. QUERY_RESULT: number;
  153235. }
  153236. interface WebGLProgram {
  153237. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  153238. }
  153239. interface EXT_disjoint_timer_query {
  153240. QUERY_COUNTER_BITS_EXT: number;
  153241. TIME_ELAPSED_EXT: number;
  153242. TIMESTAMP_EXT: number;
  153243. GPU_DISJOINT_EXT: number;
  153244. QUERY_RESULT_EXT: number;
  153245. QUERY_RESULT_AVAILABLE_EXT: number;
  153246. queryCounterEXT(query: WebGLQuery, target: number): void;
  153247. createQueryEXT(): WebGLQuery;
  153248. beginQueryEXT(target: number, query: WebGLQuery): void;
  153249. endQueryEXT(target: number): void;
  153250. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  153251. deleteQueryEXT(query: WebGLQuery): void;
  153252. }
  153253. interface WebGLUniformLocation {
  153254. _currentState: any;
  153255. }
  153256. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  153257. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  153258. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  153259. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  153260. interface WebGLRenderingContext {
  153261. readonly RASTERIZER_DISCARD: number;
  153262. readonly DEPTH_COMPONENT24: number;
  153263. readonly TEXTURE_3D: number;
  153264. readonly TEXTURE_2D_ARRAY: number;
  153265. readonly TEXTURE_COMPARE_FUNC: number;
  153266. readonly TEXTURE_COMPARE_MODE: number;
  153267. readonly COMPARE_REF_TO_TEXTURE: number;
  153268. readonly TEXTURE_WRAP_R: number;
  153269. readonly HALF_FLOAT: number;
  153270. readonly RGB8: number;
  153271. readonly RED_INTEGER: number;
  153272. readonly RG_INTEGER: number;
  153273. readonly RGB_INTEGER: number;
  153274. readonly RGBA_INTEGER: number;
  153275. readonly R8_SNORM: number;
  153276. readonly RG8_SNORM: number;
  153277. readonly RGB8_SNORM: number;
  153278. readonly RGBA8_SNORM: number;
  153279. readonly R8I: number;
  153280. readonly RG8I: number;
  153281. readonly RGB8I: number;
  153282. readonly RGBA8I: number;
  153283. readonly R8UI: number;
  153284. readonly RG8UI: number;
  153285. readonly RGB8UI: number;
  153286. readonly RGBA8UI: number;
  153287. readonly R16I: number;
  153288. readonly RG16I: number;
  153289. readonly RGB16I: number;
  153290. readonly RGBA16I: number;
  153291. readonly R16UI: number;
  153292. readonly RG16UI: number;
  153293. readonly RGB16UI: number;
  153294. readonly RGBA16UI: number;
  153295. readonly R32I: number;
  153296. readonly RG32I: number;
  153297. readonly RGB32I: number;
  153298. readonly RGBA32I: number;
  153299. readonly R32UI: number;
  153300. readonly RG32UI: number;
  153301. readonly RGB32UI: number;
  153302. readonly RGBA32UI: number;
  153303. readonly RGB10_A2UI: number;
  153304. readonly R11F_G11F_B10F: number;
  153305. readonly RGB9_E5: number;
  153306. readonly RGB10_A2: number;
  153307. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  153308. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  153309. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  153310. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  153311. readonly DEPTH_COMPONENT32F: number;
  153312. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  153313. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  153314. 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;
  153315. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  153316. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  153317. readonly TRANSFORM_FEEDBACK: number;
  153318. readonly INTERLEAVED_ATTRIBS: number;
  153319. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  153320. createTransformFeedback(): WebGLTransformFeedback;
  153321. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  153322. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  153323. beginTransformFeedback(primitiveMode: number): void;
  153324. endTransformFeedback(): void;
  153325. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  153326. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153327. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153328. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153329. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  153330. }
  153331. interface ImageBitmap {
  153332. readonly width: number;
  153333. readonly height: number;
  153334. close(): void;
  153335. }
  153336. interface WebGLQuery extends WebGLObject {
  153337. }
  153338. declare var WebGLQuery: {
  153339. prototype: WebGLQuery;
  153340. new(): WebGLQuery;
  153341. };
  153342. interface WebGLSampler extends WebGLObject {
  153343. }
  153344. declare var WebGLSampler: {
  153345. prototype: WebGLSampler;
  153346. new(): WebGLSampler;
  153347. };
  153348. interface WebGLSync extends WebGLObject {
  153349. }
  153350. declare var WebGLSync: {
  153351. prototype: WebGLSync;
  153352. new(): WebGLSync;
  153353. };
  153354. interface WebGLTransformFeedback extends WebGLObject {
  153355. }
  153356. declare var WebGLTransformFeedback: {
  153357. prototype: WebGLTransformFeedback;
  153358. new(): WebGLTransformFeedback;
  153359. };
  153360. interface WebGLVertexArrayObject extends WebGLObject {
  153361. }
  153362. declare var WebGLVertexArrayObject: {
  153363. prototype: WebGLVertexArrayObject;
  153364. new(): WebGLVertexArrayObject;
  153365. };
  153366. // Type definitions for WebVR API
  153367. // Project: https://w3c.github.io/webvr/
  153368. // Definitions by: six a <https://github.com/lostfictions>
  153369. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  153370. interface VRDisplay extends EventTarget {
  153371. /**
  153372. * Dictionary of capabilities describing the VRDisplay.
  153373. */
  153374. readonly capabilities: VRDisplayCapabilities;
  153375. /**
  153376. * z-depth defining the far plane of the eye view frustum
  153377. * enables mapping of values in the render target depth
  153378. * attachment to scene coordinates. Initially set to 10000.0.
  153379. */
  153380. depthFar: number;
  153381. /**
  153382. * z-depth defining the near plane of the eye view frustum
  153383. * enables mapping of values in the render target depth
  153384. * attachment to scene coordinates. Initially set to 0.01.
  153385. */
  153386. depthNear: number;
  153387. /**
  153388. * An identifier for this distinct VRDisplay. Used as an
  153389. * association point in the Gamepad API.
  153390. */
  153391. readonly displayId: number;
  153392. /**
  153393. * A display name, a user-readable name identifying it.
  153394. */
  153395. readonly displayName: string;
  153396. readonly isConnected: boolean;
  153397. readonly isPresenting: boolean;
  153398. /**
  153399. * If this VRDisplay supports room-scale experiences, the optional
  153400. * stage attribute contains details on the room-scale parameters.
  153401. */
  153402. readonly stageParameters: VRStageParameters | null;
  153403. /**
  153404. * Passing the value returned by `requestAnimationFrame` to
  153405. * `cancelAnimationFrame` will unregister the callback.
  153406. * @param handle Define the hanle of the request to cancel
  153407. */
  153408. cancelAnimationFrame(handle: number): void;
  153409. /**
  153410. * Stops presenting to the VRDisplay.
  153411. * @returns a promise to know when it stopped
  153412. */
  153413. exitPresent(): Promise<void>;
  153414. /**
  153415. * Return the current VREyeParameters for the given eye.
  153416. * @param whichEye Define the eye we want the parameter for
  153417. * @returns the eye parameters
  153418. */
  153419. getEyeParameters(whichEye: string): VREyeParameters;
  153420. /**
  153421. * Populates the passed VRFrameData with the information required to render
  153422. * the current frame.
  153423. * @param frameData Define the data structure to populate
  153424. * @returns true if ok otherwise false
  153425. */
  153426. getFrameData(frameData: VRFrameData): boolean;
  153427. /**
  153428. * Get the layers currently being presented.
  153429. * @returns the list of VR layers
  153430. */
  153431. getLayers(): VRLayer[];
  153432. /**
  153433. * Return a VRPose containing the future predicted pose of the VRDisplay
  153434. * when the current frame will be presented. The value returned will not
  153435. * change until JavaScript has returned control to the browser.
  153436. *
  153437. * The VRPose will contain the position, orientation, velocity,
  153438. * and acceleration of each of these properties.
  153439. * @returns the pose object
  153440. */
  153441. getPose(): VRPose;
  153442. /**
  153443. * Return the current instantaneous pose of the VRDisplay, with no
  153444. * prediction applied.
  153445. * @returns the current instantaneous pose
  153446. */
  153447. getImmediatePose(): VRPose;
  153448. /**
  153449. * The callback passed to `requestAnimationFrame` will be called
  153450. * any time a new frame should be rendered. When the VRDisplay is
  153451. * presenting the callback will be called at the native refresh
  153452. * rate of the HMD. When not presenting this function acts
  153453. * identically to how window.requestAnimationFrame acts. Content should
  153454. * make no assumptions of frame rate or vsync behavior as the HMD runs
  153455. * asynchronously from other displays and at differing refresh rates.
  153456. * @param callback Define the eaction to run next frame
  153457. * @returns the request handle it
  153458. */
  153459. requestAnimationFrame(callback: FrameRequestCallback): number;
  153460. /**
  153461. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  153462. * Repeat calls while already presenting will update the VRLayers being displayed.
  153463. * @param layers Define the list of layer to present
  153464. * @returns a promise to know when the request has been fulfilled
  153465. */
  153466. requestPresent(layers: VRLayer[]): Promise<void>;
  153467. /**
  153468. * Reset the pose for this display, treating its current position and
  153469. * orientation as the "origin/zero" values. VRPose.position,
  153470. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  153471. * updated when calling resetPose(). This should be called in only
  153472. * sitting-space experiences.
  153473. */
  153474. resetPose(): void;
  153475. /**
  153476. * The VRLayer provided to the VRDisplay will be captured and presented
  153477. * in the HMD. Calling this function has the same effect on the source
  153478. * canvas as any other operation that uses its source image, and canvases
  153479. * created without preserveDrawingBuffer set to true will be cleared.
  153480. * @param pose Define the pose to submit
  153481. */
  153482. submitFrame(pose?: VRPose): void;
  153483. }
  153484. declare var VRDisplay: {
  153485. prototype: VRDisplay;
  153486. new(): VRDisplay;
  153487. };
  153488. interface VRLayer {
  153489. leftBounds?: number[] | Float32Array | null;
  153490. rightBounds?: number[] | Float32Array | null;
  153491. source?: HTMLCanvasElement | null;
  153492. }
  153493. interface VRDisplayCapabilities {
  153494. readonly canPresent: boolean;
  153495. readonly hasExternalDisplay: boolean;
  153496. readonly hasOrientation: boolean;
  153497. readonly hasPosition: boolean;
  153498. readonly maxLayers: number;
  153499. }
  153500. interface VREyeParameters {
  153501. /** @deprecated */
  153502. readonly fieldOfView: VRFieldOfView;
  153503. readonly offset: Float32Array;
  153504. readonly renderHeight: number;
  153505. readonly renderWidth: number;
  153506. }
  153507. interface VRFieldOfView {
  153508. readonly downDegrees: number;
  153509. readonly leftDegrees: number;
  153510. readonly rightDegrees: number;
  153511. readonly upDegrees: number;
  153512. }
  153513. interface VRFrameData {
  153514. readonly leftProjectionMatrix: Float32Array;
  153515. readonly leftViewMatrix: Float32Array;
  153516. readonly pose: VRPose;
  153517. readonly rightProjectionMatrix: Float32Array;
  153518. readonly rightViewMatrix: Float32Array;
  153519. readonly timestamp: number;
  153520. }
  153521. interface VRPose {
  153522. readonly angularAcceleration: Float32Array | null;
  153523. readonly angularVelocity: Float32Array | null;
  153524. readonly linearAcceleration: Float32Array | null;
  153525. readonly linearVelocity: Float32Array | null;
  153526. readonly orientation: Float32Array | null;
  153527. readonly position: Float32Array | null;
  153528. readonly timestamp: number;
  153529. }
  153530. interface VRStageParameters {
  153531. sittingToStandingTransform?: Float32Array;
  153532. sizeX?: number;
  153533. sizeY?: number;
  153534. }
  153535. interface Navigator {
  153536. getVRDisplays(): Promise<VRDisplay[]>;
  153537. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  153538. }
  153539. interface Window {
  153540. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  153541. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  153542. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  153543. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  153544. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  153545. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  153546. }
  153547. interface Gamepad {
  153548. readonly displayId: number;
  153549. }
  153550. type XRSessionMode =
  153551. | "inline"
  153552. | "immersive-vr"
  153553. | "immersive-ar";
  153554. type XRReferenceSpaceType =
  153555. | "viewer"
  153556. | "local"
  153557. | "local-floor"
  153558. | "bounded-floor"
  153559. | "unbounded";
  153560. type XREnvironmentBlendMode =
  153561. | "opaque"
  153562. | "additive"
  153563. | "alpha-blend";
  153564. type XRVisibilityState =
  153565. | "visible"
  153566. | "visible-blurred"
  153567. | "hidden";
  153568. type XRHandedness =
  153569. | "none"
  153570. | "left"
  153571. | "right";
  153572. type XRTargetRayMode =
  153573. | "gaze"
  153574. | "tracked-pointer"
  153575. | "screen";
  153576. type XREye =
  153577. | "none"
  153578. | "left"
  153579. | "right";
  153580. type XREventType =
  153581. | "devicechange"
  153582. | "visibilitychange"
  153583. | "end"
  153584. | "inputsourceschange"
  153585. | "select"
  153586. | "selectstart"
  153587. | "selectend"
  153588. | "squeeze"
  153589. | "squeezestart"
  153590. | "squeezeend"
  153591. | "reset";
  153592. interface XRSpace extends EventTarget {
  153593. }
  153594. interface XRRenderState {
  153595. depthNear?: number;
  153596. depthFar?: number;
  153597. inlineVerticalFieldOfView?: number;
  153598. baseLayer?: XRWebGLLayer;
  153599. }
  153600. interface XRInputSource {
  153601. handedness: XRHandedness;
  153602. targetRayMode: XRTargetRayMode;
  153603. targetRaySpace: XRSpace;
  153604. gripSpace: XRSpace | undefined;
  153605. gamepad: Gamepad | undefined;
  153606. profiles: Array<string>;
  153607. }
  153608. interface XRSessionInit {
  153609. optionalFeatures?: string[];
  153610. requiredFeatures?: string[];
  153611. }
  153612. interface XRSession {
  153613. addEventListener: Function;
  153614. removeEventListener: Function;
  153615. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  153616. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  153617. requestAnimationFrame: Function;
  153618. end(): Promise<void>;
  153619. renderState: XRRenderState;
  153620. inputSources: Array<XRInputSource>;
  153621. // hit test
  153622. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  153623. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  153624. // legacy AR hit test
  153625. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  153626. // legacy plane detection
  153627. updateWorldTrackingState(options: {
  153628. planeDetectionState?: { enabled: boolean; }
  153629. }): void;
  153630. }
  153631. interface XRReferenceSpace extends XRSpace {
  153632. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  153633. onreset: any;
  153634. }
  153635. type XRPlaneSet = Set<XRPlane>;
  153636. type XRAnchorSet = Set<XRAnchor>;
  153637. interface XRFrame {
  153638. session: XRSession;
  153639. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  153640. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  153641. // AR
  153642. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  153643. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  153644. // Anchors
  153645. trackedAnchors?: XRAnchorSet;
  153646. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  153647. // Planes
  153648. worldInformation: {
  153649. detectedPlanes?: XRPlaneSet;
  153650. };
  153651. }
  153652. interface XRViewerPose extends XRPose {
  153653. views: Array<XRView>;
  153654. }
  153655. interface XRPose {
  153656. transform: XRRigidTransform;
  153657. emulatedPosition: boolean;
  153658. }
  153659. interface XRWebGLLayerOptions {
  153660. antialias?: boolean;
  153661. depth?: boolean;
  153662. stencil?: boolean;
  153663. alpha?: boolean;
  153664. multiview?: boolean;
  153665. framebufferScaleFactor?: number;
  153666. }
  153667. declare var XRWebGLLayer: {
  153668. prototype: XRWebGLLayer;
  153669. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  153670. };
  153671. interface XRWebGLLayer {
  153672. framebuffer: WebGLFramebuffer;
  153673. framebufferWidth: number;
  153674. framebufferHeight: number;
  153675. getViewport: Function;
  153676. }
  153677. declare class XRRigidTransform {
  153678. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  153679. position: DOMPointReadOnly;
  153680. orientation: DOMPointReadOnly;
  153681. matrix: Float32Array;
  153682. inverse: XRRigidTransform;
  153683. }
  153684. interface XRView {
  153685. eye: XREye;
  153686. projectionMatrix: Float32Array;
  153687. transform: XRRigidTransform;
  153688. }
  153689. interface XRInputSourceChangeEvent {
  153690. session: XRSession;
  153691. removed: Array<XRInputSource>;
  153692. added: Array<XRInputSource>;
  153693. }
  153694. interface XRInputSourceEvent extends Event {
  153695. readonly frame: XRFrame;
  153696. readonly inputSource: XRInputSource;
  153697. }
  153698. // Experimental(er) features
  153699. declare class XRRay {
  153700. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  153701. origin: DOMPointReadOnly;
  153702. direction: DOMPointReadOnly;
  153703. matrix: Float32Array;
  153704. }
  153705. declare enum XRHitTestTrackableType {
  153706. "point",
  153707. "plane"
  153708. }
  153709. interface XRHitResult {
  153710. hitMatrix: Float32Array;
  153711. }
  153712. interface XRTransientInputHitTestResult {
  153713. readonly inputSource: XRInputSource;
  153714. readonly results: Array<XRHitTestResult>;
  153715. }
  153716. interface XRHitTestResult {
  153717. getPose(baseSpace: XRSpace): XRPose | undefined;
  153718. // When anchor system is enabled
  153719. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  153720. }
  153721. interface XRHitTestSource {
  153722. cancel(): void;
  153723. }
  153724. interface XRTransientInputHitTestSource {
  153725. cancel(): void;
  153726. }
  153727. interface XRHitTestOptionsInit {
  153728. space: XRSpace;
  153729. entityTypes?: Array<XRHitTestTrackableType>;
  153730. offsetRay?: XRRay;
  153731. }
  153732. interface XRTransientInputHitTestOptionsInit {
  153733. profile: string;
  153734. entityTypes?: Array<XRHitTestTrackableType>;
  153735. offsetRay?: XRRay;
  153736. }
  153737. interface XRAnchor {
  153738. anchorSpace: XRSpace;
  153739. delete(): void;
  153740. }
  153741. interface XRPlane {
  153742. orientation: "Horizontal" | "Vertical";
  153743. planeSpace: XRSpace;
  153744. polygon: Array<DOMPointReadOnly>;
  153745. lastChangedTime: number;
  153746. }